diff --git a/backup-files-restore-symbolic-links.patch b/backup-files-restore-symbolic-links.patch new file mode 100644 index 0000000..ef5d136 --- /dev/null +++ b/backup-files-restore-symbolic-links.patch @@ -0,0 +1,164 @@ +From: Jean Delvare +Date: Wed, 9 Dec 2020 11:39:56 +0100 +Subject: backup-files: Restore symbolic links +Patch-mainline: yes +Git-commit: 26f7bc93d2bbe49a96d23f879b24e82651392497 +References: https://savannah.nongnu.org/bugs/index.php?59479 + +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 +--- + quilt/scripts/backup-files.in | 40 ++++++++++++++++++++++++++++++---------- + test/backup-files.test | 33 +++++++++++++++++++++++++++++++++ + 2 files changed, 63 insertions(+), 10 deletions(-) + +--- a/quilt/scripts/backup-files.in ++++ b/quilt/scripts/backup-files.in +@@ -89,7 +89,7 @@ backup() + dir=$(dirname "$backup") + [ -d "$dir" ] || mkdir -p "$dir" + +- if [ -e "$file" ]; then ++ if [ -L "$file" -o -e "$file" ]; then + $ECHO "Copying $file" + if [ -n "$OPT_NOLINKS" -a "$(stat @STAT_HARDLINK@ "$file")" = 1 ]; then + cp -p "$file" "$backup" +@@ -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 ++ ln -s "$(readlink "$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 +@@ -145,11 +149,13 @@ restore_all() + # Store the list of files to process + EMPTY_FILES=$(gen_tempfile) + NONEMPTY_FILES=$(gen_tempfile) +- trap "rm -f \"$EMPTY_FILES\" \"$NONEMPTY_FILES\"" EXIT ++ LINK_FILES=$(gen_tempfile) ++ trap "rm -f \"$EMPTY_FILES\" \"$NONEMPTY_FILES\" \"$LINK_FILES\"" EXIT + + cd "$OPT_PREFIX" + find . -type f -size 0 -print0 > "$EMPTY_FILES" + find . -type f -size +0 -print0 > "$NONEMPTY_FILES" ++ find . -type l -print0 > "$LINK_FILES" + cd "$OLDPWD" + + if [ -s "$EMPTY_FILES" ]; then +@@ -189,6 +195,20 @@ restore_all() + fi + fi + ++ if [ -s "$LINK_FILES" ]; then ++ (cd "$OPT_PREFIX" && find . -type d -print0) \ ++ | xargs -0 mkdir -p ++ ++ while read -d $'\0' -r ++ do ++ local file=${REPLY#./} ++ local backup=$OPT_PREFIX$file ++ ++ $ECHO "Restoring $file" ++ ln -sf "$(readlink "$backup")" "$file" ++ done < "$LINK_FILES" ++ fi ++ + if [ -z "$OPT_KEEP_BACKUP" ]; then + rm -rf "$OPT_PREFIX" + fi +@@ -212,7 +232,7 @@ copy() + dir=$(dirname "$backup") + [ -d "$dir" ] || mkdir -p "$dir" + +- if [ -e "$file" ]; then ++ if [ -L "$file" -o -e "$file" ]; then + $ECHO "Copying $file" + cp -p "$file" "$backup" + else +@@ -234,7 +254,7 @@ copy_many() + cat "$OPT_FILE" \ + | while read + do +- if [ -e "$REPLY" ]; then ++ if [ -L "$REPLY" -o -e "$REPLY" ]; then + printf '%s\0' "$REPLY" >&3 + else + # This is a rare case, not worth optimizing +--- a/test/backup-files.test ++++ b/test/backup-files.test +@@ -229,3 +229,36 @@ 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 ++ $ mkdir dir ++ $ ln -s foo dir/link ++ $ readlink dir/link ++ > foo ++ $ %{QUILT_DIR}/scripts/backup-files -B backup/ -b dir/link ++ > Copying dir/link ++ $ readlink backup/dir/link ++ > foo ++ $ rm -f dir/link ++ $ echo crap > dir/link ++ $ %{QUILT_DIR}/scripts/backup-files -B backup/ -r -k dir/link ++ > Restoring dir/link ++ $ readlink dir/link ++ > foo ++ ++ # Same but reading from a file ++ $ rm -f dir/link ++ $ echo crap > dir/link ++ $ %{QUILT_DIR}/scripts/backup-files -B backup/ -r -k -f - ++ < dir/link ++ > Restoring dir/link ++ $ readlink dir/link ++ > foo ++ ++ # Same but without specifying the file ++ $ rm -f dir/link ++ $ echo crap > dir/link ++ $ %{QUILT_DIR}/scripts/backup-files -B backup/ -r - ++ > Restoring dir/link ++ $ readlink dir/link ++ > foo diff --git a/inspect-handle-link-in-path.patch b/inspect-handle-link-in-path.patch new file mode 100644 index 0000000..da8c1e1 --- /dev/null +++ b/inspect-handle-link-in-path.patch @@ -0,0 +1,38 @@ +From: Jean Delvare +Subject: inspect-wrapper: procfs resolves links +Patch-mainline: yes +Git-commit: 6363f217b08b07cabbbe09d2d2ddc68596502e38 +References: boo#1179023 + +When patch files are passed through stdin, we get the actual patch +file name from procfs. It turns out that procfs resolves symbolic +links, and that breaks our later attempt to strip the prefix from +the path to extract a relative path to the patch file. + +This is solved by also resolving symbolic links in the prefix +before stripping it. + +Signed-off-by: Jean Delvare +--- + quilt/scripts/inspect-wrapper.in | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +--- a/quilt/scripts/inspect-wrapper.in ++++ b/quilt/scripts/inspect-wrapper.in +@@ -268,7 +268,15 @@ esac + if [ -n "$QUILT_SETUP_FAST" -a -z "$inputfile" ] + then + inputfile=$(readlink /proc/self/fd/0) +- [ "${inputfile:0:1}" = / -a -f "$inputfile" ] || inputfile= ++ if [ "${inputfile:0:1}" = / -a -f "$inputfile" ] ++ then ++ # procfs resolved the symlinks, so do the same, otherwise the ++ # path prefix won't match ++ RPM_SOURCE_DIR=$(cd -P "$RPM_SOURCE_DIR" && echo "$PWD")/ ++ else ++ # Didn't work, so fall back to the slow method ++ inputfile= ++ fi + fi + + if [ -n "$inputfile" ] diff --git a/quilt.changes b/quilt.changes index caed137..27a05db 100644 --- a/quilt.changes +++ b/quilt.changes @@ -1,3 +1,17 @@ +------------------------------------------------------------------- +Wed Dec 9 14:15:38 UTC 2020 - Jean Delvare + +- backup-files-restore-symbolic-links.patch: Handle git-generated + patches which include symbolic link manipulation (savannah bug + #59479). +- quilt.spec: Recommend "ed", as the annotate command requires it. + +------------------------------------------------------------------- +Tue Nov 24 14:37:49 UTC 2020 - Jean Delvare + +- inspect-handle-link-in-path.patch: inspect-wrapper: procfs + resolves links, so we must do the same (bsc#1179023) + ------------------------------------------------------------------- Fri Mar 29 16:06:38 UTC 2019 - Jean Delvare diff --git a/quilt.spec b/quilt.spec index 31e0ddc..8ed9bf2 100644 --- a/quilt.spec +++ b/quilt.spec @@ -1,7 +1,7 @@ # # spec file for package quilt # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -35,18 +35,21 @@ Requires: less Requires: mktemp Requires: patch Requires: perl -Url: http://savannah.nongnu.org/projects/quilt +URL: http://savannah.nongnu.org/projects/quilt Source: %{name}-%{version}.tar.bz2 Source1: suse-start-quilt-mode.el Patch1: expand.diff Patch2: quilt-support-vimdiff.patch Patch3: test-faildiff-workaround-order-bug.patch Patch4: suse-workaround-pseudo-release.patch +Patch5: inspect-handle-link-in-path.patch +Patch6: backup-files-restore-symbolic-links.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch %if 0%{?suse_version} Recommends: procmail Recommends: bzip2 +Recommends: ed Recommends: /usr/bin/rpmbuild %endif %if 0%{?suse_version} > 1120 @@ -64,6 +67,8 @@ un-applied, refreshed, and more. %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 +%patch6 -p1 %build # --with-rpmbuild=/usr/lib/rpm/rpmb: