summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2020-03-28 16:13:07 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2020-03-28 16:13:07 (GMT)
commited034ffb5f04fb58d5f43fa10b6f10e2560928b0 (patch) (unidiff)
tree75e2e1d0ea9dc9e4a0720bf47df9a8f8464d92f7
parent09f698bebd13d7e9036728501a8e728edcf1bfeb (diff)
downloadslackupgrade-ed034ffb5f04fb58d5f43fa10b6f10e2560928b0.tar.gz
slackupgrade-ed034ffb5f04fb58d5f43fa10b6f10e2560928b0.tar.bz2
Fix the -k option.
* slackupgrade: Fix declaration of the -k option Change the value of keep_file to the absolute path name.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--slackupgrade25
1 files changed, 22 insertions, 3 deletions
diff --git a/slackupgrade b/slackupgrade
index 9be3e98..f00e20b 100644
--- a/slackupgrade
+++ b/slackupgrade
@@ -414,11 +414,25 @@ function download_all() {
414 fi 414 fi
415} 415}
416 416
417function abspath() {
418 local name=$1
419 local val
420 eval val=\$$name
421 case $val in
422 /*) ;;
423 *) local dir=$(dirname $val)
424 dir=$(cd $dir 2>/dev/null && pwd) || abend "can't canonicalize $val"
425 val=$dir/$(basename $val)
426 eval $name=$val
427 ;;
428 esac
429}
430
417# ########## 431# ##########
418# Main 432# Main
419# ########## 433# ##########
420 434
421while getopts "ahIknp:qSs:vy" OPTION 435while getopts "ahIk:np:qSs:vy" OPTION
422do 436do
423 case $OPTION in 437 case $OPTION in
424 I) opmode=INCR;; 438 I) opmode=INCR;;
@@ -426,7 +440,8 @@ do
426 a) install_all=y;; 440 a) install_all=y;;
427 h) usage 441 h) usage
428 exit 0;; 442 exit 0;;
429 k) keep_file=$OPTARG;; 443 k) keep_file=$OPTARG
444 abspath keep_file;;
430 n) dry_run=y;; 445 n) dry_run=y;;
431 p) install_packages="$install_packages $OPTARG";; 446 p) install_packages="$install_packages $OPTARG";;
432 q) verbosity=q;; 447 q) verbosity=q;;
@@ -451,6 +466,10 @@ if [ $(id -u) != "0" ]; then
451 abend "must be root" 466 abend "must be root"
452fi 467fi
453 468
469if [ -n "$keep_file" ] && [ ! -f "$keep_file" ]; then
470 abend "keep file \"$keep_file\" doesn't exist or is unreadable"
471fi
472
454# Sanity check 473# Sanity check
455if [ ! -s /etc/os-release ]; then 474if [ ! -s /etc/os-release ]; then
456 abend "/etc/os-release doesn't exist" 475 abend "/etc/os-release doesn't exist"
@@ -596,7 +615,7 @@ fi) | sort -u > candidates.$$
596# Build a list of packages that should be removed after install 615# Build a list of packages that should be removed after install
597 616
598comm -2 -3 $installed_list candidates.$$ > remove.list.$$ 617comm -2 -3 $installed_list candidates.$$ > remove.list.$$
599if [ -s "$keep_file" ]; then 618if [ -n "$keep_file" ] && [ -s "$keep_file" ]; then
600 grep -v '^#' $keep_file | \ 619 grep -v '^#' $keep_file | \
601 tr -s '\n' | sort -u | comm -2 -3 remove.list.$$ - > remove.list 620 tr -s '\n' | sort -u | comm -2 -3 remove.list.$$ - > remove.list
602 rm remove.list.$$ 621 rm remove.list.$$

Return to:

Send suggestions and report system problems to the System administrator.