diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-09-12 16:40:33 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-09-12 16:40:33 +0200 |
commit | 933f20150e7a7918dbca06ce7e04111b65b29467 (patch) | |
tree | ddb6264609d69145891f7de93723f2858194f429 | |
parent | c6a4b69e5172f27b078d2489e07b0fe1fffdd282 (diff) | |
download | slackupgrade-933f20150e7a7918dbca06ce7e04111b65b29467.tar.gz slackupgrade-933f20150e7a7918dbca06ce7e04111b65b29467.tar.bz2 |
New option: -v (verbose mode)
-rw-r--r-- | slackware-upgrade-system | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/slackware-upgrade-system b/slackware-upgrade-system index abc3ff2..89b2cca 100644 --- a/slackware-upgrade-system +++ b/slackware-upgrade-system @@ -10,8 +10,8 @@ logfile= dry_run= # If 'y', don't ask anything, assume "y" as answer to all quieries assume_y= -# If 'y', enable quiet mode: don't print per-package progress information. -quiet_mode= +# Output verbosity: '' - normal, 'v' - verbose, 'q' - quiet +verbosity= # If 'y', install all packages install_all= # Names of the series that should be installed in addition to already installed @@ -22,7 +22,7 @@ keep_file= function usage() { cat <<EOF -usage: $0 [-anqy] [-d DIRECTORY] [-k FILE] [-s SERIES] +usage: $0 [-anqvy] [-d DIRECTORY] [-k FILE] [-s SERIES] Upgrade Slackware installation Options are: @@ -33,9 +33,10 @@ Options are: -h display this help list and exit -k FILE preserve packages listed in FILE -n dry-run mode: do nothing, print what would have been done - -q quiet mode: suppress messages about individual packages + -q quiet mode: suppress all messages, except errors -s SERIES additionally install all packages from SERIES; incompatible with -a + -v display messages about individual packages -y assume "yes" to all queries EOF @@ -65,14 +66,14 @@ function getyn() { function upgrade_package() { if [ -n "$dry_run" ]; then echo "upgradepkg $@" - elif [ -n "$quiet_mode" ]; then - upgradepkg "$@" >> $logfile - else + elif [ "$verbosity" = 'v' ]; then upgradepkg "$@" | tee -a $logfile | sed -n -e '/^| Upgrading/s/^| //p' + else + upgradepkg "$@" >> $logfile fi } -while getopts "ad:hnqk:s:y" OPTION +while getopts "ad:hknq:s:vy" OPTION do case $OPTION in a) install_all=y;; @@ -81,7 +82,8 @@ do exit 0;; k) keep_file=$OPTARG;; n) dry_run=y;; - q) quiet_mode=y;; + q) verbosity=q;; + v) verbosity=v;; s) install_series="$install_series $OPTARG";; y) assume_y=y;; *) usage >&2 @@ -222,7 +224,7 @@ rm -f $installed_list $avail_list # Disable interrupts during critical section trap '' HUP INT QUIT ABRT -if [ -s $remove_list -a -z "$quiet_mode" ]; then +if [ -s $remove_list -a "$verbosity" != 'q' ]; then (cat <<EOF INFO: The following packages will be removed. You will have to manually restore them after the upgrade. The package names are preserved for you @@ -292,10 +294,10 @@ if [ -s $remove_list ]; then echo "$0: removing packages" if [ -n "$dry_run" ]; then : - elif [ -n "$quiet_mode" ]; then - removepkg $(cat $remove_list) >> $logfile - else + elif [ "$verbosity" = 'v' ]; then removepkg $(cat $remove_list) | tee -a $logfile | grep '^Removing package' + else + removepkg $(cat $remove_list) >> $logfile fi echo "$0: see $remove_list for the list of packages that have been removed" fi @@ -309,7 +311,7 @@ if [ ! -s "$conffiles" ]; then rm $conffiles fi -if [ -z "$quiet_mode" ]; then +if [ "$verbosity" != 'q' ]; then echo "IMPORTANT!" if [ -s "$conffiles" ]; then cat <<EOF |