summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2020-02-07 10:53:08 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2020-02-07 10:58:31 (GMT)
commit507ae64c3e886b82435cbc963594ed5e2af3458f (patch) (unidiff)
tree873b009acbc94db6fd34c291fcb62603c709285a
parent06031d3add92479fce6b02971a23ad5931ee26dd (diff)
downloadslackupgrade-507ae64c3e886b82435cbc963594ed5e2af3458f.tar.gz
slackupgrade-507ae64c3e886b82435cbc963594ed5e2af3458f.tar.bz2
Implement the "safe upgrade" mode
In safe upgrade mode, all the necessary package tarballs are first downloaded to the spool directory. Once downloaded, the program starts upgrading using these tarballs. Each tarball is removed after being processed. The old ("incremental") mode is used if there is not enough disk space for full download.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--slackupgrade288
-rw-r--r--slackupgrade.8158
2 files changed, 353 insertions, 93 deletions
diff --git a/slackupgrade b/slackupgrade
index 662b325..ff4d46f 100644
--- a/slackupgrade
+++ b/slackupgrade
@@ -1,9 +1,9 @@
1#!/bin/bash 1#!/bin/bash
2# slackupgrade - full upgrade of a Slackware installation 2# slackupgrade - full upgrade of a Slackware installation
3# Copyright (C) 2019 Sergey Poznyakoff. 3# Copyright (C) 2019-2020 Sergey Poznyakoff.
4# 4#
5# Slackware-upgrade-system is free software; you can redistribute it and/or 5# Slackware-upgrade-system is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License as published 6# modify it under the terms of the GNU General Public License as published
7# by the Free Software Foundation; either version 3, or (at your option) 7# by the Free Software Foundation; either version 3, or (at your option)
8# any later version. 8# any later version.
9# 9#
@@ -20,6 +20,7 @@ set -e
20 20
21# Configuration directory 21# Configuration directory
22: ${SLACKUPGRADE_CONFDIR:=/etc/slackupgrade} 22: ${SLACKUPGRADE_CONFDIR:=/etc/slackupgrade}
23: ${SLACKUPGRADE_PKGDIR:=/var/slackupgrade}
23# Slackware root directory 24# Slackware root directory
24rooturl= 25rooturl=
25# Log file name 26# Log file name
@@ -41,10 +42,25 @@ install_packages=
41keep_file= 42keep_file=
42# Max. count of backup files to keep 43# Max. count of backup files to keep
43max_backup=4 44max_backup=4
45# Display progress bar when downloading
46progressbar=1
47# Operating mode. Possible values:
48# INCR Incremental mode. Archive for each package is downloaded prior
49# to its nstallation and removed immediately afterwards. This
50# ensures minimal disk space requirements.
51# SAFE Safe mode. All archives are first downloaded to
52# SLACKUPGRADE_PKGDIR and then installed. Each archive is removed
53# immediately after installing from it. This requires some 2.5G
54# of disk space at the beginning, which will be freed by the end
55# of upgrade.
56# AUTO Select incremental mode if there is enough disk space. If not,
57# ask the user if it is OK to proceed in incremental mode.
58opmode=AUTO
44 59
45# Internal variables 60# Internal variables
46remote= 61remote=
47tempdir=${TMP:-/tmp}/slackupg.$$ 62tempdir=${TMP:-/tmp}/slackupg.$$
63strip_series=0
48installed_list=$tempdir/installed.list 64installed_list=$tempdir/installed.list
49avail_index=$tempdir/avail.index 65avail_index=$tempdir/avail.index
50avail_list=$tempdir/avail.list 66avail_list=$tempdir/avail.list
@@ -132,6 +148,8 @@ function error() {
132 fi 148 fi
133} 149}
134 150
151# Abnormal termination: print error message, remove temporary directory
152# and terminate with status 1.
135function abend() { 153function abend() {
136 error "$@" 154 error "$@"
137 tempdir_remove 155 tempdir_remove
@@ -143,14 +161,12 @@ function package_file_name() {
143 if [ -z "$pkg" ]; then 161 if [ -z "$pkg" ]; then
144 error "package $name not found in index (should not happen!)" 162 error "package $name not found in index (should not happen!)"
145 else 163 else
146 echo $pkg 164 echo $pkg
147 fi 165 fi
148}
149
150function package_name_md5sum() {
151 pkg=$(awk -vname=$1 '$1==name { print $3 }' $avail_index)
152} 166}
153 167
168# check_package_md5sum PKG ARCHIVE
169# Verifies the MD5 sum of the ARCHIVE file for Slackware package PKG
154function check_package_md5sum() { 170function check_package_md5sum() {
155 if [ -n "$checksums" ]; then 171 if [ -n "$checksums" ]; then
156 awk -vcname="$1" -vdname="$2" \ 172 awk -vcname="$1" -vdname="$2" \
@@ -159,10 +175,14 @@ function check_package_md5sum() {
159 fi 175 fi
160} 176}
161 177
178# all_package_names
179# Lists all packages from the Slackware distribution.
162function all_package_names() { 180function all_package_names() {
163 grep -v '.*/kde[^/]*/' $avail_index | cut -d ' ' -f 1 181 grep -v '.*/kde[^/]*/' $avail_index | cut -d ' ' -f 1
164} 182}
165 183
184# series_package_names S
185# Lists the names of packages in Slackware series S.
166function series_package_names() { 186function series_package_names() {
167 grep '.*/'"$1/" $avail_index | cut -d ' ' -f 1 187 grep '.*/'"$1/" $avail_index | cut -d ' ' -f 1
168} 188}
@@ -171,10 +191,14 @@ function catfile() {
171 echo $rooturl/${1#./} 191 echo $rooturl/${1#./}
172} 192}
173 193
194# download_curl FILE URL
195# Downloads file from URL to FILE using curl.
174function download_curl { 196function download_curl {
175 curl $CURL_OPTIONS -L -sS -o$1 $2 197 curl $CURL_OPTIONS -L -sS -o$1 $2
176} 198}
177 199
200# download_wget LOCAL URL
201# Downloads file from URL to FILE using wget.
178function download_wget { 202function download_wget {
179 if ! wget $WGET_OPTIONS -nv -o wget.log -O$1 $2; then 203 if ! wget $WGET_OPTIONS -nv -o wget.log -O$1 $2; then
180 grep -i "failed\|error" wget.log 204 grep -i "failed\|error" wget.log
@@ -182,6 +206,8 @@ function download_wget {
182 fi 206 fi
183} 207}
184 208
209# dnfunc_init
210# Initializes the downloader function to wget or curl.
185function dnfunc_init() { 211function dnfunc_init() {
186 if [ -z "$dnfunc" ]; then 212 if [ -z "$dnfunc" ]; then
187 if wget --version >/dev/null 2>&1; then 213 if wget --version >/dev/null 2>&1; then
@@ -194,34 +220,45 @@ function dnfunc_init() {
194 fi 220 fi
195} 221}
196 222
223# download FILE
224# Downloads package FILE from the remote server. On success, returns the
225# full pathname of the downloaded copy.
197function download() { 226function download() {
198 local name=$(basename $1) 227 local name=$SLACKUPGRADE_PKGDIR/$(basename $1)
199 local url=$(catfile $1) 228 local url=$(catfile $1)
200 if $dnfunc $name $url; then 229 if $dnfunc $name $url; then
201 echo $name 230 echo $name
202 fi 231 fi
203} 232}
204 233
234# getfile PKG [GPG]
235# Retrieves the package archive file for the package PKG. If second argument
236# is non-empty, verifies the GPG signature of the file.
237# If checksums file is available, verifies also the MD5 checksum of the file.
238#
239# Returns full pathname of the retrieved file.
205function getfile() { 240function getfile() {
206 local name=$(if [ -n "$remote" ]; then 241 local name=$(if [ -n "$remote" ]; then
207 download $1 242 download $1
208 else 243 elif [ $strip_series -eq 1 ]; then
209 catfile $1 244 catfile $(basename $1)
210 fi) 245 else
211 246 catfile $1
247 fi)
248
212 if [ -n "$2" ]; then 249 if [ -n "$2" ]; then
213 ascname=$(if [ -n "$remote" ]; then 250 ascname=$(if [ -n "$remote" ]; then
214 download $1.asc 251 download $1.asc
215 else 252 else
216 catfile $1.asc 253 catfile $1.asc
217 fi) 254 fi)
218 if [ -n "$ascname" ] \ 255 if [ -n "$ascname" ] \
219 && ${GPG:-gpg} --verify $ascname $name 2>/dev/null; then 256 && ${GPG:-gpg} --verify $ascname $name 2>/dev/null; then
220 : 257 :
221 else 258 else
222 error "gpg verification failed for $name" 259 error "gpg verification failed for $name"
223 return 260 return
224 fi 261 fi
225 fi 262 fi
226 263
227 if [ -n "$checksums" ] && ! check_package_md5sum $1 $name; then 264 if [ -n "$checksums" ] && ! check_package_md5sum $1 $name; then
@@ -231,12 +268,17 @@ function getfile() {
231 echo $name 268 echo $name
232} 269}
233 270
271# dropfile FILE
272# Removes FILE, if it has been downloaded from the remote repository,
234function dropfile() { 273function dropfile() {
235 if [ -n "$remote" ]; then 274 if [ -n "$remote" ] || [ $strip_series -eq 1 ]; then
236 rm $1 275 rm $1
237 fi 276 fi
238} 277}
239 278
279# upgrade_package [OPTIONS] FILE
280# Runs upgradepkg with the supplied arguments and captures its output to
281# the log file. In verbose mode, filters parts of it to the stdout.
240function upgrade_local() { 282function upgrade_local() {
241 if [ -n "$dry_run" ]; then 283 if [ -n "$dry_run" ]; then
242 echo "upgradepkg $@" 284 echo "upgradepkg $@"
@@ -249,6 +291,8 @@ function upgrade_local() {
249 fi 291 fi
250} 292}
251 293
294# upgrade_package NAME [OPTIONS]
295# Upgrades the package NAME. OPTIONS will be passed to upgradepkg verbatim.
252function upgrade_package() { 296function upgrade_package() {
253 local name=$1 297 local name=$1
254 shift 298 shift
@@ -263,6 +307,8 @@ function upgrade_package() {
263 fi 307 fi
264} 308}
265 309
310# version_gt A B
311# Returns true if version A is greater than B.
266function version_gt() { 312function version_gt() {
267 test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1" 313 test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"
268} 314}
@@ -290,25 +336,79 @@ function backup() {
290 sort +0 -1 -n -r |\ 336 sort +0 -1 -n -r |\
291 while read n stem 337 while read n stem
292 do 338 do
293 if [ -n "$max_backup" ] && [ $n -ge $max_backup ]; then 339 if [ -n "$max_backup" ] && [ $n -ge $max_backup ]; then
294 $p rm $dir/${stem}~$n 340 $p rm $dir/${stem}~$n
295 else 341 else
296 $p mv $dir/${stem}~$n $dir/${stem}~$((n + 1)) 342 $p mv $dir/${stem}~$n $dir/${stem}~$((n + 1))
297 fi 343 fi
298 done 344 done
299 $p mv "$1~" "$1~1" 345 $p mv "$1~" "$1~1"
300 fi 346 fi
301 $p mv "$1" "$1~" 347 $p mv "$1" "$1~"
302 fi 348 fi
303} 349}
304 350
351# disk_avail_size DIR
352# Returns the available disk size (in kilobytes) on the device where
353# DIR is located
354function disk_avail_size() {
355 df -k --output=target,avail | \
356 sed 1d | \
357 awk -vdir=$1 \
358 'BEGIN { dirlen=length(dir) }
359 { len = length($1)
360 if (len <= dirlen && substr(dir, 1, len) == $1) {
361 if (mp_len < len) {
362 mp_len = len
363 mp_avail = $2
364 }
365 }
366 }
367 END { print mp_avail }'
368}
369
370# Downloads all selected packages to the spool directory.
371function download_all() {
372 info "downloading packages"
373 if [ ${COLUMNS:-0} -lt 10 ]; then
374 progressbar=0
375 fi
376 if [ $progressbar -eq 1 ]; then
377 total=$(wc -l candidates | cut -d ' ' -f 1)
378 width=$(( $COLUMNS - 7 ))
379 fi
380 i=0
381 cat candidates |
382 while read pkg
383 do
384 if [ $progressbar -eq 1 ]; then
385 n=$(( $i * $width / $total ))
386 s=$(printf "%${n}s" ' '|sed 's/./=/g')
387 printf "\r% 3d%% %s>" $(( $i * 100 / $total)) $s
388 fi
389 if [ -z "$dry_run" ]; then
390 file=$(getfile $(package_file_name $pkg))
391 if [ -z "$file" ]; then
392 abend "failed to download $pkg"
393 fi
394 fi
395 i=$(( $i + 1 ))
396 done || exit $?
397 if [ $progressbar -eq 1 ]; then
398 s=$(printf "%${width}s" ' '|sed 's/./=/g')
399 printf "\r% 3d%% %s|\n" 100 $s
400 fi
401}
402
305# ########## 403# ##########
306# Main 404# Main
307# ########## 405# ##########
308 406
309while getopts "ahknp:qs:vy" OPTION 407while getopts "ahIknp:qSs:vy" OPTION
310do 408do
311 case $OPTION in 409 case $OPTION in
410 I) opmode=INCR;;
411 S) opmode=SAFE;;
312 a) install_all=y;; 412 a) install_all=y;;
313 h) usage 413 h) usage
314 exit 0;; 414 exit 0;;
@@ -354,6 +454,10 @@ case "$(uname -m)" in
354 *) abend "architecture $(uname -m) is not yet supported" 454 *) abend "architecture $(uname -m) is not yet supported"
355esac 455esac
356 456
457if [ ! -d $SLACKUPGRADE_PKGDIR ]; then
458 mkdir -p $SLACKUPGRADE_PKGDIR || abend "can't create $SLACKUPGRADE_PKGDIR"
459fi
460
357tempdir_create 461tempdir_create
358cd $tempdir 462cd $tempdir
359 463
@@ -376,7 +480,7 @@ if [ -z "$rooturl" ]; then
376 else 480 else
377 abend "can't find distribution newer than $VERSION; please supply URL if you have any" 481 abend "can't find distribution newer than $VERSION; please supply URL if you have any"
378 fi 482 fi
379fi 483fi
380 484
381# Check if rooturl is local or remote 485# Check if rooturl is local or remote
382case $rooturl in 486case $rooturl in
@@ -394,6 +498,8 @@ if [ -z "$remote" ]; then
394 if [ ! -d $rooturl ]; then 498 if [ ! -d $rooturl ]; then
395 abend "$rooturl does not exist" 499 abend "$rooturl does not exist"
396 fi 500 fi
501 # Safe mode is meaningless with local repository
502 opmode=INCR
397fi 503fi
398 504
399# Check if rooturl contains all we need 505# Check if rooturl contains all we need
@@ -409,14 +515,14 @@ fi
409 515
410announce=$(tail +13 $checksums | \ 516announce=$(tail +13 $checksums | \
411 sed -n -r\ 517 sed -n -r\
412 -e 's/^[0-9a-fA-F]+[[:space:]]+(\.\/ANNOUNCE\.[[:digit:]_]+)$/\1/p') 518 -e 's/^[0-9a-fA-F]+[[:space:]]+(\.\/ANNOUNCE\.[[:digit:]_]+)$/\1/p')
413if [ -z "$announce" ]; then 519if [ -z "$announce" ]; then
414 abend "ANNOUNCE not found in $rooturl" 520 abend "ANNOUNCE not found in $rooturl"
415fi 521fi
416file=$(getfile $announce) 522file=$(getfile $announce)
417if [ -z "$file" ]; then 523if [ -z "$file" ]; then
418 abend "file $announce not found in $rooturl" 524 abend "file $announce not found in $rooturl"
419fi 525fi
420 526
421newversion=$(echo "$announce" | sed -e 's/\.\/ANNOUNCE\.//' -e 's/_/./g') 527newversion=$(echo "$announce" | sed -e 's/\.\/ANNOUNCE\.//' -e 's/_/./g')
422if [ -z "$newversion" ]; then 528if [ -z "$newversion" ]; then
@@ -451,7 +557,7 @@ do
451 abend "exiting" 557 abend "exiting"
452 fi 558 fi
453 dropfile $file 559 dropfile $file
454done 560done
455 561
456# Build a list of installed packages 562# Build a list of installed packages
457ls /var/log/packages |\ 563ls /var/log/packages |\
@@ -461,9 +567,9 @@ ls /var/log/packages |\
461# Build a list of packages to install 567# Build a list of packages to install
462(if [ -n "$install_all" ]; then 568(if [ -n "$install_all" ]; then
463 all_package_names 569 all_package_names
464else 570else
465 comm -1 -2 $installed_list $avail_list 571 comm -1 -2 $installed_list $avail_list
466fi 572fi
467for s in $install_series 573for s in $install_series
468do 574do
469 series_package_names $s 575 series_package_names $s
@@ -477,7 +583,7 @@ fi) | sort -u > candidates.$$
477comm -2 -3 $installed_list candidates.$$ > remove.list.$$ 583comm -2 -3 $installed_list candidates.$$ > remove.list.$$
478if [ -s "$keep_file" ]; then 584if [ -s "$keep_file" ]; then
479 grep -v '^#' $keep_file | \ 585 grep -v '^#' $keep_file | \
480 tr -s '\n' | sort | comm -2 -3 remove.list.$$ - > remove.list 586 tr -s '\n' | sort -u | comm -2 -3 remove.list.$$ - > remove.list
481 rm remove.list.$$ 587 rm remove.list.$$
482else 588else
483 mv remove.list.$$ remove.list 589 mv remove.list.$$ remove.list
@@ -488,11 +594,11 @@ if [ -f "$SLACKUPGRADE_CONFDIR/$VERSION-$newversion.repl" ]; then
488 info "reading $SLACKUPGRADE_CONFDIR/$VERSION-$newversion.repl" 594 info "reading $SLACKUPGRADE_CONFDIR/$VERSION-$newversion.repl"
489 # Update candidates and save the replacement map in a temporary. 595 # Update candidates and save the replacement map in a temporary.
490 awk '{ sub(/#.*$/,""); sub(/[[:space:]]+$/,"") } 596 awk '{ sub(/#.*$/,""); sub(/[[:space:]]+$/,"") }
491 /\\$/ { sub(/\\$/,""); p = p $0; next } 597 /\\$/ { sub(/\\$/,""); p = p $0; next }
492 NF == 0 { if (p) print p; p = ""; next } 598 NF == 0 { if (p) print p; p = ""; next }
493 { print p $0; p="" }' \ 599 { print p $0; p="" }' \
494 $SLACKUPGRADE_CONFDIR/$VERSION-$newversion.repl | \ 600 $SLACKUPGRADE_CONFDIR/$VERSION-$newversion.repl | \
495 sort +0 -1 | \ 601 sort +0 -1 | \
496 tee rename.$$ | \ 602 tee rename.$$ | \
497 join - remove.list | \ 603 join - remove.list | \
498 cut -d ' ' -f 2- | \ 604 cut -d ' ' -f 2- | \
@@ -501,9 +607,9 @@ if [ -f "$SLACKUPGRADE_CONFDIR/$VERSION-$newversion.repl" ]; then
501 sort -u > candidates 607 sort -u > candidates
502 # Use the temporary to remove the original package names from the report. 608 # Use the temporary to remove the original package names from the report.
503 awk '{print $1}' rename.$$ | \ 609 awk '{print $1}' rename.$$ | \
504 comm -13 - remove.list > $remove_report 610 comm -13 - remove.list > $remove_report
505 # Clean up 611 # Clean up
506 rm rename.$$ 612 rm rename.$$
507else 613else
508 cp remove.list $remove_report 614 cp remove.list $remove_report
509 mv candidates.$$ candidates 615 mv candidates.$$ candidates
@@ -519,7 +625,7 @@ restore them after the upgrade. The package names are preserved for you
519in the file $remove_report: 625in the file $remove_report:
520 626
521EOF 627EOF
522cat $remove_report) | ${PAGER:-more} 628 cat $remove_report) | ${PAGER:-more}
523fi 629fi
524 630
525if ! version_gt $newversion $VERSION; then 631if ! version_gt $newversion $VERSION; then
@@ -536,6 +642,89 @@ if ! getyn n "Ready for upgrade from $VERSION to $newversion. Continue"; then
536 exit 0 642 exit 0
537fi 643fi
538 644
645if [ $opmode != INCR ]; then
646 # Automatic mode selection. Compute total compressed size of packages
647 # to be installed and compare it with available disk space on the device
648 # hosting SLACKUPGRADE_PKGDIR. Select safe mode if there is enough space,
649 # otherwise ask if the user wishes to continue in incremental mode.
650 packages=$(download PACKAGES.TXT)
651 if [ -z "$packages" ]; then
652 abend "PACKAGES.TXT not found in $rooturl"
653 fi
654 download_size=$(sed -n -r \
655 -e '/PACKAGE NAME:[[:space:]]*/{' \
656 -e 's///' \
657 -e 's/^(.*)-[^-]+-(i386|x86(_64)?|arm|noarch|fw)-[[:digit:]]+(_.*)?\.t.z$/\1 &/' \
658 -e h \
659 -e '}' \
660 -e '/PACKAGE SIZE \(compressed\):[[:space:]]*/{' \
661 -e 's///' \
662 -e H \
663 -e x \
664 -e 's/\n/ /' \
665 -e p \
666 -e '}' \
667 $packages | \
668 sort +0 -1 | \
669 join candidates - | \
670 awk '{ if ($4 == "M") s += $3*1024
671 else if ($4 == "G") s += $3*1024*1024
672 else s += $3 }
673 END { print s }')
674 avail_size=$(disk_avail_size $SLACKUPGRADE_PKGDIR)
675 if [ $avail_size -lt $download_size ]; then
676 error "not enough free space in $SLACKUPGRADE_PKGDIR"
677 error "needed ${download_size}K, but only ${avail_size}K available"
678 if [ $opmode = INCR ]; then
679 abend "terminating"
680 fi
681
682 cat >&2 <<EOT
683
684Safe mode is the default for slackupgrade. In this mode, the program would
685first download all packages from the remote site, verify them and then
686proceed to actual upgrade. This ensures that even if something goes wrong
687during the upgrade, you have all tarballs at hand and can resume from
688where you left after fixing the problem.
689
690This mode cannot be used due to the disk space shortage. Slackupgrade can
691nevertheless continue in incremental download mode. In this mode, it will
692download and install packages one by one. This takes more time and is less
693error prone. If you choose this mode, type 'Y' at the prompt below. Other-
694wise, type 'N' to terminate the program, and follow the instructions you
695will get.
696
697EOT
698
699 if getyn n "Continue in incremental download mode"; then
700 opmode=INCR
701 else
702 cat >&2 <<EOT
703
704Please make sure the slackupgrade spool directory can accomodate at least
705${download_size}K of data. To do so, either free sufficient disk space on
706the device where $SLACKUPGRADE_PKGDIR resides, or set the SLACKUPGRADE_PKGDIR
707environment variable to the full pathname of the new spool directory,
708
709EOT
710 error "Terminating."
711 exit 0
712 fi
713 else
714 # Download all packages
715 download_all
716 # Switch to the local installation mode
717 rooturl=$SLACKUPGRADE_PKGDIR
718 opmode=INCR
719 # Instruct getfile to strip off the series directory from the
720 # package names.
721 strip_series=1
722 # Disable remote indicator and checksum verification (all archives
723 # have already been verified during the download).
724 unset remote checksums
725 fi
726fi
727
539info "starting upgrade of Slackware $VERSION to $newversion${dry_run:+ (DRY RUN MODE)}" 728info "starting upgrade of Slackware $VERSION to $newversion${dry_run:+ (DRY RUN MODE)}"
540 729
541pkg_names="glibc-solibs pkgtools tar xz findutils" 730pkg_names="glibc-solibs pkgtools tar xz findutils"
@@ -544,7 +733,7 @@ if [ -n "$remote" ]; then
544 # depends on. Wget is preferred over curl because of its limited 733 # depends on. Wget is preferred over curl because of its limited
545 # number of dependencies. 734 # number of dependencies.
546 pkg_names="$pkg_names aaa_elflibs wget" 735 pkg_names="$pkg_names aaa_elflibs wget"
547fi 736fi
548pkg_re='^('$(echo "$pkg_names" | sed -r -e 's/ +/|/g')')$' 737pkg_re='^('$(echo "$pkg_names" | sed -r -e 's/ +/|/g')')$'
549 738
550pkg_files= 739pkg_files=
@@ -565,7 +754,7 @@ if [ -n "$remote" ]; then
565 # Until now we have been using whatever downloader that is available 754 # Until now we have been using whatever downloader that is available
566 # (curl or wget). Switch to wget: it has all its dependecies installed. 755 # (curl or wget). Switch to wget: it has all its dependecies installed.
567 dnfunc=download_wget 756 dnfunc=download_wget
568fi 757fi
569 758
570# Upgrade the rest of packages 759# Upgrade the rest of packages
571egrep -v "$pkg_re" candidates |\ 760egrep -v "$pkg_re" candidates |\
@@ -630,4 +819,3 @@ bootloader has been updated for the new kernel!
630Good luck! 819Good luck!
631EOF 820EOF
632fi 821fi
633
diff --git a/slackupgrade.8 b/slackupgrade.8
index 8d88b58..d58b0e7 100644
--- a/slackupgrade.8
+++ b/slackupgrade.8
@@ -1,5 +1,5 @@
1.\" This file is part of slackupgrade 1.\" This file is part of slackupgrade
2.\" Copyright (C) 2019 Sergey Poznyakoff. 2.\" Copyright (C) 2019-2020 Sergey Poznyakoff.
3.\" 3.\"
4.\" Slackware-upgrade-system is free software; you can redistribute it and/or 4.\" Slackware-upgrade-system is free software; you can redistribute it and/or
5.\" modify it under the terms of the GNU General Public License as published 5.\" modify it under the terms of the GNU General Public License as published
@@ -14,14 +14,14 @@
14.\" You should have received a copy of the GNU General Public License 14.\" You should have received a copy of the GNU General Public License
15.\" along with slackupgrade. If not, see 15.\" along with slackupgrade. If not, see
16.\" <http://www.gnu.org/licenses/>. 16.\" <http://www.gnu.org/licenses/>.
17.TH SLACKUPGRADE 8 "September 23, 2019" "SLACKUPGRADE" "System Manager's Manual" 17.TH SLACKUPGRADE 8 "February 7, 2020" "SLACKUPGRADE" "System Manager's Manual"
18.SH NAME 18.SH NAME
19slackwupgrade \- do a full upgrade of a Slackware installation 19slackupgrade \- do a full upgrade of a Slackware installation
20.SH SYNOPSIS 20.SH SYNOPSIS
21.nh 21.nh
22.na 22.na
23\fBslackupgrade\fR\ 23\fBslackupgrade\fR\
24 [\fB\-anqvy\fR]\ 24 [\fB\-aInSqvy\fR]\
25 [\fB\-k \fIFILE\fR]\ 25 [\fB\-k \fIFILE\fR]\
26 [\fB\-p \fIPACKAGE\fR\]\ 26 [\fB\-p \fIPACKAGE\fR\]\
27 [\fB\-s \fISERIES\fR]\ 27 [\fB\-s \fISERIES\fR]\
@@ -48,7 +48,7 @@ directories.
48The file \fBCHECKSUMS.md5\fR and its GPG signature are downloaded 48The file \fBCHECKSUMS.md5\fR and its GPG signature are downloaded
49first. Then, the program verifies that the signature is correct. 49first. Then, the program verifies that the signature is correct.
50For this to succeed, you must have the Slackware Linux Project 50For this to succeed, you must have the Slackware Linux Project
51public key in your keyring. If you don't, run 51public key in your GPG keyring. If you don't, run
52.PP 52.PP
53.EX 53.EX
54curl -o - https://www.slackware.com/gpg-key | gpg --import 54curl -o - https://www.slackware.com/gpg-key | gpg --import
@@ -56,22 +56,15 @@ curl -o - https://www.slackware.com/gpg-key | gpg --import
56.PP 56.PP
57When this initial check is passed, the program constructs two lists 57When this initial check is passed, the program constructs two lists
58of packages: a list of currently installed packages and a list of 58of packages: a list of currently installed packages and a list of
59packages available in the distribution. When constructing the list of 59packages available in the distribution. The intersection of these two
60available packages, known differences between Slackware releases are 60is the list of \fIupgrade candidates\fR, i.e. packages that will be
61taken into account. For example, consider upgrade from version 14.1 to 61upgraded.
6214.2. It is known that the \fIportmap\fR package from 14.1 is
63replaced with the \fIrpcbind\fR in version 14.2. Consequently, if the
64program sees that \fIportmap\fR is installed on the system, it will
65include \fIrpcbind\fR to the list of installation candidates.
66Information about package differences in various versions is kept in
67\fIreplacement map files\fR. See the section \fBREPLACEMENT MAP\fR,
68for a discussion of these files.
69.PP 62.PP
70The difference between these two lists, is the set of installed 63The difference between these lists is the set of installed
71packages that have no equivalent in the available package list. Those 64packages that have no equivalent in the available package list. Those
72are \fIorphaned packages\fR, which were either removed from the Slackware 65are \fIorphaned packages\fR, which were either removed from the Slackware
73distribution, or were installed from third-party sources. It is 66distribution, or were installed from third-party sources. It is
74unpredictable whether or not these will work on the newly upgraded 67unpredictable whether these will work on the newly upgraded
75system, therefore they will be removed after a successful upgrade. 68system, therefore they will be removed after a successful upgrade.
76Before proceeding, the program will display this list on the screen 69Before proceeding, the program will display this list on the screen
77and save it in file 70and save it in file
@@ -82,32 +75,21 @@ for your consideration (here, \fIOLD\fR and \fINEW\fR stand for the
82current and new Slackware version numbers, correspondingly). After 75current and new Slackware version numbers, correspondingly). After
83the upgrade, you can re-install them, if necessary. 76the upgrade, you can re-install them, if necessary.
84.PP 77.PP
85After this step, the program will print the current Slackware version 78Known differences between Slackware releases are taken into account
86and the version you are going to upgrade to, and will ask you to 79when building lists of upgrade and delete candidates. For example,
87confirm that you really want to upgrade. This is the right moment to 80consider an upgrade from version 14.1 to 14.2. It is known that the
88quit if you decide to modify program invocation in order to handle 81\fIportmap\fR package from 14.1 is replaced with the \fIrpcbind\fR in
89orphaned packages. 82version 14.2. Consequently, if the program sees that \fIportmap\fR is
83installed on the system, it will include \fIrpcbind\fR to the list of
84installation candidates. Information about package differences in
85various versions is kept in \fIreplacement map files\fR. See the
86section \fBREPLACEMENT MAP\fR, for a discussion of these files.
90.PP 87.PP
91If you do, type \fBno\fR. You have two options. First, if there are 88In addition to upgrading already installed packages you can request
92any orphaned packages that you want to keep in place, create a 89the program to install additional series or individual packages
93\fIkeep-list\fR file. This file should contain names of those 90from the distribution with the \fB\-s\fR and \fB\-p\fR options. E.g.,
94packages, each name on a separate line. When you restart the program 91it is often a good idea to install all packages from series \fBl\fR (ell),
95use the \fB\-k \fIFILE\fR\fR option to instruct it to use this file. 92like that:
96.PP
97Secondly, if you are upgrading to the version for which there is no
98replacement map, there can be replacement packages for some of the
99orphaned ones. You can create a replacement map and save it to
100the \fB/etc/slackupgrade\fR directory (see the section
101\fBREPLACEMENT MAP\fR for details). If you do, please drop me a note
102so that your changes become available for other users (see the
103\fBBUGS\fR section, for contact information). You can also use the
104\fB\-p\fR command line option to provide the names of replacement
105packages from the command line.
106.PP
107By default, the program will upgrade only the packages actually
108installed on your system. You can request to install additional
109series from the distribution with the \fB\-s\fR option. E.g., it is
110often a good idea to install all packages from series \fBl\fR, like that:
111.PP 93.PP
112.EX 94.EX
113slackupgrade \-s l 95slackupgrade \-s l
@@ -117,6 +99,51 @@ Otherwise, you can request to install all missing packages from all
117series, excepting \fBkde*\fR, by running the command with the 99series, excepting \fBkde*\fR, by running the command with the
118\fB\-a\fR option. 100\fB\-a\fR option.
119.PP 101.PP
102Once the package lists are ready, the program prints the current
103Slackware version and the version it is going to upgrade to, and asks
104you to confirm that you really want to upgrade. This is the right
105moment to quit if you decide to modify program invocation in order to
106handle orphaned packages. See the subsection
107.B Handling of orphaned packages
108for a discussion.
109.PP
110If you decide to continue and \fBslackupgrade\fR uses the remote
111repository, it will select the upgrade mode to use. There are two
112possibilities:
113.TP
114.I Incremental mode
115In this mode, the archive for each package will be downloaded
116immediately prior to its installation and removed afterwards. The
117only exception are several basic packages that are needed for the
118upgrade process and which will be downloaded and installed in the
119first place.
120
121This mode requires little additional disk space, but it is somewhat
122risky. If something happens to your internet connection during the
123upgrade, you'll end up with partly upgraded (and consequently,
124unstable) system.
125.TP
126.I Safe mode
127In safe mode, \fBslackupgrade\fR first downloads all needed packages
128from the remote repository and then proceeds to upgrade using local
129disk copies. Downloaded files are removed when no longer needed, i.e.
130immediately after the corresponding package has been installed.
131
132This mode requires around 2.5G of free disk space on the device which
133hosts the \fBslackupgrade\fR spool directory (by default --
134.BR /var/slackupgrade ).
135You can select another location by setting the
136\fBSLACKUPGRADE_PKGDIR\fR environment variable to the full pathname
137of the spool directory you wish to use.
138
139The advantage of the safe mode is that even if something goes wrong
140during the upgrade, you have all the necessary stuff at hand to resume
141upgrade from where you left off.
142.PP
143Safe mode is assumed if there is enough disk space. Otherwise, the
144program will ask you whether you wish to continue in incremental mode
145and will act accordingly.
146.PP
120At the end of the run, the program prints additional instructions and 147At the end of the run, the program prints additional instructions and
121leaves the detailed log in file 148leaves the detailed log in file
122.nh 149.nh
@@ -131,6 +158,24 @@ conflict with the existing files, they will be stored alongside the
131original files, with the \fB.new\fR extension. The list of these 158original files, with the \fB.new\fR extension. The list of these
132files will be stored in file 159files will be stored in file
133\fB/var/log/slackupgrade\-\fIOLD\fB\-\fINEW\fB.new\fR. 160\fB/var/log/slackupgrade\-\fIOLD\fB\-\fINEW\fB.new\fR.
161.SS Handling of orphaned packages
162There are two possible ways to handle installed packages that have no
163installation candidate in the new Slackware release.
164
165First, if you want to keep in place any of them, create a
166\fIkeep-list\fR file. This file is a list of package names, each on a
167separate line. When you start \fBslackupgrade\fR, use the
168\fB\-k \fIFILE\fR\fR option to instruct it to use this file.
169.PP
170Secondly, if you are upgrading to the version for which there is no
171replacement map, there can be replacement packages for some of the
172orphaned ones. You can create a replacement map and save it to
173the \fB/etc/slackupgrade\fR directory (see the section
174\fBREPLACEMENT MAP\fR for details). If you do, please drop me a note
175so that your changes become available for other users (see the
176\fBBUGS\fR section, for contact information). You can also use the
177\fB\-p\fR command line option to provide the names of replacement
178packages from the command line.
134.SH OPTIONS 179.SH OPTIONS
135.TP 180.TP
136.B \-a 181.B \-a
@@ -139,6 +184,9 @@ Install all series except \fBkde*\fR.
139.B \-h 184.B \-h
140Display a short help summary and exit. 185Display a short help summary and exit.
141.TP 186.TP
187.B \-I
188Force using incremental mode (see also \fB\-S\fR).
189.TP
142\fB\-k \fIFILE\fR 190\fB\-k \fIFILE\fR
143After successful upgrade, \fBslackupgrade\fR will remove 191After successful upgrade, \fBslackupgrade\fR will remove
144previously installed packages that are not available in the new 192previously installed packages that are not available in the new
@@ -169,6 +217,9 @@ Install additional package.
169.B \-q 217.B \-q
170Quiet mode: suppress all messages, except error diagnostics. 218Quiet mode: suppress all messages, except error diagnostics.
171.TP 219.TP
220.B \-S
221Force using safe mode. Abort if not enough disk space is available.
222.TP
172\fB\-s \fISERIES\fR 223\fB\-s \fISERIES\fR
173Additionally install all packages from \fISERIES\fR. 224Additionally install all packages from \fISERIES\fR.
174.sp 225.sp
@@ -219,6 +270,12 @@ nearest newline character. Empty lines and comments are ignored.
219\fB/etc/slackupgrade/\fIOLD\fB\-\fINEW\fB.repl\fR 270\fB/etc/slackupgrade/\fIOLD\fB\-\fINEW\fB.repl\fR
220Replacement map for upgrades from version \fIOLD\fR to \fINEW\fR. 271Replacement map for upgrades from version \fIOLD\fR to \fINEW\fR.
221.TP 272.TP
273.B /var/slackupgrade
274Default spool directory. This is where all downloaded files are
275stored. You can override the default location by setting the
276.B SLACKUPGRADE_PKGDIR
277environment variable.
278.TP
222\fB/var/log/slackupgrade\-\fIOLD\fB\-\fINEW\fB.log\fR 279\fB/var/log/slackupgrade\-\fIOLD\fB\-\fINEW\fB.log\fR
223Detailed log of operations performed during the upgrade from version 280Detailed log of operations performed during the upgrade from version
224\fIOLD\fR to \fINEW\fR. 281\fIOLD\fR to \fINEW\fR.
@@ -250,6 +307,21 @@ name. E.g. \fBslackupgrade-14.1-14.2.log\fR is renamed to
250using the following pattern: \fBX~\fR becomes \fBX~1\fR, \fBX~1\fR 307using the following pattern: \fBX~\fR becomes \fBX~1\fR, \fBX~1\fR
251becomes \fBX~2\fR and so on. At most five backup copies are kept 308becomes \fBX~2\fR and so on. At most five backup copies are kept
252(from \fBX~\fR up to \fBX~4\fR). 309(from \fBX~\fR up to \fBX~4\fR).
310.SH ENVIRONMENT
311.TP
312.B SLACKUPGRADE_CONFDIR
313Location of the configuration directory. This is the place where
314replacement maps are stored. The default is
315.BR /etc/slackupgrade .
316.TP
317.B SLACKUPGRADE_PKGDIR
318Location of the \fBslackupgrade\fR package spool directory. This is
319the temporary storage for downloaded package tarballs. The default is
320.BR /var/slackupgrade .
321.TP
322.B TMP
323Location of the temporary directory. The default is
324.BR /tmp .
253.SH "SEE ALSO" 325.SH "SEE ALSO"
254The \fBUPGRADE.TXT\fR document, outlining the procedure as a whole: 326The \fBUPGRADE.TXT\fR document, outlining the procedure as a whole:
255.nh 327.nh
@@ -263,7 +335,7 @@ subdirectory is not used.
263.PP 335.PP
264Report bugs to <gray@gnu.org>. 336Report bugs to <gray@gnu.org>.
265.SH COPYRIGHT 337.SH COPYRIGHT
266Copyright \(co 2019 Sergey Poznyakoff 338Copyright \(co 2019 \(em 2020 Sergey Poznyakoff
267.br 339.br
268.na 340.na
269License GPLv3+: GNU GPL version 3 or later 341License GPLv3+: GNU GPL version 3 or later

Return to:

Send suggestions and report system problems to the System administrator.