diff options
Diffstat (limited to 'debian/postinst')
-rw-r--r-- | debian/postinst | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..59e9f4a --- /dev/null +++ b/debian/postinst @@ -0,0 +1,98 @@ +#!/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 + if dpkg --compare-versions "$2" le "0.13"; then + mv_conffile "/etc/etckeeper/init.d/10restore-etckeeper" \ + "/etc/etckeeper/init.d/20restore-etckeeper" + mv_conffile "/etc/etckeeper/init.d/20restore-metadata" \ + "/etc/etckeeper/init.d/10restore-metadata" + fi + if dpkg --compare-versions "$2" le "0.28"; then + for c in commit.d/30darcs-add init.d/60darcs-deleted-symlinks; do + if [ -e /etc/etckeeper/$c ]; then + chmod +x /etc/etckeeper/$c + fi + done + fi + if dpkg --compare-versions "$2" le "0.61"; then + # may be left over from a botched conffile removal + rm -f /etc/etckeeper/commit.d/40git-rm.dpkg-dist + fi + + if [ "$2" = "" ] && [ -e "/etc/etckeeper/etckeeper.conf" ]; then + # Fresh install. + . /etc/etckeeper/etckeeper.conf || true + if [ -n "$VCS" ] && [ -x "`which $VCS 2>/dev/null`" ]; then + if etckeeper init; then + if ! etckeeper commit "Initial commit"; then + echo "etckeeper commit failed; run it by hand" >&2 + fi + else + echo "etckeeper init failed; run it by hand" >&2 + fi + else + echo "etckeeper init not ran as $VCS is not installed" >&2 + fi + fi + + # prints error and exits nonzero if the ignore file cannot be updated + etckeeper update-ignore || true +esac |