debian/changelog: fix misspelling in comment crediting lolando
[git/debian.git] / debian / git.preinst
blob63fd976f18933294f16d0f3815630c70f2e40d65
1 #!/bin/sh
2 set -e
4 # /var/cache/git/ -> /var/lib/git/ transition
5 if test "$1" = upgrade &&
6 dpkg --compare-versions "$2" lt-nl '1:1.8.4~rc0-1'; then
7 mkdir -m 755 -p /var/lib/git
9 cd /var/lib/git
10 for target in ../../cache/git/*; do
11 if ! test -L "$target" && ! test -e "$target"; then
12 continue
15 link=${target#../../cache/git/}
16 if ! test -L "$link" && ! test -e "$link"; then
17 ln -s "$target" "$link"
19 done
23 # A previous version of the /var/lib/git/ transition code
24 # left behind a symlink '/var/lib/git/*' -> '../../cache/git/*'.
25 if test "$1" = upgrade &&
26 dpkg --compare-versions "$2" eq '1:1.8.4~rc0-1' &&
27 test -L '/var/lib/git/*'; then
28 target=$(readlink '/var/lib/git/*')
29 if test "$target" = '../../cache/git/*'; then
30 rm -f '/var/lib/git/*'
34 # Snippet based on dpkg-maintscript-helper from dpkg 1.15.8.
35 # Postinst explains why.
36 rm_conffile () {
37 CONFFILE=$1; shift
38 test "$1" = install || test "$1" = upgrade || return 0
39 dpkg --compare-versions "$2" lt-nl "$3" || return 0
40 test -e "$CONFFILE" || return 0
42 md5sum=$(md5sum $CONFFILE | sed -e 's/ .*//')
43 old_md5sum=$(
44 dpkg-query -W -f='${Conffiles}' git |
45 sed -n -e "\' $CONFFILE ' { s/ obsolete\$//; s/.* //; p }"
47 if test "$md5sum" != "$old_md5sum"; then
48 echo "$CONFFILE has been modified by you."
49 echo "Saving as $CONFFILE.dpkg-bak ..."
50 mv -f "$CONFFILE" "$CONFFILE.dpkg-backup"
51 else
52 echo "Moving $CONFFILE out of the way..."
53 mv -f "$CONFFILE" "$CONFFILE.dpkg-remove"
57 rm_conffile /etc/bash_completion.d/git "$1" "$2" '1:1.8.0-1~'
59 # Now /etc/emacs/site-start.d/50git-core.el belongs to the
60 # git-el package. If we are upgrading from a pre- 1.7.4.1-2~
61 # version then git-el is at most unpacked (so its version
62 # is 50git-core.el.dpkg-new if present), and we can remove
63 # an unchanged 50git-core.el file without danger.
65 rm_conffile /etc/emacs/site-start.d/50git-core.el "$1" "$2" '1:1.7.4.1-2~'
67 # Git versions before 1.7.7-2 kept about 100 hard links to
68 # /usr/lib/git-core/git at /usr/lib/git-core/git-* to avoid
69 # wasting time resolving a symlink when old scripts call "git
70 # foo" as git-foo. Btrfs doesn't like to have more than 130 or
71 # so links to a single inode in a given directory. dpkg versions
72 # 1.16.1 and later temporarily double the number of hard links to
73 # an inode when upgrading a package.
75 # Replace the hard links with symlinks _before_ upgrading to
76 # avoid trouble.
78 # For added fun, coreutils mv will not replace a file by a
79 # symlink to the same inode (bug #654666). We give
80 # /usr/lib/git-core/git its own inode to work around that.
82 if test "$1" = upgrade &&
83 dpkg --compare-versions "$2" lt-nl '1:1.7.7-2'; then
84 refinode=$(stat -c%i /usr/lib/git-core/git-add)
86 rm -f /usr/lib/git-core/git.tmp
87 cp -p /usr/lib/git-core/git /usr/lib/git-core/git.tmp
88 mv -f /usr/lib/git-core/git.tmp /usr/lib/git-core/git
89 for f in /usr/lib/git-core/*; do
90 test "$f" != /usr/lib/git-core/git &&
91 test "$f" != /usr/lib/git-core/git-add || continue
92 rm -f "$f.tmp"
93 inode=$(stat -c%i "$f")
94 test "$inode" = "$refinode" || continue
95 ln -s git "$f.tmp"
96 mv -f "$f.tmp" "$f"
97 done