Convert ${ROOT}/${WORKDIR} > ${WORKDIR}

All ${WORKDIR} == old ${ROOT}/${WORKDIR}
Set ${CONF} depending on ${ROOT}

Signed-off-by: Robby Workman <rworkman@slackware.com>
This commit is contained in:
Dave Woodfall 2021-02-16 18:48:12 +00:00 committed by Robby Workman
parent a7ca09c6c9
commit f20d83a658
2 changed files with 41 additions and 37 deletions

View file

@ -62,7 +62,7 @@ spinning() {
function system_setup() { function system_setup() {
# Create $WORKDIR just in case # Create $WORKDIR just in case
mkdir -p "${ROOT}/${WORKDIR}" mkdir -p "${WORKDIR}"
# Set LOCAL if mirror isn't through network # Set LOCAL if mirror isn't through network
# If mirror is through network, select the command to fetch # If mirror is through network, select the command to fetch
@ -162,7 +162,7 @@ function system_setup() {
fi fi
SLACKCFVERSION=$(grep "# v[0-9.]\+" $CONF/slackpkg.conf | cut -f2 -dv) 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) KERNELMD5=$(md5sum /boot/vmlinuz 2>/dev/null)
DIALOG_MAXARGS=${DIALOG_MAXARGS:-19500} DIALOG_MAXARGS=${DIALOG_MAXARGS:-19500}
echo "$0 $VERSION - Slackware Linux $SLACKWARE_VERSION" > $TMPDIR/timestamp 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 # Check if the config files are updated to the new slackpkg version
# #
if [ "${ROOT}/${WORKDIR}" = "" ]; then if [ "${WORKDIR}" = "" ]; then
echo -e "\ echo -e "\
\nYou need to upgrade your slackpkg.conf.\n\ \nYou need to upgrade your slackpkg.conf.\n\
This is a new slackpkg version and many changes happened in config files.\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 # 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 if [ "$SOURCE" = "" ]; then
echo -e "\ echo -e "\
\nThis appears to be the first time you have run slackpkg.\n\ \nThis appears to be the first time you have run slackpkg.\n\
@ -271,7 +271,7 @@ mirrors uncommented is not valid syntax.
cleanup cleanup
fi fi
MIRROR_VERSION=$(echo $SOURCE|sed "s/.*-//;s/.$//") 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 " echo -n "
You have selected a mirror for Slackware -current in ${CONF}/mirrors, You have selected a mirror for Slackware -current in ${CONF}/mirrors,
but Slackware version $SLACKWARE_VERSION appears to be installed. 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: " To confirm your choice, press Y, else press N. Then, press Enter: "
read current read current
if [ "$current" = "Y" ] || [ "$current" = "y" ]; then if [ "$current" = "Y" ] || [ "$current" = "y" ]; then
touch ${ROOT}/${WORKDIR}/current touch ${WORKDIR}/current
echo -n " echo -n "
Slackpkg will not show this warning again unless you remove the Slackpkg will not show this warning again unless you remove the
${WORKDIR}/current file. ${WORKDIR}/current file.
@ -293,7 +293,7 @@ ${WORKDIR}/current file.
cleanup cleanup
fi fi
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 # It will check if the mirror selected are ftp.slackware.com
# if set to "ftp.slackware.com" tell the user to choose another # 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 if ! [ $(which md5sum 2>/dev/null) ]; then
CHECKMD5=off CHECKMD5=off
elif ! [ -f ${ROOT}/${WORKDIR}/CHECKSUMS.md5 ] && \ elif ! [ -f ${WORKDIR}/CHECKSUMS.md5 ] && \
[ "$CMD" != "update" ] && \ [ "$CMD" != "update" ] && \
[ "$CMD" != "new-config" ] && \ [ "$CMD" != "new-config" ] && \
[ "$CHECKMD5" = "on" ]; then [ "$CHECKMD5" = "on" ]; then
@ -599,7 +599,7 @@ function mkregex_blacklist() {
" ${CONF}/blacklist > ${TMPDIR}/blacklist.tmp " ${CONF}/blacklist > ${TMPDIR}/blacklist.tmp
# create second blacklist of single packages from tmp list # 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 awk '{print " "$2" "}' > ${TMPDIR}/blacklist
# remove sets from tmp blacklist, join both lists to create unique list # 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 | awk -f /usr/libexec/slackpkg/pkglist.awk |
applyblacklist > ${TMPDIR}/tmplist applyblacklist > ${TMPDIR}/tmplist
fi fi
cat ${ROOT}/${WORKDIR}/pkglist | applyblacklist > ${TMPDIR}/pkglist cat ${WORKDIR}/pkglist | applyblacklist > ${TMPDIR}/pkglist
touch ${TMPDIR}/waiting touch ${TMPDIR}/waiting
@ -727,7 +727,7 @@ function makelist() {
done done
;; ;;
install-new) 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 \ sort -u ) dialog aaa_terminfo fontconfig \
ntfs-3g ghostscript wqy-zenhei-font-ttf \ ntfs-3g ghostscript wqy-zenhei-font-ttf \
xbacklight xf86-video-geode ; do xbacklight xf86-video-geode ; do
@ -764,8 +764,8 @@ function makelist() {
if [ "$CMD" = "file-search" ]; then if [ "$CMD" = "file-search" ]; then
# Search filelist.gz for possible matches # Search filelist.gz for possible matches
for i in ${PRIORITY[@]}; do for i in ${PRIORITY[@]}; do
if [ -e ${ROOT}/${WORKDIR}/${i}-filelist.gz ]; then if [ -e ${WORKDIR}/${i}-filelist.gz ]; then
PKGS="$(zegrep -w "${INPUTLIST}" ${ROOT}/${WORKDIR}/${i}-filelist.gz | \ PKGS="$(zegrep -w "${INPUTLIST}" ${WORKDIR}/${i}-filelist.gz | \
cut -d\ -f 1 | awk -F'/' '{print $NF}')" cut -d\ -f 1 | awk -F'/' '{print $NF}')"
for FULLNAME in $PKGS ; do for FULLNAME in $PKGS ; do
NAME=$(cutpkg ${FULLNAME}) NAME=$(cutpkg ${FULLNAME})
@ -1006,12 +1006,12 @@ function getpkg() {
# Check if anything has changed. If so, return 1, else 0 if no change. # Check if anything has changed. If so, return 1, else 0 if no change.
function checkchangelog() function checkchangelog()
{ {
if ! [ -e ${ROOT}/${WORKDIR}/CHECKSUMS.md5.asc ]; then if ! [ -e ${WORKDIR}/CHECKSUMS.md5.asc ]; then
touch ${ROOT}/${WORKDIR}/CHECKSUMS.md5.asc touch ${WORKDIR}/CHECKSUMS.md5.asc
fi fi
if ! [ -e ${ROOT}/${WORKDIR}/ChangeLog.txt ]; then if ! [ -e ${WORKDIR}/ChangeLog.txt ]; then
touch ${ROOT}/${WORKDIR}/ChangeLog.txt touch ${WORKDIR}/ChangeLog.txt
fi fi
# First we will download CHECKSUMS.md5.asc since it is a very small # 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." Please check your mirror and try again."
cleanup cleanup
fi 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 return 0
else else
return 1 return 1
@ -1112,10 +1112,10 @@ Please check your mirror and try again."
ISOK=$(checkmd5 ${TMPDIR}/FILELIST.TXT) ISOK=$(checkmd5 ${TMPDIR}/FILELIST.TXT)
fi fi
if [ "$ISOK" = "1" ]; then if [ "$ISOK" = "1" ]; then
if ! [ -e ${ROOT}/${WORKDIR}/LASTUPDATE ]; then if ! [ -e ${WORKDIR}/LASTUPDATE ]; then
echo "742868196" > ${ROOT}/${WORKDIR}/LASTUPDATE echo "742868196" > ${WORKDIR}/LASTUPDATE
fi fi
LASTUPDATE=$(cat ${ROOT}/${WORKDIR}/LASTUPDATE) LASTUPDATE=$(cat ${WORKDIR}/LASTUPDATE)
ACTUALDATE=$(date -d "$(head -1 $TMPDIR/FILELIST.TXT)" "+%s") ACTUALDATE=$(date -d "$(head -1 $TMPDIR/FILELIST.TXT)" "+%s")
if [ $ACTUALDATE -lt $LASTUPDATE ]; then if [ $ACTUALDATE -lt $LASTUPDATE ]; then
echo -e "\ echo -e "\
@ -1127,7 +1127,7 @@ Please check your mirror and try again."
fi fi
echo echo
fi fi
echo $ACTUALDATE > ${ROOT}/${WORKDIR}/LASTUPDATE echo $ACTUALDATE > ${WORKDIR}/LASTUPDATE
else else
rm $TMPDIR/FILELIST.TXT rm $TMPDIR/FILELIST.TXT
fi fi
@ -1166,10 +1166,10 @@ Please check your mirror and try again."
grep "\.t[blxg]z$" $FILELIST| \ grep "\.t[blxg]z$" $FILELIST| \
awk -f /usr/libexec/slackpkg/pkglist.awk |\ awk -f /usr/libexec/slackpkg/pkglist.awk |\
sed -e 's/^M//g' > ${TMPDIR}/pkglist 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 # 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 if ! [ -d ${ROOT}/${TEMP}/${i} ]; then
mkdir -p ${ROOT}/${TEMP}/${i} mkdir -p ${ROOT}/${TEMP}/${i}
fi 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 | \ bunzip2 -c $TMPDIR/${i}-MANIFEST.bz2 | awk -f /usr/libexec/slackpkg/filelist.awk | \
gzip > ${TMPDIR}/${i}-filelist.gz gzip > ${TMPDIR}/${i}-filelist.gz
done done
cp ${TMPDIR}/*-filelist.gz ${ROOT}/${WORKDIR}/ cp ${TMPDIR}/*-filelist.gz ${WORKDIR}/
if [ -r ${ROOT}/${WORKDIR}/filelist.gz ]; then if [ -r ${WORKDIR}/filelist.gz ]; then
rm ${ROOT}/${WORKDIR}/filelist.gz rm ${WORKDIR}/filelist.gz
ln -s ${ROOT}/${WORKDIR}/${MAIN}-filelist.gz ${ROOT}/${WORKDIR}/filelist.gz ln -s ${WORKDIR}/${MAIN}-filelist.gz ${WORKDIR}/filelist.gz
fi fi
# Concatenate PACKAGE.TXT files # Concatenate PACKAGE.TXT files
@ -1198,20 +1198,20 @@ Please check your mirror and try again."
for i in $DIRS; do for i in $DIRS; do
cat $TMPDIR/${i}-PACKAGES.TXT >> $TMPDIR/PACKAGES.TXT cat $TMPDIR/${i}-PACKAGES.TXT >> $TMPDIR/PACKAGES.TXT
done done
cp $TMPDIR/PACKAGES.TXT ${ROOT}/${WORKDIR}/PACKAGES.TXT cp $TMPDIR/PACKAGES.TXT ${WORKDIR}/PACKAGES.TXT
if [ -e $TMPDIR/CHECKSUMS.md5 ]; then 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 fi
if [ -e $TMPDIR/CHECKSUMS.md5.asc ]; then if [ -e $TMPDIR/CHECKSUMS.md5.asc ]; then
cp $TMPDIR/CHECKSUMS.md5.asc \ cp $TMPDIR/CHECKSUMS.md5.asc \
${ROOT}/${WORKDIR}/CHECKSUMS.md5.asc 2>/dev/null ${WORKDIR}/CHECKSUMS.md5.asc 2>/dev/null
fi fi
# Finally, copy ChangeLog.txt # Finally, copy ChangeLog.txt
if [ -e $TMPDIR/ChangeLog.txt ]; then if [ -e $TMPDIR/ChangeLog.txt ]; then
cp $TMPDIR/ChangeLog.txt \ cp $TMPDIR/ChangeLog.txt \
${ROOT}/${WORKDIR}/ChangeLog.txt 2>/dev/null ${WORKDIR}/ChangeLog.txt 2>/dev/null
fi fi
} }
@ -1383,7 +1383,7 @@ generate_template() {
[ "$SPINNING" = "off" ] || spinning ${TMPDIR}/waiting & [ "$SPINNING" = "off" ] || spinning ${TMPDIR}/waiting &
for i in $ROOT/var/log/packages/* ; do for i in $ROOT/var/log/packages/* ; do
PKGNAME=$( cutpkg $(basename $i)) PKGNAME=$( cutpkg $(basename $i))
grep -q " $PKGNAME " ${ROOT}/${WORKDIR}/pkglist && \ grep -q " $PKGNAME " ${WORKDIR}/pkglist && \
echo $PKGNAME >> $TMPDIR/$TEMPLATE.work echo $PKGNAME >> $TMPDIR/$TEMPLATE.work
done done
rm $TMPDIR/waiting rm $TMPDIR/waiting

View file

@ -52,7 +52,10 @@ fi
VERSION=@VERSION@ VERSION=@VERSION@
PATH=/bin:/usr/bin:/sbin:/usr/sbin PATH=/bin:/usr/bin:/sbin:/usr/sbin
SLACKWARE_VERSION=$(cat /etc/slackware-version | cut -f2 -d\ ) 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 ' SOURCE=$(sed -n '
# Remove leading and trailing blanks # Remove leading and trailing blanks
s/^[[:blank:]]*// s/^[[:blank:]]*//
@ -68,6 +71,7 @@ SOURCE=$(sed -n '
\@^https\{0,1\}://@p \@^https\{0,1\}://@p
\@^ftps\{0,1\}://@p' $CONF/mirrors) \@^ftps\{0,1\}://@p' $CONF/mirrors)
. $CONF/slackpkg.conf . $CONF/slackpkg.conf
WORKDIR=${ROOT}/${WORKDIR}
ERROR="" ERROR=""
# Set temporary directory # Set temporary directory
@ -332,8 +336,8 @@ case "$CMD" in
;; ;;
show-changelog) show-changelog)
# display changelog and exit # display changelog and exit
if [ -e ${ROOT}/${WORKDIR}/ChangeLog.txt ]; then if [ -e ${WORKDIR}/ChangeLog.txt ]; then
$MORECMD ${ROOT}/${WORKDIR}/ChangeLog.txt $MORECMD ${WORKDIR}/ChangeLog.txt
else else
echo "ChangeLog.txt file not found. Aborting" echo "ChangeLog.txt file not found. Aborting"
fi fi
@ -519,7 +523,7 @@ case "$CMD" in
if ( found != 1 ) { if ( found != 1 ) {
print \"No packages found! Try:\n\n\tslackpkg search $PATTERN\n\nand choose one (and ONLY one package).\n\" 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) new-config)
POSTINST=on POSTINST=on