summaryrefslogtreecommitdiffstats
path: root/source/a/pkgtools/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'source/a/pkgtools/scripts')
-rw-r--r--source/a/pkgtools/scripts/installpkg117
-rw-r--r--source/a/pkgtools/scripts/makepkg50
-rw-r--r--source/a/pkgtools/scripts/pkgtool33
-rw-r--r--source/a/pkgtools/scripts/removepkg63
-rw-r--r--source/a/pkgtools/scripts/setup.80.make-bootdisk98
-rw-r--r--source/a/pkgtools/scripts/upgradepkg377
6 files changed, 346 insertions, 392 deletions
diff --git a/source/a/pkgtools/scripts/installpkg b/source/a/pkgtools/scripts/installpkg
index 2d3f208d2..96c34fd93 100644
--- a/source/a/pkgtools/scripts/installpkg
+++ b/source/a/pkgtools/scripts/installpkg
@@ -21,19 +21,10 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
-# Fri Apr 22 20:45:45 UTC 2011
-# A stronger formula is needed to regularize output that will be parsed.
-unset LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
- LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT \
- LC_IDENTIFICATION LC_ALL
-LANG=C
-export LANG
-#
-# Thu Apr 21 17:31:29 UTC 2011
-# Set LC_MESSAGES=C to avoid output parsing issues.
-# Might as well do that right now.
-#LC_MESSAGES=C
-#export LC_MESSAGES
+# Sun Sep 6 21:58:36 BST 2009
+# Replaced usage of "cat" with STDIN redirection or file name parameters
+# to speed up execution on ARM.
+# Replaced pkgbase & package_name code with 'sed' script by Jim Hawkins.
#
# Sat Apr 25 21:18:53 UTC 2009
# Converted to use new pkgbase() function to remove pathname and
@@ -67,28 +58,18 @@ export LANG
# Changed $TMP directory to /var/log/setup/tmp, and chmod'ed it 700 to close
# some security holes.
+# A stronger formula is needed to regularize output that will be parsed.
+unset LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
+ LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT \
+ LC_IDENTIFICATION LC_ALL
+LANG=C
+export LANG
+
# Return a package name that has been stripped of the dirname portion
# and any of the valid extensions (only):
pkgbase() {
- PKGEXT=$(echo $1 | rev | cut -f 1 -d . | rev)
- case $PKGEXT in
- 'tgz' )
- PKGRETURN=$(basename $1 .tgz)
- ;;
- 'tbz' )
- PKGRETURN=$(basename $1 .tbz)
- ;;
- 'tlz' )
- PKGRETURN=$(basename $1 .tlz)
- ;;
- 'txz' )
- PKGRETURN=$(basename $1 .txz)
- ;;
- *)
- PKGRETURN=$(basename $1)
- ;;
- esac
- echo $PKGRETURN
+ # basename + strip extensions .tbz, .tgz, .tlz and .txz
+ echo "$1" | sed 's?.*/??;s/\.t[bglx]z$//'
}
# If installpkg encounters a problem, it will return a non-zero error code.
@@ -157,33 +138,9 @@ crunch() {
done
}
+# Strip version, architecture and build from the end of the name
package_name() {
- STRING=$(pkgbase $1)
- # Check for old style package name with one segment:
- if [ "$(echo $STRING | cut -f 1 -d -)" = "$(echo $STRING | cut -f 2 -d -)" ]; then
- echo $STRING
- else # has more than one dash delimited segment
- # Count number of segments:
- INDEX=1
- while [ ! "$(echo $STRING | cut -f $INDEX -d -)" = "" ]; do
- INDEX=$(expr $INDEX + 1)
- done
- INDEX=$(expr $INDEX - 1) # don't include the null value
- # If we don't have four segments, return the old-style (or out of spec) package name:
- if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then
- echo $STRING
- else # we have four or more segments, so we'll consider this a new-style name:
- NAME=$(expr $INDEX - 3)
- NAME="$(echo $STRING | cut -f 1-$NAME -d -)"
- echo $NAME
- # cruft for later ;)
- #VER=$(expr $INDEX - 2)
- #VER="$(echo $STRING | cut -f $VER -d -)"
- #ARCH=$(expr $INDEX - 1)
- #ARCH="$(echo $STRING | cut -f $ARCH -d -)"
- #BUILD="$(echo $STRING | cut -f $INDEX -d -)"
- fi
- fi
+ pkgbase $1 | sed 's?-[^-]*-[^-]*-[^-]*$??'
}
# Parse options:
@@ -285,8 +242,8 @@ if [ "$MODE" = "warn" ]; then
esac
( cd $TMP/scan$$ ; $packagecompression -dc | $TAR xf - install ) < $1 2> /dev/null
if [ -r $TMP/scan$$/install/doinst.sh ]; then
- if cat $TMP/scan$$/install/doinst.sh | grep ' rm -rf ' 1>/dev/null 2>/dev/null ; then
- cat $TMP/scan$$/install/doinst.sh | grep ' rm -rf ' > $TMP/scan$$/install/delete
+ if grep ' rm -rf ' $TMP/scan$$/install/doinst.sh 1>/dev/null 2>/dev/null ; then
+ grep ' rm -rf ' $TMP/scan$$/install/doinst.sh > $TMP/scan$$/install/delete
for f in `cat $TMP/scan$$/install/delete | cut -f 3,7 -d ' ' | tr ' ' '/'`; do
f="/$f"
if [ -f "$f" -o -L "$f" ]; then
@@ -428,14 +385,7 @@ for package in $* ; do
rm -f $TMP/tmplist$$ $TMP/tmpsize$$
continue
fi
- UNCOMPRESSED="$(expr $(cat $TMP/tmpsize$$ | head -n 1 | cut -f 1 -d +) / 2)"
- if [ $UNCOMPRESSED -lt 1024 ]; then
- UNCOMPRESSED="${UNCOMPRESSED}K"
- elif [ $UNCOMPRESSED -lt 10239 ]; then
- UNCOMPRESSED="$(expr $UNCOMPRESSED \* 1000 / 1024 | cut -b1).$(expr $UNCOMPRESSED \* 1000 / 1024 | cut -b2)M"
- else
- UNCOMPRESSED="$(expr $UNCOMPRESSED / 1024)M"
- fi
+ UNCOMPRESSED="$(cat $TMP/tmpsize$$ | tail -n 1 | cut -f 1 -d ' ' | numfmt --to=iec)"
rm -f $TMP/tmpsize$$
# If we still don't have a package description, look inside the package.
@@ -456,12 +406,12 @@ for package in $* ; do
fi
# Gather package infomation into a temporary file:
- cat $DESCRIPTION | grep "^$packagebase:" | cut -f 2- -d : | cut -b2- 1> $TMP/tmpmsg$$ 2> /dev/null
+ grep "^$packagebase:" $DESCRIPTION | cut -f 2- -d : | cut -b2- 1> $TMP/tmpmsg$$ 2> /dev/null
if [ "$shortname" != "$packagebase" ]; then
- cat $DESCRIPTION | grep "^$shortname:" | cut -f 2- -d : | cut -b2- 1>> $TMP/tmpmsg$$ 2> /dev/null
+ grep "^$shortname:" $DESCRIPTION | cut -f 2- -d : | cut -b2- 1>> $TMP/tmpmsg$$ 2> /dev/null
fi
# Adjust the length here. This allows a slack-desc to be any size up to 13 lines instead of fixed at 11.
- LENGTH=$(cat $TMP/tmpmsg$$ | wc -l)
+ LENGTH=$(wc -l < $TMP/tmpmsg$$ )
while [ $LENGTH -lt 12 ]; do
echo >> $TMP/tmpmsg$$
LENGTH=$(expr $LENGTH + 1)
@@ -495,12 +445,12 @@ EOF
echo "Installing package $(basename $package) $PMSG:"
fi
echo "PACKAGE DESCRIPTION:"
- cat $DESCRIPTION | grep "^$packagebase:" | uniq | sed "s/^$packagebase:/#/g"
+ grep "^$packagebase:" $DESCRIPTION | uniq | sed "s/^$packagebase:/#/g"
if [ "$shortname" != "$packagebase" ]; then
- cat $DESCRIPTION | grep "^$shortname:" | uniq | sed "s/^$shortname:/#/g"
+ grep "^$shortname:" $DESCRIPTION | uniq | sed "s/^$shortname:/#/g"
fi
elif [ "$MODE" = "terse" ]; then # emit a single description line
- printf "%-72s %-6s\n" "$(echo $shortname: $(cat $DESCRIPTION | grep "^$packagebase:" | sed "s/^$packagebase: //g" | head -n 1 | tr -d '()' | sed "s/^$packagebase //g" ) | cut -b1-72)" "[${UNCOMPRESSED}]" | cut -b1-80
+ printf "%-72s %-6s\n" "$(echo $shortname: $(echo $(cat $DESCRIPTION | grep "^$packagebase:" | sed "s/^$packagebase: //g" | head -n 1 | tr -d '()' | sed "s/^$packagebase //g" ) $(echo " ......................................................................")) | cut -b1-72)" "[${UNCOMPRESSED}]" | cut -b1-80
elif [ "$MODE" = "infobox" ]; then # install infobox package
dialog --title "Installing package $shortname $PMSG" --infobox "$(cat $TMP/tmpmsg$$)" 0 0
elif [ "$MODE" = "menu" -a "$PRIORITY" = "ADD" -a ! "$ALWAYSASK" = "yes" ]; then # ADD overrides menu mode unless -ask was used
@@ -526,7 +476,7 @@ EOF
# Make sure there are no symbolic links sitting in the way of
# incoming package files:
- cat $TMP/tmplist$$ | grep -v "/$" | while read file ; do
+ grep -v "/$" $TMP/tmplist$$ | while read file ; do
if [ -L "$ROOT/$file" ]; then
rm -f "$ROOT/$file"
fi
@@ -543,13 +493,13 @@ EOF
echo "PACKAGE MD5SUM: $(md5sum $package | cut -f 1 -d ' ')" >> $ADM_DIR/packages/$shortname
fi
echo "PACKAGE DESCRIPTION:" >> $ADM_DIR/packages/$shortname
- cat $DESCRIPTION | grep "^$packagebase:" >> $ADM_DIR/packages/$shortname 2> /dev/null
+ grep "^$packagebase:" $DESCRIPTION >> $ADM_DIR/packages/$shortname 2> /dev/null
if [ "$shortname" != "$packagebase" ]; then
- cat $DESCRIPTION | grep "^$shortname:" >> $ADM_DIR/packages/$shortname 2> /dev/null
+ grep "^$shortname:" $DESCRIPTION >> $ADM_DIR/packages/$shortname 2> /dev/null
fi
echo "FILE LIST:" >> $ADM_DIR/packages/$shortname
- ( cd $ROOT/ ; $packagecompression -dc | $TAR -xlUpvf - ) < $package >> $TMP/$shortname 2> /dev/null
- if [ "$(cat $TMP/$shortname | grep '^\./' | wc -l | tr -d ' ')" = "1" ]; then
+ ( cd $ROOT/ ; $packagecompression -dc | $TAR -xlUpvf - | sort ) < $package >> $TMP/$shortname 2> /dev/null
+ if [ "$( grep '^\./' $TMP/$shortname | wc -l | tr -d ' ')" = "1" ]; then
# Good. We have a package that meets the Slackware spec.
cat $TMP/$shortname >> $ADM_DIR/packages/$shortname
else
@@ -571,7 +521,14 @@ EOF
if [ "$MODE" = "install" ]; then
echo "Executing install script for $(basename $package)."
fi
- ( cd $ROOT/ ; sh install/doinst.sh -install; )
+ # If bash is available, use sed to convert the install script to use pushd/popd
+ # rather than spawning subshells which is slow on ARM. This will also speed up
+ # install script processing on any platform.
+ if [ -x /bin/bash ]; then
+ ( cd $ROOT/ ; sed -e's?^( cd \([^;]*\);\(.*\) )$?pushd \1 \&\> /dev/null ; \2 ; popd \&\> /dev/null?g ' install/doinst.sh | /bin/bash ; )
+ else
+ ( cd $ROOT/ ; sh install/doinst.sh ; )
+ fi
fi
# Clean up the mess...
if [ -d $ROOT/install ]; then
diff --git a/source/a/pkgtools/scripts/makepkg b/source/a/pkgtools/scripts/makepkg
index e6805476a..25c5f2364 100644
--- a/source/a/pkgtools/scripts/makepkg
+++ b/source/a/pkgtools/scripts/makepkg
@@ -1,7 +1,7 @@
#!/bin/sh
# Copyright 1994, 1998, 2008 Patrick Volkerding, Moorhead, Minnesota USA
# Copyright 2003 Slackware Linux, Inc. Concord, CA USA
-# Copyright 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# Copyright 2009, 2015 Patrick J. Volkerding, Sebeka, MN, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
@@ -21,9 +21,16 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
+# Wed Sep 23 18:36:43 UTC 2015
+# Support spaces in file/directory names. <alphageek>
+#
# Sun Apr 5 21:23:26 CDT 2009
# Support .tgz, .tbz, .tlz, and .txz packages. <volkerdi>
#
+# Fri Nov 26 13:53:36 GMT 2004
+# Patched to chmod 755 the package's root directory if needed, then restore
+# previous permissions after the package has been created. <sw>
+#
# Wed Mar 18 15:32:33 CST 1998
# Patched to avoid possible symlink attacks in /tmp.
@@ -48,18 +55,21 @@ Written by John Gilmore and Jay Fenlason." ]; then
fi
make_install_script() {
+ TAB="$(echo -e "\t")"
COUNT=1
- LINE="$(sed -n "$COUNT p" $1)"
- while [ ! "$LINE" = "" ]; do
- LINKGOESIN="$(echo "$LINE" | cut -f 1 -d " ")"
- LINKGOESIN="$(dirname $LINKGOESIN)"
- LINKNAMEIS="$(echo "$LINE" | cut -f 1 -d ' ')"
+ while :; do
+ LINE="$(sed -n "$COUNT p" $1)"
+ if [ "$LINE" = "" ]; then
+ break
+ fi
+ LINKGOESIN="$(echo "$LINE" | cut -f 1 -d "$TAB")"
+ LINKGOESIN="$(dirname "$LINKGOESIN")"
+ LINKNAMEIS="$(echo "$LINE" | cut -f 1 -d "$TAB")"
LINKNAMEIS="$(basename "$LINKNAMEIS")"
- LINKPOINTSTO="$(echo "$LINE" | cut -f 3 -d ' ')"
+ LINKPOINTSTO="$(echo "$LINE" | cut -f 2 -d "$TAB")"
echo "( cd $LINKGOESIN ; rm -rf $LINKNAMEIS )"
echo "( cd $LINKGOESIN ; ln -sf $LINKPOINTSTO $LINKNAMEIS )"
COUNT=$(expr $COUNT + 1)
- LINE="$(sed -n "$COUNT p" $1)"
done
}
@@ -189,13 +199,12 @@ case $EXTENSION in
esac
echo
-echo "Slackware package maker, version 3.14159."
+echo "Slackware package maker, version 3.141593."
echo
echo "Searching for symbolic links:"
# Get rid of possible pre-existing trouble:
INST=$(mktemp $TMP/makepkg.XXXXXX)
-# This requires the ls from coreutils-5.0 (or newer):
-find . -type l -exec ls -l --time-style=long-iso {} \; | while read foo ; do echo $foo ; done | cut -f 8- -d ' ' | cut -b3- | tee $INST
+find . -type l -printf "%p\t%l\n" | sed 's,^\./,, ; s, ,\\ ,g' | tee $INST
if [ ! "$(cat $INST)" = "" ]; then
echo
echo "Making symbolic link creation script:"
@@ -279,6 +288,18 @@ if [ "$CHOWN" = "y" ]; then
find . -type d -exec chown -v root.root {} \;
fi
+# Ensure that the 'root' of the package is chmod 755 because
+# the / of your filesystem will inherit these permissions.
+# If it's anything tighter than 755 then bad things happen such as users
+# not being able to login, users already logged in can no longer run commands
+# and so on.
+OLDROOTPERMS="$(find -name . -printf "%m\n")"
+if [ $OLDROOTPERMS -ne 755 ]; then
+ echo "WARNING: $PWD is chmod $OLDROOTPERMS"
+ echo " temporarily changing to chmod 755"
+ chmod 755 .
+fi
+
echo "Creating Slackware package: ${TARGET_NAME}/${TAR_NAME}.${EXTENSION}"
echo
rm -f ${TARGET_NAME}/${TAR_NAME}.${EXTENSION}
@@ -342,6 +363,13 @@ if find . | grep site_perl 1> /dev/null ; then
echo "WARNING: site_perl directory detected (this is fine for a local package build)"
fi
+# Restore the old permissions if they previously weren't chmod 755
+if [ $OLDROOTPERMS -ne 755 ]; then
+ echo
+ echo "Restoring permissions of $PWD to chmod $OLDROOTPERMS"
+ chmod $OLDROOTPERMS .
+fi
+
echo
echo "Slackware package ${TARGET_NAME}/${TAR_NAME}.${EXTENSION} created."
echo
diff --git a/source/a/pkgtools/scripts/pkgtool b/source/a/pkgtools/scripts/pkgtool
index dd9d6816f..fd77f2980 100644
--- a/source/a/pkgtools/scripts/pkgtool
+++ b/source/a/pkgtools/scripts/pkgtool
@@ -1,10 +1,9 @@
#!/bin/sh
#
-# Copyright 1993, 1994, 1995, 1996, 1997,
-# 1998, 1999 Patrick Volkerding, Moorhead, MN USA
+# Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999 Patrick Volkerding, Moorhead, MN USA
# Copyright 2001, 2004 Slackware Linux, Inc., Concord, CA USA
# All rights reserved.
-# Copyright 2007, 2009, 2010, 2011, 2013 Patrick Volkerding, Sebeka, MN, USA
+# Copyright 2007, 2009, 2010, 2011, 2013, 2015 Patrick Volkerding, Sebeka, MN, USA
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
@@ -44,6 +43,15 @@
# Wed Jan 26 23:06:22 GMT 2005
# * Fix for non-standard package descriptions by Jim Hawkins
+# Avoid problems if any files in /var/log/packages and /var/log/scripts
+# might contain any broken UTF-8 sequences. This was once known to cause
+# dialog to crash.
+unset LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
+ LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT \
+ LC_IDENTIFICATION LC_ALL
+LANG=C
+export LANG
+
# Return a package name that has been stripped of the dirname portion
# and any of the valid extensions (only):
pkgbase() {
@@ -72,10 +80,9 @@ SOURCE_DIR=/var/log/mount
ASK="tagfiles"
if [ -L /bin/chmod -a -L /bin/chown ]; then # probably on the bootdisk using busybox
TARGET_DIR=/mnt
+ rootdevice="$(mount | grep ' on /mnt ' | tail -n 1 | cut -f 1 -d ' ' 2> /dev/null)"
TMP=/mnt/var/log/setup/tmp
- if mount | grep "on /mnt" 1> /dev/null 2>&1 ; then # good
- true
- else # bad
+ if ! mount | grep ' on /mnt ' 1> /dev/null 2> /dev/null ; then
echo
echo
echo "You can't run pkgtool from the rootdisk until you've mounted your Linux"
@@ -95,6 +102,7 @@ if [ -L /bin/chmod -a -L /bin/chown ]; then # probably on the bootdisk using bus
fi
else
TARGET_DIR=/
+ rootdevice="$(mount | grep ' on / ' | tail -n 1 | cut -f 1 -d ' ')"
TMP=/var/log/setup/tmp
fi
if [ ! -d $TMP ]; then
@@ -212,7 +220,7 @@ else # there were no arguments, so we'll get the needed information from the
CMD_START="true"
rm -f $TMP/SeT*
while [ 0 ]; do
- dialog --title "Slackware Package Tool (pkgtool version 14.1)" \
+ dialog --title "Slackware Package Tool (pkgtool version 14.2)" \
--menu "\nWelcome to the Slackware package tool.\n\
\nWhich option would you like?\n" 17 75 7 \
"Current" "Install packages from the current directory" \
@@ -250,8 +258,7 @@ are done selecting to run the scripts." 17 70 9 \' > $TMP/setupscr
# Run each script:
for script in $(cat $TMP/return) ; do
scrpath=$ADM_DIR/setup/setup.$(echo $script | tr -d \")
- rootdevice="$(mount | head -n 1 | cut -f 1 -d ' ')"
- ( COLOR=on ; cd $TARGET_DIR ; . $scrpath / $rootdevice )
+ ( COLOR=on ; cd $TARGET_DIR ; . $scrpath $TARGET_DIR $rootdevice )
done
fi
rm -f $TMP/return $TMP/setupscr
@@ -470,7 +477,7 @@ retry, or quit?" 10 60 2 \
umount_the_source() {
if [ ! "$SOURCE_MOUNTED" = "always" ]; then
- umount $SOURCE_DEVICE 1> /dev/null 2>&1
+ umount $SOURCE_DEVICE 1> /dev/null 2> /dev/null
fi;
}
@@ -570,7 +577,7 @@ install_disk() {
CATALOG_FILE=$(basename $PACKAGE_DIR/disk*);
fi
if [ -r $PACKAGE_DIR/$CATALOG_FILE -a ! -d $PACKAGE_DIR/$CATALOG_FILE ]; then
- if grep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE 1> /dev/null 2>&1 ; then
+ if grep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE 1> /dev/null 2> /dev/null ; then
# First we check for missing packages...
for PKGTEST in $(grep "^CONTENTS:" $PACKAGE_DIR/$CATALOG_FILE | cut -f2- -d : 2> /dev/null) ; do
# This is not a perfect test. (say emacs is missing but emacs-nox is not)
@@ -601,7 +608,7 @@ EOF
for PACKAGE_FILENAME in $PACKAGE_DIR/*.t?z; do
BASE=$(pkgbase $PACKAGE_FILENAME)
BASE="$(package_name $BASE)"
- if echo $ALLOWED | grep $BASE 1> /dev/null 2>&1 ; then
+ if echo $ALLOWED | grep $BASE 1> /dev/null 2> /dev/null ; then
true
else
cat << EOF > $TMP/tmpmsg
@@ -687,7 +694,7 @@ if [ "$DISK_SETS" = "disk" ]; then
else
touch $TMP/tagfile
chmod 600 $TMP/tagfile
- if echo $DISK_SETS | grep "#a#" 1> /dev/null 2>&1; then
+ if echo $DISK_SETS | grep "#a#" 1> /dev/null 2> /dev/null ; then
A_IS_NEEDED="true"
else
A_IS_NEEDED="false"
diff --git a/source/a/pkgtools/scripts/removepkg b/source/a/pkgtools/scripts/removepkg
index 8b5a911dd..2813fc3c5 100644
--- a/source/a/pkgtools/scripts/removepkg
+++ b/source/a/pkgtools/scripts/removepkg
@@ -1,6 +1,12 @@
#!/bin/sh
# Slackware remove package script
#
+# Thu Sep 24 03:31:58 UTC 2015 <alphageek>
+# extract_links() sed adjusted to handle symlinks with spaces.
+#
+# Sun Sep 6 21:58:36 BST 2009
+# Replaced pkgbase & package_name code with 'sed' script by Jim Hawkins.
+#
# Sat Apr 25 21:18:53 UTC 2009 (12.34567890b)
# Converted to use new pkgbase() function to remove pathname and
# valid package extensions.
@@ -72,7 +78,7 @@
# Copyright 1994, 1995, 1998 Patrick Volkerding, Moorhead, Minnesota USA
# Copyright 2001, Slackware Linux, Inc., Concord, CA USA
-# Copyright 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# Copyright 2009, 2015 Patrick J. Volkerding, Sebeka, MN, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
@@ -96,25 +102,8 @@
# Return a package name that has been stripped of the dirname portion
# and any of the valid extensions (only):
pkgbase() {
- PKGEXT=$(echo $1 | rev | cut -f 1 -d . | rev)
- case $PKGEXT in
- 'tgz' )
- PKGRETURN=$(basename $1 .tgz)
- ;;
- 'tbz' )
- PKGRETURN=$(basename $1 .tbz)
- ;;
- 'tlz' )
- PKGRETURN=$(basename $1 .tlz)
- ;;
- 'txz' )
- PKGRETURN=$(basename $1 .txz)
- ;;
- *)
- PKGRETURN=$(basename $1)
- ;;
- esac
- echo $PKGRETURN
+ # basename + strip extensions .tbz, .tgz, .tlz and .txz
+ echo "$1" | sed 's?.*/??;s/\.t[bglx]z$//'
}
# This makes "sort" run much faster:
@@ -149,7 +138,7 @@ cat_except() {
}
extract_links() {
- sed -n 's,^( *cd \([^ ;][^ ;]*\) *; *rm -rf \([^ )][^ )]*\) *) *$,\1/\2,p'
+ sed -n 's,^[ ]*( [ ]*cd[ ]* \(.*\) [ ]*; [ ]*rm [ ]*-rf[ ]* \(.*\) [ ]*)[ ]*$,\1/\2,p'
}
preserve_file() {
@@ -228,7 +217,7 @@ delete_links() {
if [ -L "$ROOT/$LINK" ]; then
if [ ! "$WARN" = "true" ]; then
echo " --> Deleting symlink $ROOT/$LINK"
- rm -f $ROOT/$LINK
+ rm -f "$ROOT/$LINK"
else
echo " --> $ROOT/$LINK (symlink) would be deleted"
fi
@@ -271,38 +260,14 @@ delete_cats() {
}
package_name() {
- STRING=$(pkgbase $1)
+ STRING=$(pkgbase $1 | sed 's?-[^-]*-[^-]*-[^-]*$??')
# If we don't do this, commands run later will take the '-' to be an option
# and will destroy the package database. Packages should not contain spaces
# in them. Normally this type of problem results from a command line typo.
if [ "$(echo $STRING | cut -b 1)" = "-" ]; then
STRING="malformed-package-name-detected"
fi
- # Check for old style package name with one segment:
- if [ "$(echo $STRING | cut -f 1 -d -)" = "$(echo $STRING | cut -f 2 -d -)" ]; then
- echo $STRING
- else # has more than one dash delimited segment
- # Count number of segments:
- INDEX=1
- while [ ! "$(echo $STRING | cut -f $INDEX -d -)" = "" ]; do
- INDEX=$(expr $INDEX + 1)
- done
- INDEX=$(expr $INDEX - 1) # don't include the null value
- # If we don't have four segments, return the old-style (or out of spec) package name:
- if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then
- echo $STRING
- else # we have four or more segments, so we'll consider this a new-style name:
- NAME=$(expr $INDEX - 3)
- NAME="$(echo $STRING | cut -f 1-$NAME -d -)"
- echo $NAME
- # cruft for later ;)
- #VER=$(expr $INDEX - 2)
- #VER="$(echo $STRING | cut -f $VER -d -)"
- #ARCH=$(expr $INDEX - 1)
- #ARCH="$(echo $STRING | cut -f $ARCH -d -)"
- #BUILD="$(echo $STRING | cut -f $INDEX -d -)"
- fi
- fi
+ echo $STRING
}
# Conversion to 'comm' utility by Mark Wisdom.
@@ -329,7 +294,7 @@ remove_packages() {
fi
if [ ! -e $ADM_DIR/packages/$PKGNAME ]; then
- long_package=$(ls -1 $ADM_DIR/packages/${PKGNAME}* | grep -m 1 "${PKGNAME}-[^-]*-[^-]*-[^-]*$")
+ long_package=$(ls -1 $ADM_DIR/packages/${PKGNAME}* | grep -m 1 "^${PKGNAME}-[^-]*-[^-]*-[^-]*$")
if [ -e "$long_package" ]; then
PKGNAME=$(basename $long_package)
fi
diff --git a/source/a/pkgtools/scripts/setup.80.make-bootdisk b/source/a/pkgtools/scripts/setup.80.make-bootdisk
index a5d442354..1f0202a53 100644
--- a/source/a/pkgtools/scripts/setup.80.make-bootdisk
+++ b/source/a/pkgtools/scripts/setup.80.make-bootdisk
@@ -5,13 +5,12 @@ if [ -r /usr/lib/setup/setup ]; then
else
RDIR=/dev/null
fi
-NDIR=/dev/null
TMP=/var/log/setup/tmp
if [ ! -d $TMP ]; then
mkdir -p $TMP
fi
-if [ -z "$T_PX" ]; then
+if [ -z "$1" ]; then
T_PX=/
else
T_PX="$1"
@@ -22,6 +21,16 @@ else
ROOT_DEVICE="$2"
fi
+if [ -r $T_PX/usr/share/syslinux/mbr.bin ]; then
+ MBR_BIN=$T_PX/usr/share/syslinux/mbr.bin
+elif [ -r /usr/share/syslinux/mbr.bin ]; then
+ MBR_BIN=/usr/share/syslinux/mbr.bin
+else
+ dialog --title "ERROR: USB BOOT STICK NOT CREATED" --msgbox \
+ "Master Boot Record file mbr.bin not found. This script requires that the syslinux package is installed." 6 60
+ exit
+fi
+
while [ 0 ]; do # the bootdisk menu loop
# Run "rescan-scsi-bus -l" to get an up to date overview of devices:
/sbin/rescan-scsi-bus -l 1>$RDIR 2>$RDIR
@@ -38,7 +47,7 @@ while [ 0 ]; do # the bootdisk menu loop
fi
dialog --title "MAKE USB FLASH BOOT" --default-item "$DEFAULTITEM" --menu \
"If your computer supports booting from a USB device, it is recommended that you make \
-a USB boot stick for your system at this time. It will boot your computer straight \
+a USB boot stick for your system at this time. It will boot your computer straight \
into the root filesystem on $ROOT_DEVICE. \n\
\n\
Please insert a USB flash memory stick and then press ENTER to create a boot stick. \n\
@@ -89,31 +98,56 @@ otherwise select 'No'." 12 70
dialog --title "CREATING USB BOOT STICK" --infobox "Creating SYSLINUX bootdisk for \
$ROOT_DEVICE on /dev/$STICK." 3 64
- # Determine max size of the filesystem (in KB) we want to create:
- USBSIZE=$(( $(cat /sys/block/$STICK/size) / 2048))
- if [ $USBSIZE -lt 512 ]; then DOSSIZE=$(($USBSIZE*1024))
- else DOSSIZE=$((512*1024))
- fi
- # Hack from Pat. If we're wasting a whole stick, who cares if the partition is
- # extra-small, as long as the kernel fits? Also, FAT12 is the least problematic.
- DOSSIZE=15861
+ # Create a 16M partition with FAT16. This should be large enough for any kernel (for now).
+ PARTSIZE="+16384K"
+ # Zero out master boot record and then initialize it with one bootable dos partition
+ dd if=/dev/zero of=/dev/$STICK bs=512 count=1 1> $RDIR 2> $RDIR
+ echo "PARTSIZE=$PARTSIZE" 1> $RDIR
+ fdisk /dev/$STICK << EOF 1> $RDIR 2> $RDIR
+n
+p
+1
+2048
+$PARTSIZE
+t 1
+6
+a
+w
+EOF
if [ -x /sbin/mkdosfs ]; then
- /sbin/mkdosfs -I -n USBSLACK -F 12 /dev/$STICK $DOSSIZE 1> /dev/null 2> /dev/null
+ /sbin/mkdosfs -I -n USBSLACK -F 16 /dev/${STICK}1 1> $RDIR 2> $RDIR
+ else
+ chroot $T_PX /sbin/mkdosfs -I -n USBSLACK -F 16 /dev/${STICK}1 1> $RDIR 2> $RDIR
+ fi
+ sync
+ # install syslinux
+ if which syslinux-nomtools 1> $RDIR 2> $RDIR ; then
+ syslinux-nomtools -i -s /dev/${STICK}1 1> $RDIR 2> $RDIR
+ elif which strace 1> $RDIR 2> $RDIR ; then
+ # There is a race condition between udev >= 214 and mtools which causes
+ # the regular version of syslinux to fail when installing to USB, but
+ # strace changes the timing just enough that it usually works:
+ strace syslinux -i -s /dev/${STICK}1 1> $RDIR 2> $RDIR
else
- chroot $T_PX /sbin/mkdosfs -I -n USBSLACK -F 12 /dev/$STICK $DOSSIZE 1> /dev/null 2> /dev/null
+ # This might work when the issues with mtools and udev are addressed,
+ # or if syslinux is eventually able to work around them.
+ syslinux -i -s /dev/${STICK}1 1> $RDIR 2> $RDIR
fi
+ # make the device bootable:
+ echo "dd if=$MBR_BIN of=/dev/$STICK" 1> $RDIR 2> $RDIR
+ dd if=$MBR_BIN of=/dev/$STICK 1> $RDIR 2> $RDIR
+ sync
+ # mount the device and write some configuration files
if [ ! -d $TMP/bootdisk ]; then
- mkdir $TMP/bootdisk
+ mkdir $TMP/bootdisk 2> $RDIR
fi
- mount -t vfat /dev/$STICK $TMP/bootdisk 1> /dev/null 2> /dev/null
- if [ -r $T_PX/vmlinuz ]; then
- cp $T_PX/vmlinuz $TMP/bootdisk/vmlinuz
- elif [ -r $T_PX/boot/vmlinuz ]; then
- cp $T_PX/boot/vmlinuz $TMP/bootdisk/vmlinuz
+ mount -t vfat /dev/${STICK}1 $TMP/bootdisk 1> $RDIR 2> $RDIR
+ if [ -r $T_PX/boot/vmlinuz ]; then
+ cp $T_PX/boot/vmlinuz $TMP/bootdisk/vmlinuz 1> $RDIR 2> $RDIR
+ elif [ -r $T_PX/vmlinuz ]; then
+ cp $T_PX/vmlinuz $TMP/bootdisk/vmlinuz 1> $RDIR 2> $RDIR
fi
- # We don't need the isolinux bootloader with syslinux do we?
- #cp $T_PX/usr/share/syslinux/isolinux.bin $TMP/bootdisk/
- cat << EOF > $TMP/bootdisk/message.txt
+ cat << EOF > $TMP/bootdisk/message.txt 2> $RDIR
Welcome to the 09Slackware07 Linux custom USB boot stick!
@@ -131,7 +165,7 @@ kernel parameters you might need depending on your hardware, and which
drivers are included in your kernel.
EOF
- cat << EOF > $TMP/bootdisk/syslinux.cfg
+ cat << EOF > $TMP/bootdisk/syslinux.cfg 2> $RDIR
default vmlinuz root=$ROOT_DEVICE vga=normal ro
prompt 1
timeout 6000
@@ -147,7 +181,7 @@ label mount
kernel vmlinuz
append root=$ROOT_DEVICE vga=normal ro
EOF
- cat << EOF > $TMP/bootdisk/f1.txt
+ cat << EOF > $TMP/bootdisk/f1.txt 2> $RDIR
STANDARD MODES:
To make the kernel prompt for standard video modes use: vga=ask
@@ -169,9 +203,9 @@ EOF
EOF
if [ "$(uname -m)" == "x86_64" ]; then # also install an EFI bootloader
- mkdir -p $TMP/bootdisk/EFI/BOOT 1> /dev/null 2> /dev/null
- cp $T_PX/boot/elilo-x86_64.efi $TMP/bootdisk/EFI/BOOT/BOOTX64.EFI 1> /dev/null 2> /dev/null
- cat << EOF > $TMP/bootdisk/EFI/BOOT/message.txt 2> /dev/null
+ mkdir -p $TMP/bootdisk/EFI/BOOT 1> $RDIR 2> $RDIR
+ cp $T_PX/boot/elilo-x86_64.efi $TMP/bootdisk/EFI/BOOT/BOOTX64.EFI 1> $RDIR 2> $RDIR
+ cat << EOF > $TMP/bootdisk/EFI/BOOT/message.txt 2> $RDIR
Welcome to the Slackware Linux custom USB boot stick!
@@ -190,7 +224,7 @@ drivers are included in your kernel.
Hit ENTER to boot:
EOF
- cat << EOF > $TMP/bootdisk/EFI/BOOT/elilo.conf 2> /dev/null
+ cat << EOF > $TMP/bootdisk/EFI/BOOT/elilo.conf 2> $RDIR
chooser=simple
message=message.txt
delay=300
@@ -202,10 +236,12 @@ image=/vmlinuz
append="root=$ROOT_DEVICE vga=normal ro"
EOF
fi # end EFI installation
- umount /dev/$STICK
+ sync
+ umount /dev/${STICK}1
rm -r $TMP/bootdisk
- # Make the device bootable:
- syslinux -s /dev/$STICK 1> /dev/null 2> /dev/null
+ # Sometimes the nomtools version of syslinux will leave the volume mounted,
+ # so umount again:
+ umount /dev/${STICK}1 2> $RDIR
if [ "$T_PX" = "/" ]; then
dialog --title "USB BOOT STICK CREATED" --msgbox \
"The USB boot stick has been successfully created on device /dev/$STICK." 6 60
diff --git a/source/a/pkgtools/scripts/upgradepkg b/source/a/pkgtools/scripts/upgradepkg
index 6b0c2abb4..5e0299806 100644
--- a/source/a/pkgtools/scripts/upgradepkg
+++ b/source/a/pkgtools/scripts/upgradepkg
@@ -1,7 +1,8 @@
-#!/bin/sh
+#!/bin/bash
# Copyright 1999 Patrick Volkerding, Moorhead, Minnesota, USA
# Copyright 2001, 2002, 2003 Slackware Linux, Inc., Concord, California, USA
-# Copyright 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# Copyright 2009, 2015 Patrick J. Volkerding, Sebeka, MN, USA
+# Copyright 2015 Michal Nazarewicz <mina86@mina86.com>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
@@ -34,29 +35,20 @@
# Support new compression types and package extensions.
# Converted to use new pkgbase() function to remove pathname and
# valid package extensions.
+#
+# Sat 17 Jan 16:21:32 UTC 2015 mina86
+# Various optimisation mostly resolving around avoiding having to fork
+# and call cut, basename and other helper commands. Slight
+# refactoring of code calling removepkg.
# Return a package name that has been stripped of the dirname portion
# and any of the valid extensions (only):
pkgbase() {
- PKGEXT=$(echo $1 | rev | cut -f 1 -d . | rev)
- case $PKGEXT in
- 'tgz' )
- PKGRETURN=$(basename $1 .tgz)
- ;;
- 'tbz' )
- PKGRETURN=$(basename $1 .tbz)
- ;;
- 'tlz' )
- PKGRETURN=$(basename $1 .tlz)
- ;;
- 'txz' )
- PKGRETURN=$(basename $1 .txz)
- ;;
- *)
- PKGRETURN=$(basename $1)
- ;;
+ PKGRETURN=${1##*/}
+ case "$PKGRETURN" in *.t[gblx]z)
+ PKGRETURN=${PKGRETURN%.*}
esac
- echo $PKGRETURN
+ echo "$PKGRETURN"
}
usage() {
@@ -101,6 +93,8 @@ umask 022
# $ROOT defined?
if [ -d "$ROOT" ]; then
export ROOT
+else
+ unset ROOT
fi
# --help or no args?
@@ -147,173 +141,158 @@ done # processing args
# old package.
package_name() {
- STRING=$(pkgbase $1)
- # Check for old style package name with one segment:
- if [ "$(echo $STRING | cut -f 1 -d -)" = "$(echo $STRING | cut -f 2 -d -)" ]; then
+ STRING=$(pkgbase "$1")
+ case "$STRING" in
+ *-*-*-*)
+ # At least four segments, strip version arch and build and return name:
+ echo "${STRING%-*-*-*}"
+ # cruft for later ;)
+ # BUILD=${STRING##*-}
+ # STRING=${STRING%*-}
+ # ARCH=${STRING##*-}
+ # STRING=${STRING%*-}
+ # VER=${STRING%*-}
+ ;;
+ *)
+ # Old style package name with one segment or we don't have four
+ # segments: return the old-style (or out of spec) package name.
echo $STRING
- else # has more than one dash delimited segment
- # Count number of segments:
- INDEX=1
- while [ ! "$(echo $STRING | cut -f $INDEX -d -)" = "" ]; do
- INDEX=$(expr $INDEX + 1)
- done
- INDEX=$(expr $INDEX - 1) # don't include the null value
- # If we don't have four segments, return the old-style (or out of spec) package name:
- if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then
- echo $STRING
- else # we have four or more segments, so we'll consider this a new-style name:
- NAME=$(expr $INDEX - 3)
- NAME="$(echo $STRING | cut -f 1-$NAME -d -)"
- echo $NAME
- # cruft for later ;)
- #VER=$(expr $INDEX - 2)
- #VER="$(echo $STRING | cut -f $VER -d -)"
- #ARCH=$(expr $INDEX - 1)
- #ARCH="$(echo $STRING | cut -f $ARCH -d -)"
- #BUILD="$(echo $STRING | cut -f $INDEX -d -)"
- fi
- fi
+ esac
}
ERRCODE=0
# Main processing loop:
-while [ ! "$1" = "" ]; do
-
-# Simple package integrity check:
-if [ ! -f $(echo $1 | cut -f 2 -d '%') ]; then
- ERRCODE=4
- echo "Cannot install $1: file not found"
- shift 1
- continue;
-fi
+for ARG; do
+ OLD=${ARG%'%'*} # first segment, = $ARG if no %
+ NEW=${ARG#*'%'} # second segment, = $ARG if no %
+
+ # Simple package integrity check:
+ if ! [ -f "$NEW" ]; then
+ ERRCODE=4
+ echo "Cannot install $ARG: file not found"
+ continue;
+ fi
-# Figure out the names of the old and new packages:
-OLD=$(echo $1 | cut -f 1 -d '%')
-NEW=$(echo $1 | cut -f 2 -d '%')
-INCOMINGDIR=$(dirname $NEW)
-# These are the package names with the extension:
-NNAME=$(basename $NEW)
-ONAME=$(basename $OLD)
-# These are the package names without the extension:
-OLD=$(pkgbase $OLD)
-NEW=$(pkgbase $NEW)
-
-# Make sure the extension is valid:
-if [ "$NNAME" = "$NEW" ]; then
- # We won't throw an ERRCODE for this, but the package is skipped:
- echo "Cannot install $1: invalid package extension"
- shift 1
- continue;
-fi
+ # Figure out the names of the old and new packages:
+ INCOMINGDIR=$(dirname $NEW)
+ # These are the package names with the extension:
+ NNAME=${NEW##*/}
+ ONAME=${OLD##*/}
+ # These are the package names without the extension:
+ OLD=$(pkgbase $OLD)
+ NEW=$(pkgbase $NEW)
+
+ # Make sure the extension is valid:
+ if [ "$NNAME" = "$NEW" ]; then
+ # We won't throw an ERRCODE for this, but the package is skipped:
+ echo "Cannot install $OLD: invalid package extension"
+ continue;
+ fi
-# Check and fix the old package name:
-SHORT="$(package_name $OLD)"
-if [ ! -r $ROOT/var/log/packages/$OLD ]; then
- if ls $ROOT/var/log/packages/$SHORT* 1> /dev/null 2> /dev/null ; then
- for installed_package in $ROOT/var/log/packages/$SHORT* ; do
- if [ "$(package_name $installed_package)" = "$SHORT" ]; then # found one
- OLD="$(basename $installed_package)"
- break
- fi
- done
+ # Check and fix the old package name:
+ SHORT="$(package_name $OLD)"
+ if [ ! -r $ROOT/var/log/packages/$OLD ]; then
+ if ls $ROOT/var/log/packages/$SHORT* 1> /dev/null 2> /dev/null ; then
+ for installed_package in $ROOT/var/log/packages/$SHORT* ; do
+ if [ "$(package_name $installed_package)" = "$SHORT" ]; then # found one
+ OLD="${installed_package##*/}"
+ break
+ fi
+ done
+ fi
fi
-fi
-# Test to see if both the old and new packages are where we expect them
-# to be -- skip to the next package (or package pair) if anything's wrong:
+ # Test to see if both the old and new packages are where we expect them
+ # to be -- skip to the next package (or package pair) if anything's wrong:
-if [ ! -r $ROOT/var/log/packages/$OLD ]; then
- if [ ! "$INSTALL_NEW" = "yes" ]; then
- if [ "$DRY_RUN" = "true" ]; then
- echo "$OLD would not be upgraded (no installed package named $SHORT)."
- else
- echo
- echo "Error: there is no installed package named $OLD."
- echo " (looking for $ROOT/var/log/packages/$OLD)"
- echo
- fi
- ERRCODE=1
- else # --install-new was given, so install the new package:
- if [ "$DRY_RUN" = "true" ]; then
- echo "$NEW would be installed (new package)."
- else
- cat << EOF
+ if [ ! -r $ROOT/var/log/packages/$OLD ]; then
+ if [ ! "$INSTALL_NEW" = "yes" ]; then
+ if [ "$DRY_RUN" = "true" ]; then
+ echo "$OLD would not be upgraded (no installed package named $SHORT)."
+ else
+ echo
+ echo "Error: there is no installed package named $OLD."
+ echo " (looking for $ROOT/var/log/packages/$OLD)"
+ echo
+ fi
+ ERRCODE=1
+ else # --install-new was given, so install the new package:
+ if [ "$DRY_RUN" = "true" ]; then
+ echo "$NEW would be installed (new package)."
+ else
+ cat << EOF
+==============================================================================
| Installing new package $INCOMINGDIR/$NNAME
+==============================================================================
EOF
- /sbin/installpkg $INCOMINGDIR/$NNAME
+ /sbin/installpkg $INCOMINGDIR/$NNAME
+ fi
fi
- fi
- shift 1
- continue;
-elif [ ! -r "$INCOMINGDIR/$NNAME" ]; then
- if [ "$DRY_RUN" = "true" ]; then
- echo "$NEW incoming package not found (command line)."
- else
- echo
- echo "Error: incoming package $INCOMINGDIR/$NNAME not found."
- echo
- fi
- shift 1
- ERRCODE=1
- continue;
-fi
-
-# Unless --reinstall was given, compare the package names
-# and skip any exact matches:
-if [ ! "$REINSTALL" = "true" ]; then
- if [ "$OLD" = "$NEW" ]; then
+ continue;
+ elif [ ! -r "$INCOMINGDIR/$NNAME" ]; then
if [ "$DRY_RUN" = "true" ]; then
- echo "$NEW would be skipped (already installed)."
+ echo "$NEW incoming package not found (command line)."
else
- cat << EOF
+ echo
+ echo "Error: incoming package $INCOMINGDIR/$NNAME not found."
+ echo
+ fi
+ ERRCODE=1
+ continue;
+ fi
+
+ # Unless --reinstall was given, compare the package names
+ # and skip any exact matches:
+ if [ ! "$REINSTALL" = "true" ]; then
+ if [ "$OLD" = "$NEW" ]; then
+ if [ "$DRY_RUN" = "true" ]; then
+ echo "$NEW would be skipped (already installed)."
+ else
+ cat << EOF
+==============================================================================
| Skipping package $NEW (already installed)
+==============================================================================
EOF
+ fi
+ continue;
fi
- shift 1
- continue;
fi
-fi
-# Showtime. Let's do the upgrade. First, we will rename all the
-# installed packages with this basename to make them easy to remove later:
+ # Showtime. Let's do the upgrade. First, we will rename all the
+ # installed packages with this basename to make them easy to remove later:
-TIMESTAMP=$(date +%Y-%m-%d,%T)
-SHORT="$(package_name $OLD)"
-if [ "$DRY_RUN" = "true" ]; then
- echo -n "$NEW would upgrade: "
- for installed_package in $ROOT/var/log/packages/$SHORT* ; do
- if [ "$(package_name $installed_package)" = "$SHORT" ]; then
- echo -n "$(pkgbase $installed_package)"
+ TIMESTAMP=$(date +%Y-%m-%d,%T)
+ SHORT="$(package_name $OLD)"
+ if [ "$DRY_RUN" = "true" ]; then
+ echo -n "$NEW would upgrade: "
+ for installed_package in $ROOT/var/log/packages/$SHORT* ; do
+ if [ "$(package_name $installed_package)" = "$SHORT" ]; then
+ echo -n "$(pkgbase $installed_package)"
+ fi
+ done
+ echo
+ continue
fi
+ for installed_package in $ROOT/var/log/packages/$SHORT* ; do
+ if [ "$(package_name $installed_package)" = "$SHORT" ]; then
+ mv $installed_package ${installed_package}-upgraded-$TIMESTAMP
+ fi
done
- echo
- shift 1
- continue
-fi
-for installed_package in $ROOT/var/log/packages/$SHORT* ; do
- if [ "$(package_name $installed_package)" = "$SHORT" ]; then
- mv $installed_package ${installed_package}-upgraded-$TIMESTAMP
- fi
-done
-for installed_script in $ROOT/var/log/scripts/$SHORT* ; do
- if [ "$(package_name $installed_script)" = "$SHORT" ]; then
- if [ -r $installed_script ]; then
- mv $installed_script ${installed_script}-upgraded-$TIMESTAMP
+ for installed_script in $ROOT/var/log/scripts/$SHORT* ; do
+ if [ "$(package_name $installed_script)" = "$SHORT" ]; then
+ if [ -r $installed_script ]; then
+ mv $installed_script ${installed_script}-upgraded-$TIMESTAMP
+ fi
fi
- fi
-done
+ done
-# Print a banner for the current upgrade:
-cat << EOF
+ # Print a banner for the current upgrade:
+ cat << EOF
+==============================================================================
| Upgrading $OLD package using $INCOMINGDIR/$NNAME
@@ -321,67 +300,49 @@ cat << EOF
EOF
-# Next, the new package is pre-installed:
-if [ "$VERBOSE" = "verbose" ]; then
- /sbin/installpkg $INCOMINGDIR/$NNAME
- RETCODE=$?
-else
- echo "Pre-installing package $NEW..."
- /sbin/installpkg $INCOMINGDIR/$NNAME 1> /dev/null
- RETCODE=$?
-fi
-# Make sure that worked:
-if [ ! $RETCODE = 0 ]; then
- echo "ERROR: Package $INCOMINGDIR/$NNAME did not install"
- echo "correctly. You may need to reinstall your old package"
- echo "to avoid problems. Make sure the new package is not"
- echo "corrupted."
- sleep 30
- # Skip this package, but still try to proceed. Good luck...
- shift 1
- continue;
-fi
-
-# Now, the leftovers from the old package(s) can go. Pretty simple, huh? :)
-if [ -d "$ROOT" ]; then
- ( cd $ROOT/var/log/packages
- for rempkg in *-$TIMESTAMP ; do
- if [ "$VERBOSE" = "verbose" ]; then
- ROOT=$ROOT /sbin/removepkg $rempkg
- else
- ROOT=$ROOT /sbin/removepkg $rempkg | grep -v "Skipping\." | grep -v "Removing files:"
- fi
- done
- )
-else
- ( cd /var/log/packages
- for rempkg in *-$TIMESTAMP ; do
- if [ "$VERBOSE" = "verbose" ]; then
- /sbin/removepkg $rempkg
- else
- /sbin/removepkg $rempkg | grep -v "Skipping\." | grep -v "Removing files:"
- fi
- done
- )
-fi
-echo
-
-# Again! Again!
-# Seriously, the reinstalling of a package can be crucial if any files
-# shift location, so we should always reinstall as the final step:
-if [ ! "$NOT_PARANOID" = "true" ]; then
- /sbin/installpkg $INCOMINGDIR/$NNAME
-fi
+ # Next, the new package is pre-installed:
+ if [ "$VERBOSE" = "verbose" ]; then
+ /sbin/installpkg $INCOMINGDIR/$NNAME
+ RETCODE=$?
+ else
+ echo "Pre-installing package $NEW..."
+ /sbin/installpkg $INCOMINGDIR/$NNAME 1> /dev/null
+ RETCODE=$?
+ fi
+ # Make sure that worked:
+ if [ ! $RETCODE = 0 ]; then
+ echo "ERROR: Package $INCOMINGDIR/$NNAME did not install"
+ echo "correctly. You may need to reinstall your old package"
+ echo "to avoid problems. Make sure the new package is not"
+ echo "corrupted."
+ sleep 30
+ # Skip this package, but still try to proceed. Good luck...
+ continue;
+ fi
-echo "Package $OLD upgraded with new package $INCOMINGDIR/$NNAME."
-ERRCODE=0
+ # Now, the leftovers from the old package(s) can go. Pretty simple, huh? :)
+ for rempkg in "$ROOT/var/log/packages/"*"-$TIMESTAMP"; do
+ if [ "$VERBOSE" = "verbose" ]; then
+ /sbin/removepkg "${rempkg##*/}"
+ else
+ /sbin/removepkg "${rempkg##*/}" | grep -v 'Skipping\.\|Removing files:'
+ fi
+ done
+ echo
-# Process next parameter:
-shift 1
+ # Again! Again!
+ # Seriously, the reinstalling of a package can be crucial if any files
+ # shift location, so we should always reinstall as the final step:
+ if [ ! "$NOT_PARANOID" = "true" ]; then
+ /sbin/installpkg $INCOMINGDIR/$NNAME
+ fi
+ echo "Package $OLD upgraded with new package $INCOMINGDIR/$NNAME."
+ ERRCODE=0
done
if [ ! "$DRY_RUN" = "true" ]; then
echo
fi
exit $ERRCODE
+