aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2020-02-07 16:56:19 +0100
committerSergey Poznyakoff <gray@gnu.org.ua>2020-02-07 16:56:19 +0100
commit0a5f8ec4230566295e3f5b82e6083fd5b9bb2dea (patch)
tree19e903e41fa42ef60464608b5314331792dc8c47
parentbed14b11e3d3070b92bb66203ae42d9e31393299 (diff)
downloadslackupgrade-0a5f8ec4230566295e3f5b82e6083fd5b9bb2dea.tar.gz
slackupgrade-0a5f8ec4230566295e3f5b82e6083fd5b9bb2dea.tar.bz2
Make sure all downloaded files are removed
-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
@@ -72,33 +72,38 @@ e
f
k
l
n
t
tcl
x
xap
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
mkdir $tempdir
umask $u
}
function tempdir_remove() {
- rm -rf $tempdir
+ rm -rf $tempdir $onexit_remove_list
}
function usage() {
cat <<EOF
usage: $0 [-anqvy] [-k FILE] [-s SERIES] [DIRECTORY]
Upgrade Slackware installation
Options are:
-a install all series except kde*
-h display this help list and exit
-k FILE preserve packages listed in FILE
@@ -244,29 +249,36 @@ function getfile() {
elif [ $strip_series -eq 1 ]; then
catfile $(basename $1)
else
catfile $1
fi)
if [ -n "$2" ]; then
ascname=$(if [ -n "$remote" ]; then
download $1.asc
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
if [ -n "$checksums" ] && ! check_package_md5sum $1 $name; then
error "ERROR: $1: checksum failed"
name=
fi
echo $name
}
# dropfile FILE
@@ -503,35 +515,37 @@ if [ -z "$remote" ]; then
fi
# Check if rooturl contains all we need
info "verifying distribution"
#
# Download CHECKSUMS.md5. So far it is the only file that is gpg-checked.
# For the rest we rely on MD5 sums.
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\
-e 's/^[0-9a-fA-F]+[[:space:]]+(\.\/ANNOUNCE\.[[:digit:]_]+)$/\1/p')
if [ -z "$announce" ]; then
abend "ANNOUNCE not found in $rooturl"
fi
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
abend "cannot determine new version"
fi
# Create list and index of available files
tail +13 $checksums | \
sed -r \
-n \
-e 's/^[0-9a-fA-F]+[[:space:]]+(\.\/slackware(64)?\/.*\/(.*)-[^-]+-(i386|x86(_64)?|arm|noarch|fw)-[[:digit:]]+(_.*)?\.t.z)$/\3 \1/p' | \
tee $avail_index | awk '{print $1}' | sort > $avail_list
@@ -642,24 +656,25 @@ if ! getyn n "Ready for upgrade from $VERSION to $newversion. Continue"; then
exit 0
fi
if [ $opmode != INCR ]; then
# Automatic mode selection. Compute total compressed size of packages
# to be installed and compare it with available disk space on the device
# hosting SLACKUPGRADE_PKGDIR. Select safe mode if there is enough space,
# otherwise ask if the user wishes to continue in incremental mode.
packages=$(download PACKAGES.TXT)
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///' \
-e 's/^(.*)-[^-]+-(i386|x86(_64)?|arm|noarch|fw)-[[:digit:]]+(_.*)?\.t.z$/\1 &/' \
-e h \
-e '}' \
-e '/PACKAGE SIZE \(compressed\):[[:space:]]*/{' \
-e 's///' \
-e H \
-e x \
-e 's/\n/ /' \
-e p \
@@ -735,24 +750,25 @@ if [ -n "$remote" ]; then
pkg_names="$pkg_names aaa_elflibs wget"
fi
pkg_re='^('$(echo "$pkg_names" | sed -r -e 's/ +/|/g')')$'
pkg_files=
info "downloading essential packages"
for pkg in $pkg_names
do
file=$(getfile $(package_file_name $pkg))
if [ -z "$file" ]; then
abend "failed to download $pkg"
fi
+ onexit_remove $file
pkg_files="$pkg_files${pkg_files:+ }$file"
done
info "installing essential packages"
upgrade_local $pkg_files
if [ -n "$remote" ]; then
# Until now we have been using whatever downloader that is available
# (curl or wget). Switch to wget: it has all its dependecies installed.
dnfunc=download_wget
fi

Return to:

Send suggestions and report system problems to the System administrator.