aboutsummaryrefslogtreecommitdiffsponsor
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/autoupdate132
-rw-r--r--src/rc.update12
-rw-r--r--src/test/test_autoupdate.sh22
3 files changed, 83 insertions, 83 deletions
diff --git a/src/autoupdate b/src/autoupdate
index eac1999..397a091 100644
--- a/src/autoupdate
+++ b/src/autoupdate
@@ -31,21 +31,12 @@ export UPDATE_INFO="${UPDATE_INFO:-$STAGING_DIR/info.txt}"
# Information of interest to the admin on failure.
export UPDATE_ERROR="${UPDATE_ERROR:-$STAGING_DIR/error.txt}"
-# Slackware mirror containing packages.
-export SLACKWARE_MIRROR="rsync://mirrors.kernel.org/slackware/slackware64-15.0"
-
-# A local Slackware mirror with just enough information to support slackpkg.
-#
-# This step could be skipped if slackpkg supports downloading updates without
-# installing them.
-export LOCAL_MIRROR=${LOCAL_MIRROR:-"/var/cache/slack-autoupdate/mirror"}
-
# Avoid concurrently running with another instance.
if [ "$(ls /var/lock/autoupdate.* 2>/dev/null)" ]; then
echo "Another instance of autoupdate is running. If this is not correct, you can remove /var/lock/autoupdate.* files and run autoupdate again." \
- >>"$PACKAGE_DIR/$(basename $UPDATE_ERROR)"
+ >>"$PACKAGE_DIR/$(basename "$UPDATE_ERROR")"
if [ "$NOTIFY" = "yes" ]; then
- cat "$PACKAGE_DIR/$(basename $UPDATE_ERROR)"
+ cat "$PACKAGE_DIR/$(basename "$UPDATE_ERROR")"
fi
exit 1
@@ -60,14 +51,6 @@ if [ -n "$(find "$PACKAGE_DIR" -name "*.t*z")" ]; then
exit 0
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>/dev/null
-if [ "$?" -eq "$SLACKPKG_UPDATES_PENDING" ]; then
- exit 0
-fi
-
# Make the set of package updates available atomically by storing them in a
# temporary location until completion.
rm -fr "$STAGING_DIR"
@@ -77,53 +60,77 @@ if ! OUTPUT="$(
# Capture this subshell's error output to standard output.
exec 2>&1
- (
- echo "downloading updates from $SLACKWARE_MIRROR..."
-
- # Support slackpkg with the least required files for patches.
- #
- # 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
- if [ "$?" -ne "$SLACKPKG_UPDATES_PENDING" ]; then
+ echo "Checking updates for slackpkg..."
+
+ slackpkg -batch=on -default_answer=n update || exit "$?"
+
+ CHANGELOG_TXT="$(mktemp /tmp/slack-autoupdate.XXXXXX)"
+ PACKAGE_UPDATES="$(mktemp /tmp/slack-autoupdate.XXXXXX)"
+ trap "rm -f ${CHANGELOG_TXT} ${PACKAGE_UPDATES}" EXIT
+
+ slackpkg -batch=on -default_answer=n upgrade-all \
+ | grep "\.t.z$" \
+ | tee "$PACKAGE_UPDATES" \
+ || exit "$?"
+
+ if [ ! -s "$PACKAGE_UPDATES" ]; then
+ # No updates
exit 0
fi
+ #
+ # We need slackpkg to support downloading an exact package file to a provided
+ # location. The following is a workaround.
+ #
+
+ 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)
+
+ while read PKG; do
+ PKG_URL="$(
+ grep "${PKG}$" /var/lib/slackpkg/CHECKSUMS.md5 \
+ | tr -s ' ' \
+ | cut -f 2 -d ' '
+ )" || exit "$?"
+
+ wget \
+ --quiet \
+ --directory-prefix="$STAGING_DIR" \
+ "${SOURCE}${PKG_URL}" \
+ "${SOURCE}${PKG_URL}.asc" \
+ || exit "$?"
+ done <"$PACKAGE_UPDATES"
+
+ gpg2 --verify-files "$STAGING_DIR"/*.asc || exit "$?"
+
(
+ # Provide update information to the user.
+
# Redirect this subshell's standard output to info file.
exec 1>>"$UPDATE_INFO"
+ LAST_INSTALLED_PACKAGE="$(
+ grep \
+ $(ls /var/log/packages | sed "s/$/\\\|/g" | tr --delete '\n')XXXXX" \
+ /var/lib/slackpkg/ChangeLog.txt \
+ | head -n 1
+ )"
+
echo "Slackware updates"
echo
- slackpkg show-changelog | diff - "$LOCAL_MIRROR/ChangeLog.txt"
+ grep --before-context 10000 "$LAST_INSTALLED_PACKAGE" /var/lib/slackpkg/ChangeLog.txt
echo
)
)"; then
@@ -133,16 +140,19 @@ fi
if ! OUTPUT="$(
exec 2>&1
+ echo "Checking updates for sbotools..."
+
if [ ! -f /etc/sbotools/sbotools.conf ] \
|| [ "$(sed -n 's/PKG_DIR=//p' /etc/sbotools/sbotools.conf)" != "$STAGING_DIR" ]; then
# Assume sbotools is disabled.
exit 0
fi
- UPDATE_INFO=$(mktemp /tmp/sbocheck.XXXXXX)
+ PACKAGE_UPDATES=$(mktemp /tmp/slack-autoupdate.XXXXXX)
+ trap "rm -f ${PACKAGE_UPDATES}" EXIT
- (sbocheck | tee $UPDATE_INFO) || exit 1
- if grep -i "no updates available" "$UPDATE_INFO"; then
+ (sbocheck | tee $PACKAGE_UPDATES) || exit 1
+ if grep -i "no updates available" "$PACKAGE_UPDATES"; then
exit 0
fi
@@ -157,7 +167,7 @@ if ! OUTPUT="$(
echo "Slackbuild updates"
echo
- cat "$UPDATE_INFO"
+ cat "$PACKAGE_UPDATES"
echo
)
)"; then
diff --git a/src/rc.update b/src/rc.update
index d781867..7c80cdc 100644
--- a/src/rc.update
+++ b/src/rc.update
@@ -7,10 +7,6 @@
# 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
@@ -31,9 +27,8 @@ 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 1>/dev/null 2>/dev/null; echo $?)"
-if [ -z "$UPDATES" ] && [ "$SLACKPKG_UPDATES" != "$SLACKPKG_UPDATES_PENDING" ]; then
+if [ -z "$UPDATES" ]; then
exit 0
fi
@@ -43,11 +38,6 @@ 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"
diff --git a/src/test/test_autoupdate.sh b/src/test/test_autoupdate.sh
index e2eaf08..80ffa1b 100644
--- a/src/test/test_autoupdate.sh
+++ b/src/test/test_autoupdate.sh
@@ -9,9 +9,6 @@ export PACKAGE_DIR="${PACKAGE_DIR:-/var/spool/slack-autoupdate}"
# Packages are temperarily stored here until success.
export STAGING_DIR="${STAGING_DIR:-/var/cache/slack-autoupdate/staging}"
-# The system's local Slackware mirror.
-export LOCAL_MIRROR=${LOCAL_MIRROR:-"/var/cache/slack-autoupdate/mirror"}
-
# Use fake chmod and chown commands to avoid errors when making packages.
BIN_DIR="$(realpath $(dirname "${BASH_SOURCE[0]}"))/bin"
@@ -59,23 +56,26 @@ bwrap \
--"
$INSTANCE ln -s ../lib/pkgtools/packages "/var/log/packages"
+$INSTANCE mkdir --parents "/var/lib/pkgtools/packages"
echo "Preparing slackpkg test case"
(
- mkdir -p "$TEST_DIR/etc"
+ mkdir --parents "$TEST_DIR/etc"
cp --recursive /etc/slackpkg "$TEST_DIR/etc/"
- echo http://mirrors.kernel.org/slackware/slackware64-14.2/ > "$TEST_DIR/etc/slackpkg/mirrors"
+ echo http://mirrors.slackware.com/slackware/slackware64-15.0/ > "$TEST_DIR/etc/slackpkg/mirrors"
echo "WGETFLAGS=\"-4 --quiet\"" >> "$TEST_DIR/etc/slackpkg/slackpkg.conf" # REMOVE ME
- yes | $INSTANCE slackpkg update >/dev/null || exit 1
- echo http://mirrors.kernel.org/slackware/slackware64-15.0/ > "$TEST_DIR/etc/slackpkg/mirrors"
+
+ yes | $INSTANCE slackpkg update gpg
+ $INSTANCE slackpkg -batch=on -default_answer=y update
+ touch "$TEST_DIR/var/lib/pkgtools/packages/xpdf-4.00-x86_64-3"
+ touch "$TEST_DIR/var/lib/pkgtools/packages/xz-5.0.0-x86_64-4_slack15.0"
)
echo "Preparing sbotools test case"
(
$INSTANCE sboconfig --pkg-dir "$STAGING_DIR" >/dev/null
- mkdir -p "$TEST_DIR/var/lib/pkgtools/packages"
touch "$TEST_DIR/var/lib/pkgtools/packages/bubblewrap-0.7.0-x86_64-1_SBo"
$INSTANCE sbosnap fetch
)
@@ -104,11 +104,11 @@ if [ ! -f "$TEST_DIR/$PACKAGE_DIR/info.txt" ]; then
echo "expected '$PACKAGE_DIR/info.txt' file to be created"
fi
-$INSTANCE slackpkg -mirror="file:///$LOCAL_MIRROR/" check-updates >/dev/null
-if [ "$?" -ne 100 ]; then
+if [ -z "$(find "$TEST_DIR/$PACKAGE_DIR" -name 'xpdf-*.t*z')" ] \
+ || [ -z "$(find "$TEST_DIR/$PACKAGE_DIR" -name 'xz-*.t*z')" ]; then
TESTS_PASS=false
- echo "slackpkg: expected to have updates available but had exit code $?"
+ echo "slackpkg: expected to have xpdf and xz package update"
else
echo "slackpkg: ok"
fi