#!/bin/sh PREFIX= . $PREFIX/lib/libalpine.sh # set up temp dir init_tmpdir TMPD LBUCACHE="$TMPD/lbucache" usage() { echo "$PROGRAM $VERSION Usage: $PROGAM [-aihl] -a Select all updated files. -h Show this help. -i Use all new init.d scripts. -l List updated files. " } is_modified() { [ -f "$LBUCACHE" ] || lbu status -a | awk '{print $2}' > "$LBUCACHE" test -n "`( echo \"$1\" ; cat \"$LBUCACHE\" ) | sort | uniq -d`" } is_initd() { echo "$1" | grep etc/init.d/ > /dev/null } while getopts "alih" opt ; do case "$opt" in a) aflag="-a" ;; i) iflag="-i" ;; l) lflag="-l" ;; h|*) usage;; esac done shift `expr $OPTIND - 1` for apknew in $(find "$ROOT/etc" -name '*.apk-new') ; 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 if [ "$iflag" ] && is_initd "$f" ; then echo "Autoupdating $p" mv "$apknew" "$p" continue fi diff -u "$p" "$apknew" # 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"