summaryrefslogtreecommitdiff
path: root/lbu.in
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-09-29 15:37:26 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-09-29 15:37:26 +0000
commit7840f2d8b7c63a96e4d68edcab1d49e39bcf1511 (patch)
treee67f1348d231f8287249d63e38f4a279e4e94b87 /lbu.in
parent5572e8a3db95f179b3433e5ea5f8c6fa2c8c65ab (diff)
downloadalpine-conf-7840f2d8b7c63a96e4d68edcab1d49e39bcf1511.zip
lbu: try handle full media
try avoid ending up with a lbu media without any apkovl.
Diffstat (limited to 'lbu.in')
-rw-r--r--lbu.in21
1 files changed, 18 insertions, 3 deletions
diff --git a/lbu.in b/lbu.in
index 38154d5..c1ab743 100644
--- a/lbu.in
+++ b/lbu.in
@@ -75,9 +75,18 @@ backup_apkovl() {
vecho "Creating backup $backup"
if [ -z "$DRYRUN" ]; then
mv "$outfile" "$backup"
+ APKOVL_BACKUP="$backup"
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
check_openssl() {
[ -z "$ENCRYPTION" ] && return 0
@@ -274,10 +283,16 @@ cmd_package() {
if [ "x$pkg" = "x-" ]; then
cat "$tmppkg"
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
- vecho "Created $pkg"
+ [ $rc -eq 0 ] && vecho "Created $pkg"
fi
return $rc
}
@@ -354,7 +369,6 @@ cmd_commit() {
outfile="$outfile.$ENCRYPTION"
fi
-
# remove old config files
if [ -n "$DELETEOLDCONFIGS" ] ; then
local rmfiles=$(ls "$mnt/"*.apkovl.tar.gz* 2>/dev/null)
@@ -382,6 +396,7 @@ cmd_commit() {
# create package
if ! cmd_package "$outfile"; then
+ restore_apkovl "$outfile"
cleanup
die "Problems creating archive. aborting"
fi