aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2008-06-24 09:56:45 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2008-06-24 09:56:45 +0000
commitc7e6eae6efa437ed2d28f36ee91ece08450ed598 (patch)
treea1ed37ccf468747e48b7d0b2fbde5ef5d636d829
parent7e11b0b756570e182e8c0d26f2342e56594ec96f (diff)
downloadalpine-conf-c7e6eae6efa437ed2d28f36ee91ece08450ed598.tar.bz2
alpine-conf-c7e6eae6efa437ed2d28f36ee91ece08450ed598.tar.xz
implemented lbu revert
-rw-r--r--Makefile2
-rw-r--r--lbu41
2 files changed, 37 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index c3b7fd7..0e0ae95 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-V=1.5.1
+V=1.6
P=alpine-conf
PV=$(P)-$(V)
APKF=$(PV).apk
diff --git a/lbu b/lbu
index b5b4ef1..2cb2d81 100644
--- a/lbu
+++ b/lbu
@@ -48,6 +48,7 @@ Available subcommands:
status (stat, st)
update (up)
log
+ revert
Common options:
-h Show help for subcommand.
@@ -77,6 +78,17 @@ mount_once() {
fi
}
+# create backupfile
+backup_apkovl() {
+ local outfile="$1"
+ local d=$( date -u -r "$outfile" "+%Y%m%d%H%m%S" )
+ local backup=$(echo "$outfile" | sed "s/\.apkovl\.tar\.gz/.$d.tar.gz/")
+ vecho "Creating backup $backup"
+ if [ -z "$DRYRUN" ]; then
+ mv "$outfile" "$backup"
+ fi
+}
+
# verify we have openssl if we want to encrypt
check_openssl() {
[ -z "$ENCRYPTION" ] && return 0
@@ -354,10 +366,7 @@ cmd_commit() {
else
lines=$(ls -1 "$mnt"/*.apkovl.tar.gz* 2>/dev/null)
if [ "$lines" = "$outfile" ]; then
- local d=$( date -u -r "$outfile" "+%Y%m%d%H%m%S" )
- local backup=$(echo "$outfile" | sed "s/\.apkovl\.tar\.gz/.$d.tar.gz/")
- vecho "Creating backup $backup"
- [ -z "$DRYRUN" ] && mv "$outfile" "$backup"
+ backup_apkovl "$outfile"
elif [ -n "$lines" ]; then
# More then one apkovl, this is a security concern
cleanup
@@ -467,12 +476,32 @@ cmd_log() {
#---------------------------------------------------------------------------
# lbu_revert - revert to old config
usage_revert() {
+ cat <<EOF
+$PROGRAM $VERSION
+Revert to older commit.
+
+usage: $PROGRAM revert <REVISION> [<media>]
+
+The revision should be one of the files listed by 'lbu log'.
+EOF
}
cmd_revert() {
- local revertto=$1
local media=${2:-"$LBU_MEDIA"}
+ [ -z "$media" ] && usage_revert
+ local mnt="/media/$media"
+ local revertto="$mnt/$1"
+ local current="$mnt/$(hostname).apkovl.tar.gz"
+
+ if [ -n "$ENCRYPTION" ]; then
+ outfile="$outfile.$ENCRYPTION"
+ fi
+ mount_once "$mnt" || die "failed to mount $mnt"
+ [ -f "$revertto" ] || die "file not found: $revertto"
+ backup_apkovl "$outfile"
+ vecho "Reverting to $1"
+ [ -z "$DRYRUN" ] && mv "$revertto" "$outfile"
}
#---------------------------------------------------------------------------
@@ -564,6 +593,8 @@ case "$cmd" in
package|pkg) SUBCMD="package";;
status|stat|st) SUBCMD="status";;
update|up) SUBCMD="update";;
+ log) SUBCMD="log";;
+ revert) SUBCMD="revert";;
*) usage;;
esac