summaryrefslogtreecommitdiffstats
path: root/debian/git.preinst
blob: 05be8e019410a1de67b7d4b03bffd1656c68f892 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
set -e

#DEBHELPER#

# /var/cache/git/ -> /var/lib/git/ transition
if test "$1" = upgrade &&
   dpkg --compare-versions "$2" lt-nl '1:1.8.4~rc0-1'; then
	mkdir -m 755 -p /var/lib/git
	(
		cd /var/lib/git
		for target in ../../cache/git/*; do
			if ! test -L "$target" && ! test -e "$target"; then
				continue
			fi

			link=${target#../../cache/git/}
			if ! test -L "$link" && ! test -e "$link"; then
				ln -s "$target" "$link"
			fi
		done
	)
fi

# A previous version of the /var/lib/git/ transition code
# left behind a symlink '/var/lib/git/*' -> '../../cache/git/*'.
if test "$1" = upgrade &&
   dpkg --compare-versions "$2" eq '1:1.8.4~rc0-1' &&
   test -L '/var/lib/git/*'; then
	target=$(readlink '/var/lib/git/*')
	if test "$target" = '../../cache/git/*'; then
		rm -f '/var/lib/git/*'
	fi
fi