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

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
		echo "warning: etckeeper failed to commit changes in /etc using $VCS" >&2
	fi
fi
	
if [ -e $pl.pre-install ]; then
	rm -f $pl.pre-install
fi