summaryrefslogtreecommitdiff
path: root/post-install.d/50vcs-commit
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-10-23 14:46:31 +0200
committeremkael <emkael@tlen.pl>2016-10-23 14:46:31 +0200
commit2040ffd9ba70548b02fd89e1e6bfb7031505562e (patch)
treecb7af6d80ecdbab0b4236c67a1d846a1684ff161 /post-install.d/50vcs-commit
parent01cff54d4007c5ade9fca76138fa181f74deb143 (diff)
Detailed post-install commit messagesHEADmaster
Diffstat (limited to 'post-install.d/50vcs-commit')
-rwxr-xr-xpost-install.d/50vcs-commit48
1 files changed, 48 insertions, 0 deletions
diff --git a/post-install.d/50vcs-commit b/post-install.d/50vcs-commit
index 53138c8..12f997e 100755
--- a/post-install.d/50vcs-commit
+++ b/post-install.d/50vcs-commit
@@ -3,6 +3,43 @@ set -e
pl="/var/cache/etckeeper/packagelist"
+get_changes () {
+ if [ "$VCS" = git ]; then
+ git diff --stat | grep '|' | cut -d'|' -f1 | cut -b2-
+ git ls-files --exclude-standard --others
+ fi
+ if [ "$VCS" = hg ]; then
+ hg status --no-status
+ fi
+ if [ "$VCS" = bzr ]; then
+ bzr status -S | cut -b5-
+ fi
+ if [ "$VCS" = darcs ]; then
+ # ignore ' file -> file' lines for moved files
+ # trim ' -M +N rP' from change summary
+ darcs whatsnew --summary | grep -v '^ .* -> ' | cut -d' ' -f2- | sed 's/ [-+r][0-9]\+//g;s/^\.\///'
+ # lines beginning with 'a' show unversioned files
+ darcs whatsnew --look-for-adds --boring --summary | grep '^a' | cut -d' ' -f2- | sed 's/^\.\///'
+ fi
+}
+
+get_changed_packages () {
+ if [ "$LOWLEVEL_PACKAGE_MANAGER" = dpkg ]; then
+ get_changes | sed 's/^/\/etc\//;s/\s*$//' | xargs -d '\n' dpkg 2>/dev/null -S | cut -d':' -f1 | sed 's/, /\n/g'
+ fi
+ if [ "$LOWLEVEL_PACKAGE_MANAGER" = rpm ]; then
+ # if output contains file path, file was not found
+ get_changes | sed 's/^/\/etc\//;s/\s*$//' | xargs -d '\n' rpm --qf '%{NAME}\n' -qf | grep -v "/etc/"
+ fi
+ # is it even possible to use pacmatic without pacman?
+ if [ "$LOWLEVEL_PACKAGE_MANAGER" = pacman -o "$LOWLEVEL_PACKAGE_MANAGER" = pacmatic ]; then
+ get_changes | sed 's/^/\/etc\//;s/\s*$//' | xargs -d '\n' pacman 2>/dev/null -Qo | rev | cut -d' ' -f1-2 | rev | cut -d' ' -f1
+ fi
+ if [ "$LOWLEVEL_PACKAGE_MANAGER" = pkgng ]; then
+ get_changes | sed 's/^/\/etc\//;s/\s*$//' | xargs -d '\n' pkg which --quiet | rev | cut -d'-' -f2- | rev
+ fi
+}
+
if etckeeper unclean; then
message="committing changes in /etc after $HIGHLEVEL_PACKAGE_MANAGER run"
@@ -11,6 +48,16 @@ if etckeeper unclean; then
(
echo "$message"
echo
+ get_changed_packages | sort | uniq > $pl.found-pkgs
+ if [ -s $pl.found-pkgs ]; then
+ sed -i 's/^/^[-+]/;s/$/ /' $pl.found-pkgs
+ etckeeper list-installed | diff -U0 $pl.pre-install - | tail -n+4 | egrep '^[-+]' | grep -f $pl.found-pkgs > $pl.found-packages
+ if [ -s $pl.found-packages ]; then
+ echo "Packages with configuration changes:"
+ cat $pl.found-packages || true
+ echo
+ fi
+ fi
echo "Package changes:"
etckeeper list-installed | diff -U0 $pl.pre-install - | tail -n+4 | egrep '^[-+]' || true
) | etckeeper commit --stdin
@@ -26,3 +73,4 @@ if etckeeper unclean; then
fi
rm -f $pl.pre-install $pl.fmt
+rm -f $pl.found-pkgs $pl.found-packages