summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2020-02-07 15:56:19 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2020-02-07 15:56:19 (GMT)
commit0a5f8ec4230566295e3f5b82e6083fd5b9bb2dea (patch) (side-by-side diff)
tree19e903e41fa42ef60464608b5314331792dc8c47
parentbed14b11e3d3070b92bb66203ae42d9e31393299 (diff)
downloadslackupgrade-0a5f8ec4230566295e3f5b82e6083fd5b9bb2dea.tar.gz
slackupgrade-0a5f8ec4230566295e3f5b82e6083fd5b9bb2dea.tar.bz2
Make sure all downloaded files are removed
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--slackupgrade26
1 files changed, 21 insertions, 5 deletions
diff --git a/slackupgrade b/slackupgrade
index ada387b..30bfa9c 100644
--- a/slackupgrade
+++ b/slackupgrade
@@ -81,6 +81,11 @@ xfce
y
"
+onexit_remove_list=
+function onexit_remove() {
+ onexit_remove_list="$onexit_remove_list${onexit_remove_list:+ }$1"
+}
+
function tempdir_create() {
u=$(umask)
umask 077
@@ -89,7 +94,7 @@ function tempdir_create() {
}
function tempdir_remove() {
- rm -rf $tempdir
+ rm -rf $tempdir $onexit_remove_list
}
function usage() {
@@ -253,11 +258,18 @@ function getfile() {
else
catfile $1.asc
fi)
- if [ -n "$ascname" ] \
- && ${GPG:-gpg} --verify $ascname $name 2>/dev/null; then
- :
+ if [ -n "$ascname" ]; then
+ if ! err=$(${GPG:-gpg} --verify $ascname $name 2>&1 >/dev/null)
+ then
+ error "$err"
+ error "gpg verification failed for $name"
+ dropfile $ascname
+ return
+ else
+ dropfile $ascname
+ fi
else
- error "gpg verification failed for $name"
+ error "$name: no clearsign signature file found"
return
fi
fi
@@ -512,6 +524,7 @@ checksums=$(getfile CHECKSUMS.md5 gpg)
if [ -z "$checksums" ]; then
abend "CHECKSUMS.md5 not found in $rooturl"
fi
+onexit_remove $checksums
announce=$(tail +13 $checksums | \
sed -n -r\
@@ -523,6 +536,7 @@ file=$(getfile $announce)
if [ -z "$file" ]; then
abend "file $announce not found in $rooturl"
fi
+onexit_remove $file
newversion=$(echo "$announce" | sed -e 's/\.\/ANNOUNCE\.//' -e 's/_/./g')
if [ -z "$newversion" ]; then
@@ -651,6 +665,7 @@ if [ $opmode != INCR ]; then
if [ -z "$packages" ]; then
abend "PACKAGES.TXT not found in $rooturl"
fi
+ onexit_remove $packages
download_size=$(sed -n -r \
-e '/PACKAGE NAME:[[:space:]]*/{' \
-e 's///' \
@@ -744,6 +759,7 @@ do
if [ -z "$file" ]; then
abend "failed to download $pkg"
fi
+ onexit_remove $file
pkg_files="$pkg_files${pkg_files:+ }$file"
done

Return to:

Send suggestions and report system problems to the System administrator.