zoukankan      html  css  js  c++  java
  • patch文件制作,排除符号链接的方法

    #!/bin/sh

    #parameter check
    # $1 is regarded as the original folder
    # $2 is regarded as the latest folder
    # $3 is regraded as the patch file
    if [ $# -lt 3 ];then
    echo "usage:$0 original_dir dest_dir patch_file"
    exit -1;
    fi

    #variable declare
    ori_dir=$1
    new_dir=$2
    patch_file=$3

    #remove the old patch file
    if [ -f ${patch_file} ];then
    rm ${patch_file}
    fi

    #find out all the files, except symbol link
    ori_files=`cd ${ori_dir}; find ./ -type f ! -type l`

    for file in ${ori_files};do
      if [ -f ${ori_dir}/${file} ];then
        if [ -f ${new_dir}/${file} ];then
          #remove the "./" symbol from the file string.
          file=`echo ${file} | sed s/"./"//`
          diff -uNr ${ori_dir}/${file} ${new_dir}/${file} >> ${patch_file}
        fi
      fi
    done

    2. 另外一种方法:

    (1)查找某个目录下的所有符号链接文件,重定向到一个文件

    find 某个目录 -type l > symbolic_list

    (2)由于符号链接文件中包含了路径"/",所以在每一行的头和尾加上引号"

    sed -i -e "s/^/"/" -e "s/$/"/" symbolic_list

    (3)使用diff命令制作patch文件,用其X参数排除符号链接文件

    diff -uNr -X symbolic_list originalSourceDirectory newSourceDirectory > xxxx.patch

    这样制作出来的patch文件也是不包含原始目录下symbolic link文件

    PS:patch文件的使用(以下命令中的x代表去掉patch文件中的第几个"/",0代表不去掉,1代表去掉第一个"/",以此类推)

    patch -px -d 目录 < patch文件

    diff命令手册    : diff
    patch命令手册: patch

  • 相关阅读:
    iOS开发---业务逻辑
    iOS 蓝牙功能 bluetooth
    iOS 企业版 安装失败 原因
    iOS 生命周期 -init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear、viewDidDisappear 区别和用途
    iOS 7 修改默认布局从status bar 底部开始
    企业打包时不能安装原因
    UISegmentedControl 功能简单 分析
    ios 推送 证书配置
    ios 获取手机设备信息
    创建quickstart报错
  • 原文地址:https://www.cnblogs.com/eric-geoffrey/p/3161996.html
Copyright © 2011-2022 走看看