aboutsummaryrefslogtreecommitdiff
path: root/src/recipes/use-current-kernel.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/recipes/use-current-kernel.sh')
-rw-r--r--src/recipes/use-current-kernel.sh156
1 files changed, 78 insertions, 78 deletions
diff --git a/src/recipes/use-current-kernel.sh b/src/recipes/use-current-kernel.sh
index 50b08e7..6673bfb 100644
--- a/src/recipes/use-current-kernel.sh
+++ b/src/recipes/use-current-kernel.sh
@@ -1,92 +1,92 @@
-# 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
-#
+slackware_current_kernel_source() {
+ # 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)..."
+ local staging_dir="$1"
+ local update_info="$2"
-# Get Slackware version.
-source /etc/os-release
+ # Get the system's 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/")"
+ local mirror=$(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)
+ mirror="$(echo $mirror | 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
+ yes y | slackpkg -mirror="$mirror" -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
+ local 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
+ 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
-OUTPUT="$(slackpkg -batch=on -default_answer=n upgrade kernel)" || exit_code="$?"
-if [ $exit_code -ne 0 ] && [ $exit_code -ne 20 ] && [ $exit_code -ne 100 ]; then
+ local output="$(slackpkg -batch=on -default_answer=n upgrade kernel)" || exit_code="$?"
# slackpkg has several safe exit codes.
- exit exit_code
-fi
+ if [ $exit_code -ne 0 ] && [ $exit_code -ne 20 ] && [ $exit_code -ne 100 ]; then
+ exit exit_code
+ fi
-echo "$OUTPUT" \
- | grep "\.t.z$" \
- | tee "$PACKAGE_UPDATES"
-if [ ! -s "$PACKAGE_UPDATES" ]; then
- # No updates
- exit 0
-fi
+ echo "$output" \
+ | grep "\.t.z$" \
+ | tee "$package_updates"
+ 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 "$?"
+ 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"
+ wget \
+ --directory-prefix="$STAGING_DIR" \
+ "${mirror}${PKG_URL}" \
+ "${mirror}${PKG_URL}.asc" \
+ || exit 1
+ done <"$package_updates"
-if ! gpg2 --verify-files "$STAGING_DIR"/kernel-*.asc; then
- echo "gpg verification failed"
- exit 1
-fi
+ 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"
+ (
+ # 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
-)
+ while read PKG; do
+ echo " - $PKG"
+ done <"$package_updates"
+ )
+}