Asking review of slackpkg script . @bassmadrigal & chrisretusn
by babydr from LinuxQuestions.org on (#5GX9M)
Hello Bassmadrigal & Chrisretusn ,
Requesting review of the script below for when 15.+ becomes published .
Looking for suggestions of better methodologies &/or readability .
Tia , JimL
Code:#!/bin/bash
# Note: this shell script uses slackpkg-15.X and newer functions .
#
# V2a(202104211510) , Jim Laferriere <babydr@baby-dragons.com>
# V1c(201810181209) , "
#
# Tell us what version of slackware/slamd64 we are running
#
echo -en "\n$(cat /etc/slackware-version)\n\n"
cat << PROGDB
#
# Updating 'The package list' ie: program database .
#
PROGDB
slackpkg -batch=on -default_answer=y update
aAa=$(ls /var/lib/pkgtools/packages/slackpkg* | awk -F'/' '{print $6}')
bBb=$(slackpkg info slackpkg | grep "PACKAGE[[:space:]]NAME:" | awk -F":" '{print $2}' | sed -e's/[[:space:]]//g' -e's/\.txz$//')
if [ "${aAa}" != "${bBb}" ]; then
cat << PROGSLACKPKG
#
# Upgrading from ${aAa} to ${bBb}
#
# will also reload 'The package list' as successful install
# will remove the files needed for the remainder of the script .
#
PROGSLACKPKG
slackpkg -batch=on -default_answer=y upgrade slackpkg
slackpkg -batch=on -default_answer=y update
fi
cat << PROGNEW
#
# Install Any NEW packages .
#
PROGNEW
slackpkg -batch=on -default_answer=y install-new
cat << PROGUPG
#
# Upgrade installed packages that are updated .
#
PROGUPG
slackpkg -batch=on -default_answer=y upgrade-all
exit


Requesting review of the script below for when 15.+ becomes published .
Looking for suggestions of better methodologies &/or readability .
Tia , JimL
Code:#!/bin/bash
# Note: this shell script uses slackpkg-15.X and newer functions .
#
# V2a(202104211510) , Jim Laferriere <babydr@baby-dragons.com>
# V1c(201810181209) , "
#
# Tell us what version of slackware/slamd64 we are running
#
echo -en "\n$(cat /etc/slackware-version)\n\n"
cat << PROGDB
#
# Updating 'The package list' ie: program database .
#
PROGDB
slackpkg -batch=on -default_answer=y update
aAa=$(ls /var/lib/pkgtools/packages/slackpkg* | awk -F'/' '{print $6}')
bBb=$(slackpkg info slackpkg | grep "PACKAGE[[:space:]]NAME:" | awk -F":" '{print $2}' | sed -e's/[[:space:]]//g' -e's/\.txz$//')
if [ "${aAa}" != "${bBb}" ]; then
cat << PROGSLACKPKG
#
# Upgrading from ${aAa} to ${bBb}
#
# will also reload 'The package list' as successful install
# will remove the files needed for the remainder of the script .
#
PROGSLACKPKG
slackpkg -batch=on -default_answer=y upgrade slackpkg
slackpkg -batch=on -default_answer=y update
fi
cat << PROGNEW
#
# Install Any NEW packages .
#
PROGNEW
slackpkg -batch=on -default_answer=y install-new
cat << PROGUPG
#
# Upgrade installed packages that are updated .
#
PROGUPG
slackpkg -batch=on -default_answer=y upgrade-all
exit