# Download kernel updates from Slackware Current for a stable release. # # For this to work, make sure the kernel packages are blacklisted in # /etc/slackpkg/blacklist. # # kernel-generic.* # kernel-huge.* # kernel-modules.* # kernel-source.* # # This script uses an unusual pattern for running commands on exit, similar to # Golang's defer. These will not be run when the script is stopped with # Control+c. # # D="[command]; $D"; trap "$D" EXIT # echo "Checking kernel updates from Slackware Current (slackpkg)..." # Get Slackware version. source /etc/os-release SOURCE=$(sed -n ' # Remove leading and trailing blanks s/^[[:blank:]]*// s/[[:blank:]]*$// # Only one token is allowed per line /[[:blank:]]/d # A single solidus should end the URI s,[/]*$,/, # Print the lines beginning with one of the URI schemes we look for \@^file://@p \@^cdrom://@p \@^local://@p \@^https\{0,1\}://@p \@^ftps\{0,1\}://@p' /etc/slackpkg/mirrors) SOURCE="$(echo $SOURCE | sed 's/-$VERSION/-current/')" yes y | slackpkg -mirror="$SOURCE" -batch=on -default_answer=yes update D="yes | slackpkg -batch=on -default_answer=yes update"; trap "$D" EXIT PACKAGE_UPDATES="$(mktemp /tmp/slack-autoupdate.XXXXXX)" D="rm -f ${PACKAGE_UPDATES}; $D"; trap "$D" EXIT mv /etc/slackpkg/blacklist /etc/slackpkg/blacklist.orig touch /etc/slackpkg/blacklist D="mv -f /etc/slackpkg/blacklist.orig /etc/slackpkg/blacklist; $D"; trap "$D" EXIT slackpkg -batch=on -default_answer=n \ upgrade kernel \ | grep "\.t.z$" \ | tee "$PACKAGE_UPDATES" \ || exit "$?" if [ ! -s "$PACKAGE_UPDATES" ]; then # No updates exit 0 fi while read PKG; do PKG_URL="$( grep "${PKG}$" /var/lib/slackpkg/CHECKSUMS.md5 \ | tr -s ' ' \ | cut -f 2 -d ' ' )" || exit "$?" wget \ --directory-prefix="$STAGING_DIR" \ "${SOURCE}${PKG_URL}" \ "${SOURCE}${PKG_URL}.asc" \ || exit 1 done <"$PACKAGE_UPDATES" if ! gpg2 --verify-files "$STAGING_DIR"/kernel-*.asc; then echo "gpg verification failed" exit 1 fi ( # Redirect this subshell's standard output to info file. exec 1>>"$UPDATE_INFO" echo "## Slackware current kernel updates" echo while read PKG; do echo " - $PKG" done <"$PACKAGE_UPDATES" echo )