summaryrefslogtreecommitdiff
path: root/pre-install.d/50uncommitted-changes
blob: 231eeb1b5abb1d47a9a66791a37f771bfc29784c (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
#!/bin/sh
set -e

. /etc/etckeeper/etckeeper.conf

if [ -d .git ] && ! LANG=C git-status 2>&1 | grep -q "working directory clean"; then
	RET="true"
	if [ "$HIGHLEVEL_PACKAGE_MANAGER" = "apt" ]; then
		. /usr/share/debconf/confmodule
		db_capb escape
		db_title etckeeper

		db_reset etckeeper/unclean || true
		db_subst etckeeper/unclean STATUS $(git-status | debconf-escape -e) || true
		db_input critical etckeeper/unclean || true
		db_go || true
		db_get etckeeper/unclean
	fi
	if [ "$RET" = true ]; then
		git add .
		if ! git commit $GIT_COMMIT_OPTIONS -m "saving uncommitted changes in /etc prior to $HIGHLEVEL_PACKAGE_MANAGER run"; then
			if [ "$HIGHLEVEL_PACKAGE_MANAGER" = "apt" ]; then
				db_input critical etckeeper/commit_failed || true
				db_go || true
				db_reset etckeeper/commit_failed || true
			elif [ "$HIGHLEVE_PACKAGE_MANAGER" = "pacman-g2" ]; then
				echo "error: etckeeper failed to commit changes in /etc using git (git commit failed)"
				exit 1
			fi
		fi
	fi
	if [ "$HIGHLEVEL_PACKAGE_MANAGER" = "apt" ]; then
		db_reset etckeeper/unclean || true
	fi
fi