diff options
author | Patrick J Volkerding <volkerdi@slackware.com> | 2018-05-28 19:12:29 +0000 |
---|---|---|
committer | Eric Hameleers <alien@slackware.com> | 2018-05-31 23:39:35 +0200 |
commit | 646a5c1cbfd95873950a87b5f75d52073a967023 (patch) | |
tree | b8b8d2ab3b0d432ea69ad1a64d1c789649d65020 /source/a/pkgtools/scripts | |
parent | d31c50870d0bee042ce660e445c9294a59a3a65b (diff) | |
download | current-646a5c1cbfd95873950a87b5f75d52073a967023.tar.gz current-646a5c1cbfd95873950a87b5f75d52073a967023.tar.xz |
Mon May 28 19:12:29 UTC 201820180528191229
a/pkgtools-15.0-noarch-13.txz: Rebuilt.
installpkg: default line length for --terselength is the number of columns.
removepkg: added --terse mode.
upgradepkg: default line length for --terselength is the number of columns.
upgradepkg: accept -option in addition to --option.
ap/vim-8.1.0026-x86_64-1.txz: Upgraded.
d/bison-3.0.5-x86_64-1.txz: Upgraded.
e/emacs-26.1-x86_64-1.txz: Upgraded.
kde/kopete-4.14.3-x86_64-8.txz: Rebuilt.
Recompiled against libidn-1.35.
n/conntrack-tools-1.4.5-x86_64-1.txz: Upgraded.
n/libnetfilter_conntrack-1.0.7-x86_64-1.txz: Upgraded.
n/libnftnl-1.1.0-x86_64-1.txz: Upgraded.
n/links-2.16-x86_64-2.txz: Rebuilt.
Rebuilt to enable X driver for -g mode.
n/lynx-2.8.9dev.19-x86_64-1.txz: Upgraded.
n/nftables-0.8.5-x86_64-1.txz: Upgraded.
n/p11-kit-0.23.11-x86_64-1.txz: Upgraded.
n/ulogd-2.0.7-x86_64-1.txz: Upgraded.
n/whois-5.3.1-x86_64-1.txz: Upgraded.
xap/network-manager-applet-1.8.12-x86_64-1.txz: Upgraded.
xap/vim-gvim-8.1.0026-x86_64-1.txz: Upgraded.
Diffstat (limited to 'source/a/pkgtools/scripts')
-rw-r--r-- | source/a/pkgtools/scripts/explodepkg | 64 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/installpkg | 327 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/makebootdisk | 42 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/makepkg | 249 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/pkgdiff | 164 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/pkgtool | 69 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/removepkg | 175 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/setup.80.make-bootdisk | 28 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/setup.htmlview | 14 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/setup.services | 45 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/upgradepkg | 209 |
11 files changed, 924 insertions, 462 deletions
diff --git a/source/a/pkgtools/scripts/explodepkg b/source/a/pkgtools/scripts/explodepkg index 110ebf069..e1f9b1281 100644 --- a/source/a/pkgtools/scripts/explodepkg +++ b/source/a/pkgtools/scripts/explodepkg @@ -1,7 +1,7 @@ #!/bin/sh # Copyright 1994, 1998, 2000 Patrick Volkerding, Concord, CA, USA # Copyright 2001, 2003 Slackware Linux, Inc., Concord, CA, USA -# Copyright 2007, 2009 Patrick Volkerding, Sebeka, MN, USA +# Copyright 2007, 2009, 2017, 2018 Patrick Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -21,32 +21,15 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -TAR=tar-1.13 -$TAR --help 1> /dev/null 2> /dev/null -if [ ! $? = 0 ]; then - TAR=tar -fi -if [ ! "`LC_MESSAGES=C $TAR --version`" = "tar (GNU tar) 1.13 - -Copyright (C) 1988, 92,93,94,95,96,97,98, 1999 Free Software Foundation, Inc. -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -Written by John Gilmore and Jay Fenlason." ]; then - echo "WARNING: pkgtools are unstable with tar > 1.13." - echo " You should provide a \"tar-1.13\" in your \$PATH." - sleep 5 -fi - if [ $# = 0 ]; then cat << EOF Usage: explodepkg package_name [package_name2, ...] Explodes a Slackware compatible software package -(or any tar+{gzip,bzip2,lzma,xz archive) in the current directory. +(or any tar+{gzip,bzip2,lz,xz archive) in the current directory. Equivalent to (for each package listed): - ( umask 000 ; cat package_name | COMPRESSOR -dc | tar xvf package_name ) + ( umask 000 ; cat package_name | COMPRESSOR -dc | tar xpvf package_name ) Note: This should only be used for debugging or examining packages, not for installing them. It doesn't execute installation scripts or update the package @@ -55,6 +38,10 @@ indexes in /var/log/packages and /var/log/scripts. EOF fi +# Set maximum number of threads to use. By default, this will be the number +# of CPU threads: +THREADS="$(nproc)" + # Main loop: for PKG in $* ; do echo "Exploding package $PKG in current directory:" @@ -69,25 +56,50 @@ for PKG in $* ; do packagecompression=gzip ;; 'tbz' ) - packagecompression=bzip2 + if which lbzip2 1> /dev/null 2> /dev/null ; then + packagecompression=lbzip2 + else + packagecompression=bzip2 + fi ;; 'bz2' ) - packagecompression=bzip2 + if which lbzip2 1> /dev/null 2> /dev/null ; then + packagecompression=lbzip2 + else + packagecompression=bzip2 + fi ;; 'tlz' ) - packagecompression=lzma + if which plzip 1> /dev/null 2> /dev/null ; then + packagecompression="plzip --threads=${THREADS}" + elif which lzip 1> /dev/null 2> /dev/null ; then + packagecompression=lzip + else + echo "ERROR: lzip compression utility not found in \$PATH." + exit 3 + fi + ;; + 'lz' ) + if which plzip 1> /dev/null 2> /dev/null ; then + packagecompression="plzip --threads=${THREADS}" + elif which lzip 1> /dev/null 2> /dev/null ; then + packagecompression=lzip + else + echo "ERROR: lzip compression utility not found in \$PATH." + exit 3 + fi ;; 'lzma' ) packagecompression=lzma ;; 'txz' ) - packagecompression=xz + packagecompression="xz --threads=${THREADS}" ;; 'xz' ) - packagecompression=xz + packagecompression="xz --threads=${THREADS}" ;; esac - ( umask 000 ; cat $PKG | $packagecompression -dc | $TAR xvf - 2> /dev/null ) + ( umask 000 ; cat $PKG | $packagecompression -dc | tar --xattrs --xattrs-include='*' --keep-directory-symlink -xpvf - 2> /dev/null ) if [ -r install/doinst.sh ]; then echo echo "An installation script was detected in ./install/doinst.sh, but" diff --git a/source/a/pkgtools/scripts/installpkg b/source/a/pkgtools/scripts/installpkg index 96c34fd93..87a7f57ac 100644 --- a/source/a/pkgtools/scripts/installpkg +++ b/source/a/pkgtools/scripts/installpkg @@ -1,7 +1,7 @@ #!/bin/sh # Copyright 1994, 1998, 2000 Patrick Volkerding, Concord, CA, USA # Copyright 2001, 2003 Slackware Linux, Inc., Concord, CA, USA -# Copyright 2007, 2009, 2011 Patrick Volkerding, Sebeka, MN, USA +# Copyright 2007, 2009, 2011, 2017, 2018 Patrick Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -21,6 +21,33 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +# Thu May 24 20:23:55 UTC 2018 +# Added --terselength option to set the line length in --terse mode. +# Allow adding NOLOCK in an install script to allow it to run without locking. +# +# Sat May 19 22:42:03 UTC 2018 +# Implement locking to prevent screen output or install script collisions if +# multiple copies of installpkg are running simultaneously. +# Use ${MCOOKIE} instead of $$ (might as well, since we already generated it). +# +# Tue Apr 17 17:26:44 UTC 2018 +# Quit with the funny business in /install. Note however that /install still +# isn't a safe directory to use in a package for anything other than package +# metadata. Other files placed there are going to be left on the system in +# /installpkg-$(mcookie). That could be worked around, but we'll wait until +# someone reports there is a need. The main reason to do this is that /install +# was a collision point if more than one copy of installpkg was running at +# once. With this change, the pkgtools are (more or less) thread-safe. +# +# Tue Feb 13 01:19:46 UTC 2018 +# Use recent tar, and support restoring POSIX ACLs and extended attributes. +# +# Tue Dec 12 21:49:48 UTC 2017 +# If possible, use multiple decompression threads. +# +# Thu Dec 7 04:09:17 UTC 2017 +# Change meaning of .tlz to tar.lz (lzip) +# # 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. @@ -58,13 +85,6 @@ # 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() { @@ -88,21 +108,27 @@ MD5SUM=0 # So that we know what to expect... umask 022 -TAR=tar-1.13 -$TAR --help 1> /dev/null 2> /dev/null -if [ ! $? = 0 ]; then - TAR=tar -fi -if [ ! "$(LC_MESSAGES=C $TAR --version)" = "tar (GNU tar) 1.13 -Copyright (C) 1988, 92,93,94,95,96,97,98, 1999 Free Software Foundation, Inc. -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# If we have mcookie and a tar that is recent enough to support --transform, +# then we can stop needlessly erasing files in the /install directory while +# also making installpkg thread-safe. Don't check for recent tar - we'll +# already break from --attrs and --xattrs anyway if the wrong tar is used. +if which mcookie 1> /dev/null 2> /dev/null ; then + MCOOKIE=$(mcookie) + INSTDIR=installpkg-${MCOOKIE} +else + # Well, we will make due with this: + MCOOKIE=$$ + INSTDIR=installpkg-${MCOOKIE} +fi -Written by John Gilmore and Jay Fenlason." ]; then - echo "WARNING: pkgtools are unstable with tar > 1.13." - echo " You should provide a \"tar-1.13\" in your \$PATH." - sleep 5 +# Create a lockfile directory if it doesn't exist. We can use it to prevent +# screen corruption (from multiple dialogs) and install script collisions +# (from multiple scripts trying to work on the same files) in the case of +# parallel instances of installpkg. +INSTLOCKDIR=${INSTLOCKDIR:-/run/installpkg-lock} +if [ ! -d $INSTLOCKDIR ]; then + mkdir -p $INSTLOCKDIR fi usage() { @@ -116,16 +142,24 @@ options: --warn (warn if files will be overwritten, but do not install) --root /mnt (install someplace else, like /mnt) --infobox (use dialog to draw an info box) --terse (display a one-line short description for install) + --terselength <length> (line length in terse mode - default is + the number of columns available) --menu (confirm package installation with a menu, unless the priority is [required] or ADD) --ask (used with menu mode: always ask if a package should be installed regardless of what the package's priority is) - --priority ADD|REC|OPT|SKP (provide a priority for the entire + --priority ADD|REC|OPT|SKP (provide a priority for the entire package list to use instead of the priority in the tagfile) --tagfile /somedir/tagfile (specify a different file to use - for package priorities. The default is "tagfile" in + for package priorities. The default is "tagfile" in the package's directory) + --threads <number> For xz/plzip compressed packages, set the max + number of threads to be used for decompression. Only has + an effect if a multithreaded compressor was used, and then + only on large packages. For plzip, the default is equal to + the number of CPU threads available on the machine. For xz, + the default is equal to 2. --md5sum (record the package's md5sum in the metadata file) EOF @@ -143,6 +177,17 @@ package_name() { pkgbase $1 | sed 's?-[^-]*-[^-]*-[^-]*$??' } +# Set maximum number of threads to use. By default, this will be the number +# of CPU threads: +THREADS="$(nproc)" + +# Set default line length for terse mode: +if which tput 1> /dev/null 2> /dev/null ; then + TERSELENGTH=$(tput cols) +else + TERSELENGTH=80 +fi + # Parse options: MODE=install # standard text-mode while [ 0 ]; do @@ -158,6 +203,9 @@ while [ 0 ]; do elif [ "$1" = "-terse" -o "$1" = "--terse" ]; then MODE=terse shift 1 + elif [ "$1" = "-terselength" -o "$1" = "--terselength" ]; then + TERSELENGTH=$2 + shift 2 elif [ "$1" = "-menu" -o "$1" = "--menu" ]; then MODE=menu shift 1 @@ -174,6 +222,12 @@ while [ 0 ]; do exit fi shift 2 + elif [ "$1" = "-threads" -o "$1" = "--threads" ]; then + THREADS="$2" + shift 2 + # xz has not yet implemented multi-threaded decompression. + # Who knows if or how well it will work... + XZ_THREADS_FORCED=yes elif [ "$1" = "-priority" -o "$1" = "--priority" ]; then if [ "$2" = "" ]; then usage @@ -222,41 +276,56 @@ fi # If -warn mode was requested, produce the output and then exit: if [ "$MODE" = "warn" ]; then while [ -f "$1" ]; do - mkdir -p $TMP/scan$$ + mkdir -p $TMP/scan${MCOOKIE} # Determine extension: packageext="$( echo $1 | rev | cut -f 1 -d . | rev)" - # Determine compressor utility: + # Determine decompressor utility: case $packageext in 'tgz' ) packagecompression=gzip ;; 'tbz' ) - packagecompression=bzip2 + if which lbzip2 1> /dev/null 2> /dev/null ; then + packagecompression=lbzip2 + else + packagecompression=bzip2 + fi ;; 'tlz' ) - packagecompression=lzma + if which plzip 1> /dev/null 2> /dev/null ; then + packagecompression="plzip --threads=${THREADS}" + elif which lzip 1> /dev/null 2> /dev/null ; then + packagecompression=lzip + else + echo "ERROR: lzip compression utility not found in \$PATH." + exit 3 + fi ;; 'txz' ) - packagecompression=xz + if [ ! "$XZ_THREADS_FORCED" = "yes" ]; then + packagecompression="xz --threads=${THREADS}" + else + packagecompression="xz --threads=2" + fi ;; esac - ( cd $TMP/scan$$ ; $packagecompression -dc | $TAR xf - install ) < $1 2> /dev/null - if [ -r $TMP/scan$$/install/doinst.sh ]; then - 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 + ( cd $TMP/scan${MCOOKIE} ; $packagecompression -dc | tar xf - install ) < $1 2> /dev/null + if [ -r $TMP/scan${MCOOKIE}/install/doinst.sh ]; then + if grep ' rm -rf ' $TMP/scan${MCOOKIE}/install/doinst.sh 1>/dev/null 2>/dev/null ; then + grep ' rm -rf ' $TMP/scan${MCOOKIE}/install/doinst.sh > $TMP/scan${MCOOKIE}/install/delete + for f in `cat $TMP/scan${MCOOKIE}/install/delete | cut -f 3,7 -d ' ' | tr ' ' '/'`; do f="/$f" if [ -f "$f" -o -L "$f" ]; then echo "$f" fi done fi - if [ -d $TMP/scan$$ ]; then - ( cd $TMP/scan$$ ; rm -rf install ) 2> /dev/null - ( cd $TMP ; rmdir scan$$ ) 2> /dev/null + if [ -d $TMP/scan${MCOOKIE} ]; then + ( cd $TMP/scan${MCOOKIE} ; rm -rf install ) 2> /dev/null + ( cd $TMP ; rmdir scan${MCOOKIE} ) 2> /dev/null fi fi - for f in `( $packagecompression -dc | $TAR tf - ) < $1 | grep -v 'drwx'`; do + for f in `( $packagecompression -dc | tar tf - ) < $1 | grep -v 'drwx'`; do f="/$f" if [ -f "$f" -o -L "$f" ]; then echo "$f" @@ -304,18 +373,33 @@ for package in $* ; do packagecompression=gzip ;; 'tbz' ) - packagecompression=bzip2 + if which lbzip2 1> /dev/null 2> /dev/null ; then + packagecompression=lbzip2 + else + packagecompression=bzip2 + fi ;; 'tlz' ) - packagecompression=lzma + if which plzip 1> /dev/null 2> /dev/null ; then + packagecompression="plzip --threads=${THREADS}" + elif which lzip 1> /dev/null 2> /dev/null ; then + packagecompression=lzip + else + echo "ERROR: lzip compression utility not found in \$PATH." + exit 3 + fi ;; 'txz' ) - packagecompression=xz + if [ ! "$XZ_THREADS_FORCED" = "yes" ]; then + packagecompression="xz --threads=${THREADS}" + else + packagecompression="xz --threads=2" + fi ;; esac # Test presence of external compression utility: - if ! $packagecompression --help 1> /dev/null 2> /dev/null ; then + if ! $(echo $packagecompression | cut -f 1 -d ' ') --help 1> /dev/null 2> /dev/null ; then EXITSTATUS=5 if [ "$MODE" = "install" ]; then echo "Cannot install $package: external compression utility $packagecompression missing" @@ -375,28 +459,38 @@ for package in $* ; do if [ "$MODE" = "install" ]; then echo "Verifying package $(basename $package)." fi - cat $package | $packagecompression -dc | dd 2> $TMP/tmpsize$$ | $TAR tf - 1> $TMP/tmplist$$ 2> /dev/null + # The stray cat reduces the frequency of the lack of reported size. + # If it still fails, we hit it with a bigger hammer down below. + cat $package | $packagecompression -dc | LC_ALL=C dd 2> $TMP/tmpsize${MCOOKIE} | cat | tar tf - 2> /dev/null 1> $TMP/tmplist${MCOOKIE} TARERROR=$? if [ ! "$TARERROR" = "0" ]; then EXITSTATUS=1 # tar file corrupt if [ "$MODE" = "install" ]; then echo "Unable to install $package: tar archive is corrupt (tar returned error code $TARERROR)" fi - rm -f $TMP/tmplist$$ $TMP/tmpsize$$ + rm -f $TMP/tmplist${MCOOKIE} $TMP/tmpsize${MCOOKIE} continue fi - UNCOMPRESSED="$(cat $TMP/tmpsize$$ | tail -n 1 | cut -f 1 -d ' ' | numfmt --to=iec)" - rm -f $TMP/tmpsize$$ + UNCOMPRESSED="$(cat $TMP/tmpsize${MCOOKIE} | tail -n 1 | cut -f 1 -d ' ' | numfmt --to=iec)" + # Weird bug "fix". Sometimes we get no uncompressed size (this started when we + # moved away from tar-1.13, but I don't see what that could have to do with + # it). So, if we have no uncompressed size here, demand it in this loop. + # Hopefully the bug is not weird enough to make this an infinite loop. :/ + while [ "$UNCOMPRESSED" = "" ]; do + cat $package | $packagecompression -dc | LC_ALL=C dd 1> /dev/null 2> $TMP/tmpsize${MCOOKIE} + UNCOMPRESSED="$(cat $TMP/tmpsize${MCOOKIE} | tail -n 1 | cut -f 1 -d ' ' | numfmt --to=iec)" + done + rm -f $TMP/tmpsize${MCOOKIE} # If we still don't have a package description, look inside the package. # This requires a costly untar. if [ "$DESCRIPTION" = "" ]; then - mkdir -p $TMP/scan$$ - ( cd $TMP/scan$$ ; $packagecompression -dc | $TAR xf - install ) < $package 2> /dev/null - if grep "^$packagebase:" "$TMP/scan$$/install/slack-desc" 1> /dev/null 2> /dev/null ; then - DESCRIPTION="$TMP/scan$$/install/slack-desc" - elif grep "^$shortname:" "$TMP/scan$$/install/slack-desc" 1> /dev/null 2> /dev/null ; then - DESCRIPTION="$TMP/scan$$/install/slack-desc" + mkdir -p $TMP/scan${MCOOKIE} + ( cd $TMP/scan${MCOOKIE} ; $packagecompression -dc | tar xf - install ) < $package 2> /dev/null + if grep "^$packagebase:" "$TMP/scan${MCOOKIE}/install/slack-desc" 1> /dev/null 2> /dev/null ; then + DESCRIPTION="$TMP/scan${MCOOKIE}/install/slack-desc" + elif grep "^$shortname:" "$TMP/scan${MCOOKIE}/install/slack-desc" 1> /dev/null 2> /dev/null ; then + DESCRIPTION="$TMP/scan${MCOOKIE}/install/slack-desc" fi fi @@ -406,20 +500,20 @@ for package in $* ; do fi # Gather package infomation into a temporary file: - grep "^$packagebase:" $DESCRIPTION | cut -f 2- -d : | cut -b2- 1> $TMP/tmpmsg$$ 2> /dev/null + grep "^$packagebase:" $DESCRIPTION | cut -f 2- -d : | cut -b2- 1> $TMP/tmpmsg${MCOOKIE} 2> /dev/null if [ "$shortname" != "$packagebase" ]; then - grep "^$shortname:" $DESCRIPTION | cut -f 2- -d : | cut -b2- 1>> $TMP/tmpmsg$$ 2> /dev/null + grep "^$shortname:" $DESCRIPTION | cut -f 2- -d : | cut -b2- 1>> $TMP/tmpmsg${MCOOKIE} 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=$(wc -l < $TMP/tmpmsg$$ ) + LENGTH=$(wc -l < $TMP/tmpmsg${MCOOKIE} ) while [ $LENGTH -lt 12 ]; do - echo >> $TMP/tmpmsg$$ + echo >> $TMP/tmpmsg${MCOOKIE} LENGTH=$(expr $LENGTH + 1) done - echo "Size: Compressed: ${COMPRESSED}, uncompressed: ${UNCOMPRESSED}." >> $TMP/tmpmsg$$ + echo "Size: Compressed: ${COMPRESSED}, uncompressed: ${UNCOMPRESSED}." >> $TMP/tmpmsg${MCOOKIE} # For recent versions of dialog it is necessary to add \n to the end of each line # or it will remove repeating spaces and mess up our careful formatting: - cat << EOF > $TMP/controlns$$ + cat << EOF > $TMP/controlns${MCOOKIE} \n \n \n @@ -434,9 +528,9 @@ for package in $* ; do \n \n EOF - paste -d "" $TMP/tmpmsg$$ $TMP/controlns$$ > $TMP/pasted$$ - rm -f $TMP/controlns$$ - mv $TMP/pasted$$ $TMP/tmpmsg$$ + paste -d "" $TMP/tmpmsg${MCOOKIE} $TMP/controlns${MCOOKIE} > $TMP/pasted${MCOOKIE} + rm -f $TMP/controlns${MCOOKIE} + mv $TMP/pasted${MCOOKIE} $TMP/tmpmsg${MCOOKIE} # Emit information to the console: if [ "$MODE" = "install" ]; then if [ "$PMSG" = "" ]; then @@ -450,23 +544,33 @@ EOF grep "^$shortname:" $DESCRIPTION | uniq | sed "s/^$shortname:/#/g" fi elif [ "$MODE" = "terse" ]; then # emit a single description line - 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 + ( flock 9 || exit 11 + printf "%-$(expr $TERSELENGTH - 7)s %-6s\n" "$(echo $shortname: $(echo $(cat $DESCRIPTION | grep "^$packagebase:" | sed "s/^$packagebase: //g" | head -n 1 | tr -d '()' | sed "s/^$packagebase //g" ) $(echo " $(printf '.%.0s' {1..256})")) | cut -b1-$(expr $TERSELENGTH - 7))" "$(printf "[%4s]" $UNCOMPRESSED)" + ) 9> $INSTLOCKDIR/dialog.lock elif [ "$MODE" = "infobox" ]; then # install infobox package - dialog --title "Installing package $shortname $PMSG" --infobox "$(cat $TMP/tmpmsg$$)" 0 0 + ( flock 9 || exit 11 + dialog --title "Installing package $shortname $PMSG" --infobox "$(cat $TMP/tmpmsg${MCOOKIE})" 0 0 + ) 9> $INSTLOCKDIR/dialog.lock elif [ "$MODE" = "menu" -a "$PRIORITY" = "ADD" -a ! "$ALWAYSASK" = "yes" ]; then # ADD overrides menu mode unless -ask was used - dialog --title "Installing package $shortname $PMSG" --infobox "$(cat $TMP/tmpmsg$$)" 0 0 + ( flock 9 || exit 11 + dialog --title "Installing package $shortname $PMSG" --infobox "$(cat $TMP/tmpmsg${MCOOKIE})" 0 0 + ) 9> $INSTLOCKDIR/dialog.lock elif [ "$MODE" = "menu" -a "$USERPRIORITY" = "ADD" ]; then # install no matter what $PRIORITY - dialog --title "Installing package $shortname $PMSG" --infobox "$(cat $TMP/tmpmsg$$)" 0 0 + ( flock 9 || exit 11 + dialog --title "Installing package $shortname $PMSG" --infobox "$(cat $TMP/tmpmsg${MCOOKIE})" 0 0 + ) 9> $INSTLOCKDIR/dialog.lock else # we must need a full menu: - dialog --title "Package Name: $shortname $PMSG" --menu "$(cat $TMP/tmpmsg$$)" 0 0 3 \ - "Yes" "Install package $shortname" \ - "No" "Do not install package $shortname" \ - "Quit" "Abort software installation completely" 2> $TMP/reply$$ - if [ ! $? = 0 ]; then - echo "No" > $TMP/reply$$ - fi - REPLY="$(cat $TMP/reply$$)" - rm -f $TMP/reply$$ $TMP/tmpmsg$$ + ( flock 9 || exit 11 + dialog --title "Package Name: $shortname $PMSG" --menu "$(cat $TMP/tmpmsg${MCOOKIE})" 0 0 3 \ + "Yes" "Install package $shortname" \ + "No" "Do not install package $shortname" \ + "Quit" "Abort software installation completely" 2> $TMP/reply${MCOOKIE} + if [ ! $? = 0 ]; then + echo "No" > $TMP/reply${MCOOKIE} + fi + ) 9> $INSTLOCKDIR/dialog.lock + REPLY="$(cat $TMP/reply${MCOOKIE})" + rm -f $TMP/reply${MCOOKIE} $TMP/tmpmsg${MCOOKIE} if [ "$REPLY" = "Quit" ]; then exit 99 # EXIT STATUS 99 = ABORT! elif [ "$REPLY" = "No" ]; then @@ -476,12 +580,12 @@ EOF # Make sure there are no symbolic links sitting in the way of # incoming package files: - grep -v "/$" $TMP/tmplist$$ | while read file ; do + grep -v "/$" $TMP/tmplist${MCOOKIE} | while read file ; do if [ -L "$ROOT/$file" ]; then rm -f "$ROOT/$file" fi done - rm -f $TMP/tmplist$$ + rm -f $TMP/tmplist${MCOOKIE} # Write the package file database entry and install the package: echo "PACKAGE NAME: $shortname" > $ADM_DIR/packages/$shortname @@ -498,56 +602,79 @@ EOF grep "^$shortname:" $DESCRIPTION >> $ADM_DIR/packages/$shortname 2> /dev/null fi echo "FILE LIST:" >> $ADM_DIR/packages/$shortname - ( cd $ROOT/ ; $packagecompression -dc | $TAR -xlUpvf - | sort ) < $package >> $TMP/$shortname 2> /dev/null + if [ "$INSTDIR" = "install" ]; then + ( cd $ROOT/ ; $packagecompression -dc | tar --acls --xattrs --xattrs-include='*' --keep-directory-symlink -xpvf - | LC_ALL=C sort ) < $package >> $TMP/$shortname 2> /dev/null + else + ( cd $ROOT/ ; $packagecompression -dc | tar --transform "s,^install$,$INSTDIR," --transform "s,^install/,$INSTDIR/," --acls --xattrs --xattrs-include='*' --keep-directory-symlink -xpvf - | LC_ALL=C sort ) < $package >> $TMP/$shortname 2> /dev/null + fi 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 # Some dumb bunny built a package with something other than makepkg. Bad! # Oh well. Bound to happen. Par for the course. Fix it and move on... - echo "WARNING: Package has not been created with 'makepkg'" - echo './' >> $ADM_DIR/packages/$shortname - cat $TMP/$shortname >> $ADM_DIR/packages/$shortname + # We'll assume it's just a recent tar with an unfiltered filelist with all + # files prefixed with "./". No guarantees, but this will usually work. + cat $TMP/$shortname | sed '2,$s,^\./,,' >> $ADM_DIR/packages/$shortname fi rm -f $TMP/$shortname - # It's a good idea to make sure those newly installed libraries - # are properly activated for use: - if [ -x /sbin/ldconfig ]; then - /sbin/ldconfig + # It's a good idea to make sure those newly installed libraries are properly + # activated for use, unless ROOT is pointing somewhere else in which case + # running ldconfig on the host system won't make any difference: + if [ "$ROOT" = "" ] && [ -x /sbin/ldconfig ]; then + ( flock 9 || exit 11 + /sbin/ldconfig 2> /dev/null + ) 9> $INSTLOCKDIR/ldconfig.lock fi - if [ -f $ROOT/install/doinst.sh ]; then + if [ -f $ROOT/$INSTDIR/doinst.sh ]; then if [ "$MODE" = "install" ]; then echo "Executing install script for $(basename $package)." fi - # 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 ; ) + # Don't use locking if the script contains "NOLOCK": + if grep -q NOLOCK $ROOT/$INSTDIR/doinst.sh ; then + # 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 ' $INSTDIR/doinst.sh | /bin/bash + else + cd $ROOT/ ; sh $INSTDIR/doinst.sh + fi + else # use locking + # 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 + ( flock 9 || exit 11 + cd $ROOT/ ; sed -e's?^( cd \([^;]*\);\(.*\) )$?pushd \1 \&\> /dev/null ; \2 ; popd \&\> /dev/null?g ' $INSTDIR/doinst.sh | /bin/bash + ) 9> $INSTLOCKDIR/doinst.sh.lock + else + ( flock 9 || exit 11 + cd $ROOT/ ; sh $INSTDIR/doinst.sh + ) 9> $INSTLOCKDIR/doinst.sh.lock + fi fi fi # Clean up the mess... - if [ -d $ROOT/install ]; then - if [ -r $ROOT/install/doinst.sh ]; then - cp $ROOT/install/doinst.sh $ADM_DIR/scripts/$shortname + if [ -d $ROOT/$INSTDIR ]; then + if [ -r $ROOT/$INSTDIR/doinst.sh ]; then + cp $ROOT/$INSTDIR/doinst.sh $ADM_DIR/scripts/$shortname chmod 755 $ADM_DIR/scripts/$shortname fi # /install/doinst.sh and /install/slack-* are reserved locations for the package system. - ( cd $ROOT/install ; rm -f doinst.sh slack-* 1> /dev/null 2>&1 ) - rmdir $ROOT/install 1> /dev/null 2>&1 + # Heh, not any more with a recent tar :-) + ( cd $ROOT/$INSTDIR ; rm -f doinst.sh slack-* 1> /dev/null 2>&1 ) + rmdir $ROOT/$INSTDIR 1> /dev/null 2>&1 fi # If we used a scan directory, get rid of it: - if [ -d "$TMP/scan$$" ]; then - rm -rf "$TMP/scan$$" + if [ -d "$TMP/scan${MCOOKIE}" ]; then + rm -rf "$TMP/scan${MCOOKIE}" fi - rm -f $TMP/tmpmsg$$ $TMP/reply$$ + rm -f $TMP/tmpmsg${MCOOKIE} $TMP/reply${MCOOKIE} if [ "$MODE" = "install" ]; then echo "Package $(basename $package) installed." - echo fi done diff --git a/source/a/pkgtools/scripts/makebootdisk b/source/a/pkgtools/scripts/makebootdisk index 86b843a8b..93ccc5a99 100644 --- a/source/a/pkgtools/scripts/makebootdisk +++ b/source/a/pkgtools/scripts/makebootdisk @@ -10,7 +10,7 @@ # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; @@ -206,8 +206,8 @@ format_disk() { fdformat $FDEV 1> /dev/null 2> /dev/null if [ ! $? = 0 ]; then dialog --title "ERROR: FLOPPY FORMAT FAILED" --msgbox "The attempt to format the floppy \ -disk in /dev/fd0 has failed, probably due to bad media. Please try again with a \ -different disk. If that doesn't work, perhaps the drive needs cleaning." 0 0 +disk in /dev/fd0 has failed, probably due to bad media. Please try again with a \ +different disk. If that doesn't work, perhaps the drive needs cleaning." 0 0 return 1 fi } @@ -218,8 +218,8 @@ while [ 0 ]; do # menu loop dialog --title "MAKE BOOT FLOPPY FROM KERNEL" \ --default-item $DEFAULT_ITEM \ --backtitle "$KMSG" --menu "This menu allows you to make a SYSLINUX bootdisk \ -from a compiled kernel. The SYSLINUX bootloader has the advantage of \ -using a FAT filesystem making it easy to replace the kernel later. \ +from a compiled kernel. The SYSLINUX bootloader has the advantage of \ +using a FAT filesystem making it easy to replace the kernel later. \ Which option would you like?" 12 67 2 \ "syslinux" "Make a SYSLINUX bootdisk" \ "exit" "Exit this program" 2> $TMP/return @@ -238,7 +238,7 @@ cat << EOF > $TMP/tmpmsg The kernel $KERNEL is $kernel_size K (which is more than 1023 Kb in size), so it probably won't -boot standalone on the floppy. Use the 'syslinux' +boot standalone on the floppy. Use the 'syslinux' method instead. EOF @@ -271,9 +271,9 @@ YES creates the disk, NO aborts.\n" 14 62 choose_kernel fi dialog --title "CREATING SYSLINUX BOOTDISK IN /dev/fd0" --backtitle "$KMSG" --yesno "Now put a \ -floppy in your boot drive. This will be made into a SYSLINUX \ -bootdisk that you can use to start your Linux system. Any data on the \ -target disk will be destroyed. YES creates the disk, NO aborts." 8 62 +floppy in your boot drive. This will be made into a SYSLINUX \ +bootdisk that you can use to start your Linux system. Any data on the \ +target disk will be destroyed. YES creates the disk, NO aborts." 8 62 if [ $? = 0 ]; then # make the disk format_disk if [ ! $? = 0 ]; then @@ -292,7 +292,7 @@ $ROOT_DEVICE in /dev/fd0." 3 64 if [ ! "$?" = "0" ]; then dialog --title "ERROR COPYING KERNEL TO FLOPPY" \ --msgbox "Sorry, but there was an error copying the kernel to the \ -floppy disk. Possibly the kernel is too large to fit the disk. \ +floppy disk. Possibly the kernel is too large to fit the disk. \ This program will now exit." 0 0 umount /dev/fd0 rm -rf $TMP/bootdisk @@ -303,15 +303,15 @@ This program will now exit." 0 0 Welcome to the 09Slackware07 Linux custom bootdisk! By default, this disk boots a root Linux partition on $ROOT_DEVICE when you -hit ENTER. If you'd like to boot some other partition, use a command like +hit ENTER. If you'd like to boot some other partition, use a command like this on the prompt below: mount root=/dev/sda1 ro Where "/dev/sda1" is the partition you want to boot, and "ro" specifies that -the partition should be initially mounted as read-only. If you wish to mount -the partition read-write, use "rw" instead. To set the video console mode, -use the vga= parameter (press F1 to see a table). You may also add any other +the partition should be initially mounted as read-only. If you wish to mount +the partition read-write, use "rw" instead. To set the video console mode, +use the vga= parameter (press F1 to see a table). You may also add any other kernel parameters you might need depending on your hardware, and which drivers are included in your kernel. @@ -341,7 +341,7 @@ EOF FRAMEBUFFER MODES: To get the kernel to start in VESA framebuffer mode, you need to pass it - a vga= init string on the "boot:" prompt. Here's a table: + a vga= init string on the "boot:" prompt. Here's a table: Colors 640x480 800x600 1024x768 1280x1024 1600x1200 --------+--------------------------------------------- @@ -376,9 +376,9 @@ EOF choose_kernel fi dialog --title "CREATING LILO BOOTDISK IN /dev/fd0" --backtitle "$KMSG" --yesno "Now put a \ -floppy in your boot drive. This will be made into a LILO \ -bootdisk that you can use to start your Linux system. Any data on the \ -target disk will be destroyed. YES creates the disk, NO aborts." 8 62 +floppy in your boot drive. This will be made into a LILO \ +bootdisk that you can use to start your Linux system. Any data on the \ +target disk will be destroyed. YES creates the disk, NO aborts." 8 62 if [ $? = 0 ]; then # make the disk format_disk DEV=/dev/fd0u1680 @@ -422,14 +422,14 @@ EOF Welcome to the Slackware Linux custom LILO bootdisk! By default, this disk boots a root Linux partition on $ROOT_DEVICE when -you hit ENTER. If you'd like to boot some other partition, use a command +you hit ENTER. If you'd like to boot some other partition, use a command like this on the LILO prompt below: mount root=/dev/sda1 ro Where "/dev/sda1" is the partition you want to boot, and "ro" specifies that -the partition should be initially mounted as read-only. If you which to mount -the partition read-write, use "rw" instead. You may also add any other kernel +the partition should be initially mounted as read-only. If you which to mount +the partition read-write, use "rw" instead. You may also add any other kernel parameters you might need depending on your hardware, and which drivers are included in your kernel. diff --git a/source/a/pkgtools/scripts/makepkg b/source/a/pkgtools/scripts/makepkg index 25c5f2364..f9241cb96 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, 2015 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2009, 2015, 2017, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -21,6 +21,16 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +# Mon May 21 18:31:20 UTC 2018 +# Add --compress option, usually used to change the preset compression level +# or block size. +# +# Tue Feb 13 00:46:12 UTC 2018 +# Use recent tar, and support storing POSIX ACLs and extended attributes. +# +# Tue Dec 12 21:55:59 UTC 2017 +# If possible, use multiple compression threads. +# # Wed Sep 23 18:36:43 UTC 2015 # Support spaces in file/directory names. <alphageek> # @@ -36,23 +46,7 @@ CWD=$(pwd) -TAR=tar-1.13 umask 022 -$TAR --help 1> /dev/null 2> /dev/null -if [ ! $? = 0 ]; then - TAR=tar -fi -if [ ! "$(LC_MESSAGES=C $TAR --version)" = "tar (GNU tar) 1.13 - -Copyright (C) 1988, 92,93,94,95,96,97,98, 1999 Free Software Foundation, Inc. -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -Written by John Gilmore and Jay Fenlason." ]; then - echo "WARNING: pkgtools are unstable with tar > 1.13." - echo " You should provide a \"tar-1.13\" in your \$PATH." - sleep 5 -fi make_install_script() { TAB="$(echo -e "\t")" @@ -80,26 +74,48 @@ Usage: makepkg package_name.tgz (or: package_name.tbz, package_name.tlz, package_name.txz) Makes a Slackware compatible package containing the contents of the current -and all subdirectories. If symbolic links exist, they will be removed and +and all subdirectories. If symbolic links exist, they will be removed and an installation script will be made to recreate them later. This script will be called "install/doinst.sh". You may add any of your own ash-compatible shell scripts to this file and rebuild the package if you wish. options: -l, --linkadd y|n (moves symlinks into doinst.sh: recommended) -p, --prepend (prepend rather than append symlinks to an existing - doinst.sh. Useful to link libraries needed by - programs in the doinst.sh script) - -c, --chown y|n (resets all permissions to root:root 755 - - not generally recommended) + doinst.sh. Useful to link libraries needed by programs in + the doinst.sh script) + -c, --chown y|n (resets all permissions to root:root 755 - not + generally recommended) + --threads <number> For xz/plzip compressed packages, set the max + number of threads to be used for compression. Only has an + effect on large packages. For plzip, the default is equal to + the number of CPU threads available on the machine. For xz, + the default is equal to 2 (due to commonly occuring memory + related failures when using many threads with multi-threaded + xz compression). + --compress <option> Supply a custom option to the compressor. + This will be used in place of the default, which is: -9 + --acls Support storing POSIX ACLs in the package. The resulting + package will not be compatible with pkgtools version < 15.0. + --xattrs Support storing extended attributes in the package. The + resulting package will not be compatible with pkgtools + version < 15.0. -If these options are not set, makepkg will prompt as appropriate. +If these options are not set, makepkg will prompt if appropriate. EOF } TMP=/tmp # This can be a hole, but I'm going to be careful about file # creation in there, so don't panic. :^) +# Set maximum number of threads to use. By default, this will be the number +# of CPU threads: +THREADS="$(nproc)" + +# Set default compression option. +COMPRESS_OPTION="-9" + # Parse options +unset ACLS XATTRS while [ 0 ]; do if [ "$1" = "--linkadd" -o "$1" = "-l" ]; then if [ "$2" = "y" ]; then @@ -124,6 +140,21 @@ while [ 0 ]; do elif [ "$1" = "-p" -o "$1" = "--prepend" ]; then PREPEND=y shift 1 + elif [ "$1" = "-threads" -o "$1" = "--threads" ]; then + THREADS="$2" + shift 2 + # xz has memory issues with threads it seems, so we'll use two threads by + # default unless we see that something else was user-selected: + XZ_THREADS_FORCED=yes + elif [ "$1" = "-compress" -o "$1" = "--compress" ]; then + COMPRESS_OPTION="$2" + shift 2 + elif [ "$1" = "--acls" ]; then + ACLS="--acls" + shift 1 + elif [ "$1" = "--xattrs" ]; then + XATTRS="--xattrs" + shift 1 elif [ "$1" = "-h" -o "$1" = "-H" -o "$1" = "--help" -o $# = 0 ]; then usage exit 0 @@ -136,26 +167,109 @@ PACKAGE_NAME="$1" TARGET_NAME="$(dirname $PACKAGE_NAME)" PACKAGE_NAME="$(basename $PACKAGE_NAME)" -# Identify package extension: +# Identify package extension and compression type to use: if [ ! "$(basename $PACKAGE_NAME .tgz)" = "$PACKAGE_NAME" ]; then EXTENSION="tgz" + COMPEXT="gz" + COMPRESSOR="gzip ${COMPRESS_OPTION} -c" + if ! which gzip 1> /dev/null 2> /dev/null ; then + echo "ERROR: gzip compression utility not found in \$PATH." + exit 3 + fi elif [ ! "$(basename $PACKAGE_NAME .tar.gz)" = "$PACKAGE_NAME" ]; then - # .tar.compression is also supported, although the resulting "packages" will - # not be installable by installpkg without the correct 3 letter extension - # instead. EXTENSION="tar.gz" + COMPRESSOR="gzip ${COMPRESS_OPTION} -c" + if ! which gzip 1> /dev/null 2> /dev/null ; then + echo "ERROR: gzip compression utility not found in \$PATH." + exit 3 + fi elif [ ! "$(basename $PACKAGE_NAME .tbz)" = "$PACKAGE_NAME" ]; then EXTENSION="tbz" + if which lbzip2 1> /dev/null 2> /dev/null ; then + COMPRESSOR="lbzip2 ${COMPRESS_OPTION} -c" + else + if which bzip2 1> /dev/null 2> /dev/null ; then + COMPRESSOR="bzip2 ${COMPRESS_OPTION} -c" + else + echo "ERROR: bzip2 compression utility not found in \$PATH." + exit 3 + fi + fi elif [ ! "$(basename $PACKAGE_NAME .tar.bz2)" = "$PACKAGE_NAME" ]; then EXTENSION="tar.bz2" + if which lbzip2 1> /dev/null 2> /dev/null ; then + COMPRESSOR="lbzip2 ${COMPRESS_OPTION} -c" + else + if which bzip2 1> /dev/null 2> /dev/null ; then + COMPRESSOR="bzip2 ${COMPRESS_OPTION} -c" + else + echo "ERROR: bzip2 compression utility not found in \$PATH." + exit 3 + fi + fi elif [ ! "$(basename $PACKAGE_NAME .tlz)" = "$PACKAGE_NAME" ]; then EXTENSION="tlz" + if which plzip 1> /dev/null 2> /dev/null ; then + COMPRESSOR="plzip ${COMPRESS_OPTION} --threads=${THREADS} -c" + else + echo "WARNING: plzip compression utility not found in \$PATH." + echo "WARNING: package will not support multithreaded decompression." + if which lzip 1> /dev/null 2> /dev/null ; then + COMPRESSOR="lzip ${COMPRESS_OPTION} -c" + else + echo "ERROR: lzip compression utility not found in \$PATH." + exit 3 + fi + fi +elif [ ! "$(basename $PACKAGE_NAME .tar.lz)" = "$PACKAGE_NAME" ]; then + EXTENSION="tar.lz" + if which plzip 1> /dev/null 2> /dev/null ; then + COMPRESSOR="plzip ${COMPRESS_OPTION} --threads=${THREADS} -c" + else + echo "WARNING: plzip compression utility not found in \$PATH." + echo "WARNING: package will not support multithreaded decompression." + if which lzip 1> /dev/null 2> /dev/null ; then + COMPRESSOR="lzip ${COMPRESS_OPTION} -c" + else + echo "ERROR: lzip compression utility not found in \$PATH." + exit 3 + fi + fi elif [ ! "$(basename $PACKAGE_NAME .tar.lzma)" = "$PACKAGE_NAME" ]; then EXTENSION="tar.lzma" + COMPRESSOR="lzma ${COMPRESS_OPTION} -c" + if ! which lzma 1> /dev/null 2> /dev/null ; then + echo "ERROR: lzma compression utility not found in \$PATH." + exit 3 + fi elif [ ! "$(basename $PACKAGE_NAME .txz)" = "$PACKAGE_NAME" ]; then EXTENSION="txz" + if [ ! "$XZ_THREADS_FORCED" = "yes" ]; then + # Two threads by default with xz due to memory failures on 32-bit. Not that + # it matters much... if upstream ever gets around to implementing multi- + # threaded decompression we'll revisit this default. :-D + COMPRESSOR="xz ${COMPRESS_OPTION} --threads=2 -c" + else + COMPRESSOR="xz ${COMPRESS_OPTION} --threads=${THREADS} -c" + fi + if ! which xz 1> /dev/null 2> /dev/null ; then + echo "ERROR: xz compression utility not found in \$PATH." + exit 3 + fi elif [ ! "$(basename $PACKAGE_NAME .tar.xz)" = "$PACKAGE_NAME" ]; then EXTENSION="tar.xz" + if [ ! "$XZ_THREADS_FORCED" = "yes" ]; then + # Two threads by default with xz due to memory failures on 32-bit. Not that + # it matters much... if upstream ever gets around to implementing multi- + # threaded decompression we'll revisit this default. :-D + COMPRESSOR="xz ${COMPRESS_OPTION} --threads=2 -c" + else + COMPRESSOR="xz ${COMPRESS_OPTION} --threads=${THREADS} -c" + fi + if ! which xz 1> /dev/null 2> /dev/null ; then + echo "ERROR: xz compression utility not found in \$PATH." + exit 3 + fi else EXTENSION="$(echo $PACKAGE_NAME | rev | cut -f 1 -d . | rev)" echo "ERROR: Package extension .$EXTENSION is not supported." @@ -170,36 +284,8 @@ if [ "$CWD" = "$TARGET_NAME" -o "." = "$TARGET_NAME" ]; then exit 2 fi -# Make sure external compression utility is available: -case $EXTENSION in -'tgz' | 'tar.gz' ) - if ! which gzip 1> /dev/null 2> /dev/null ; then - echo "ERROR: gzip compression utility not found in \$PATH." - exit 3 - fi - ;; -'tbz' | 'tar.bz2' ) - if ! which bzip2 1> /dev/null 2> /dev/null ; then - echo "ERROR: bzip2 compression utility not found in \$PATH." - exit 3 - fi - ;; -'tlz' | 'tar.lzma' ) - if ! which lzma 1> /dev/null 2> /dev/null ; then - echo "ERROR: lzma compression utility not found in \$PATH." - exit 3 - fi - ;; -'txz' | 'tar.xz' ) - if ! which xz 1> /dev/null 2> /dev/null ; then - echo "ERROR: xz compression utility not found in \$PATH." - exit 3 - fi - ;; -esac - echo -echo "Slackware package maker, version 3.141593." +echo "Slackware package maker, version 3.14159265." echo echo "Searching for symbolic links:" # Get rid of possible pre-existing trouble: @@ -303,36 +389,27 @@ fi echo "Creating Slackware package: ${TARGET_NAME}/${TAR_NAME}.${EXTENSION}" echo rm -f ${TARGET_NAME}/${TAR_NAME}.${EXTENSION} -case $EXTENSION in -'tgz' | 'tar.gz' ) - $TAR cvf - . | gzip -9c > ${TARGET_NAME}/${TAR_NAME}.${EXTENSION} - ERRCODE=$? - if [ ! $? = 0 ]; then - echo "ERROR: gzip returned error code $? -- makepkg failed." - fi - ;; -'tbz' | 'tar.bz2' ) - $TAR cvf - . | bzip2 -9c > ${TARGET_NAME}/${TAR_NAME}.${EXTENSION} - ERRCODE=$? - if [ ! $ERRCODE = 0 ]; then - echo "ERROR: bzip2 returned error code $ERRCODE -- makepkg failed." - fi - ;; -'tlz' | 'tar.lzma' ) - $TAR cvf - . | lzma -c > ${TARGET_NAME}/${TAR_NAME}.${EXTENSION} - ERRCODE=$? - if [ ! $ERRCODE = 0 ]; then - echo "ERROR: lzma returned error code $ERRCODE -- makepkg failed." - fi - ;; -'txz' | 'tar.xz' ) - $TAR cvf - . | xz -c > ${TARGET_NAME}/${TAR_NAME}.${EXTENSION} - ERRCODE=$? - if [ ! $ERRCODE = 0 ]; then - echo "ERROR: xz returned error code $ERRCODE -- makepkg failed." - fi - ;; -esac + +# HISTORICAL NOTE 2/2018: +# In the interest of maximizing portability of this script, we'll use find +# and sed to create a filelist compatible with tar-1.13, and then use a +# more modern tar version to create the archive. +# +# Other (but possibly less portable) ways to achieve the same result: +# +# Use the tar --transform and --show-transformed-names options: +# tar --transform "s,^\./\(.\),\1," --show-transformed-names $ACLS $XATTRS -cvf - . | $COMPRESSOR > ${TARGET_NAME}/${TAR_NAME}.${EXTENSION} +# +# Use cpio: +# find ./ | sed '2,$s,^\./,,' | cpio --quiet -ovHustar > ${TARGET_NAME}/${TAR_NAME}.tar + +# Create the package: +find ./ | sed '2,$s,^\./,,' | tar --no-recursion $ACLS $XATTRS -T - -cvf - | $COMPRESSOR > ${TARGET_NAME}/${TAR_NAME}.${EXTENSION} +ERRCODE=$? +if [ ! $ERRCODE = 0 ]; then + echo "ERROR: $COMPRESSOR returned error code $ERRCODE -- makepkg failed." + exit 1 +fi # Warn of zero-length files: find . -type f -size 0c | while read file ; do diff --git a/source/a/pkgtools/scripts/pkgdiff b/source/a/pkgtools/scripts/pkgdiff new file mode 100644 index 000000000..ca21ad8f2 --- /dev/null +++ b/source/a/pkgtools/scripts/pkgdiff @@ -0,0 +1,164 @@ +#!/bin/sh +# Copyright 2002 Patrick J. Volkerding, Concord, CA, USA +# Copyright 2018 Patrick J. Volkerding, Sebeka, Minnesota, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +CWD=$(pwd) + +# Display usage for basic usage errors: +usage() { + cat << EOF +pkgdiff: missing file arguments +Try 'pkgdiff --help' for more information. +EOF +} + +# Display full --help if requested: +helpme() { + cat << EOF +Usage: pkgdiff [OPTION] FILE1 FILE2 +Show which files are new and which are removed between two tar archives. +The tar archives may be uncompressed, or compressed with gzip, bzip2, +xz, or lzip. Also works with .rpm and .deb. + + --help display this help and exit + -c use ANSI color with default tree mode + -a show simple text (ASCII) diff of package file lists + +By default, the trees are drawn with in crude ASCII with no color. For +the full-color effect, try something like this: + + pkgdiff -c package1 package2 | less -r + +EOF + # --help doesn't return + exit 22 +} + +# How the heck do I open this? +explode() { + tar xf $1 1> /dev/null 2> /dev/null + # Check for common extensions and do additional magic: + if [ ! "$(basename $1)" = "$(basename $1 .zip)" ]; then + unzip $1 1> /dev/null 2> /dev/null + fi + if [ ! "$(basename $1)" = "$(basename $1 .rpm)" ]; then + cp $1 . + rpm2tgz $(basename $1) 1> /dev/null 2> /dev/null + rm -f $(basename $1) + tar xzf $(basename $1 .rpm).tgz 1> /dev/null 2> /dev/null + rm -f $(basename $1 .rpm).tgz + fi + if [ ! "$(basename $1)" = "$(basename $1 .deb)" ]; then + cp $1 . + ar x $(basename $1) 1> /dev/null 2> /dev/null + tar xf data.tar.xz 1> /dev/null 2> /dev/null + rm -f * 2> /dev/null + fi + # Diffs for other archive formats are welcome. +} + +# Parse options. +# -c turns on colorization ala dircolors: +unset COLOR +if [ "$1" = "-c" ]; then + COLOR="-C" + shift 1 +fi +if [ "$1" = "-a" ]; then + ASCII=true + shift 1 +fi +if [ "$1" = "--help" ]; then + helpme +fi + +TMPDIR=$(mktemp -d) +cd $TMPDIR + +if [ ! -r "$1" ]; then + if [ -d "$CWD/$1" ]; then + usage + exit 99 + else + PKG1="$CWD/$1" + fi +else + PKG1="$1" +fi + +if [ ! -r "$2" ]; then + if [ -d "$CWD/$2" ]; then + usage + #echo "pkgdiff -- find the difference between two tar archives" + #echo "usage: pkgdiff [ -C ] pkg1 pkg2" + exit 99 + else + PKG2="$CWD/$2" + fi +else + PKG2="$2" +fi + +# We have to account for the possibility that the packages have the +# same name, but different contents... +if [ "$(basename $PKG1)" = "$(basename $PKG2)" ]; then + PKG1=${PKG1}.orig +fi + +# This will be mighty safe even if we ended up in /tmp. +PKG=.pkgdiff.$(mcookie) + +( mkdir -p $TMPDIR/$PKG/1 + cd $TMPDIR/$PKG/1 + if [ -r $PKG1 ]; then + explode $PKG1 + elif [ -r $(dirname $PKG1)/$(basename $PKG1 .orig) ]; then + explode $(dirname $PKG1)/$(basename $PKG1 .orig) + fi + if [ ! "$ASCII" = "true" ]; then + tree $COLOR -a --noreport > ../$(basename $PKG1) + else + find ./ | sed '2,$s,^\./,,' | tar --no-recursion -T - -cf - | tar tf - | sort > ../$(basename $PKG1) + fi +) +( mkdir -p $TMPDIR/$PKG/2 + cd $TMPDIR/$PKG/2 + explode $PKG2 + if [ ! "$ASCII" = "true" ]; then + tree $COLOR -a --noreport > ../$(basename $PKG2) + else + find ./ | sed '2,$s,^\./,,' | tar --no-recursion -T - -cf - | tar tf - | sort > ../$(basename $PKG2) + fi +) + +# Always going that extra mile... ;) +if [ -r $PKG1 ]; then + touch -r $PKG1 $TMPDIR/$PKG/$(basename $PKG1) +elif [ -r $(dirname $PKG1)/$(basename $PKG1 .orig) ]; then + touch -r $(dirname $PKG1)/$(basename $PKG1 .orig) $TMPDIR/$PKG/$(basename $PKG1) +fi +touch -r $PKG2 $TMPDIR/$PKG/$(basename $PKG2) + +rm -rf $TMPDIR/$PKG/{1,2} +( cd $TMPDIR/$PKG ; diff -d -u $(basename $PKG1) $(basename $PKG2) ) + +# cleanup: +rm -rf $PKG $TMPDIR diff --git a/source/a/pkgtools/scripts/pkgtool b/source/a/pkgtools/scripts/pkgtool index fd77f2980..000bb0020 100644 --- a/source/a/pkgtools/scripts/pkgtool +++ b/source/a/pkgtools/scripts/pkgtool @@ -3,7 +3,7 @@ # 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, 2015 Patrick Volkerding, Sebeka, MN, USA +# Copyright 2007, 2009, 2010, 2011, 2013, 2015, 2016 Patrick Volkerding, Sebeka, MN, USA # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: @@ -13,7 +13,7 @@ # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; @@ -43,15 +43,6 @@ # 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() { @@ -86,7 +77,7 @@ if [ -L /bin/chmod -a -L /bin/chown ]; then # probably on the bootdisk using bus echo echo echo "You can't run pkgtool from the rootdisk until you've mounted your Linux" - echo "partitions beneath /mnt. Here are some examples:" + echo "partitions beneath /mnt. Here are some examples:" echo echo "If your root partition is /dev/sda1 you would type:" echo "mount /dev/sda1 /mnt" @@ -220,12 +211,11 @@ 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.2)" \ + dialog --title "Slackware Package Tool (pkgtool version 15.0)" \ --menu "\nWelcome to the Slackware package tool.\n\ -\nWhich option would you like?\n" 17 75 7 \ +\nWhich option would you like?\n" 16 75 6 \ "Current" "Install packages from the current directory" \ "Other" "Install packages from some other directory" \ -"Floppy" "Install packages from floppy disks" \ "Remove" "Remove packages that are currently installed" \ "View" "View the list of files contained in a package" \ "Setup" "Choose Slackware installation scripts to run again" \ @@ -243,7 +233,7 @@ else # there were no arguments, so we'll get the needed information from the fi if [ "$REPLY" = "Setup" ]; then echo 'dialog --title "SELECT SYSTEM SETUP SCRIPTS" --item-help --checklist \ - "Please use the spacebar to select the setup scripts to run. Hit enter when you \ + "Please use the spacebar to select the setup scripts to run. Hit enter when you \ are done selecting to run the scripts." 17 70 9 \' > $TMP/setupscr for script in $ADM_DIR/setup/setup.* ; do BLURB=$(grep '#BLURB' $script | cut -b8-) @@ -273,10 +263,10 @@ create_list_of_installed_packages #Pkgtool scans your system to determine which packages you have \ #installed and prepares a list for you." 0 0 ( - echo 'dialog $DEFITEM --item-help --menu "Please select the package you wish to view." 17 68 10 \ - --file $TMP/list_of_installed_packages \' - echo "2> $TMP/return" + echo 'dialog $DEFITEM --item-help --menu "Please select the package you wish to view." 17 68 10 \' ) > $TMP/viewscr + cat $TMP/list_of_installed_packages >> $TMP/viewscr + echo "2> $TMP/return" >> $TMP/viewscr while [ 0 ]; do . $TMP/viewscr if [ ! "$(cat $TMP/return)" = "" ]; then @@ -306,11 +296,11 @@ dialog --title "SELECT PACKAGES TO REMOVE" --item-help --checklist \ "Please select the \ packages you wish to Remove. Use the \ spacebar to select packages to delete, and the UP/DOWN arrow keys to \ -scroll up and down through the entire list." 20 75 11 \ ---file $TMP/temporary_list \\ +scroll up and down through the entire list." 20 75 11 \\ EOF - echo "2> $TMP/return" ) > $TMP/rmscript + cat $TMP/temporary_list >> $TMP/rmscript + echo "2> $TMP/return" >> $TMP/rmscript if [ -L $LOG -o -r $LOG ]; then rm -f $LOG fi @@ -334,39 +324,6 @@ in $TMP: PKGTOOL.REMOVED." 0 0 chmod 1777 /tmp # No, return to the main menu: # exit - elif [ "$REPLY" = "Floppy" ]; then - dialog --title "SELECT FLOPPY DRIVE" --menu "Which floppy drive would \ -you like to install from?" \ -11 70 4 \ -"/dev/fd0u1440" "1.44 MB first floppy drive" \ -"/dev/fd1u1440" "1.44 MB second floppy drive" \ -"/dev/fd0h1200" "1.2 MB first floppy drive" \ -"/dev/fd1h1200" "1.2 MB second floppy drive" 2> $TMP/wdrive - if [ $? = 1 ]; then - dialog --clear - exit - fi - SOURCE_DEVICE="$(cat $TMP/wdrive)" - rm -f $TMP/wdrive - cat << EOF > $TMP/tmpmsg - -Enter the names of any disk sets you would like to install. -Separate the sets with a space, like this: a b oi x - -To install packages from one disk, hit [enter] without typing -anything. - -EOF - dialog --title "SOFTWARE SELECTION" --inputbox "$(cat $TMP/tmpmsg)" 13 70 2> $TMP/sets - DISK_SETS="$(cat $TMP/sets)" - rm -f $TMP/sets - if [ "$DISK_SETS" = "" ]; then - DISK_SETS="disk" - else - DISK_SETS=$(echo $DISK_SETS | sed 's/ /#/g') - DISK_SETS="#$DISK_SETS" - fi - break; elif [ "$REPLY" = "Other" ]; then dialog --title "SELECT SOURCE DIRECTORY" --inputbox "Please enter the name of the directory that you wish to \ install packages from:" 10 50 2> $TMP/pkgdir @@ -562,7 +519,7 @@ install_disk() { fi # ! "$DISK_SETS" = "disk" - # It's possible that the tagfile was specified on the command line. If that's + # It's possible that the tagfile was specified on the command line. If that's # the case, then we'll just override whatever we figured out up above. if [ ! "$USETAG" = "" ]; then cat $USETAG > $TMP/tagfile diff --git a/source/a/pkgtools/scripts/removepkg b/source/a/pkgtools/scripts/removepkg index 2813fc3c5..14af10f37 100644 --- a/source/a/pkgtools/scripts/removepkg +++ b/source/a/pkgtools/scripts/removepkg @@ -1,6 +1,50 @@ #!/bin/sh # Slackware remove package script # +# Copyright 1994, 1995, 1998 Patrick Volkerding, Moorhead, Minnesota USA +# Copyright 2001, Slackware Linux, Inc., Concord, CA USA +# Copyright 2009, 2015, 2016 Patrick J. Volkerding, Sebeka, MN, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# Sun May 27 18:02:23 UTC 2018 +# Added --terse mode to print one line per removed package. +# +# Wed May 23 17:31:23 UTC 2018 +# Use file locking to prevent more than one copy of ldconfig from running at +# a time. +# +# Thu Sep 15 17:46:28 UTC 2016 <volkerdi> +# If removepkg is called with a short package name (no -$VERSION-$ARCH-$BUILD), +# remove the most recently installed matching package, not the oldest one. +# +# Thu Sep 15 08:09:01 BST 2016 <mozes> +# - Handle finding >1 match for a package. Thanks to SeB on LQ for the feedback. +# +# Wed Sep 14 20:44:00 BST 2016 <mozes> +# - Modify package_name function to cater for package file names that contain +# >=4 hyphens. +# Thanks to coralfang on LQ for the report and to Jim Hawkins for the patch. +# - Modified to handle packages that contain file names with backslashes +# Thanks to aaazen on LQ for the report and the patch. +# # Thu Sep 24 03:31:58 UTC 2015 <alphageek> # extract_links() sed adjusted to handle symlinks with spaces. # @@ -76,28 +120,8 @@ # Original Version from Slackware 3.0 # -# Copyright 1994, 1995, 1998 Patrick Volkerding, Moorhead, Minnesota USA -# Copyright 2001, Slackware Linux, Inc., Concord, CA USA -# Copyright 2009, 2015 Patrick J. Volkerding, Sebeka, MN, USA -# All rights reserved. -# -# Redistribution and use of this script, with or without modification, is -# permitted provided that the following conditions are met: -# -# 1. Redistributions of this script must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# +# Needed to find package names within the 'remove_packages' function: +shopt -s extglob # Return a package name that has been stripped of the dirname portion # and any of the valid extensions (only): @@ -120,6 +144,13 @@ fi ADM_DIR=$ROOT/var/log PRES_DIR=$TMP/preserved_packages +# Lock directory for ldconfig... share it with installpkg so that upgradepkg +# becomes properly ldconfig-locked, too. +INSTLOCKDIR=${INSTLOCKDIR:-/run/installpkg-lock} +if [ ! -d $INSTLOCKDIR ]; then + mkdir -p $INSTLOCKDIR +fi + # This simple cat_except() should be used on the installer, # since the busybox "find" can't handle the complex find # syntax: @@ -131,8 +162,8 @@ PRES_DIR=$TMP/preserved_packages # removed when ROOT= is used: cat_except() { ( cd "$1" && \ - if [ $(find . -type f -maxdepth 1 | wc -l) -ne 1 ]; then - cat $(find . -type f -maxdepth 1 | grep -v "$2") + if [ $(find . -type f -maxdepth 1 2> /dev/null | wc -l) -ne 1 ]; then + cat $(find . -type f -maxdepth 1 2> /dev/null | grep -v "$2") 2> /dev/null fi ) } @@ -166,11 +197,11 @@ keep_files() { while read FILE ; do if [ ! -d "$ROOT/$FILE" ]; then if [ -r "$ROOT/$FILE" ]; then - echo " --> $ROOT/$FILE was found in another package. Skipping." + ! [ $TERSE ] && 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." + ! [ $TERSE ] && echo "WARNING: Nonexistent $ROOT/$FILE was found in another package. Skipping." fi fi else @@ -182,29 +213,31 @@ keep_files() { keep_links() { while read LINK ; do if [ -L "$ROOT/$LINK" ]; then - echo " --> $ROOT/$LINK (symlink) was found in another package. Skipping." + ! [ $TERSE ] && echo " --> $ROOT/$LINK (symlink) was found in another package. Skipping." else - echo "WARNING: Nonexistent $ROOT/$LINK (symlink) was found in another package. Skipping." + ! [ $TERSE ] && echo "WARNING: Nonexistent $ROOT/$LINK (symlink) was found in another package. Skipping." fi done } delete_files() { - while read FILE ; do + local unset LC_ALL # Locally (within this delete_files function) allow handling of backslashes + while read -r AFILE ; do # do not expand backslashes on read + FILE=$(printf "%b" "$AFILE") # unescape octal characters if [ ! -d "$ROOT/$FILE" ]; then if [ -r "$ROOT/$FILE" ]; then if [ "$ROOT/$FILE" -nt "$ADM_DIR/packages/$PKGNAME" ]; then - echo "WARNING: $ROOT/$FILE changed after package installation." + ! [ $TERSE ] && echo "WARNING: $ROOT/$FILE changed after package installation." fi if [ ! "$WARN" = "true" ]; then - echo " --> Deleting $ROOT/$FILE" + ! [ $TERSE ] && echo " --> Deleting $ROOT/$FILE" preserve_file "$FILE" && rm -f "$ROOT/$FILE" else - echo " --> $ROOT/$FILE would be deleted" + ! [ $TERSE ] && echo " --> $ROOT/$FILE would be deleted" preserve_file "$FILE" fi else - echo " --> $ROOT/$FILE no longer exists. Skipping." + ! [ $TERSE ] && echo " --> $ROOT/$FILE no longer exists. Skipping." fi else preserve_dir "$FILE" @@ -216,13 +249,13 @@ delete_links() { while read LINK ; do if [ -L "$ROOT/$LINK" ]; then if [ ! "$WARN" = "true" ]; then - echo " --> Deleting symlink $ROOT/$LINK" + ! [ $TERSE ] && echo " --> Deleting symlink $ROOT/$LINK" rm -f "$ROOT/$LINK" else - echo " --> $ROOT/$LINK (symlink) would be deleted" + ! [ $TERSE ] && echo " --> $ROOT/$LINK (symlink) would be deleted" fi else - echo " --> $ROOT/$LINK (symlink) no longer exists. Skipping." + ! [ $TERSE ] && echo " --> $ROOT/$LINK (symlink) no longer exists. Skipping." fi done } @@ -233,13 +266,13 @@ delete_dirs() { 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" + ! [ $TERSE ] && echo " --> Deleting empty directory $ROOT/$DIR" rmdir "$ROOT/$DIR" else - echo "WARNING: Unique directory $ROOT/$DIR contains new files" + ! [ $TERSE ] && echo "WARNING: Unique directory $ROOT/$DIR contains new files" fi else - echo " --> $ROOT/$DIR (dir) would be deleted if empty" + ! [ $TERSE ] && echo " --> $ROOT/$DIR (dir) would be deleted if empty" fi fi done @@ -250,33 +283,21 @@ delete_cats() { while read FILE ; do if [ -f "$ROOT/$FILE" ]; then if [ ! "$WARN" = "true" ]; then - echo " --> Deleting $ROOT/$FILE (fmt man page)" + ! [ $TERSE ] && echo " --> Deleting $ROOT/$FILE (fmt man page)" rm -f $ROOT/$FILE else - echo " --> $ROOT/$FILE (fmt man page) would be deleted" + ! [ $TERSE ] && echo " --> $ROOT/$FILE (fmt man page) would be deleted" fi fi done } -package_name() { - 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 - echo $STRING -} - # Conversion to 'comm' utility by Mark Wisdom. # is pretty nifty! :^) remove_packages() { - for PKGLIST in $* + for PKGLIST in $* do PKGNAME=$(pkgbase $PKGLIST) - 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, @@ -285,24 +306,22 @@ remove_packages() { # be removed. If you want to remove them all, you'll need to run # removepkg again until it removes all the same-named packages. if [ ! -e $ADM_DIR/packages/$PKGNAME ]; then - SHORT="$(package_name $PKGNAME)" - for long_package in $ADM_DIR/packages/${PKGNAME}* ; do - if [ "$SHORT" = "$(package_name $long_package)" ]; then - PKGNAME="$(basename $long_package)" - fi - done - fi - - if [ ! -e $ADM_DIR/packages/$PKGNAME ]; then - long_package=$(ls -1 $ADM_DIR/packages/${PKGNAME}* | grep -m 1 "^${PKGNAME}-[^-]*-[^-]*-[^-]*$") - if [ -e "$long_package" ]; then - PKGNAME=$(basename $long_package) + # Short name not found - finally try looking for full name - e.g. foo-1.0-arm-1 + pushd $ADM_DIR/packages > /dev/null + # Don't set PKGNAME if there are no matches: + if [ ! "$( ls -1 $PKGNAME-+([^-])-+([^-])-+([^-]) 2>/dev/null | wc -l )" = "0" ]; then + # If there is more than one package with the same name, set PKGNAME to the + # most recently installed version. This does not affect the behavior of + # upgradepkg, which always removes all other existing versions of the + # same package. + PKGNAME=$( ls -1t $PKGNAME-+([^-])-+([^-])-+([^-]) 2> /dev/null | head -n1 ) fi + popd > /dev/null fi if [ -r $ADM_DIR/packages/$PKGNAME ]; then if [ ! "$WARN" = true ]; then - echo "Removing package $ADM_DIR/packages/$PKGNAME..." + echo "Removing package: $(basename $ADM_DIR/packages/$PKGNAME)" fi if fgrep "./" $ADM_DIR/packages/$PKGNAME 1> /dev/null 2>&1; then TRIGGER="^\.\/" @@ -310,7 +329,7 @@ remove_packages() { TRIGGER="FILE LIST:" fi if [ ! "$WARN" = true ]; then - echo "Removing files:" + ! [ $TERSE ] && echo "Removing files:" fi sed -n "/$TRIGGER/,/^$/p" < $ADM_DIR/packages/$PKGNAME | \ fgrep -v "FILE LIST:" | sort -u > $TMP/delete_list$$ @@ -325,7 +344,7 @@ remove_packages() { comm -12 $TMP/del_link_list$$ $TMP/required_list$$ | keep_links comm -23 $TMP/del_link_list$$ $TMP/required_list$$ | delete_links else - cat $ADM_DIR/scripts/* | extract_links | \ + cat $ADM_DIR/scripts/* 2> /dev/null | extract_links | \ sort -u > $TMP/required_links$$ mv $TMP/required_list$$ $TMP/required_files$$ sort -u $TMP/required_links$$ $TMP/required_files$$ >$TMP/required_list$$ @@ -348,22 +367,27 @@ remove_packages() { fi fi if [ ! "$WARN" = "true" ]; then - for DIR in $ADM_DIR/removed_packages $ADM_DIR/removed_scripts ; do - if [ ! -d $DIR ] ; then mkdir -p $DIR ; chmod 755 $DIR ; fi - done + mkdir -p $ADM_DIR/removed_packages $ADM_DIR/removed_scripts mv $ADM_DIR/packages/$PKGNAME $ADM_DIR/removed_packages if [ -r $ADM_DIR/scripts/$PKGNAME ]; then mv $ADM_DIR/scripts/$PKGNAME $ADM_DIR/removed_scripts fi fi else - echo "No such package: $ADM_DIR/packages/$PKGNAME. Can't remove." + echo "No such package: $(basename $ADM_DIR/packages/$PKGNAME). Can't remove." + fi + # In the case where a library and symlink are removed but an earlier version + # remains on the machine, this will link it up and save potential problems: + if [ "$ROOT" = "" ] && [ -x /sbin/ldconfig ]; then + ( flock 9 || exit 11 + /sbin/ldconfig 2> /dev/null + ) 9> $INSTLOCKDIR/ldconfig.lock fi done } if [ "$#" = "0" ]; then - echo "Usage: $(basename $0) [-copy] [-keep] [-preserve] [-warn] packagename ..."; exit 1 + echo "Usage: $(basename $0) [--copy] [--keep] [--preserve] [--terse] [--warn] packagename ..."; exit 1 fi while : ; do @@ -371,6 +395,7 @@ while : ; do -copy | --copy) WARN=true; PRESERVE=true; shift;; -keep | --keep) KEEP=true; shift;; -preserve | --preserve) PRESERVE=true; shift;; + -terse | --terse) TERSE=0; shift;; -warn | --warn) WARN=true; shift;; -* | --*) echo "Usage: $(basename $0) [-copy] [-keep] [-preserve] [-warn] packagename ..."; exit 1;; *) break @@ -378,6 +403,7 @@ while : ; do done if [ "$WARN" = "true" ]; then + unset TERSE echo "Only warning... not actually removing any files." if [ "$PRESERVE" = "true" ]; then echo "Package contents is copied to $PRES_DIR." @@ -392,4 +418,3 @@ else fi remove_packages $* - diff --git a/source/a/pkgtools/scripts/setup.80.make-bootdisk b/source/a/pkgtools/scripts/setup.80.make-bootdisk index 1f0202a53..c1753bc59 100644 --- a/source/a/pkgtools/scripts/setup.80.make-bootdisk +++ b/source/a/pkgtools/scripts/setup.80.make-bootdisk @@ -27,7 +27,7 @@ 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 + "Master Boot Record file mbr.bin not found. This script requires that the syslinux package is installed." 6 60 exit fi @@ -47,12 +47,12 @@ 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\ +Please insert a USB flash memory stick and then press ENTER to create a boot stick. \n\ \n\ -WARNING! The existing contents of the USB stick will be erased. \n\ +WARNING! The existing contents of the USB stick will be erased. \n\ " 18 70 2 \ "Create" "Make a USB Linux boot stick" \ "Skip" "Skip making a USB boot stick" \ @@ -98,7 +98,7 @@ otherwise select 'No'." 12 70 dialog --title "CREATING USB BOOT STICK" --infobox "Creating SYSLINUX bootdisk for \ $ROOT_DEVICE on /dev/$STICK." 3 64 - # Create a 16M partition with FAT16. This should be large enough for any kernel (for now). + # 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 @@ -152,15 +152,15 @@ EOF Welcome to the 09Slackware07 Linux custom USB boot stick! By default, this stick boots a root Linux partition on $ROOT_DEVICE when you -hit ENTER. If you'd like to boot some other partition, use a command like +hit ENTER. If you'd like to boot some other partition, use a command like this on the prompt below: mount root=/dev/sda1 ro Where "/dev/sda1" is the partition you want to boot, and "ro" specifies that -the partition should be initially mounted as read-only. If you wish to mount -the partition read-write, use "rw" instead. To set the video console mode, -use the vga= parameter (press F1 to see a table). You may also add any other +the partition should be initially mounted as read-only. If you wish to mount +the partition read-write, use "rw" instead. To set the video console mode, +use the vga= parameter (press F1 to see a table). You may also add any other kernel parameters you might need depending on your hardware, and which drivers are included in your kernel. @@ -187,7 +187,7 @@ EOF FRAMEBUFFER MODES: To get the kernel to start in VESA framebuffer mode, you need to pass it - a vga= init string on the "boot:" prompt. Here's a table: + a vga= init string on the "boot:" prompt. Here's a table: Colors 640x480 800x600 1024x768 1280x1024 1600x1200 --------+--------------------------------------------- @@ -210,14 +210,14 @@ EOF Welcome to the Slackware Linux custom USB boot stick! By default, this stick boots a root Linux partition on $ROOT_DEVICE when you -hit ENTER. If you'd like to boot some other partition, use a command like +hit ENTER. If you'd like to boot some other partition, use a command like this on the prompt below: huge.s root=/dev/sda1 ro Where "/dev/sda1" is the partition you want to boot, and "ro" specifies that -the partition should be initially mounted as read-only. If you wish to mount -the partition read-write, use "rw" instead. You may also add any other +the partition should be initially mounted as read-only. If you wish to mount +the partition read-write, use "rw" instead. You may also add any other kernel parameters you might need depending on your hardware, and which drivers are included in your kernel. @@ -248,7 +248,7 @@ EOF exit fi dialog --title "USB BOOT STICK CREATED" --ok-label Continue --cancel-label Create --menu \ -"The USB boot stick has been successfully created on device /dev/$STICK. If you would like to \ +"The USB boot stick has been successfully created on device /dev/$STICK. If you would like to \ create an additional boot stick, please select 'Create' and we'll go back and make another \ one, otherwise select 'Continue' to continue configuring your system." 12 71 2 \ "Continue" "Continue the configuration (done making boot sticks)" \ diff --git a/source/a/pkgtools/scripts/setup.htmlview b/source/a/pkgtools/scripts/setup.htmlview index 2fd9930a7..980391003 100644 --- a/source/a/pkgtools/scripts/setup.htmlview +++ b/source/a/pkgtools/scripts/setup.htmlview @@ -2,21 +2,21 @@ #BLURB="Set a default browser link." # Sorry, this is not a full menu, and may not ever be. # It is trivial to find the htmllink symbolic link and -# point it at the browser that you like. Besides, +# point it at the browser that you like. Besides, # this is not a Linux standard that could be locating -# in any official document. It seems to have been +# in any official document. It seems to have been # started without any consultation with other # distributions by <take a wild guess>, and now things # expect it to be there. # # -# Note 1. Listing a browser doesn't mean we ship it. -# Note 2. Complaints about our preferences or missing -# browsers in the list will be considered. -# Yell at Pat about it. ;-) +# Note 1. Listing a browser doesn't mean we ship it. +# Note 2. Complaints about our preferences or missing +# browsers in the list will be considered. +# Yell at Pat about it. ;-) # There must be no link, or we assume the admin set it and -# do nothing. Can you tell this Q+D script was written for +# do nothing. Can you tell this Q+D script was written for # the initial installation? for browser in firefox seamonkey konqueror galeon epiphany links lynx ; do diff --git a/source/a/pkgtools/scripts/setup.services b/source/a/pkgtools/scripts/setup.services index f700a8df4..b57ad33fa 100644 --- a/source/a/pkgtools/scripts/setup.services +++ b/source/a/pkgtools/scripts/setup.services @@ -10,12 +10,12 @@ rm -f $TMP/tmpscript cat << EOF > $TMP/tmpscript dialog --title "CONFIRM STARTUP SERVICES TO RUN" --item-help --checklist \\ -"The selected services will be started at boot time. If you \\ +"The selected services will be started at boot time. If you \\ don't need them, you may unselect them to turn them off (which may improve \\ -overall system security). You may also choose to start services that are \\ -not run by default, but be aware that more services means less security. \\ -Use the spacebar to select or unselect the services you wish to run. \\ -Recommended choices have been preselected. \\ +overall system security). You may also choose to start services that are \\ +not run by default, but be aware that more services means less security. \\ +Use the spacebar to select or unselect the services you wish to run. \\ +Recommended choices have been preselected. \\ Press the ENTER key when you are finished." \\ 20 75 7 \\ EOF @@ -64,6 +64,17 @@ if [ -r etc/rc.d/rc.dnsmasq ]; then EOF fi +if [ -r etc/rc.d/rc.dovecot ]; then + if [ -x etc/rc.d/rc.dovecot ]; then + RC_DOVECOT=on + else + RC_DOVECOT=off + fi + cat << EOF >> $TMP/tmpscript + "rc.dovecot" "Dovecot IMAP/POP3 server" $RC_DOVECOT "Dovecot provides remote mailbox access for email clients." \\ +EOF +fi + if [ -r etc/rc.d/rc.fuse ]; then if [ -x etc/rc.d/rc.fuse ]; then RC_FUSE=on @@ -185,6 +196,17 @@ if [ -r etc/rc.d/rc.pcmcia ]; then EOF fi +if [ -r etc/rc.d/rc.postfix ]; then + if [ -x etc/rc.d/rc.postfix ]; then + RC_POSTFIX=on + else + RC_POSTFIX=off + fi + cat << EOF >> $TMP/tmpscript + "rc.postfix" "The Postfix mail server" $RC_POSTFIX "The Postfix server allows your machine to send and receive mail." \\ +EOF +fi + if [ -r etc/rc.d/rc.rpc ]; then if [ -x etc/rc.d/rc.rpc ]; then RC_RPC=on @@ -229,6 +251,17 @@ if [ -r etc/rc.d/rc.sendmail ]; then EOF fi +if [ -r etc/rc.d/rc.smartd ]; then + if [ -x etc/rc.d/rc.smartd ]; then + RC_SMARTD=on + else + RC_SMARTD=off + fi + cat << EOF >> $TMP/tmpscript + "rc.smartd" "SMART monitoring daemon" $RC_SMARTD "The SMART daemon monitors your hard drives to help predict failures." \\ +EOF +fi + if [ -r etc/rc.d/rc.snmpd ]; then if [ -x etc/rc.d/rc.snmpd ]; then RC_SNMPD=on @@ -273,7 +306,7 @@ if [ ! $? = 0 ]; then exit fi -for service in rc.atalk rc.bind rc.cups rc.dnsmasq rc.fuse rc.hald rc.hplip rc.httpd rc.inetd rc.ip_forward rc.lprng rc.messagebus rc.mysqld rc.ntpd rc.pcmcia rc.rpc rc.samba rc.saslauthd rc.snmpd rc.sendmail rc.syslog rc.sshd ; do +for service in rc.atalk rc.bind rc.cups rc.dovecot rc.dnsmasq rc.fuse rc.hald rc.hplip rc.httpd rc.inetd rc.ip_forward rc.lprng rc.messagebus rc.mysqld rc.ntpd rc.pcmcia rc.postfix rc.rpc rc.samba rc.saslauthd rc.smartd rc.snmpd rc.sendmail rc.syslog rc.sshd ; do if [ -f etc/rc.d/$service ]; then if grep -w $service $TMP/reply 1> /dev/null ; then chmod 755 etc/rc.d/$service diff --git a/source/a/pkgtools/scripts/upgradepkg b/source/a/pkgtools/scripts/upgradepkg index 5e0299806..f943f9360 100644 --- a/source/a/pkgtools/scripts/upgradepkg +++ b/source/a/pkgtools/scripts/upgradepkg @@ -13,7 +13,7 @@ # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; @@ -22,24 +22,32 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -# Modified to handle either old 8.3 or new package-version-arch-build.tgz -# packages, Sat Nov 17 14:25:58 PST 2001 volkerdi +# Thu May 24 20:23:55 UTC 2018 +# Added --terselength option to set the line length in --terse mode. +# Use a lockfile to prevent output collisions in --terse mode. # -# Rewritten to clean out _all_ old packages of a given basename, not just -# the first one found, Thu Apr 4 01:01:05 PST 2002 volkerdi +# Wed May 23 03:35:28 UTC 2018 +# Added --terse, which limits screen output to one line per package. # -# Added --install-new and --reinstall, Fri May 31 14:11:14 PDT 2002 volkerdi -# Added --dry-run, Sat Apr 26 18:13:29 PDT 2003 +# 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. # # Sat Apr 25 21:18:53 UTC 2009 # 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. +# Added --dry-run, Sat Apr 26 18:13:29 PDT 2003 +# +# Added --install-new and --reinstall, Fri May 31 14:11:14 PDT 2002 volkerdi +# +# Rewritten to clean out _all_ old packages of a given basename, not just +# the first one found, Thu Apr 4 01:01:05 PST 2002 volkerdi +# +# Modified to handle either old 8.3 or new package-version-arch-build.tgz +# packages, Sat Nov 17 14:25:58 PST 2001 volkerdi # Return a package name that has been stripped of the dirname portion # and any of the valid extensions (only): @@ -58,20 +66,20 @@ Usage: upgradepkg newpackage [newpackage2 ... ] upgradepkg 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 +older version to a newer one. It does this by INSTALLING the new package onto the system, and then REMOVING any files from the old package that -aren't in the new package. If the old and new packages have the same -name, a single argument is all that is required. If the packages have +aren't in the new package. If the old and new packages have the same +name, a single argument is all that is required. If the packages have different names, supply the name of the old package followed by a percent -symbol (%), then the name of the new package. Do not add any extra +symbol (%), then the name of the new package. Do not add any extra whitespace between pairs of old/new package names. Before upgrading a package, save any configuration files (such as in /etc) -that you wish to keep. Sometimes these will be preserved, but it depends -on the package. If you want to force new versions of the config files +that you wish to keep. Sometimes these will be preserved, but it depends +on the package. If you want to force new versions of the config files to be installed, remove the old ones manually prior to running upgradepkg. -To upgrade in a directory other than / (such as /mnt): +To upgrade in a directory other than / (such as /mnt): ROOT=/mnt upgradepkg package.tgz (or .tbz, .tlz, .txz) @@ -103,41 +111,71 @@ if [ "$1" = "" -o "$1" = "--help" -o "$1" = "-?" ]; then exit 1; fi -# Arg processing loop. These must come before any packages are listed. +# Create a lockfile directory if it doesn't exist. We can use it to prevent +# output line collisions in --terse mode. +INSTLOCKDIR=${INSTLOCKDIR:-/run/upgradepkg-lock} +if [ ! -d $INSTLOCKDIR ]; then + mkdir -p $INSTLOCKDIR +fi + +# Set default line length for terse mode: +if which tput 1> /dev/null 2> /dev/null ; then + TERSELENGTH=$(tput cols) +else + TERSELENGTH=80 +fi + +# Arg processing loop. These must come before any packages are listed. while [ 0 ]; do - if [ "$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 + 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 - # it to improperly disappear. It does slightly speed things up, though. + # it to improperly disappear. It does slightly speed things up, though. # Don't use it. NOT_PARANOID="true" shift 1 - elif [ "$1" = "--install-new" ]; then + 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" shift 1 + elif [ "$1" = "-terse" -o "$1" = "--terse" ]; then + # Output one line per installed/upgraded package by calling installpkg + # with --terse. Use TERSE=0 for true, so we can check with test. + TERSE=0 + shift 1 + elif [ "$1" = "-terselength" -o "$1" = "--terselength" ]; then + # Set line length in --terse mode: + TERSELENGTH=$2 + shift 2 else # no more args break; fi done # processing args +# A couple not-really-documented features to adjust the behavior of --terse +# mode. These need to be used in addition to --terse, and passed in as +# environment variables. +# PLAINTERSE=0 (This outputs the standard terse line from installpkg, rather +# than prefixing it with "Upgrading:" or "Installing:") +# INFOBOX=0 (This outputs the installpkg --infobox instead of a terse line) + # Here's a function to figure out the package name from one of those -# new long filenames. We'll need this to double check the name of the +# new long filenames. We'll need this to double check the name of the # old package. package_name() { @@ -170,7 +208,7 @@ for ARG; do # Simple package integrity check: if ! [ -f "$NEW" ]; then ERRCODE=4 - echo "Cannot install $ARG: file not found" + ! [ $TERSE ] && echo "Cannot install $ARG: file not found" continue; fi @@ -186,7 +224,7 @@ for ARG; do # 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" + ! [ $TERSE ] && echo "Cannot install $OLD: invalid package extension" continue; fi @@ -204,31 +242,42 @@ for ARG; do 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: + # 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 + ! [ $TERSE ] && echo + ! [ $TERSE ] && echo "Error: there is no installed package named $OLD." + ! [ $TERSE ] && echo " (looking for $ROOT/var/log/packages/$OLD)" + ! [ $TERSE ] && 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 [ $PLAINTERSE ]; then + /sbin/installpkg --terse --terselength $TERSELENGTH $INCOMINGDIR/$NNAME + elif [ $INFOBOX ]; then + /sbin/installpkg --infobox $INCOMINGDIR/$NNAME + elif [ $TERSE ]; then + OUTPUTLINE="$(/sbin/installpkg --terse --terselength $(expr $TERSELENGTH - 12) $INCOMINGDIR/$NNAME)" + ( flock 9 || exit 11 + echo "Installing: ${OUTPUTLINE}" + ) 9> $INSTLOCKDIR/outputline.lock + else + cat << EOF +============================================================================== | Installing new package $INCOMINGDIR/$NNAME +============================================================================== EOF - /sbin/installpkg $INCOMINGDIR/$NNAME + /sbin/installpkg $INCOMINGDIR/$NNAME + fi fi fi continue; @@ -236,9 +285,9 @@ EOF if [ "$DRY_RUN" = "true" ]; then echo "$NEW incoming package not found (command line)." else - echo - echo "Error: incoming package $INCOMINGDIR/$NNAME not found." - echo + ! [ $TERSE ] && echo + ! [ $TERSE ] && echo "Error: incoming package $INCOMINGDIR/$NNAME not found." + ! [ $TERSE ] && echo fi ERRCODE=1 continue; @@ -251,13 +300,15 @@ EOF if [ "$DRY_RUN" = "true" ]; then echo "$NEW would be skipped (already installed)." else - cat << EOF + if ! [ $TERSE ]; then + cat << EOF +============================================================================== | Skipping package $NEW (already installed) +============================================================================== EOF + fi fi continue; fi @@ -292,57 +343,73 @@ EOF done # Print a banner for the current upgrade: - cat << EOF + if ! [ $TERSE ]; then + cat << EOF +============================================================================== | Upgrading $OLD package using $INCOMINGDIR/$NNAME +============================================================================== - EOF - + fi # Next, the new package is pre-installed: if [ "$VERBOSE" = "verbose" ]; then - /sbin/installpkg $INCOMINGDIR/$NNAME - RETCODE=$? + if ! [ $TERSE ]; then + /sbin/installpkg $INCOMINGDIR/$NNAME + RETCODE=$? + else + /sbin/installpkg $INCOMINGDIR/$NNAME 1> /dev/null + RETCODE=$? + fi else - echo "Pre-installing package $NEW..." - /sbin/installpkg $INCOMINGDIR/$NNAME 1> /dev/null - RETCODE=$? + if [ $PLAINTERSE ]; then + /sbin/installpkg --terse --terselength $TERSELENGTH $INCOMINGDIR/$NNAME + elif [ $INFOBOX ]; then + /sbin/installpkg --infobox $INCOMINGDIR/$NNAME + elif [ $TERSE ]; then + OUTPUTLINE="$(/sbin/installpkg --terse --terselength $(expr $TERSELENGTH - 12) $INCOMINGDIR/$NNAME)" + RETCODE=$? + ( flock 9 || exit 11 + echo "Upgrading: ${OUTPUTLINE}" + ) 9> $INSTLOCKDIR/outputline.lock + else + echo "Pre-installing package $NEW..." + /sbin/installpkg $INCOMINGDIR/$NNAME 1> /dev/null + RETCODE=$? + fi 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 "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 + sleep 15 # Skip this package, but still try to proceed. Good luck... continue; fi - # 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 - + ( flock 9 || exit 11 + for rempkg in "$ROOT/var/log/packages/"*"-$TIMESTAMP"; do + if [ "$VERBOSE" = "verbose" ]; then + /sbin/removepkg "${rempkg##*/}" + elif ! [ $TERSE ]; then + /sbin/removepkg "${rempkg##*/}" | grep -v 'Skipping\.\|Removing files:' + else + /sbin/removepkg "${rempkg##*/}" > /dev/null + fi + done + ) 9> $INSTLOCKDIR/removepkg.lock # 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 + if ! [ $TERSE ]; then + /sbin/installpkg $INCOMINGDIR/$NNAME + else + /sbin/installpkg $INCOMINGDIR/$NNAME 1> /dev/null + fi fi - - echo "Package $OLD upgraded with new package $INCOMINGDIR/$NNAME." + ! [ $TERSE ] && echo "Package $OLD upgraded with new package $INCOMINGDIR/$NNAME." ERRCODE=0 done - -if [ ! "$DRY_RUN" = "true" ]; then - echo -fi exit $ERRCODE - |