Commit 7840f2d8 authored by Natanael Copa's avatar Natanael Copa

lbu: try handle full media

try avoid ending up with a lbu media without any apkovl.
parent 5572e8a3
...@@ -75,9 +75,18 @@ backup_apkovl() { ...@@ -75,9 +75,18 @@ backup_apkovl() {
vecho "Creating backup $backup" vecho "Creating backup $backup"
if [ -z "$DRYRUN" ]; then if [ -z "$DRYRUN" ]; then
mv "$outfile" "$backup" mv "$outfile" "$backup"
APKOVL_BACKUP="$backup"
fi fi
} }
restore_apkovl() {
local outfile="$1"
if [ -n "$DRYRUN" ] || [ -z "$APKOVL_BACKUP" ]; then
return 0
fi
mv "$APKOVL_BACKUP" "$outfile"
}
# 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
...@@ -274,10 +283,16 @@ cmd_package() { ...@@ -274,10 +283,16 @@ cmd_package() {
if [ "x$pkg" = "x-" ]; then if [ "x$pkg" = "x-" ]; then
cat "$tmppkg" cat "$tmppkg"
else else
cp "$tmppkg" "$pkg" if cp "$tmppkg" "$pkg.new"; then
mv "$pkg.new" "$pkg"
rc=$?
else
rm -f "$pkg.new"
rc=1
fi
fi fi
fi fi
vecho "Created $pkg" [ $rc -eq 0 ] && vecho "Created $pkg"
fi fi
return $rc return $rc
} }
...@@ -354,7 +369,6 @@ cmd_commit() { ...@@ -354,7 +369,6 @@ cmd_commit() {
outfile="$outfile.$ENCRYPTION" outfile="$outfile.$ENCRYPTION"
fi fi
# remove old config files # remove old config files
if [ -n "$DELETEOLDCONFIGS" ] ; then if [ -n "$DELETEOLDCONFIGS" ] ; then
local rmfiles=$(ls "$mnt/"*.apkovl.tar.gz* 2>/dev/null) local rmfiles=$(ls "$mnt/"*.apkovl.tar.gz* 2>/dev/null)
...@@ -382,6 +396,7 @@ cmd_commit() { ...@@ -382,6 +396,7 @@ cmd_commit() {
# create package # create package
if ! cmd_package "$outfile"; then if ! cmd_package "$outfile"; then
restore_apkovl "$outfile"
cleanup cleanup
die "Problems creating archive. aborting" die "Problems creating archive. aborting"
fi fi
......
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