diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2003-10-28 13:48:22 +0000 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2003-10-28 13:48:22 +0000 |
commit | 5b3c46d7f9cc3be46af00c556ea887f437dbeb04 (patch) | |
tree | bb13169d66c8c825c876da57e0f8917992de21dc /scripts | |
parent | 99d31b7f2ca0041cb7870c6ebecd44e3fc1700d4 (diff) | |
download | quilt-5b3c46d7f9cc3be46af00c556ea887f437dbeb04.tar.gz |
- Remove .pc/*/.pc files, and adjust various scripts accordingly.
- Run test/one.test inside sub-directory.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/apatch.in | 63 | ||||
-rw-r--r-- | scripts/patchfns.in | 83 | ||||
-rwxr-xr-x | scripts/rpatch.in | 63 |
3 files changed, 63 insertions, 146 deletions
diff --git a/scripts/apatch.in b/scripts/apatch.in index 973988a..69f327f 100755 --- a/scripts/apatch.in +++ b/scripts/apatch.in @@ -25,13 +25,16 @@ usage() rollback_patch() { - local patch=$1 pc_file=$(pc_file_name $patch) - @LIB@/backup-files $silent_unless_verbose \ - -f $pc_file -B .pc/$patch/ -r + local patch=$1 pc_file=$(gen_tempfile) + + # FIXME backup_files should scan the directory hierarchy itself. + files_in_patch $patch > $pc_file + @LIB@/backup-files $silent_unless_verbose -f $pc_file -B .pc/$patch/ -r if [ -z "$opt_leave_rejects" ] then - rm -f $(files_in_patch $patch | @SED@ -e 's/$/\.rej/') + @SED@ -e 's/$/\.rej/' $pc_file | xargs rm -f fi + rm -f $pc_file } interrupt() @@ -55,15 +58,15 @@ apply_patch() if [ "x${patch_file:(-3)}" = "x.gz" ] then gzip -cd $patch_file \ - | @PATCH@ $(patch_args $patch) --no-backup-if-mismatch \ + | @PATCH@ $(patch_args $patch) --backup --prefix=".pc/$patch/" \ -E $silent $force_apply elif [ "x${patch_file:(-4)}" = "x.bz2" ] then bzip2 -cd $patch_file \ - | @PATCH@ $(patch_args $patch) --no-backup-if-mismatch \ + | @PATCH@ $(patch_args $patch) --backup --prefix=".pc/$patch/" \ -E $silent $force_apply else - @PATCH@ $(patch_args $patch) --no-backup-if-mismatch \ + @PATCH@ $(patch_args $patch) --backup --prefix=".pc/$patch/" \ -E $silent -i $patch_file $force_apply fi } @@ -71,39 +74,9 @@ apply_patch() apatch() { local patch=$(stripit $1) - local pc_file=$(pc_file_name $patch) local file status - trap "" SIGINT - if ! refresh_file_list $patch - then - echo $"refresh_file_list failed" - return 1 - fi - echo $"Applying $patch" - if ! [ -e $pc_file ] - then - echo $"Patch $patch appears to be empty, applied" - add_to_db $patch - return 0 - fi - - status=$? - if [ $status -eq 2 ] - then - [ -z "$opt_quiet" ] && echo $"Recreated file list for $patch" - elif [ $status -ne 0 ] - then - return 1 - fi - - if ! @LIB@/backup-files $silent_unless_verbose \ - -f $pc_file -B .pc/$patch/ - then - exit 1 - fi - trap "interrupt $patch" SIGINT apply_patch $patch @@ -111,18 +84,20 @@ apatch() trap "" SIGINT - # Remember date/time of applying so that pop can - # avoid reverse applying the patch in the usual cases. - touch $pc_file - if [ $status -eq 0 -o -n "$opt_force" ] then add_to_db $patch if [ $status -eq 0 ] then - rm -f $pc_file~refresh + rm -f .pc/$patch~refresh else - touch $pc_file~refresh + touch .pc/$patch~refresh + fi + if [ "$(shopt -s nullglob ; echo .pc/$patch/*)" = "" ] + then + echo $"Patch $patch appears to be empty, applied" + elif [ $status -ne 0 ] + then echo $"Applied $patch (forced; needs refresh)" fi else @@ -181,7 +156,7 @@ fi patch=$(stripit $1) top=$(top_patch) -if [ -n "$top" -a -e $(pc_file_name $top)~refresh ] +if [ -n "$top" -a -e .pc/$top~refresh ] then echo $"The topmost patch $top needs to be refreshed first." exit 1 diff --git a/scripts/patchfns.in b/scripts/patchfns.in index e8f0808..a4329df 100644 --- a/scripts/patchfns.in +++ b/scripts/patchfns.in @@ -234,16 +234,6 @@ rename_in_series() rm -f $tmpfile } -pc_file_name() -{ - while [ $# -gt 0 ] - do - echo ".pc/$1/.pc" - shift - done - -} - backup_file_name() { local patch=$1 @@ -357,10 +347,14 @@ next_patch_for_file() if [ -n "$patches_on_top" ] then - grep -l -E "^$(quote_re $file)\$" \ - $(pc_file_name $patches_on_top) \ - | head -n 1 \ - | @SED@ -e 's:^\.pc/::' -e 's:/\.pc$::' + for patch in $patches_on_top + do + if [ -f $(backup_file_name $patch $file) ] + then + echo $patch + break + fi + done fi } @@ -397,16 +391,19 @@ stripit() file_in_patch() { local file=$1 patch=$2 - files_in_patch $patch \ - | grep -q -E "^$(quote_re $file)\$" + [ -f ".pc/$patch/$file" ] } files_in_patch() { - local pc_file=$(pc_file_name $1) - if [ -e "$pc_file" ] + local patch="$1" + local path=".pc/$patch" + if [ -d "$path" ] then - cat $pc_file + for file in $(find "$path" -type f) + do + echo "${file:${#path}+1}" + done fi } @@ -425,47 +422,6 @@ touched_by_patch() }' } -refresh_file_list() -{ - local patch=$1 - local pc_file=$(pc_file_name $patch) - local patch_file=$(patch_file_name $patch) - - if ! [ -e "$patch_file" ] - then - return 0 - fi - if [ ! -e $pc_file -o \ - $pc_file -ot $patch_file -o \ - $pc_file -ot $SERIES ] - then - local tmpfile status - if ! mkdir -p $(dirname $pc_file) || \ - ! tmpfile=$(gen_tempfile) - then - return 1 - fi - - # Do not reorder files in the file list... - - if [ -e $pc_file ] - then - cat $pc_file >> $tmpfile - fi - if ! touched_by_patch $(patch_strip_level $patch) \ - $patch >> $tmpfile - then - return 1 - fi - @AWK@ ' { if (seen[$0]) next - seen[$0]=1 - print - }' $tmpfile > $pc_file - rm $tmpfile - return 0 - fi -} - fix_diff_header() { local from=$1 to=$2 @@ -478,10 +434,9 @@ diff_file() local file=$1 old_file=$2 new_file=$3 local old_hdr new_hdr line - if [ ! -e "$old_file" -a ! -e "$new_file" ] - then - return 0 - fi + [ -s "$old_file" ] || old_file=/dev/null + [ -s "$new_file" ] || new_file=/dev/null + if [ $opt_strip_level -eq 0 ] then old_hdr=$file.orig diff --git a/scripts/rpatch.in b/scripts/rpatch.in index 286ccd7..9f07f36 100755 --- a/scripts/rpatch.in +++ b/scripts/rpatch.in @@ -57,16 +57,10 @@ files_may_have_changed() { local patch=$1 file local patch_file=$(patch_file_name $patch) - local pc_file=$(pc_file_name $patch) - - if ! [ -e $pc_file ] - then - return 1 - fi - local apply_ts=$(date -r $pc_file '+%s') ts + local apply_ts=$(date -r ".pc/$patch" '+%s') ts - if [ -e "$patch_file" -a $pc_file -ot "$patch_file" ] + if [ -e "$patch_file" -a ".pc/$patch" -ot "$patch_file" ] then return 0 fi @@ -89,18 +83,12 @@ files_may_have_changed() rollback_patch() { - local patch=$1 pc_file=$(pc_file_name $patch) - @LIB@/backup-files $silent_unless_verbose \ - -f $pc_file -z ~rpatch -r - rm -f $(files_in_patch $patch | @SED@ -e 's/$/\.rej/') -} + local patch=$1 pc_file=$2 -interrupt() -{ - local patch=$1 - rollback_patch $patch - echo $"Interrupted by user; patch $patch was not removed." - exit 1 + # We may only have applied the patch half-way, so only some of the + # backup files may exist. Ignore missing files (-F). + @LIB@/backup-files $silent_unless_verbose -f $pc_file -z ~rpatch -rF + @SED@ -e 's/$/\.rej/' $pc_file | xargs rm -f } reverse_patch() @@ -117,24 +105,26 @@ reverse_patch() if [ "x${patch_file:(-3)}" = "x.gz" ] then gzip -cd $patch_file \ - | @PATCH@ $(patch_args $patch) --no-backup-if-mismatch \ + | @PATCH@ $(patch_args $patch) --backup --suffix="~rpatch" \ -R -E $silent elif [ "x${patch_file:(-4)}" = "x.bz2" ] then bzip2 -cd $patch_file \ - | @PATCH@ $(patch_args $patch) --no-backup-if-mismatch \ + | @PATCH@ $(patch_args $patch) --backup --suffix="~rpatch" \ -R -E $silent else - @PATCH@ $(patch_args $patch) --no-backup-if-mismatch \ + @PATCH@ $(patch_args $patch) --backup --suffix="~rpatch" \ -R -E $silent -i $patch_file fi } rpatch() { - local patch=$1 pc_file=$(pc_file_name $patch) + local patch=$1 pc_file=$(gen_tempfile) - if ! [ -e $pc_file ] + # FIXME backup-files should scan the directory tree itself. + files_in_patch $patch > $pc_file + if ! [ -s $pc_file ] then echo $"Patch $patch appears to be empty, removed" remove_from_db $patch @@ -153,24 +143,15 @@ rpatch() @LIB@/backup-files $silent -f $pc_file -B .pc/$patch/ -r status=$? remove_from_db $patch - rm -f $pc_file~refresh + rm -f .pc/$patch~refresh if [ $status != 0 ] then exit $status fi else - if ! @LIB@/backup-files $silent_unless_verbose \ - -f $pc_file -z ~rpatch - then - echo $"Failed to create temporary files" >&2 - return 1 - fi - - trap "interrupt $patch" SIGINT - + trap "interrupted=1" SIGINT reverse_patch $patch status=$? - trap "" SIGINT if [ $status -eq 0 ] && verify_removal $patch @@ -182,11 +163,17 @@ rpatch() remove_from_db $patch else - rollback_patch $patch - echo $"Patch $patch does not remove (enforce with -f)" + rollback_patch $patch $pc_file + if [ -n "$interrupted" ] + then + echo $"Interrupted by user; patch $patch was not removed." + else + echo $"Patch $patch does not remove (enforce with -f)" + fi return 1 fi fi + rm -f $pc_file trap - SIGINT } @@ -233,7 +220,7 @@ patch=$(stripit $1) [ -z "$opt_verbose" ] && silent_unless_verbose=-s top=$(top_patch) -if [ -n "$top" -a -e $(pc_file_name $top)~refresh -a -z "$opt_force" ] +if [ -n "$top" -a -e .pc/$top~refresh -a -z "$opt_force" ] then echo $"The topmost patch $top needs to be refreshed first." exit 1 |