From 63027113ffc563be2023fd2503592ff1765fecff Mon Sep 17 00:00:00 2001 From: Slack Coder Date: Wed, 20 Mar 2024 11:03:11 -0500 Subject: Fix update and download scripts - Correct syncing of Slackware mirror for slackpkg. - Fix kernel check for updating kernel. --- src/autoupdate | 45 +++++++++++++++++++++++++++++++-------------- src/rc.update | 16 +++++++++++++--- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/src/autoupdate b/src/autoupdate index 04e432b..eac1999 100644 --- a/src/autoupdate +++ b/src/autoupdate @@ -32,7 +32,7 @@ export UPDATE_INFO="${UPDATE_INFO:-$STAGING_DIR/info.txt}" export UPDATE_ERROR="${UPDATE_ERROR:-$STAGING_DIR/error.txt}" # Slackware mirror containing packages. -export SLACKWARE_MIRROR="${SLACKWARE_MIRROR:-rsync://mirrors.kernel.org/slackware/slackware64-15.0}" +export SLACKWARE_MIRROR="rsync://mirrors.kernel.org/slackware/slackware64-15.0" # A local Slackware mirror with just enough information to support slackpkg. # @@ -63,7 +63,7 @@ fi # This is slackpkg's exit code when updates are available. SLACKPKG_UPDATES_PENDING=100 -slackpkg -mirror="file:///$LOCAL_MIRROR/" check-updates >/dev/null 2>&1 +slackpkg -mirror="file:///$LOCAL_MIRROR/" check-updates >/dev/null 2>/dev/null if [ "$?" -eq "$SLACKPKG_UPDATES_PENDING" ]; then exit 0 fi @@ -81,18 +81,35 @@ if ! OUTPUT="$( echo "downloading updates from $SLACKWARE_MIRROR..." # Support slackpkg with the least required files for patches. - mkdir --parents "$LOCAL_MIRROR" - cd "$LOCAL_MIRROR" \ - && rsync "$SLACKWARE_MIRROR/CHECKSUMS.md5" . \ - && rsync "$SLACKWARE_MIRROR/CHECKSUMS.md5.asc" . \ - && rsync "$SLACKWARE_MIRROR/ChangeLog.txt" . \ - && rsync "$SLACKWARE_MIRROR/FILELIST.TXT" . \ - && rsync "$SLACKWARE_MIRROR/GPG-KEY" . \ - && rsync "$SLACKWARE_MIRROR/extra" . \ - && rsync "$SLACKWARE_MIRROR/pasture" . \ - && rsync "$SLACKWARE_MIRROR/patches" . \ - && rsync "$SLACKWARE_MIRROR/testing" . \ - && rsync "$SLACKWARE_MIRROR/slackware64/PACKAGES.TXT" slackware64 + # + # Grab the changelog last to avoid slackpkg possibly reporting updates on a + # partially synced mirror. Rsync does not guarantee argument order matches + # download order. + mkdir --parents "$LOCAL_MIRROR/slackware64" && \ + rsync \ + --links --times \ + "$SLACKWARE_MIRROR/slackware64/PACKAGES.TXT" \ + "$LOCAL_MIRROR/slackware64/." \ + && rsync \ + --delete --links --recursive --times \ + "$SLACKWARE_MIRROR/FILELIST.TXT" \ + "$SLACKWARE_MIRROR/GPG-KEY" \ + "$SLACKWARE_MIRROR/extra" \ + --exclude "extra/source" \ + "$SLACKWARE_MIRROR/PACKAGES.TXT" \ + "$SLACKWARE_MIRROR/pasture" \ + --exclude "pasture/source" \ + "$SLACKWARE_MIRROR/patches" \ + --exclude "patches/source" \ + "$SLACKWARE_MIRROR/testing" \ + --exclude "testing/source" \ + "$LOCAL_MIRROR/." \ + && rsync \ + --times \ + "$SLACKWARE_MIRROR/ChangeLog.txt" \ + "$SLACKWARE_MIRROR/CHECKSUMS.md5" \ + "$SLACKWARE_MIRROR/CHECKSUMS.md5.asc" \ + "$LOCAL_MIRROR/." ) || exit $? slackpkg -mirror="file:///$LOCAL_MIRROR/" check-updates diff --git a/src/rc.update b/src/rc.update index db384ca..d781867 100644 --- a/src/rc.update +++ b/src/rc.update @@ -7,6 +7,10 @@ # will run if found. We recommend placing this under /usr/local/sbin. # +# The init system is run without a $USER or $HOME, and they are needed for some +# applications. +export GNUPGHOME="$(getent passwd root | cut -d: -f6)/.gnupg" + # A local Slackware mirror with just enough information to support slackpkg. # # This step could be skipped if slackpkg supports downloading updates without @@ -27,9 +31,9 @@ UPDATE_INFO="$UPDATE_DIR/info.txt" UPDATE_ERROR="$UPDATE_DIR/error.txt" UPDATES=$(find "$UPDATE_DIR" -name '*.t*z' | sort) -SLACKPKG_UPDATES="$(slackpkg -mirror="file:///$LOCAL_MIRROR/" check-updates >&-; echo $?)" +SLACKPKG_UPDATES="$(slackpkg -mirror="file:///$LOCAL_MIRROR/" check-updates 1>/dev/null 2>/dev/null; echo $?)" -if [ -z "$UPDATES" -a "$SLACKPKG_UPDATES" -ne "$SLACKPKG_UPDATES_PENDING" ]; then +if [ -z "$UPDATES" ] && [ "$SLACKPKG_UPDATES" != "$SLACKPKG_UPDATES_PENDING" ]; then exit 0 fi @@ -38,13 +42,19 @@ if read -r -t 5 -p "Installing updates, press enter to skip this process..."; th fi OLD_KERNEL="$(realpath /boot/vmlinuz)" + +if [ "$SLACKPKG_UPDATES" == "$SLACKPKG_UPDATES_PENDING" ]; then + slackpkg -batch=on -default_answer=n -mirror="file:///$LOCAL_MIRROR/" update >/dev/null + slackpkg -batch=on -default_answer=y -postinst=off -mirror="file:///$LOCAL_MIRROR/" upgrade-all +fi + for PKG in $UPDATES; do upgradepkg --install-new "$PKG" && rm "$PKG" done NEW_KERNEL="$(realpath /boot/vmlinuz)" -if [ "$OLD_KERNEL" -ne "$NEW_KERNEL" ]; then +if [ "$OLD_KERNEL" != "$NEW_KERNEL" ]; then if command -v install-kernel &> /dev/null; then install-kernel "$NEW_KERNEL" fi -- cgit v1.2.3