aboutsummaryrefslogtreecommitdiff
path: root/slackware-upgrade-system
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2019-09-12 12:32:54 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2019-09-12 12:32:54 +0200
commit48d00ee156651256bd338f4d8f3aff73f75a2249 (patch)
tree7f3be8af76fd6ea52649655abc66761e8d7f5afd /slackware-upgrade-system
parentb746c5f05cea810c47900bb6ce99fe15b912f1bb (diff)
downloadslackupgrade-48d00ee156651256bd338f4d8f3aff73f75a2249.tar.gz
slackupgrade-48d00ee156651256bd338f4d8f3aff73f75a2249.tar.bz2
Upgrade only what's necessary unless -a is given
Diffstat (limited to 'slackware-upgrade-system')
-rw-r--r--slackware-upgrade-system68
1 files changed, 56 insertions, 12 deletions
diff --git a/slackware-upgrade-system b/slackware-upgrade-system
index d016749..acc8288 100644
--- a/slackware-upgrade-system
+++ b/slackware-upgrade-system
@@ -4,8 +4,11 @@ set -e
PKGDIR=/root/slackware
logfile=/var/log/slackware-upgrade-system.log
+dry_run=
assume_y=
quiet_mode=
+install_all=
+install_series=
function getyn() {
if [ "$assume_y" = y ]; then
@@ -29,20 +32,25 @@ function getyn() {
}
function upgrade_package() {
- if [ -n "$quiet_mode" ]; then
+ if [ -n "$dry_run" ]; then
+ echo "upgradepkg $@"
+ elif [ -n "$quiet_mode" ]; then
upgradepkg "$@" >> $logfile
else
upgradepkg "$@" | tee -a $logfile | sed -n -e '/^| Upgrading/s/^| //p'
fi
}
-while getopts "yqd:" OPTION
+while getopts "ad:ns:qy" OPTION
do
case $OPTION in
- y) assume_y=y;;
- q) quiet_mode=y;;
+ a) install_all=y;;
d) PKGDIR=$OPTARG;;
- *) echo >&2 "usage: $0 [-d DIRECTORY] [-yq]"
+ n) dry_run=y;;
+ s) install_series="$install_series $OPTARG";;
+ q) quiet_mode=y;;
+ y) assume_y=y;;
+ *) echo >&2 "usage: $0 [-anqy] [-d DIRECTORY] [-s SERIES]"
exit 1
esac
done
@@ -103,6 +111,7 @@ fi
# Prepare a list of packages that should be removed after install
installed_list=/tmp/installed.list
avail_list=/tmp/avail.list
+candidates=
remove_list=/tmp/remove.list
ls /var/log/packages |\
@@ -121,15 +130,20 @@ find $PKGDIR \
sort > $avail_list
comm -2 -3 $installed_list $avail_list > $remove_list
-rm -f $inst_list $avail_list
+if [ -z "$install_all" ]; then
+ candidates=$(comm -1 -2 $installed_list $avail_list)
+fi
+rm -f $installed_list $avail_list
-(cat <<EOF
+if [ -s $remove_list -a -z "$quiet_mode" ]; 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
in the file $remove_list:
EOF
cat $remove_list) | ${PAGER:-more}
+fi
if ! getyn n "Ready for upgrade. Continue"; then
echo "Exiting"
@@ -147,20 +161,50 @@ upgrade_package a/tar-*.tgz
upgrade_package a/xz-*.tgz
upgrade_package a/findutils-*.txz
-find . -depth -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort |
- while read dir
- do
+echo "$candidates">/tmp/c
+if [ -n "$candidates" ]; then
+ for name in $candidates
+ do
+ ls */$name*.t?z | \
+ sed -r -n "/$name"'-[^-]+-(i386|x86(_64)?|arm|noarch|fw)-[[:digit:]]+(_.*)?\.t.z$/p'
+ done | \
+ sort | \
+ while read pkg
+ do
+ s=$(basename ${pkg%/*})
+ if [ "$prev" != "$s" ]; then
+ echo "$0: installing selected files from series $s"
+ prev=$s
+ fi
+ upgrade_package --install-new $pkg
+ done
+ for s in $install_series
+ do
+ if [ -d $s ]; then
+ echo "$0: installing additional series $s"
+ upgrade_package --install-new $s/*.t?z
+ else
+ echo >&2 "$0: no such series: $s"
+ fi
+ done
+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
;;
esac
- done
+ done
+fi
if [ -s $remove_list ]; then
echo "$0: removing packages"
- if [ -n "$quiet_mode" ]; then
+ if [ -n "$dry_run" ]; then
+ :
+ elif [ -n "$quiet_mode" ]; then
removepkg $(cat $remove_list) >> $logfile
else
removepkg $(cat $remove_list) | tee -a $logfile | grep '^Removing package'

Return to:

Send suggestions and report system problems to the System administrator.