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) (unidiff)
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
81y 81y
82" 82"
83 83
84onexit_remove_list=
85function onexit_remove() {
86 onexit_remove_list="$onexit_remove_list${onexit_remove_list:+ }$1"
87}
88
84function tempdir_create() { 89function tempdir_create() {
85 u=$(umask) 90 u=$(umask)
86 umask 077 91 umask 077
@@ -89,7 +94,7 @@ function tempdir_create() {
89} 94}
90 95
91function tempdir_remove() { 96function tempdir_remove() {
92 rm -rf $tempdir 97 rm -rf $tempdir $onexit_remove_list
93} 98}
94 99
95function usage() { 100function usage() {
@@ -253,11 +258,18 @@ function getfile() {
253 else 258 else
254 catfile $1.asc 259 catfile $1.asc
255 fi) 260 fi)
256 if [ -n "$ascname" ] \ 261 if [ -n "$ascname" ]; then
257 && ${GPG:-gpg} --verify $ascname $name 2>/dev/null; then 262 if ! err=$(${GPG:-gpg} --verify $ascname $name 2>&1 >/dev/null)
258 : 263 then
264 error "$err"
265 error "gpg verification failed for $name"
266 dropfile $ascname
267 return
268 else
269 dropfile $ascname
270 fi
259 else 271 else
260 error "gpg verification failed for $name" 272 error "$name: no clearsign signature file found"
261 return 273 return
262 fi 274 fi
263 fi 275 fi
@@ -512,6 +524,7 @@ checksums=$(getfile CHECKSUMS.md5 gpg)
512if [ -z "$checksums" ]; then 524if [ -z "$checksums" ]; then
513 abend "CHECKSUMS.md5 not found in $rooturl" 525 abend "CHECKSUMS.md5 not found in $rooturl"
514fi 526fi
527onexit_remove $checksums
515 528
516announce=$(tail +13 $checksums | \ 529announce=$(tail +13 $checksums | \
517 sed -n -r\ 530 sed -n -r\
@@ -523,6 +536,7 @@ file=$(getfile $announce)
523if [ -z "$file" ]; then 536if [ -z "$file" ]; then
524 abend "file $announce not found in $rooturl" 537 abend "file $announce not found in $rooturl"
525fi 538fi
539onexit_remove $file
526 540
527newversion=$(echo "$announce" | sed -e 's/\.\/ANNOUNCE\.//' -e 's/_/./g') 541newversion=$(echo "$announce" | sed -e 's/\.\/ANNOUNCE\.//' -e 's/_/./g')
528if [ -z "$newversion" ]; then 542if [ -z "$newversion" ]; then
@@ -651,6 +665,7 @@ if [ $opmode != INCR ]; then
651 if [ -z "$packages" ]; then 665 if [ -z "$packages" ]; then
652 abend "PACKAGES.TXT not found in $rooturl" 666 abend "PACKAGES.TXT not found in $rooturl"
653 fi 667 fi
668 onexit_remove $packages
654 download_size=$(sed -n -r \ 669 download_size=$(sed -n -r \
655 -e '/PACKAGE NAME:[[:space:]]*/{' \ 670 -e '/PACKAGE NAME:[[:space:]]*/{' \
656 -e 's///' \ 671 -e 's///' \
@@ -744,6 +759,7 @@ do
744 if [ -z "$file" ]; then 759 if [ -z "$file" ]; then
745 abend "failed to download $pkg" 760 abend "failed to download $pkg"
746 fi 761 fi
762 onexit_remove $file
747 pkg_files="$pkg_files${pkg_files:+ }$file" 763 pkg_files="$pkg_files${pkg_files:+ }$file"
748done 764done
749 765

Return to:

Send suggestions and report system problems to the System administrator.