summaryrefslogtreecommitdiff
path: root/debian/postinst
blob: 7cd4573946c84fbbc9dd9e50765dcd972b5feb02 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
set -e

# source confmodule to ensure templates are loaded
. /usr/share/debconf/confmodule

#DEBHELPER#

# Move a conffile without triggering a dpkg question
mv_conffile() {
	OLDCONFFILE="$1"
	NEWCONFFILE="$2"

	if [ -e "$OLDCONFFILE" ]; then
		echo "Preserving user changes to $NEWCONFFILE ..."
		mv -f "$NEWCONFFILE" "$NEWCONFFILE".dpkg-new
		mv -f "$OLDCONFFILE" "$NEWCONFFILE"
	fi
}

case "$1" in
configure)
	if dpkg --compare-versions "$2" le "0.7"; then
		if [ -d /etc/etckeeper/pre-apt.d ]; then
			mv_conffile "/etc/etckeeper/pre-apt.d/README" \
				"/etc/etckeeper/pre-install.d/README"
			mv_conffile "/etc/etckeeper/pre-apt.d/50uncommitted-changes" \
				"/etc/etckeeper/pre-install.d/50uncommitted-changes"
			rmdir --ignore-fail-on-non-empty /etc/etckeeper/pre-apt.d
		fi
		if [ -d /etc/etckeeper/post-apt.d ]; then
			mv_conffile "/etc/etckeeper/post-apt.d/README" \
				"/etc/etckeeper/post-install.d/README"
			mv_conffile "/etc/etckeeper/post-apt.d/10git-test" \
				"/etc/etckeeper/post-install.d/10vcs-test"
			mv_conffile "/etc/etckeeper/post-apt.d/30git-add" \
				"/etc/etckeeper/post-install.d/30git-add"
			mv_conffile "/etc/etckeeper/post-apt.d/40git-rm" \
				"/etc/etckeeper/post-install.d/40git-rm"
			mv_conffile "/etc/etckeeper/post-apt.d/50git-commit" \
				"/etc/etckeeper/post-install.d/50vcs-commit"
			rmdir --ignore-fail-on-non-empty /etc/etckeeper/post-apt.d
		fi
		mv_conffile "/etc/etckeeper/init.d/40git-init" \
			"/etc/etckeeper/init.d/40vcs-init"
		mv_conffile "/etc/etckeeper/init.d/50git-ignore" \
			"/etc/etckeeper/init.d/50vcs-ignore"
		mv_conffile "/etc/etckeeper/init.d/50git-perm" \
			"/etc/etckeeper/init.d/50vcs-perm"
		mv_conffile "/etc/etckeeper/init.d/50git-pre-commit-hook" \
			"/etc/etckeeper/init.d/50vcs-pre-commit-hook"
		mv_conffile "/etc/etckeeper/init.d/70git-add" \
			"/etc/etckeeper/init.d/70git-add"
	fi
	if dpkg --compare-versions "$2" le "0.10"; then
        	for c in 10vcs-test 30git-add 30hg-addremove 40git-rm; do
			mv_conffile "/etc/etckeeper/post-install.d/$c" \
				"/etc/etckeeper/commit.d/$c"

		done
	fi
esac