[opensuse-kernel] [PATCH] sequence-patch: Clean up when patch fails to apply
sequence-patch: Clean up when patch fails to apply If a patch fails to apply, we shouldn't keep its backup files in .pc/. They are no longer needed and may confuse quilt. Also, if a patch is skipped because it can be applied reversed, the resulting tree should be as if the patch wasn't in the series at all. This means we shouldn't leave .rej files behind, nor the backup .pc/ directory for that patch. --- scripts/sequence-patch.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) --- a/scripts/sequence-patch.sh +++ b/scripts/sequence-patch.sh @@ -147,8 +147,12 @@ apply_patches() { STATUS=0 SKIPPED_PATCHES="$SKIPPED_PATCHES $PATCH" PATCH="# $PATCH" + remove_rejects $backup_dir $PATCH_DIR fi fi + + # Backup directory is no longer needed + rm -rf $backup_dir fi if ! $QUILT; then @@ -515,6 +519,26 @@ restore_files() { [ ${#remove[@]} -ne 0 ] \ && printf "%s\n" "${remove[@]}" | xargs rm -f popd > /dev/null + fi +} + +# Helper function to remove stray .rej files. +remove_rejects() { + local backup_dir=$1 patch_dir=$2 file + local -a remove + + if [ -d $backup_dir ]; then + pushd $backup_dir > /dev/null + for file in $(find . -type f) ; do + if [ -f "$patch_dir/$file.rej" ]; then + remove[${#remove[@]}]="$file.rej" + fi + done + cd $patch_dir + #echo "Remove rejects: ${remove[@]}" + [ ${#remove[@]} -ne 0 ] \ + && printf "%s\n" "${remove[@]}" | xargs rm -f + popd > /dev/null fi } -- Jean Delvare Suse L3 Support -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-kernel+owner@opensuse.org
participants (1)
-
Jean Delvare