Commit c7e6eae6 authored by Natanael Copa's avatar Natanael Copa
Browse files

implemented lbu revert

parent 7e11b0b7
V=1.5.1 V=1.6
P=alpine-conf P=alpine-conf
PV=$(P)-$(V) PV=$(P)-$(V)
APKF=$(PV).apk APKF=$(PV).apk
......
...@@ -48,6 +48,7 @@ Available subcommands: ...@@ -48,6 +48,7 @@ Available subcommands:
status (stat, st) status (stat, st)
update (up) update (up)
log log
revert
Common options: Common options:
-h Show help for subcommand. -h Show help for subcommand.
...@@ -77,6 +78,17 @@ mount_once() { ...@@ -77,6 +78,17 @@ mount_once() {
fi 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 # verify we have openssl if we want to encrypt
check_openssl() { check_openssl() {
[ -z "$ENCRYPTION" ] && return 0 [ -z "$ENCRYPTION" ] && return 0
...@@ -354,10 +366,7 @@ cmd_commit() { ...@@ -354,10 +366,7 @@ cmd_commit() {
else else
lines=$(ls -1 "$mnt"/*.apkovl.tar.gz* 2>/dev/null) lines=$(ls -1 "$mnt"/*.apkovl.tar.gz* 2>/dev/null)
if [ "$lines" = "$outfile" ]; then if [ "$lines" = "$outfile" ]; then
local d=$( date -u -r "$outfile" "+%Y%m%d%H%m%S" ) backup_apkovl "$outfile"
local backup=$(echo "$outfile" | sed "s/\.apkovl\.tar\.gz/.$d.tar.gz/")
vecho "Creating backup $backup"
[ -z "$DRYRUN" ] && mv "$outfile" "$backup"
elif [ -n "$lines" ]; then elif [ -n "$lines" ]; then
# More then one apkovl, this is a security concern # More then one apkovl, this is a security concern
cleanup cleanup
...@@ -467,12 +476,32 @@ cmd_log() { ...@@ -467,12 +476,32 @@ cmd_log() {
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# lbu_revert - revert to old config # lbu_revert - revert to old config
usage_revert() { 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() { cmd_revert() {
local revertto=$1
local media=${2:-"$LBU_MEDIA"} 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 ...@@ -564,6 +593,8 @@ case "$cmd" in
package|pkg) SUBCMD="package";; package|pkg) SUBCMD="package";;
status|stat|st) SUBCMD="status";; status|stat|st) SUBCMD="status";;
update|up) SUBCMD="update";; update|up) SUBCMD="update";;
log) SUBCMD="log";;
revert) SUBCMD="revert";;
*) usage;; *) usage;;
esac esac
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment