diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2004-11-15 22:43:19 +0000 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2004-11-15 22:43:19 +0000 |
commit | 3277df52256cfb00d32580fa8519fa2a428a9a92 (patch) | |
tree | 081f89ab7a697cf462dd2d393acd50f22619c852 /scripts | |
parent | acf7a65fb03114102d1d46302d9d221a3acd0c5a (diff) | |
download | quilt-3277df52256cfb00d32580fa8519fa2a428a9a92.tar.gz |
- Get rid of the apatch and rpatch helper scripts: Integrate them
in the push and pop commands. This should bring a small
performance improvement.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/apatch.in | 205 | ||||
-rwxr-xr-x | scripts/rpatch.in | 188 |
2 files changed, 0 insertions, 393 deletions
diff --git a/scripts/apatch.in b/scripts/apatch.in deleted file mode 100755 index 7e58c50..0000000 --- a/scripts/apatch.in +++ /dev/null @@ -1,205 +0,0 @@ -#! @BASH@ - -# This script is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# See the COPYING and AUTHORS files for more details. - -# Read in library functions -if [ "$(type -t patch_file_name)" != function ] -then - if ! [ -r @SCRIPTS@/patchfns ] - then - echo "Cannot read library @SCRIPTS@/patchfns" >&2 - exit 1 - fi - . @SCRIPTS@/patchfns -fi - -usage() -{ - printf $"Usage: $0 [-fqv] patchname\n" - exit 1 -} - -interrupt() -{ - rollback_patch $1 - printf $"Interrupted by user; patch %s was not applied.\n" \ - "$(print_patch $patch)" >&2 - exit 1 -} - -apply_patch() -{ - local patch=$1 - local patch_file=$(patch_file_name $patch) output - - if ! [ -s $patch_file ] - then - printf $"Patch %s appears to be empty\n" "$patch_file" - return 0 - fi - - if [ "x${patch_file:(-3)}" = "x.gz" ] - then - gzip -cd $patch_file \ - | @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) \ - --backup --prefix="$QUILT_PC/$patch/" \ - $no_reject_files \ - -E $silent $force_apply 2>&1 - elif [ "x${patch_file:(-4)}" = "x.bz2" ] - then - bzip2 -cd $patch_file \ - | @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) \ - --backup --prefix="$QUILT_PC/$patch/" \ - $no_reject_files \ - -E $silent $force_apply 2>&1 - else - @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) \ - --backup --prefix="$QUILT_PC/$patch/" \ - $no_reject_files \ - -E $silent $force_apply -i $patch_file 2>&1 - fi -} - -rollback_patch() -{ - local patch=$1 - - @LIB@/backup-files $silent_unless_verbose -r -B $QUILT_PC/$patch/ - -} - -apatch() -{ - local patch=$1 - local file status - - printf $"Applying patch %s\n" "$(print_patch $patch)" - trap "interrupt $patch" SIGINT - - no_reject_files= - if [ -z "$opt_leave_rejects" ]; then - local tmp="$(gen_tempfile)" - trap "rm -f $tmp" EXIT - no_reject_files="-r $tmp" - fi - - output="$(apply_patch $patch)" - status=${PIPESTATUS[0]} - - trap "" SIGINT - - if [ $status -ne 0 -a -z "$opt_leave_rejects" ] - then - # The reject files are removed in rollback_patch. - echo "$output" \ - | @AWK@ ' - /^patching file / { filename = substr($0, 15) } - { if ('${#silent}' != 0) - gsub(/ -- saving rejects to file .*/, "") - else - gsub(/ -- saving rejects to file .*/, " -- rejects in file " filename) - } - { print } - ' - elif [ -n "$output" ] - then - echo "$output" - fi - - if [ $status -eq 0 -o -n "$opt_force" ] - then - add_to_db $patch - if [ $status -eq 0 ] - then - rm -f $QUILT_PC/$patch~refresh - else - touch $QUILT_PC/$patch~refresh - fi - - if [ -e "$QUILT_PC/$patch" ] - then - touch $QUILT_PC/$patch/.timestamp - fi - - if [ "$(shopt -s nullglob ; echo $QUILT_PC/$patch/*)" = "" ] - then - printf $"Patch %s appears to be empty, applied\n" \ - "$(print_patch $patch)" - elif [ $status -ne 0 ] - then - printf $"Applied patch %s (forced; needs refresh)\n" \ - "$(print_patch $patch)" - fi - else - rollback_patch $patch - printf $"Patch %s does not apply (enforce with -f)\n" \ - "$(print_patch $patch)" - status=1 - fi - trap - SIGINT - return $status -} - -options=`getopt -o fqvh --long leave-rejects,interactive -- "$@"` - -if [ $? -ne 0 ] -then - usage -fi - -eval set -- "$options" - -while true -do - case "$1" in - -f) - opt_force=1 - shift ;; - -q) - opt_quiet=1 - shift ;; - -v) - opt_verbose=1 - shift ;; - --leave-rejects) - opt_leave_rejects=1 - shift ;; - --interactive) - opt_interactive=1 - shift ;; - -h) - usage -h ;; - --) - shift - break ;; - esac -done - -if [ $# -ne 1 ] -then - usage -fi - -[ -n "$opt_quiet" ] && silent=-s -[ -z "$opt_verbose" ] && silent_unless_verbose=-s -[ -z "$opt_interactive" ] && force_apply=-f -[ -n "$opt_force" ] && opt_leave_rejects=1 - -patch=$1 - -top=$(top_patch) -if [ -n "$top" -a -e $QUILT_PC/$top~refresh ] -then - printf $"The topmost patch %s needs to be refreshed first.\n" \ - "$(print_patch $top)" - exit 1 -fi - -apatch $patch -### Local Variables: -### mode: shell-script -### End: -# vim:filetype=sh diff --git a/scripts/rpatch.in b/scripts/rpatch.in deleted file mode 100755 index b33652a..0000000 --- a/scripts/rpatch.in +++ /dev/null @@ -1,188 +0,0 @@ -#! @BASH@ - -# This script is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# See the COPYING and AUTHORS files for more details. - -# Read in library functions -if [ "$(type -t patch_file_name)" != function ] -then - if ! [ -r @SCRIPTS@/patchfns ] - then - echo "Cannot read library @SCRIPTS@/patchfns" >&2 - exit 1 - fi - . @SCRIPTS@/patchfns -fi - -usage() -{ - printf $"Usage: %s [-fRq] patchname\n" "$0" - exit 1 -} - -files_may_have_changed() -{ - local patch=$1 file - local patch_file=$(patch_file_name $patch) - - if [ $? -ne 0 -o ! -e "$patch_file" \ - -o ! -e "$QUILT_PC/$patch/.timestamp" \ - -o "$QUILT_PC/$patch/.timestamp" -ot "$patch_file" ] - then - return 0 - fi - - local apply_ts=$(date -r "$QUILT_PC/$patch/.timestamp" '+%s') ts - for file in $(files_in_patch $patch) - do - ts=$(date -r $file '+%s' 2> /dev/null) - [ -z "$ts" ] && return 0 - [ "$ts" -gt $apply_ts ] && return 0 - done - return 1 -} - -# Check if all changes have been folded back into the patch (quilt refresh), -# and report any pending changes. -check_for_pending_changes() -{ - local patch=$1 - local patch_file=$(patch_file_name $patch) - local patch_args=$(patch_args $patch) - local workdir=$(gen_tempfile -d quilt) status=0 - - if [ -d $QUILT_PC/$patch ] - then - if ! rmdir $workdir || # note that this is racey... - ! cp -rl $QUILT_PC/$patch $workdir/ - then - printf $"Failed to copy files to temporary directory\n" >&2 - rm -rf $workdir - return 1 - fi - - # Now we may have some zero-size files that have no - # permissions (which represent files that the patch - # creates). Those may have been created in the meantime, - # but patch would refuse to touch them: We must remove - # them here. - find $workdir -type f -size 0 -exec rm -f '{}' ';' - - fi - - if [ -s $patch_file ] - then - if ! cat_file $patch_file \ - | @PATCH@ -d $workdir $patch_args \ - --no-backup-if-mismatch -E \ - >/dev/null 2>/dev/null - then - if ! [ -e $QUILT_PC/$patch ] - then - printf $"Failed to patch temporary files\n" >&2 - rm -rf $workdir - return 1 - fi - fi - fi - - local remains=$(gen_tempfile) - for file in $(files_in_patch $patch) - do - diff_file $file $workdir/$file $file >> $remains - done - - if [ -s $remains ] - then - printf $"Patch %s does not remove cleanly (refresh it or enforce with -f)\n" \ - "$(print_patch $patch)" >&2 - status=1 - fi - rm -f $remains - rm -rf $workdir - - return $status -} - -rpatch() -{ - local patch=$1 status=0 - - trap "" SIGINT - if [ -z "$opt_force" ] && \ - ( [ -n "$opt_remove" ] || files_may_have_changed $patch ) - then - check_for_pending_changes $patch || status=1 - fi - - if [ $status -eq 0 ] - then - printf $"Removing patch %s\n" "$(print_patch $patch)" - rm -f "$QUILT_PC/$patch/.timestamp" - @LIB@/backup-files $silent -r -t -B $QUILT_PC/$patch/ - - status=$? - remove_from_db $patch - rm -f $QUILT_PC/$patch~refresh - fi - trap - SIGINT - return $status -} - -options=`getopt -o fRqvh -- "$@"` - -if [ $? -ne 0 ] -then - usage -fi - -eval set -- "$options" - -while true -do - case "$1" in - -f) - opt_force=1 - shift ;; - -R) - opt_remove=1 # remove properly with patch -R; no tricks - unset opt_force - shift ;; - -q) - opt_quiet=1 - shift ;; - -v) - opt_verbose=1 - shift ;; - -h) - usage -h ;; - --) - shift - break ;; - esac -done - -if [ $# -ne 1 ] -then - usage -fi - -patch=$1 -[ -n "$opt_quiet" ] && silent=-s -[ -z "$opt_verbose" ] && silent_unless_verbose=-s - -top=$(top_patch) -if [ -n "$top" -a -e $QUILT_PC/$top~refresh -a -z "$opt_force" ] -then - printf $"Patch %s needs to be refreshed first.\n" \ - "$(print_patch $top)" >&2 - exit 1 -fi - -rpatch "$patch" || exit 1 -### Local Variables: -### mode: shell-script -### End: -# vim:filetype=sh |