From 73f6bb19a6a9b5e2dcbf392a259dbbe68bed5dca Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Tue, 13 Dec 2016 23:11:25 +0100 Subject: Make it possible to replace a package instead of simply upgrading it. Example: Replace eudev with systemd (actual request made by Dlackware). The package list should then contain the following line: eudev%systemd I.e. the package to be replaced, followed by a '%', followed by the name of the package that replaces the original. This is similar syntax to the way in which you tell upgradepkg to replace one package with another bearing a different name. --- make_slackware_live.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'make_slackware_live.sh') diff --git a/make_slackware_live.sh b/make_slackware_live.sh index a11a617..7cee8e3 100755 --- a/make_slackware_live.sh +++ b/make_slackware_live.sh @@ -353,7 +353,12 @@ function install_pkgs() { fi fi - for PKG in $(cat ${PKGFILE} |grep -v -E '^ *#|^$' |cut -d: -f1); do + for PKGPAT in $(cat ${PKGFILE} |grep -v -E '^ *#|^$' |cut -d: -f1); do + # Extract the name of the package to install: + PKG=$(echo $PKGPAT |cut -d% -f2) + # Extract the name of the potential package to replace; if there is + # no package to replace then the 'cut' will make REP equal to PKG: + REP=$(echo $PKGPAT |cut -d% -f1) # Look in ./patches ; then ./${DISTRO}$DIRSUFFIX ; then ./extra # Need to escape any '+' in package names such a 'gtk+2': if [ ! -z "${SL_PATCHROOT}" ]; then @@ -375,13 +380,18 @@ function install_pkgs() { echo "-- Package $PKG was not found in $(dirname ${SL_REPO}) !" else # Determine if we need to install or upgrade a package: - for INSTPKG in $(ls -1 "$2"/var/log/packages/${PKG}-* 2>/dev/null |rev |cut -d/ -f1 |cut -d- -f4- |rev) ; do - if [ "$INSTPKG" = "$PKG" ]; then + for INSTPKG in $(ls -1 "$2"/var/log/packages/${REP}-* 2>/dev/null |rev |cut -d/ -f1 |cut -d- -f4- |rev) ; do + if [ "$INSTPKG" = "$REP" ]; then break fi done - if [ "$INSTPKG" = "$PKG" ]; then - ROOT="$2" upgradepkg --reinstall "${FULLPKG}" + if [ "$INSTPKG" = "$REP" ]; then + if [ "$PKG" = "$REP" ]; then + ROOT="$2" upgradepkg --reinstall "${FULLPKG}" + else + # We need to replace one package (REP) with another (FULLPKG): + ROOT="$2" upgradepkg "${REP}%${FULLPKG}" + fi else installpkg --terse --root "$2" "${FULLPKG}" fi -- cgit v1.2.3