]> pd.if.org Git - zpackage/commitdiff
add script to commit configfiles to git
authorNathan Wagner <nw@hydaspes.if.org>
Mon, 3 Dec 2018 08:15:30 +0000 (08:15 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Mon, 3 Dec 2018 08:15:30 +0000 (08:15 +0000)
zpm-confgit [new file with mode: 0755]

diff --git a/zpm-confgit b/zpm-confgit
new file mode 100755 (executable)
index 0000000..5d82d40
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# add all installed config files to git
+
+# GIT_DIR=/var/lib/zpm/confgit
+
+
+if [ -z "$TARGET" ]; then
+       TARGET=/var/lib/zpm/confgit
+       export TARGET
+fi
+
+if [ ! -d "$TARGET" ]; then
+       git init $TARGET
+fi
+
+efail=0
+for pkgid in $(zpm list -I "$@"); do
+zpm foreach-path -p $pkgid -F 'configuration = 1' | rsync --info=all0,backup1 --exclude=.git --files-from=- -drp / $TARGET
+if [ $? -ne 0 ]; then
+       efail=1
+fi
+(
+set -e
+cd $TARGET
+git add .
+git diff --quiet && git diff --staged --quiet || git commit -m "update $pkgid configuration files"
+)
+if [ $? -ne 0 ]; then
+       efail=1
+fi
+done
+
+exit $efail