summaryrefslogtreecommitdiff
path: root/post-install.d/50vcs-commit
blob: edd3444dce2ce380e63c5b6905bbf65e21eb6a8d (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
#!/bin/sh
set -e

if [ "$1" = "fail-debconf" ]; then
	. /usr/share/debconf/confmodule
	db_title etckeeper
	db_subst etckeeper/commit_failed VCS "$VCS"
	db_input critical etckeeper/commit_failed || true
	db_go || true
	db_reset etckeeper/commit_failed || true
	exit 0
fi
		
pl="/var/cache/etckeeper/packagelist"

if etckeeper unclean; then
	message="committing changes in /etc after $HIGHLEVEL_PACKAGE_MANAGER run"

	set +e
	if [ -e $pl.pre-install ]; then
		(
			echo "$message"
			echo
			echo "Package changes:"
			etckeeper list-installed | diff -U0 $pl.pre-install - | tail -n+4 | egrep '^[-+]' || true
		) | etckeeper commit --stdin
	else
		etckeeper commit "$(printf "$message")"
	fi
	status=$?
	set -e

	if [ "$status" != 0 ]; then
		if [ -e /usr/share/debconf/confmodule ]; then
			$0 fail-debconf
		else
			echo "error: etckeeper failed to commit changes in /etc using $VCS"
			exit 1
		fi
	fi
fi
	
if [ -e $pl.pre-install ]; then
	rm -f $pl.pre-install
fi