From f20d83a658cb66982d41cbb291bce6ca35548bfa Mon Sep 17 00:00:00 2001 From: Dave Woodfall Date: Tue, 16 Feb 2021 18:48:12 +0000 Subject: Convert ${ROOT}/${WORKDIR} > ${WORKDIR} All ${WORKDIR} == old ${ROOT}/${WORKDIR} Set ${CONF} depending on ${ROOT} Signed-off-by: Robby Workman --- files/core-functions.sh | 66 ++++++++++++++++++++++++------------------------- files/slackpkg | 12 ++++++--- 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/files/core-functions.sh b/files/core-functions.sh index ef33f59..7289114 100644 --- a/files/core-functions.sh +++ b/files/core-functions.sh @@ -62,7 +62,7 @@ spinning() { function system_setup() { # Create $WORKDIR just in case - mkdir -p "${ROOT}/${WORKDIR}" + mkdir -p "${WORKDIR}" # Set LOCAL if mirror isn't through network # If mirror is through network, select the command to fetch @@ -162,7 +162,7 @@ function system_setup() { fi SLACKCFVERSION=$(grep "# v[0-9.]\+" $CONF/slackpkg.conf | cut -f2 -dv) - CHECKSUMSFILE=${ROOT}/${WORKDIR}/CHECKSUMS.md5 + CHECKSUMSFILE=${WORKDIR}/CHECKSUMS.md5 KERNELMD5=$(md5sum /boot/vmlinuz 2>/dev/null) DIALOG_MAXARGS=${DIALOG_MAXARGS:-19500} echo "$0 $VERSION - Slackware Linux $SLACKWARE_VERSION" > $TMPDIR/timestamp @@ -197,7 +197,7 @@ ARCH values\n" # Check if the config files are updated to the new slackpkg version # - if [ "${ROOT}/${WORKDIR}" = "" ]; then + if [ "${WORKDIR}" = "" ]; then echo -e "\ \nYou need to upgrade your slackpkg.conf.\n\ This is a new slackpkg version and many changes happened in config files.\n\ @@ -234,7 +234,7 @@ the problem.\n" # Checking if is the first time running slackpkg # - if ! [ -f ${ROOT}/${WORKDIR}/pkglist ] && [ "$CMD" != "update" ]; then + if ! [ -f ${WORKDIR}/pkglist ] && [ "$CMD" != "update" ]; then if [ "$SOURCE" = "" ]; then echo -e "\ \nThis appears to be the first time you have run slackpkg.\n\ @@ -271,7 +271,7 @@ mirrors uncommented is not valid syntax. cleanup fi MIRROR_VERSION=$(echo $SOURCE|sed "s/.*-//;s/.$//") - if [ "$MIRROR_VERSION" = "current" ] && [ ! -f ${ROOT}/${WORKDIR}/current ]; then + if [ "$MIRROR_VERSION" = "current" ] && [ ! -f ${WORKDIR}/current ]; then echo -n " You have selected a mirror for Slackware -current in ${CONF}/mirrors, but Slackware version $SLACKWARE_VERSION appears to be installed. @@ -283,7 +283,7 @@ Is this really what you want? To confirm your choice, press Y, else press N. Then, press Enter: " read current if [ "$current" = "Y" ] || [ "$current" = "y" ]; then - touch ${ROOT}/${WORKDIR}/current + touch ${WORKDIR}/current echo -n " Slackpkg will not show this warning again unless you remove the ${WORKDIR}/current file. @@ -293,7 +293,7 @@ ${WORKDIR}/current file. cleanup fi fi - [ ! "$MIRROR_VERSION" = "current" ] && rm -f ${ROOT}/${WORKDIR}/current + [ ! "$MIRROR_VERSION" = "current" ] && rm -f ${WORKDIR}/current # It will check if the mirror selected are ftp.slackware.com # if set to "ftp.slackware.com" tell the user to choose another @@ -343,7 +343,7 @@ use slackpkg.\n" # if ! [ $(which md5sum 2>/dev/null) ]; then CHECKMD5=off - elif ! [ -f ${ROOT}/${WORKDIR}/CHECKSUMS.md5 ] && \ + elif ! [ -f ${WORKDIR}/CHECKSUMS.md5 ] && \ [ "$CMD" != "update" ] && \ [ "$CMD" != "new-config" ] && \ [ "$CHECKMD5" = "on" ]; then @@ -599,7 +599,7 @@ function mkregex_blacklist() { " ${CONF}/blacklist > ${TMPDIR}/blacklist.tmp # create second blacklist of single packages from tmp list - grep -E -f ${TMPDIR}/blacklist.tmp ${ROOT}/${WORKDIR}/pkglist | + grep -E -f ${TMPDIR}/blacklist.tmp ${WORKDIR}/pkglist | awk '{print " "$2" "}' > ${TMPDIR}/blacklist # remove sets from tmp blacklist, join both lists to create unique list @@ -630,7 +630,7 @@ function makelist() { awk -f /usr/libexec/slackpkg/pkglist.awk | applyblacklist > ${TMPDIR}/tmplist fi - cat ${ROOT}/${WORKDIR}/pkglist | applyblacklist > ${TMPDIR}/pkglist + cat ${WORKDIR}/pkglist | applyblacklist > ${TMPDIR}/pkglist touch ${TMPDIR}/waiting @@ -727,7 +727,7 @@ function makelist() { done ;; install-new) - for i in $(awk -f /usr/libexec/slackpkg/install-new.awk ${ROOT}/${WORKDIR}/ChangeLog.txt |\ + for i in $(awk -f /usr/libexec/slackpkg/install-new.awk ${WORKDIR}/ChangeLog.txt |\ sort -u ) dialog aaa_terminfo fontconfig \ ntfs-3g ghostscript wqy-zenhei-font-ttf \ xbacklight xf86-video-geode ; do @@ -764,8 +764,8 @@ function makelist() { if [ "$CMD" = "file-search" ]; then # Search filelist.gz for possible matches for i in ${PRIORITY[@]}; do - if [ -e ${ROOT}/${WORKDIR}/${i}-filelist.gz ]; then - PKGS="$(zegrep -w "${INPUTLIST}" ${ROOT}/${WORKDIR}/${i}-filelist.gz | \ + if [ -e ${WORKDIR}/${i}-filelist.gz ]; then + PKGS="$(zegrep -w "${INPUTLIST}" ${WORKDIR}/${i}-filelist.gz | \ cut -d\ -f 1 | awk -F'/' '{print $NF}')" for FULLNAME in $PKGS ; do NAME=$(cutpkg ${FULLNAME}) @@ -1006,12 +1006,12 @@ function getpkg() { # Check if anything has changed. If so, return 1, else 0 if no change. function checkchangelog() { - if ! [ -e ${ROOT}/${WORKDIR}/CHECKSUMS.md5.asc ]; then - touch ${ROOT}/${WORKDIR}/CHECKSUMS.md5.asc + if ! [ -e ${WORKDIR}/CHECKSUMS.md5.asc ]; then + touch ${WORKDIR}/CHECKSUMS.md5.asc fi - if ! [ -e ${ROOT}/${WORKDIR}/ChangeLog.txt ]; then - touch ${ROOT}/${WORKDIR}/ChangeLog.txt + if ! [ -e ${WORKDIR}/ChangeLog.txt ]; then + touch ${WORKDIR}/ChangeLog.txt fi # First we will download CHECKSUMS.md5.asc since it is a very small @@ -1025,7 +1025,7 @@ function checkchangelog() Please check your mirror and try again." cleanup fi - if diff --brief ${ROOT}/${WORKDIR}/CHECKSUMS.md5.asc $TMPDIR/CHECKSUMS.md5.asc ; then + if diff --brief ${WORKDIR}/CHECKSUMS.md5.asc $TMPDIR/CHECKSUMS.md5.asc ; then return 0 else return 1 @@ -1112,10 +1112,10 @@ Please check your mirror and try again." ISOK=$(checkmd5 ${TMPDIR}/FILELIST.TXT) fi if [ "$ISOK" = "1" ]; then - if ! [ -e ${ROOT}/${WORKDIR}/LASTUPDATE ]; then - echo "742868196" > ${ROOT}/${WORKDIR}/LASTUPDATE + if ! [ -e ${WORKDIR}/LASTUPDATE ]; then + echo "742868196" > ${WORKDIR}/LASTUPDATE fi - LASTUPDATE=$(cat ${ROOT}/${WORKDIR}/LASTUPDATE) + LASTUPDATE=$(cat ${WORKDIR}/LASTUPDATE) ACTUALDATE=$(date -d "$(head -1 $TMPDIR/FILELIST.TXT)" "+%s") if [ $ACTUALDATE -lt $LASTUPDATE ]; then echo -e "\ @@ -1127,7 +1127,7 @@ Please check your mirror and try again." fi echo fi - echo $ACTUALDATE > ${ROOT}/${WORKDIR}/LASTUPDATE + echo $ACTUALDATE > ${WORKDIR}/LASTUPDATE else rm $TMPDIR/FILELIST.TXT fi @@ -1166,10 +1166,10 @@ Please check your mirror and try again." grep "\.t[blxg]z$" $FILELIST| \ awk -f /usr/libexec/slackpkg/pkglist.awk |\ sed -e 's/^M//g' > ${TMPDIR}/pkglist - cp ${TMPDIR}/pkglist ${ROOT}/${WORKDIR}/pkglist + cp ${TMPDIR}/pkglist ${WORKDIR}/pkglist # Create the slackware tree under TEMP directory - for i in $( cut -f7 -d\ ${ROOT}/${WORKDIR}/pkglist | sort -u ) ; do + for i in $( cut -f7 -d\ ${WORKDIR}/pkglist | sort -u ) ; do if ! [ -d ${ROOT}/${TEMP}/${i} ]; then mkdir -p ${ROOT}/${TEMP}/${i} fi @@ -1185,11 +1185,11 @@ Please check your mirror and try again." bunzip2 -c $TMPDIR/${i}-MANIFEST.bz2 | awk -f /usr/libexec/slackpkg/filelist.awk | \ gzip > ${TMPDIR}/${i}-filelist.gz done - cp ${TMPDIR}/*-filelist.gz ${ROOT}/${WORKDIR}/ + cp ${TMPDIR}/*-filelist.gz ${WORKDIR}/ - if [ -r ${ROOT}/${WORKDIR}/filelist.gz ]; then - rm ${ROOT}/${WORKDIR}/filelist.gz - ln -s ${ROOT}/${WORKDIR}/${MAIN}-filelist.gz ${ROOT}/${WORKDIR}/filelist.gz + if [ -r ${WORKDIR}/filelist.gz ]; then + rm ${WORKDIR}/filelist.gz + ln -s ${WORKDIR}/${MAIN}-filelist.gz ${WORKDIR}/filelist.gz fi # Concatenate PACKAGE.TXT files @@ -1198,20 +1198,20 @@ Please check your mirror and try again." for i in $DIRS; do cat $TMPDIR/${i}-PACKAGES.TXT >> $TMPDIR/PACKAGES.TXT done - cp $TMPDIR/PACKAGES.TXT ${ROOT}/${WORKDIR}/PACKAGES.TXT + cp $TMPDIR/PACKAGES.TXT ${WORKDIR}/PACKAGES.TXT if [ -e $TMPDIR/CHECKSUMS.md5 ]; then - cp $TMPDIR/CHECKSUMS.md5 ${ROOT}/${WORKDIR}/CHECKSUMS.md5 2>/dev/null + cp $TMPDIR/CHECKSUMS.md5 ${WORKDIR}/CHECKSUMS.md5 2>/dev/null fi if [ -e $TMPDIR/CHECKSUMS.md5.asc ]; then cp $TMPDIR/CHECKSUMS.md5.asc \ - ${ROOT}/${WORKDIR}/CHECKSUMS.md5.asc 2>/dev/null + ${WORKDIR}/CHECKSUMS.md5.asc 2>/dev/null fi # Finally, copy ChangeLog.txt if [ -e $TMPDIR/ChangeLog.txt ]; then cp $TMPDIR/ChangeLog.txt \ - ${ROOT}/${WORKDIR}/ChangeLog.txt 2>/dev/null + ${WORKDIR}/ChangeLog.txt 2>/dev/null fi } @@ -1383,7 +1383,7 @@ generate_template() { [ "$SPINNING" = "off" ] || spinning ${TMPDIR}/waiting & for i in $ROOT/var/log/packages/* ; do PKGNAME=$( cutpkg $(basename $i)) - grep -q " $PKGNAME " ${ROOT}/${WORKDIR}/pkglist && \ + grep -q " $PKGNAME " ${WORKDIR}/pkglist && \ echo $PKGNAME >> $TMPDIR/$TEMPLATE.work done rm $TMPDIR/waiting diff --git a/files/slackpkg b/files/slackpkg index b822e84..8ad173f 100644 --- a/files/slackpkg +++ b/files/slackpkg @@ -52,7 +52,10 @@ fi VERSION=@VERSION@ PATH=/bin:/usr/bin:/sbin:/usr/sbin SLACKWARE_VERSION=$(cat /etc/slackware-version | cut -f2 -d\ ) -CONF=${CONF:-/etc/slackpkg} + +[ -z "$ROOT" ] && CONF=${CONF:-/etc/slackpkg} +[ -n "$ROOT" ] && CONF=${CONF:-"${ROOT}/etc/slackpkg"} + SOURCE=$(sed -n ' # Remove leading and trailing blanks s/^[[:blank:]]*// @@ -68,6 +71,7 @@ SOURCE=$(sed -n ' \@^https\{0,1\}://@p \@^ftps\{0,1\}://@p' $CONF/mirrors) . $CONF/slackpkg.conf +WORKDIR=${ROOT}/${WORKDIR} ERROR="" # Set temporary directory @@ -332,8 +336,8 @@ case "$CMD" in ;; show-changelog) # display changelog and exit - if [ -e ${ROOT}/${WORKDIR}/ChangeLog.txt ]; then - $MORECMD ${ROOT}/${WORKDIR}/ChangeLog.txt + if [ -e ${WORKDIR}/ChangeLog.txt ]; then + $MORECMD ${WORKDIR}/ChangeLog.txt else echo "ChangeLog.txt file not found. Aborting" fi @@ -519,7 +523,7 @@ case "$CMD" in if ( found != 1 ) { print \"No packages found! Try:\n\n\tslackpkg search $PATTERN\n\nand choose one (and ONLY one package).\n\" } - }" ${ROOT}/${WORKDIR}/PACKAGES.TXT 2>/dev/null + }" ${WORKDIR}/PACKAGES.TXT 2>/dev/null ;; new-config) POSTINST=on -- cgit v1.2.3