As "patch" originally did not handle symbolic links, backup-files didn't have to care about them either. But now that git has introduced an extended syntax which allows manipulating symbolic links in patch files, "quilt push" may create or delete symbolic links, which means that backup-files must support such operations too.
Also extend the backup-files test case to cover these operations. This fixes bug #59479: https://savannah.nongnu.org/bugs/index.php?59479 Signed-off-by: Jean Delvare <[email protected]> --- quilt/scripts/backup-files.in | 22 +++++++++++++--------- test/backup-files.test | 29 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 9 deletions(-) --- quilt.orig/quilt/scripts/backup-files.in 2019-04-15 08:57:43.755394855 +0200 +++ quilt/quilt/scripts/backup-files.in 2020-11-18 15:32:48.224687161 +0100 @@ -110,24 +110,28 @@ restore() local file=$1 local backup=$OPT_PREFIX$file - if [ ! -e "$backup" ]; then + if [ ! -L "$backup" -a ! -e "$backup" ]; then return 1 fi - if [ -s "$backup" ]; then + if [ -L "$backup" -o -s "$backup" ]; then $ECHO "Restoring $file" - if [ -e "$file" ]; then + if [ -L "$file" -o -e "$file" ]; then rm "$file" else mkdir -p "$(dirname "$file")" fi - ln "$backup" "$file" 2>&4 || cp -p "$backup" "$file" + if [ -L "$backup" ]; then + cp -P "$backup" "$file" + else + ln "$backup" "$file" 2>&4 || cp -p "$backup" "$file" + fi - if [ -n "$OPT_TOUCH" ]; then + if [ -n "$OPT_TOUCH" -a ! -L "$file" ]; then touch "$file" fi else $ECHO "Removing $file" - if [ -e "$file" ]; then + if [ -L "$file" -o -e "$file" ]; then rm "$file" fi fi @@ -149,7 +153,7 @@ restore_all() cd "$OPT_PREFIX" find . -type f -size 0 -print0 > "$EMPTY_FILES" - find . -type f -size +0 -print0 > "$NONEMPTY_FILES" + find . \( -type f -size +0 -o -type l \) -print0 > "$NONEMPTY_FILES" cd "$OLDPWD" if [ -s "$EMPTY_FILES" ]; then @@ -164,7 +168,7 @@ restore_all() local target_dir=$PWD if (cd "$OPT_PREFIX" && \ - xargs -0 cp -l --parents --remove-destination \ + xargs -0 cp -Pl --parents --remove-destination \ --target-directory="$target_dir" \ < "$NONEMPTY_FILES" 2>&4); then notify_action Restoring "$NONEMPTY_FILES" @@ -185,7 +189,7 @@ restore_all() fi if [ -n "$OPT_TOUCH" ]; then - xargs -0 touch -c < "$NONEMPTY_FILES" + xargs -0 touch -ch < "$NONEMPTY_FILES" fi fi --- quilt.orig/test/backup-files.test 2020-11-18 15:26:03.471924591 +0100 +++ quilt/test/backup-files.test 2020-11-18 15:33:53.223456181 +0100 @@ -229,3 +229,32 @@ Unit test of the backup-files script. > 1 $ [ ! -s new ] || echo "file snapshot/new should be empty" $ rm -rf snapshot + + # Test backup and restoration of a symbolic link + $ ln -s foo link + $ readlink link + > foo + $ %{QUILT_DIR}/scripts/backup-files -B backup/ -b link + > Copying link + $ readlink backup/link + > foo + $ rm -f link + $ %{QUILT_DIR}/scripts/backup-files -B backup/ -k -r link + > Restoring link + $ readlink link + > foo + + # Same but reading from a file + $ rm -f link + $ %{QUILT_DIR}/scripts/backup-files -B backup/ -k -r -f - + < link + > Restoring link + $ readlink link + > foo + + # Same but without specifying the file + $ rm -f link + $ %{QUILT_DIR}/scripts/backup-files -B backup/ -r - + > Restoring link + $ readlink link + > foo -- Jean Delvare SUSE L3 Support _______________________________________________ Quilt-dev mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/quilt-dev
