I sent these patches to Pat and Roberto 2 months ago,
but received no response. So I'll post them here to
see if any of the Slackware community find the
changes as useful as I do.
I started this patch because when keeping my
systems up to date with slackpkg upgrade-all there
was so much noise in the output that made it
difficult to easily see what packages had been
updated properly.
Installpkg already has a 'terse' option to reduce
its verbosity. These patches add the 'terse'
option to removepkg and upgradepkg. So now this
option is consistent across the package tools.
Also, in the name of consistency, installpkg and
removepkg accept both -OPTION and --OPTION, but
upgradepkg did not. Now they will all accept either
single or double dash options(so we don't have to
remember which is which anymore).
Finally, I added an ENV VAR named TERSEPKG that
all Slackware package tools honor. Now when running
other utilities that call Slackware package tools,
as slackpkg does, terse mode can be used even if
those other utilities do not support it directly.
I then added these same features to slackpkg
itself.
Here are examples of different ways the changes
can be used:
TERSEPKG=1 slackpkg upgrade-all
OR
slackpkg -terse=on upgrade-all
TERSEPKG=1 [installpkg | removepkg | upgradepkg ]
OR
installpkg [-terse | --terse]
removepkg [-terse | --terse]
upgradepkg [-terse | --terse]
The Patches:
Code:
--- installpkg.orig 2011-04-22 16:50:43.000000000 -0400
+++ installpkg 2014-04-02 11:56:49.702802107 -0400
@@ -21,6 +21,9 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
+# Mon Mar 31 19:14:15 EDT 2014 Xsane
+# Added TERSEPKG ENV
+#
# 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 \
@@ -187,7 +190,11 @@
}
# Parse options:
+if [ $TERSEPKG ]; then
+MODE=terse
+else
MODE=install # standard text-mode
+fi
while [ 0 ]; do
if [ "$1" = "-warn" -o "$1" = "--warn" ]; then
MODE=warn
Code:
--- removepkg.orig 2009-04-28 16:44:26.000000000 -0400
+++ removepkg 2014-04-02 18:17:22.918159700 -0400
@@ -1,6 +1,9 @@
#!/bin/sh
# Slackware remove package script
#
+# Revision 12.34567890c Mon Mar 31 19:17:45 EDT 2014 Xsane
+# Added -terse option and TERSEPKG ENV.
+#
# Sat Apr 25 21:18:53 UTC 2009 (12.34567890b)
# Converted to use new pkgbase() function to remove pathname and
# valid package extensions.
@@ -177,11 +180,11 @@
while read FILE ; do
if [ ! -d "$ROOT/$FILE" ]; then
if [ -r "$ROOT/$FILE" ]; then
- echo " --> $ROOT/$FILE was found in another package. Skipping."
+ $ECHO " --> $ROOT/$FILE was found in another package. Skipping."
preserve_file "$FILE"
else
if [ "$(echo $FILE | cut -b1-8)" != "install/" ]; then
- echo "WARNING: Nonexistent $ROOT/$FILE was found in another package. Skipping."
+ $ECHO "WARNING: Nonexistent $ROOT/$FILE was found in another package. Skipping."
fi
fi
else
@@ -193,9 +196,9 @@
keep_links() {
while read LINK ; do
if [ -L "$ROOT/$LINK" ]; then
- echo " --> $ROOT/$LINK (symlink) was found in another package. Skipping."
+ $ECHO " --> $ROOT/$LINK (symlink) was found in another package. Skipping."
else
- echo "WARNING: Nonexistent $ROOT/$LINK (symlink) was found in another package. Skipping."
+ $ECHO "WARNING: Nonexistent $ROOT/$LINK (symlink) was found in another package. Skipping."
fi
done
}
@@ -208,14 +211,14 @@
echo "WARNING: $ROOT/$FILE changed after package installation."
fi
if [ ! "$WARN" = "true" ]; then
- echo " --> Deleting $ROOT/$FILE"
+ $ECHO " --> Deleting $ROOT/$FILE"
preserve_file "$FILE" && rm -f "$ROOT/$FILE"
else
echo " --> $ROOT/$FILE would be deleted"
preserve_file "$FILE"
fi
else
- echo " --> $ROOT/$FILE no longer exists. Skipping."
+ $ECHO " --> $ROOT/$FILE no longer exists. Skipping."
fi
else
preserve_dir "$FILE"
@@ -227,13 +230,13 @@
while read LINK ; do
if [ -L "$ROOT/$LINK" ]; then
if [ ! "$WARN" = "true" ]; then
- echo " --> Deleting symlink $ROOT/$LINK"
+ $ECHO " --> Deleting symlink $ROOT/$LINK"
rm -f $ROOT/$LINK
else
echo " --> $ROOT/$LINK (symlink) would be deleted"
fi
else
- echo " --> $ROOT/$LINK (symlink) no longer exists. Skipping."
+ $ECHO " --> $ROOT/$LINK (symlink) no longer exists. Skipping."
fi
done
}
@@ -244,7 +247,7 @@
if [ -d "$ROOT/$DIR" ]; then
if [ ! "$WARN" = "true" ]; then
if [ $(ls -a "$ROOT/$DIR" | wc -l) -eq 2 ]; then
- echo " --> Deleting empty directory $ROOT/$DIR"
+ $ECHO " --> Deleting empty directory $ROOT/$DIR"
rmdir "$ROOT/$DIR"
else
echo "WARNING: Unique directory $ROOT/$DIR contains new files"
@@ -261,7 +264,7 @@
while read FILE ; do
if [ -f "$ROOT/$FILE" ]; then
if [ ! "$WARN" = "true" ]; then
- echo " --> Deleting $ROOT/$FILE (fmt man page)"
+ $ECHO " --> Deleting $ROOT/$FILE (fmt man page)"
rm -f $ROOT/$FILE
else
echo " --> $ROOT/$FILE (fmt man page) would be deleted"
@@ -311,7 +314,7 @@
for PKGLIST in $*
do
PKGNAME=$(pkgbase $PKGLIST)
- echo
+ $ECHO
# If we don't have a package match here, then we will attempt to find
# a package using the long name format (name-version-arch-build) for
# which the base package name was given. On a properly-managed machine,
@@ -345,7 +348,7 @@
TRIGGER="FILE LIST:"
fi
if [ ! "$WARN" = true ]; then
- echo "Removing files:"
+ $ECHO "Removing files:"
fi
sed -n "/$TRIGGER/,/^$/p" < $ADM_DIR/packages/$PKGNAME | \
fgrep -v "FILE LIST:" | sort -u > $TMP/delete_list$$
@@ -398,16 +401,23 @@
}
if [ "$#" = "0" ]; then
- echo "Usage: $(basename $0) [-copy] [-keep] [-preserve] [-warn] packagename ..."; exit 1
+ echo "Usage: $(basename $0) [-terse] [-copy] [-keep] [-preserve] [-warn] packagename ..."; exit 1
+fi
+
+if [ $TERSEPKG ]; then
+ECHO="true"
+else
+ECHO="echo"
fi
while : ; do
case "$1" in
+ -terse | --terse) ECHO=true; shift;;
-copy | --copy) WARN=true; PRESERVE=true; shift;;
-keep | --keep) KEEP=true; shift;;
-preserve | --preserve) PRESERVE=true; shift;;
-warn | --warn) WARN=true; shift;;
- -* | --*) echo "Usage: $(basename $0) [-copy] [-keep] [-preserve] [-warn] packagename ..."; exit 1;;
+ -* | --*) echo "Usage: $(basename $0) [-terse] [-copy] [-keep] [-preserve] [-warn] packagename ..."; exit 1;;
*) break
esac
done
Code:
--- upgradepkg.orig 2010-05-11 12:41:49.000000000 -0400
+++ upgradepkg 2014-04-02 18:17:33.612161124 -0400
@@ -34,6 +34,12 @@
# Support new compression types and package extensions.
# Converted to use new pkgbase() function to remove pathname and
# valid package extensions.
+#
+# Sun Mar 30 23:51:10 EDT 2014 Xsane
+# Added --terse and ENV TERSEPKG
+# Added -OPTION for consistency with installpkg and removepkg
+# Added options(sans no-paranoia) to help output.
+#
# Return a package name that has been stripped of the dirname portion
# and any of the valid extensions (only):
@@ -62,8 +68,8 @@
usage() {
cat << EOF
-Usage: upgradepkg newpackage [newpackage2 ... ]
- upgradepkg oldpackage%newpackage [oldpackage2%newpackage2 ... ]
+Usage: upgradepkg [options] newpackage [newpackage2 ... ]
+ upgradepkg [options] oldpackage%newpackage [oldpackage2%newpackage2 ... ]
Upgradepkg upgrades a Slackware package (.tgz, .tbz, .tlz, .txz) from an
older version to a newer one. It does this by INSTALLING the new package
@@ -83,6 +89,15 @@
ROOT=/mnt upgradepkg package.tgz (or .tbz, .tlz, .txz)
+Options:
+ --help Show this page.
+ --install-new Install packages even when no matches are found.
+ --reinstall Reinstall packages even when installed version matches.
+ --verbose, -v Increase verbosity.
+ --terse Decrease verbosity.
+ --dry-run Report which packages would be installed or upgraded
+ but don't actually perform the upgrades.
+
EOF
}
@@ -104,14 +119,22 @@
fi
# --help or no args?
-if [ "$1" = "" -o "$1" = "--help" -o "$1" = "-?" ]; then
+if [ "$1" = "" -o "$1" = "--help" -o "$1" = "-help" -o "$1" = "-?" ]; then
usage;
exit 1;
fi
+if [ $TERSEPKG ]; then
+MODE="-terse "
+ECHO="true"
+else
+MODE=""
+ECHO="echo"
+fi
+
# Arg processing loop. These must come before any packages are listed.
while [ 0 ]; do
- if [ "$1" = "--no-paranoia" ]; then
+ if [ "$1" = "--no-paranoia" -o "$1" = "-no-paranoia" ]; then
# Enable --no-paranoia mode. This is so not-recommended that we're
# not even going to document it. ;) If a file used to be directly
# managed and now is moved into place, using --no-paranoia will cause
@@ -119,20 +142,25 @@
# Don't use it.
NOT_PARANOID="true"
shift 1
- elif [ "$1" = "--install-new" ]; then
+ elif [ "$1" = "--terse" -o "$1" = "-terse" ]; then
+ # Ask removepkg and installpkg to be quiet, please.
+ MODE="-terse "
+ ECHO="true"
+ shift 1
+ elif [ "$1" = "--install-new" -o "$1" = "-install-new" ]; then
# Install packages that do not already have an installed version.
# The usual default is to skip them.
INSTALL_NEW="yes"
shift 1
- elif [ "$1" = "--reinstall" ]; then
+ elif [ "$1" = "--reinstall" -o "$1" = "-reinstall" ]; then
# Reinstall packages even if the installed one is the same version.
REINSTALL="true"
shift 1
- elif [ "$1" = "--verbose" -o "$1" = "-v" ]; then
+ elif [ "$1" = "--verbose" -o "$1" = "-verbose" -o "$1" = "-v" ]; then
# We're adding a --verbose mode that doesn't filter removepkg as much
VERBOSE="verbose"
shift 1
- elif [ "$1" = "--dry-run" ]; then
+ elif [ "$1" = "--dry-run" -o "$1" = "-dry-run" ]; then
# Output a report about which packages would be installed or upgraded
# but don't actually perform the upgrades.
DRY_RUN="true"
@@ -245,7 +273,7 @@
+==============================================================================
EOF
- /sbin/installpkg $INCOMINGDIR/$NNAME
+ /sbin/installpkg ${MODE}$INCOMINGDIR/$NNAME
fi
fi
shift 1
@@ -326,7 +354,7 @@
/sbin/installpkg $INCOMINGDIR/$NNAME
RETCODE=$?
else
- echo "Pre-installing package $NEW..."
+ $ECHO "Pre-installing package $NEW..."
/sbin/installpkg $INCOMINGDIR/$NNAME 1> /dev/null
RETCODE=$?
fi
@@ -349,7 +377,7 @@
if [ "$VERBOSE" = "verbose" ]; then
ROOT=$ROOT /sbin/removepkg $rempkg
else
- ROOT=$ROOT /sbin/removepkg $rempkg | grep -v "Skipping\." | grep -v "Removing files:"
+ ROOT=$ROOT /sbin/removepkg ${MODE}$rempkg | grep -v "Skipping\." | grep -v "Removing files:"
fi
done
)
@@ -359,21 +387,21 @@
if [ "$VERBOSE" = "verbose" ]; then
/sbin/removepkg $rempkg
else
- /sbin/removepkg $rempkg | grep -v "Skipping\." | grep -v "Removing files:"
+ /sbin/removepkg ${MODE}$rempkg | grep -v "Skipping\." | grep -v "Removing files:"
fi
done
)
fi
-echo
+$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
+ /sbin/installpkg ${MODE}$INCOMINGDIR/$NNAME
fi
-echo "Package $OLD upgraded with new package $INCOMINGDIR/$NNAME."
+$ECHO "Package $OLD upgraded with new package $INCOMINGDIR/$NNAME."
ERRCODE=0
# Process next parameter:
Code:
--- slackpkg.orig 2011-03-24 22:42:10.000000000 -0400
+++ slackpkg 2014-04-02 11:57:32.339768320 -0400
@@ -40,6 +40,14 @@
. $CONF/slackpkg.conf
ERROR=""
+# Honor TERSEPKG ENV
+if [ $TERSEPKG ]; then
+ECHO="true"
+else
+ECHO="echo"
+fi
+MODE=''
+
# Set temporary directory
#
TMPDIR=$(mktemp -p /tmp -d slackpkg.XXXXXX 2>/dev/null)
@@ -63,6 +71,11 @@
while [ -n "$1" ] ; do
case $1 in
+ -terse=on)
+ MODE='--terse '
+ ECHO="true"
+ shift
+ ;;
-delall=on)
DELALL=on
shift
Code:
--- core-functions.sh.orig 2013-09-17 16:36:36.000000000 -0400
+++ core-functions.sh 2014-04-02 13:12:28.244600063 -0400
@@ -861,7 +861,7 @@
echo -e "${NAMEPKG}:\t$ERROR" >> $TMPDIR/error.log
fi
else
- echo -e "\tPackage $1 is already in cache - not downloading"
+ $ECHO -e "\tPackage $1 is already in cache - not downloading"
fi
# Check if we have sufficient disk space to install selected package
@@ -909,13 +909,13 @@
echo -e "\tInstalling ${1/%.t[blxg]z/}..."
;;
upgradepkg)
- echo -e "\tUpgrading ${1/%.t[blxg]z/}..."
+ $ECHO -e "\tUpgrading ${1/%.t[blxg]z/}..."
;;
*)
echo -e "\c"
;;
esac
- ( cd $CACHEPATH && $2 $1 )
+ ( cd $CACHEPATH && $2 ${MODE}$1 )
else
rm $CACHEPATH/$1 2>/dev/null
echo -e "\tERROR - Package not installed! $ERROR error!"