Whamcloud - gitweb
- merge 0.7rc1 from b_devel to HEAD (20030612 merge point)
[fs/lustre-release.git] / lustre / kernel_patches / scripts / patchfns
index b6cc468..78e494b 100644 (file)
@@ -11,9 +11,9 @@ DB=applied-patches
 # Otherwise use "."
 #
 
-if [ x$PATCHSCRIPTS != x ]
+if [ x$PATCHSCRIPTS_LIBDIR != x ]
 then
-       P=$PATCHSCRIPTS
+       P=$PATCHSCRIPTS_LIBDIR
 elif [ -d ./patch-scripts ]
 then
        P=./patch-scripts
@@ -69,7 +69,20 @@ is_applied()
                return 1
        fi
 }
-
+check_pc_match()
+{
+       if [ -f /usr/bin/lsdiff ]; then
+               tmpfile=$(mktemp /tmp/p_XXXXXX) || exit 1
+               lsdiff --strip=1 $1 > $tmpfile 
+               diff $2 $tmpfile > /dev/null
+               if [ $? != 0 ]; then
+                       echo " $1 do not match with $2 "
+                       echo " $2 will be changed to match $2"
+                       cat $tmpfile > $P/pc/$PATCH_NAME.pc
+               fi
+               rm -rf $tmpfile
+       fi
+} 
 can_apply()
 {
        if patch -p1 --dry-run -i "$1" -f
@@ -166,19 +179,23 @@ copy_file_to_bup()
        file=$1
        patch=$2
        bup="$file"~"$patch"
+       orig="$file"~"orig"
+       src_dir=`pwd`
 
        if [ -e $bup ]
        then
                echo "Cannot install file $file in patch $patch: backup $bup exists"
                exit 1
        fi
-
        if [ -e $file ]
        then
-               cp $file "$file"~"$patch"
+               cp -p $file "$file"~"$patch"
        else
                echo "file $file appears to be newly added"
        fi
+       if [ ! -L "$orig" ]; then
+               ln -s "$src_dir/$bup" $orig
+       fi      
 }
 
 install_file_in_patch()