diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-09-12 15:50:13 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-09-12 15:50:13 +0200 |
commit | c6a4b69e5172f27b078d2489e07b0fe1fffdd282 (patch) | |
tree | dbd3d0cebfb7dcec88aa1be3457699c19e185bdb /slackware-upgrade-system | |
parent | 85a7a7d77d7d7c91b69da9b8bd6dd700c7aca042 (diff) | |
download | slackupgrade-c6a4b69e5172f27b078d2489e07b0fe1fffdd282.tar.gz slackupgrade-c6a4b69e5172f27b078d2489e07b0fe1fffdd282.tar.bz2 |
Formatting changes
Diffstat (limited to 'slackware-upgrade-system')
-rw-r--r-- | slackware-upgrade-system | 98 |
1 files changed, 54 insertions, 44 deletions
diff --git a/slackware-upgrade-system b/slackware-upgrade-system index 3407fb3..abc3ff2 100644 --- a/slackware-upgrade-system +++ b/slackware-upgrade-system @@ -2,14 +2,22 @@ set -e -ROOTDIR=/root/slackware -PKGDIR=$ROOTDIR/slackware64 +# Slackware root directory +rootdir=/root/slackware +# Log file name logfile= +# 'y', if dry-run mode is requested 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= +# If 'y', install all packages install_all= +# Names of the series that should be installed in addition to already installed +# packages. Ignored, if install_all is set. install_series= +# Name of the keep-list file. keep_file= function usage() { @@ -21,13 +29,13 @@ Options are: -a install all series except kde* -d DIRECTORY look for slackware distribution in DIRECTORY; - default is $ROOTDIR + default is $rootdir -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 -s SERIES additionally install all packages from SERIES; - incompatible with -a + incompatible with -a -y assume "yes" to all queries EOF @@ -43,14 +51,14 @@ function getyn() { [yY]) dfl_s=" [Y/n]";; [nN]) dfl_s=" [y/N]";; *) dfl_s=""; dlf="";; - esac - - printf "%s$dfl_s? " "$*" - read REPLY </dev/tty - case "${REPLY:-$dfl}" in + esac + + printf "%s$dfl_s? " "$*" + read REPLY </dev/tty + case "${REPLY:-$dfl}" in [yY]*) /bin/true;; *) /bin/false;; - esac + esac fi } @@ -68,7 +76,7 @@ while getopts "ad:hnqk:s:y" OPTION do case $OPTION in a) install_all=y;; - d) PKGDIR=$OPTARG;; + d) rootdir=$OPTARG;; h) usage exit 0;; k) keep_file=$OPTARG;; @@ -79,19 +87,19 @@ do *) usage >&2 exit 1 esac -done +done shift $(($OPTIND - 1)) if [ $# -gt 0 ]; then echo >&2 "$0: unexpected arguments" usage >&2 exit 1 -fi +fi if [ $(id -u) != "0" ]; then echo >&2 "$0: must be root" exit 1 -fi +fi # Sanity check if [ ! -s /etc/os-release ]; then @@ -104,26 +112,28 @@ fi if [ "$ID" != "slackware" ]; then echo >&2 "$0: this doesn't seem to be a Slackware installation" exit 1 -fi +fi -# Check if ROOTDIR exists and contains the necessary files and directories -if [ ! -d $ROOTDIR ]; then - echo >&2 "$0: $ROOTDIR does not exist" +# Check if rootdir exists and contains the necessary files and directories +if [ ! -d $rootdir ]; then + echo >&2 "$0: $rootdir does not exist" exit 1 fi -newversion=$(ls $ROOTDIR/ANNOUNCE.* |\ - sed -e 's|.*/||' -e 's/ANNOUNCE\.//' -e 's/_/./g') +newversion=$(ls $rootdir/ANNOUNCE.* |\ + sed -e 's|.*/||' -e 's/ANNOUNCE\.//' -e 's/_/./g') if [ -z "$newversion" ]; then echo >&2 "$0: cannot determine new version" exit 1 -fi +fi logfile=/var/log/slackware-upgrade-system-$VERSION-$newversion.log -# Check if PKGDIR exists and contains the necessary files and directories -if [ ! -d $PKGDIR ]; then - echo >&2 "$0: $PKGDIR does not exist" +# Check if pkgdir exists and contains the necessary files and directories +pkgdir=$rootdir/slackware64 + +if [ ! -d $pkgdir ]; then + echo >&2 "$0: $pkgdir does not exist" exit 1 fi @@ -135,13 +145,13 @@ FILE_LIST MANIFEST.bz2 EOF -missing=$(find $PKGDIR -depth -mindepth 1 -maxdepth 1 \ - -type f -printf '%f\n' | \ - sort | \ - comm -1 -3 - $tmplist) +missing=$(find $pkgdir -depth -mindepth 1 -maxdepth 1 \ + -type f -printf '%f\n' | \ + sort | \ + comm -1 -3 - $tmplist) rm $tmplist if [ -n "$missing" ]; then - echo >&2 "$0: The following required files are missing in $PKGDIR:" + echo >&2 "$0: The following required files are missing in $pkgdir:" echo >&2 "$missing" exit 1 fi @@ -163,13 +173,13 @@ xfce y EOF -missing=$(find $PKGDIR -depth -mindepth 1 -maxdepth 1 \ - -type d -printf '%f\n' | \ - sort | \ - comm -1 -3 - $tmplist) +missing=$(find $pkgdir -depth -mindepth 1 -maxdepth 1 \ + -type d -printf '%f\n' | \ + sort | \ + comm -1 -3 - $tmplist) rm $tmplist if [ -n "$missing" ]; then - echo >&2 "$0: The following required directories are missing in $PKGDIR:" + echo >&2 "$0: The following required directories are missing in $pkgdir:" echo >&2 "$missing" exit 1 fi @@ -184,7 +194,7 @@ ls /var/log/packages |\ sed -r -e 's/-[^-]+-(i386|x86(_64)?|arm|noarch|fw)-[[:digit:]]+(_.*)?//' |\ sort > $installed_list -find $PKGDIR \ +find $pkgdir \ -depth \ -mindepth 2 -maxdepth 2 \ -type f \ @@ -206,7 +216,7 @@ fi if [ -z "$install_all" ]; then candidates=$(comm -1 -2 $installed_list $avail_list) -fi +fi rm -f $installed_list $avail_list # Disable interrupts during critical section @@ -225,9 +235,9 @@ fi if ! getyn n "Ready for upgrade from $VERSION to $newversion. Continue"; then echo "Exiting" exit 0 -fi +fi -cd $PKGDIR +cd $pkgdir # Upgrade the glibc shared libraries. echo "$0: Upgrading shared libraries" @@ -260,20 +270,20 @@ if [ -n "$candidates" ]; then do if [ -d $s ]; then echo "$0: installing additional series $s" - upgrade_package --install-new $s/*.t?z + upgrade_package --install-new $s/*.t?z else echo >&2 "$0: no such series: $s" fi done -else +else find . -depth -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort | while read dir do case $dir in kde*) ;; *) echo "$0: installing packages from series $dir" - upgrade_package --install-new $dir/*.t?z - ;; + upgrade_package --install-new $dir/*.t?z + ;; esac done fi @@ -285,7 +295,7 @@ if [ -s $remove_list ]; then elif [ -n "$quiet_mode" ]; then removepkg $(cat $remove_list) >> $logfile else - removepkg $(cat $remove_list) | tee -a $logfile | grep '^Removing package' + removepkg $(cat $remove_list) | tee -a $logfile | grep '^Removing package' fi echo "$0: see $remove_list for the list of packages that have been removed" fi @@ -308,7 +318,7 @@ list and compare them with their counterparts without the ".new" suffix. Remove the "*.new" files when finished. The list of files follows: EOF - cat $conffiles + cat $conffiles cat <<EOF For your convenience, this list is preserved in the file $conffiles. |