Add $ROOT to $WORKDIR, $TEMP, and $TMPDIR instances

This *should* have no effect if $ROOT is blank

Files modified:
  files/core-functions.sh
  files/slackpkg
This commit is contained in:
Robby Workman 2017-12-30 00:53:53 -06:00
parent c73c1a9008
commit 70948050f9
2 changed files with 35 additions and 34 deletions

View file

@ -59,7 +59,7 @@ spinning() {
function system_setup() { function system_setup() {
# Create $WORKDIR just in case # Create $WORKDIR just in case
mkdir -p "$WORKDIR" mkdir -p "${ROOT}/${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
@ -154,7 +154,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=$WORKDIR/CHECKSUMS.md5 CHECKSUMSFILE=${ROOT}/${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
@ -189,7 +189,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 [ "$WORKDIR" = "" ]; then if [ "${ROOT}/${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\
@ -226,7 +226,7 @@ the problem.\n"
# Checking if is the first time running slackpkg # Checking if is the first time running slackpkg
# #
if ! [ -f ${WORKDIR}/pkglist ] && [ "$CMD" != "update" ]; then if ! [ -f ${ROOT}/${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\
@ -312,7 +312,7 @@ use slackpkg.\n"
# #
if ! [ $(which md5sum 2>/dev/null) ]; then if ! [ $(which md5sum 2>/dev/null) ]; then
CHECKMD5=off CHECKMD5=off
elif ! [ -f ${WORKDIR}/CHECKSUMS.md5 ] && \ elif ! [ -f ${ROOT}/${WORKDIR}/CHECKSUMS.md5 ] && \
[ "$CMD" != "update" ] && \ [ "$CMD" != "update" ] && \
[ "$CHECKMD5" = "on" ]; then [ "$CHECKMD5" = "on" ]; then
echo -e "\n\ echo -e "\n\
@ -567,7 +567,7 @@ function makelist() {
else else
ls -1 $ROOT/var/log/packages/* | awk -f /usr/libexec/slackpkg/pkglist.awk | applyblacklist > ${TMPDIR}/tmplist ls -1 $ROOT/var/log/packages/* | awk -f /usr/libexec/slackpkg/pkglist.awk | applyblacklist > ${TMPDIR}/tmplist
fi fi
cat ${WORKDIR}/pkglist | applyblacklist > ${TMPDIR}/pkglist cat ${ROOT}/${WORKDIR}/pkglist | applyblacklist > ${TMPDIR}/pkglist
touch ${TMPDIR}/waiting touch ${TMPDIR}/waiting
@ -669,7 +669,7 @@ function makelist() {
done done
;; ;;
install-new) install-new)
for i in $(awk -f /usr/libexec/slackpkg/install-new.awk ${WORKDIR}/ChangeLog.txt |\ for i in $(awk -f /usr/libexec/slackpkg/install-new.awk ${ROOT}/${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
@ -706,8 +706,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 ${WORKDIR}/${i}-filelist.gz ]; then if [ -e ${ROOT}/${WORKDIR}/${i}-filelist.gz ]; then
PKGS="$(zegrep -w "${INPUTLIST}" ${WORKDIR}/${i}-filelist.gz | \ PKGS="$(zegrep -w "${INPUTLIST}" ${ROOT}/${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})
@ -849,7 +849,7 @@ function getpkg() {
PKGNAME=( $(grep -m 1 -- "[[:space:]]${1/%.t[blxg]z/}[[:space:]]" ${TMPDIR}/pkglist) ) PKGNAME=( $(grep -m 1 -- "[[:space:]]${1/%.t[blxg]z/}[[:space:]]" ${TMPDIR}/pkglist) )
NAMEPKG=${PKGNAME[5]}.${PKGNAME[7]} NAMEPKG=${PKGNAME[5]}.${PKGNAME[7]}
FULLPATH=${PKGNAME[6]} FULLPATH=${PKGNAME[6]}
CACHEPATH=${TEMP}/${FULLPATH} CACHEPATH=${ROOT}/${TEMP}/${FULLPATH}
# Create destination dir if it isn't there # Create destination dir if it isn't there
if ! [ -d $CACHEPATH ]; then if ! [ -d $CACHEPATH ]; then
@ -947,8 +947,8 @@ function getpkg() {
# #
function checkchangelog() function checkchangelog()
{ {
if ! [ -e ${WORKDIR}/ChangeLog.txt ]; then if ! [ -e ${ROOT}/${WORKDIR}/ChangeLog.txt ]; then
touch ${WORKDIR}/ChangeLog.txt touch ${ROOT}/${WORKDIR}/ChangeLog.txt
fi fi
echo -e "\tDownloading..." echo -e "\tDownloading..."
@ -964,7 +964,7 @@ Please check your mirror and try again."
cleanup cleanup
fi fi
if diff --brief ${WORKDIR}/ChangeLog.txt $TMPDIR/ChangeLog.txt ; then if diff --brief ${ROOT}/${WORKDIR}/ChangeLog.txt $TMPDIR/ChangeLog.txt ; then
return 0 return 0
else else
return 1 return 1
@ -983,7 +983,7 @@ function updatefilelists()
fi fi
fi fi
echo echo
cp ${TMPDIR}/ChangeLog.txt ${WORKDIR}/ChangeLog.txt cp ${TMPDIR}/ChangeLog.txt ${ROOT}/${WORKDIR}/ChangeLog.txt
# #
# Download MANIFEST, FILELIST.TXT and CHECKSUMS.md5 # Download MANIFEST, FILELIST.TXT and CHECKSUMS.md5
@ -1039,10 +1039,10 @@ function updatefilelists()
ISOK=$(checkmd5 ${TMPDIR}/FILELIST.TXT) ISOK=$(checkmd5 ${TMPDIR}/FILELIST.TXT)
fi fi
if [ "$ISOK" = "1" ]; then if [ "$ISOK" = "1" ]; then
if ! [ -e $WORKDIR/LASTUPDATE ]; then if ! [ -e ${ROOT}/${WORKDIR}/LASTUPDATE ]; then
echo "742868196" > $WORKDIR/LASTUPDATE echo "742868196" > ${ROOT}/${WORKDIR}/LASTUPDATE
fi fi
LASTUPDATE=$(cat $WORKDIR/LASTUPDATE) LASTUPDATE=$(cat ${ROOT}/${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 "\
@ -1054,7 +1054,7 @@ function updatefilelists()
fi fi
echo echo
fi fi
echo $ACTUALDATE > $WORKDIR/LASTUPDATE echo $ACTUALDATE > ${ROOT}/${WORKDIR}/LASTUPDATE
else else
rm $TMPDIR/FILELIST.TXT rm $TMPDIR/FILELIST.TXT
fi fi
@ -1093,12 +1093,12 @@ function updatefilelists()
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 ${WORKDIR}/pkglist cp ${TMPDIR}/pkglist ${ROOT}/${WORKDIR}/pkglist
# Create the slackware tree under TEMP directory # Create the slackware tree under TEMP directory
for i in $( cut -f7 -d\ ${WORKDIR}/pkglist | sort -u ) ; do for i in $( cut -f7 -d\ ${ROOT}/${WORKDIR}/pkglist | sort -u ) ; do
if ! [ -d ${TEMP}/${i} ]; then if ! [ -d ${ROOT}/${TEMP}/${i} ]; then
mkdir -p ${TEMP}/${i} mkdir -p ${ROOT}/${TEMP}/${i}
fi fi
done done
@ -1112,11 +1112,11 @@ function updatefilelists()
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 ${WORKDIR}/ cp ${TMPDIR}/*-filelist.gz ${ROOT}/${WORKDIR}/
if [ -r ${WORKDIR}/filelist.gz ]; then if [ -r ${ROOT}/${WORKDIR}/filelist.gz ]; then
rm ${WORKDIR}/filelist.gz rm ${ROOT}/${WORKDIR}/filelist.gz
ln -s ${WORKDIR}/${MAIN}-filelist.gz ${WORKDIR}/filelist.gz ln -s ${ROOT}/${WORKDIR}/${MAIN}-filelist.gz ${ROOT}/${WORKDIR}/filelist.gz
fi fi
# Concatenate PACKAGE.TXT files # Concatenate PACKAGE.TXT files
@ -1125,15 +1125,15 @@ function updatefilelists()
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 ${WORKDIR}/PACKAGES.TXT cp $TMPDIR/PACKAGES.TXT ${ROOT}/${WORKDIR}/PACKAGES.TXT
if [ -e $TMPDIR/CHECKSUMS.md5 ]; then if [ -e $TMPDIR/CHECKSUMS.md5 ]; then
cp $TMPDIR/CHECKSUMS.md5 $WORKDIR/CHECKSUMS.md5 2>/dev/null cp $TMPDIR/CHECKSUMS.md5 ${ROOT}/${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 \
$WORKDIR/CHECKSUMS.md5.asc 2>/dev/null ${ROOT}/${WORKDIR}/CHECKSUMS.md5.asc 2>/dev/null
fi fi
} }
@ -1315,7 +1315,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 " ${WORKDIR}/pkglist && \ grep -q " $PKGNAME " ${ROOT}/${WORKDIR}/pkglist && \
echo $PKGNAME >> $TMPDIR/$TEMPLATE.work echo $PKGNAME >> $TMPDIR/$TEMPLATE.work
done done
rm $TMPDIR/waiting rm $TMPDIR/waiting

View file

@ -42,10 +42,11 @@ ERROR=""
# Set temporary directory # Set temporary directory
# #
TMPDIR=$(mktemp -p /tmp -d slackpkg.XXXXXX 2>/dev/null) mkdir -p ${ROOT}/tmp
TMPDIR=$(mktemp -p ${ROOT}/tmp -d slackpkg.XXXXXX 2>/dev/null)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
TMPDIR="/tmp/slackpkg.${RANDOM}" TMPDIR="${ROOT}/tmp/slackpkg.${RANDOM}"
mkdir -m 700 $TMPDIR || TMPDIR="FAILED" mkdir -p -m 700 $TMPDIR || TMPDIR="FAILED"
fi fi
# #
@ -485,7 +486,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\"
} }
}" ${WORKDIR}/PACKAGES.TXT 2>/dev/null }" ${ROOT}/${WORKDIR}/PACKAGES.TXT 2>/dev/null
;; ;;
new-config) new-config)
POSTINST=on POSTINST=on