tags 654596 + patch
quit

Anders Kaseorg wrote:

> I’ll let you decide which version is less horrible.

Let's go with this one, I guess.

-- >8 --
Subject: git.preinst: work around overzealous "mv" check

coreutils mv refuses to move a symlink over a hard link to the same
file, so the code in preinst to handle upgrades from versions in
which builtins were hard links doesn't work.

Instead, it errors out with the message

        mv: `/usr/lib/git-core/git-add.tmp' and `/usr/lib/git-core/git-add' are 
the same file

This isn't a limitation of the rename() syscall, but a
coreutils-specific check in mv.  It is possible to interpret POSIX as
permitting that kind of safety check for src and dst pointing to the
same file, so let's steer clear by making the symlink target a
different inode.

The cost is some complication and a megabyte wasted until the new
version is unpacked.

Reported-by: Jon Dowland <j...@debian.org>
Analysis-by: Anders Kaseorg <ande...@mit.edu>
Works-around: http://debbugs.gnu.org/6960 
Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 debian/changelog   |   10 ++++++++++
 debian/git.preinst |   13 +++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 3a8b2f40..1323525d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+git (1:1.7.8.2-1.1) unstable; urgency=medium
+
+  * debian/git.preinst: on upgrade from git <= 1:1.7.7-1, replace
+    /usr/lib/git-core/git with a copy of itself.  This prevents "are the
+    same file" errors when replacing hard links to the old copy with
+    symlinks using "mv" (thx Jon Dowland and Anders Kaseorg; closes:
+    #654666).
+
+ -- Jonathan Nieder <jrnie...@gmail.com>  Wed, 04 Jan 2012 18:53:21 -0600
+
 git (1:1.7.8.2-1) unstable; urgency=low
 
   * merge branch debian-experimental.
diff --git a/debian/git.preinst b/debian/git.preinst
index c32fdbfe..eccf0d89 100644
--- a/debian/git.preinst
+++ b/debian/git.preinst
@@ -42,12 +42,21 @@ rm_conffile /etc/emacs/site-start.d/50git-core.el "$1" "$2"
 #
 # Replace the hard links with symlinks _before_ upgrading to
 # avoid trouble.
+#
+# For added fun, coreutils mv will not replace a file by a
+# symlink to the same inode (bug #654666).  We give
+# /usr/lib/git-core/git its own inode to work around that.
 
 if test "$1" = upgrade &&
    dpkg --compare-versions "$2" lt-nl '1:1.7.7-2'; then
-       refinode=$(stat -c%i /usr/lib/git-core/git)
+       refinode=$(stat -c%i /usr/lib/git-core/git-add)
+
+       rm -f /usr/lib/git-core/git.tmp
+       cp -p /usr/lib/git-core/git /usr/lib/git-core/git.tmp
+       mv -f /usr/lib/git-core/git.tmp /usr/lib/git-core/git
        for f in /usr/lib/git-core/*; do
-               test "$f" != /usr/lib/git-core/git || continue
+               test "$f" != /usr/lib/git-core/git &&
+               test "$f" != /usr/lib/git-core/git-add || continue
                rm -f "$f.tmp"
                inode=$(stat -c%i "$f")
                test "$inode" = "$refinode" || continue
-- 
1.7.8.2




--
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to