summaryrefslogtreecommitdiffstats
path: root/update-conf
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2006-10-14 09:31:03 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2006-10-14 09:31:03 +0000
commitccaf94592342255f3f0692c242196fb157a48137 (patch)
treeead59f55d6eedb39843ff755962e03a25e3f78c6 /update-conf
downloadalpine-conf-ccaf94592342255f3f0692c242196fb157a48137.tar.bz2
alpine-conf-ccaf94592342255f3f0692c242196fb157a48137.tar.xz
intial import - version 0.6.0
Diffstat (limited to 'update-conf')
-rw-r--r--update-conf74
1 files changed, 74 insertions, 0 deletions
diff --git a/update-conf b/update-conf
new file mode 100644
index 0000000..c13d8cb
--- /dev/null
+++ b/update-conf
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+
+PREFIX=
+. $PREFIX/lib/libalpine.sh
+
+# set up temp dir
+init_tmpdir TMPD
+
+LBUCACHE="$TMPD/lbucache"
+
+usage() {
+ echo "$PROGRAM $VERSION
+Usage: $PROGAM [-ahl]
+
+ -a Select all updated files.
+ -h Show this help.
+ -l List updated files.
+"
+}
+
+
+is_modified() {
+ [ -f "$LBUCACHE" ] || lbu status -a | awk '{print $2}' > "$LBUCACHE"
+ test -n "`( echo \"$1\" ; cat \"$LBUCACHE\" ) | sort | uniq -d`"
+}
+
+while getopts "alh" opt ; do
+ case "$opt" in
+ a) aflag="-a" ;;
+ l) lflag="-l" ;;
+ h|*) usage;;
+ esac
+done
+shift `expr $OPTIND - 1`
+
+find "$ROOT/etc" -name '*.apk-new' | while read apknew ; do
+ p="${apknew%.apk-new}"
+ f="${p#${ROOT}/}"
+ unset choice
+
+ if [ "$lflag" ] ; then
+
+ # just list the file
+ if [ "$aflag" ] || is_modified "$f" ; then
+ echo "$p"
+ fi
+
+ elif [ "$aflag" ] || is_modified "$f" ; then
+
+ # ask user what to do with the file
+ while [ -z "$choice" ] ; do
+ echo "New $p available:"
+ echon "Quit, Next, Show diff, Edit new, Zap new, Use new (q/n/s/e/z/u) [s]: "
+ default_read choice "s" </dev/tty
+ case "$choice" in
+ q) exit;;
+ n) continue;;
+ s) diff -u "$p" "$apknew" | ${PAGER:-less}
+ unset choice
+ ;;
+ e) ${EDITOR:-vi} "$apknew" ; unset choice;;
+ z) rm "$apknew";;
+ u) mv "$apknew" "$p";;
+ *) unset choice;;
+ esac
+ done
+ else
+ # auto update
+ echo "Autoupdating unchanged $p"
+ mv "$apknew" "$p"
+ fi
+done
+