~rbn/packagetools

2ab5a0af0c382d0ffe4ca700bdc2d74329abe023 — Ruben Schuller 4 months ago 10e639c
add example upgrading script
1 files changed, 54 insertions(+), 0 deletions(-)

A scripts/upgrade-slackware
A scripts/upgrade-slackware => scripts/upgrade-slackware +54 -0
@@ 0,0 1,54 @@
#!/bin/bash

# settings
MIRROR=${MIRROR:-/mnt/mirror/slackware/slackware64-14.2/}

function join_by { local IFS="$1"; shift; echo "$*"; }

declare NOOP
declare -a EXCLUDE

while [[ $# -gt 0 ]]; do
	key="$1"
	
	case $key in
		-n|--noop)
			NOOP=NOOP
			shift # past argument
		;;
		-e|--exclude)
			EXCLUDE+=($2)
			shift
			shift
		;;
		-h|--help)
			cat << EOF
usage: $0 [-h] [-n] [-e regexp]

-h		print help
-n		print commands instead of running them
-e REGEXP	exclude packages matching REGEXP

runs packagetools -upgrade to select upgradeable packages, filters them using
grep -v and runs upgradepkg for them. kernel-* packages are installed using
installpkg to keep old versions installed as fallback.
EOF
		exit
		;;
	esac
done

GREP_EXCLUDE=$( IFS='|'; echo "${EXCLUDE[*]}" )

for x in $(packagetools -repo "${MIRROR}/" -upgrade | grep -v -E "$GREP_EXCLUDE" | cut -f 12); do
	( gpg --verify "${MIRROR}/${x}.asc" 2> /dev/null ) || ( echo "${x}: GPG verification failed!"; exit 255 )

	INSTALLCOMMAND="/sbin/upgradepkg"
	echo "$x" | egrep -q 'kernel-.*.txz' && INSTALLCOMMAND="/sbin/installpkg"

	if [[ "x$NOOP" == "xNOOP" ]]; then
		echo sudo ${INSTALLCOMMAND} ${MIRROR}/$x
	else
		sudo ${INSTALLCOMMAND} ${MIRROR}/$x
	fi
done