X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=etc%2Fapt%2Fhg-snapshot-script;fp=etc%2Fapt%2Fhg-snapshot-script;h=95e986508ba3a61440d706bfdc03f219103c4cd6;hb=55466f63b5d5c8b28ea1400a434eae4ee7dc67eb;hp=0000000000000000000000000000000000000000;hpb=12f0aa60f20df76f4a10a08b84590d1485c062b2;p=grml-etc-core.git diff --git a/etc/apt/hg-snapshot-script b/etc/apt/hg-snapshot-script new file mode 100755 index 0000000..95e9865 --- /dev/null +++ b/etc/apt/hg-snapshot-script @@ -0,0 +1,39 @@ +#!/bin/sh +# Filename: hg-snapshot-script +# Purpose: automatically track changed files using mercurial +# Authors: grml-team (grml.org), (c) Michael Prokop +# Bug-Reports: see http://grml.org/bugs/ +# License: This file is licensed under the GPL v2 or any later version. +# Latest change: Mit Sep 26 22:46:32 CEST 2007 [mika] +################################################################################ + +set -e + +caller=$(ps axww | mawk '/aptitude|apt-get/ {for (i=5; i<=NF ; i++) printf ("%s ",$i); printf ("\n") }' | head -1) + +hg addremove 1>/dev/null +STATUS="$(hg st)" + +if [ -z "$STATUS" ] ; then + echo "hg-snapshot-script: nothing to be done" +else + case "$1" in + pre) + echo "hg-snapshot-script: found changed files:" + hg st + hg ci -m "snapshot from $LOGNAME before: $caller" + ;; + post) + echo "hg-snapshot-script: found changed files:" + hg st + hg ci -m "snapshot from $LOGNAME after: $caller" + ;; + *) + echo "hg-snapshot-script: found changed files:" + hg st + hg ci -m "snapshot from $LOGNAME on $(date '+%Y-%m-%d - %H:%M:%S')" + ;; + esac +fi + +## END OF FILE #################################################################