diff options
author | Patrick J Volkerding <volkerdi@slackware.com> | 2009-08-26 10:00:38 -0500 |
---|---|---|
committer | Eric Hameleers <alien@slackware.com> | 2018-05-31 22:41:17 +0200 |
commit | 5a12e7c134274dba706667107d10d231517d3e05 (patch) | |
tree | 55718d5acb710fde798d9f38d0bbaf594ed4b296 /source/a/pkgtools/scripts | |
download | current-5a12e7c134274dba706667107d10d231517d3e05.tar.gz |
Slackware 13.0slackware-13.0
Wed Aug 26 10:00:38 CDT 2009
Slackware 13.0 x86_64 is released as stable! Thanks to everyone who
helped make this release possible -- see the RELEASE_NOTES for the
credits. The ISOs are off to the replicator. This time it will be a
6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD.
We're taking pre-orders now at store.slackware.com. Please consider
picking up a copy to help support the project. Once again, thanks to
the entire Slackware community for all the help testing and fixing
things and offering suggestions during this development cycle.
As always, have fun and enjoy! -P.
Diffstat (limited to 'source/a/pkgtools/scripts')
-rw-r--r-- | source/a/pkgtools/scripts/explodepkg | 97 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/installpkg | 568 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/makebootdisk | 444 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/makepkg | 347 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/pkgtool | 754 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/removepkg | 430 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/setup.70.install-kernel | 5 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/setup.80.make-bootdisk | 175 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/setup.htmlview | 33 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/setup.services | 287 | ||||
-rw-r--r-- | source/a/pkgtools/scripts/upgradepkg | 387 |
11 files changed, 3527 insertions, 0 deletions
diff --git a/source/a/pkgtools/scripts/explodepkg b/source/a/pkgtools/scripts/explodepkg new file mode 100644 index 00000000..a113b085 --- /dev/null +++ b/source/a/pkgtools/scripts/explodepkg @@ -0,0 +1,97 @@ +#!/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 +# 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. + +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. +Equivalent to (for each package listed): + + ( umask 000 ; cat package_name | COMPRESSOR -dc | tar xzvf 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 +indexes in /var/log/packages and /var/log/scripts. + +EOF +fi + +# Main loop: +for PKG in $* ; do + echo "Exploding package $PKG in current directory:" + # Determine extension: + packageext="$( echo $PKG | rev | cut -f 1 -d . | rev)" + # Determine compression utility: + case $packageext in + 'tgz' ) + packagecompression=gzip + ;; + 'gz' ) + packagecompression=gzip + ;; + 'tbz' ) + packagecompression=bzip2 + ;; + 'bz2' ) + packagecompression=bzip2 + ;; + 'tlz' ) + packagecompression=lzma + ;; + 'lzma' ) + packagecompression=lzma + ;; + 'txz' ) + packagecompression=xz + ;; + 'xz' ) + packagecompression=xz + ;; + esac + ( umask 000 ; cat $PKG | $packagecompression -dc | $TAR xvf - 2> /dev/null ) + if [ -r install/doinst.sh ]; then + echo + echo "An installation script was detected in ./install/doinst.sh, but" + echo "was not executed." + fi +done + diff --git a/source/a/pkgtools/scripts/installpkg b/source/a/pkgtools/scripts/installpkg new file mode 100644 index 00000000..31bb0b71 --- /dev/null +++ b/source/a/pkgtools/scripts/installpkg @@ -0,0 +1,568 @@ +#!/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 +# 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. +# +# Sat Apr 25 21:18:53 UTC 2009 +# Converted to use new pkgbase() function to remove pathname and +# valid package extensions. +# +# Sat Apr 4 22:58:06 CDT 2009 +# Support additional compression formats if the supporting utilities exist: +# .tbz - bzip2 +# .tlz - lzma +# .txz - xz (also LZMA) +# And of course, .tgz (gzip) is not going anywhere. :-) <volkerdi> +# Add command switches to determine the uncompressed package size even if +# that will slow things down, and to add the package's md5sum to the +# metadata stored in /var/log/packages/. +# +# Fri Dec 21 17:21:35 CST 2007 +# Added a patch from Johnny Morano to work around package removal issues +# caused by packages that do not comply with FHS combined with a grep +# regex error in installpkg. Any package with a single-letter top- +# level directory could not be removed. +# +# Shortened some of the top-line dialog output to avoid overflowing the +# textbox (needed as some of the packages, especially in X, have very +# long base package names now). <pjv> +# +# Sun Nov 26 12:38:25 CST 1995 +# Added patch from Glenn Moloney <glenn@physics.unimelb.edu.au> to allow +# packages to be installed to directories other than /. +# +# Wed Mar 18 15:15:51 CST 1998 +# Changed $TMP directory to /var/log/setup/tmp, and chmod'ed it 700 to close +# some security holes. + +# Return a package name that has been stripped of the dirname portion +# and any of the valid extensions (only): +pkgbase() { + PKGEXT=$(echo $1 | rev | cut -f 1 -d . | rev) + case $PKGEXT in + 'tgz' ) + PKGRETURN=$(basename $1 .tgz) + ;; + 'tbz' ) + PKGRETURN=$(basename $1 .tbz) + ;; + 'tlz' ) + PKGRETURN=$(basename $1 .tlz) + ;; + 'txz' ) + PKGRETURN=$(basename $1 .txz) + ;; + *) + PKGRETURN=$(basename $1) + ;; + esac + echo $PKGRETURN +} + +# If installpkg encounters a problem, it will return a non-zero error code. +# If it finds more than one problem (i.e. with a list of packages) you'll only +# hear about the most recent one. :) +# 1 = tar returned error code +# 2 = corrupt compression envelope +# 3 = does not end in .tgz +# 4 = no such file +# 5 = external compression utility missing +# 99 = user abort from menu mode +EXITSTATUS=0 + +# Do not store md5sums by default: +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. + +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 + +usage() { + cat << EOF +Usage: installpkg [options] <package_filename> + +Installpkg is used to install a .t{gz,bz,lz,xz} package like this: + installpkg slackware-package-1.0.0-i486-1.tgz (or .tbz, .tlz, .txz) + +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) + --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 + 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 + the package's directory) + --md5sum (record the package's md5sum in the metadata file) + +EOF +} + +# Eliminate whitespace function: +crunch() { + while read FOO ; do + echo $FOO + done +} + +package_name() { + STRING=$(pkgbase $1) + # Check for old style package name with one segment: + if [ "$(echo $STRING | cut -f 1 -d -)" = "$(echo $STRING | cut -f 2 -d -)" ]; then + echo $STRING + else # has more than one dash delimited segment + # Count number of segments: + INDEX=1 + while [ ! "$(echo $STRING | cut -f $INDEX -d -)" = "" ]; do + INDEX=$(expr $INDEX + 1) + done + INDEX=$(expr $INDEX - 1) # don't include the null value + # If we don't have four segments, return the old-style (or out of spec) package name: + if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then + echo $STRING + else # we have four or more segments, so we'll consider this a new-style name: + NAME=$(expr $INDEX - 3) + NAME="$(echo $STRING | cut -f 1-$NAME -d -)" + echo $NAME + # cruft for later ;) + #VER=$(expr $INDEX - 2) + #VER="$(echo $STRING | cut -f $VER -d -)" + #ARCH=$(expr $INDEX - 1) + #ARCH="$(echo $STRING | cut -f $ARCH -d -)" + #BUILD="$(echo $STRING | cut -f $INDEX -d -)" + fi + fi +} + +# Parse options: +MODE=install # standard text-mode +while [ 0 ]; do + if [ "$1" = "-warn" -o "$1" = "--warn" ]; then + MODE=warn + shift 1 + elif [ "$1" = "-md5sum" -o "$1" = "--md5sum" ]; then + MD5SUM=1 + shift 1 + elif [ "$1" = "-infobox" -o "$1" = "--infobox" ]; then + MODE=infobox + shift 1 + elif [ "$1" = "-menu" -o "$1" = "--menu" ]; then + MODE=menu + shift 1 + elif [ "$1" = "-ask" -o "$1" = "--ask" ]; then + ALWAYSASK="yes" + shift 1 + elif [ "$1" = "-tagfile" -o "$1" = "--tagfile" ]; then + if [ -r "$2" ]; then + USERTAGFILE="$2" + elif [ -r "$(pwd)/$2" ]; then + USERTAGFILE="$(pwd)/$2" + else + usage + exit + fi + shift 2 + elif [ "$1" = "-priority" -o "$1" = "--priority" ]; then + if [ "$2" = "" ]; then + usage + exit + fi + USERPRIORITY="$2" + shift 2 + elif [ "$1" = "-root" -o "$1" = "--root" ]; then + if [ "$2" = "" ]; then + usage + exit + fi + ROOT="$2" + shift 2 + else + break + fi +done + +# Set the prefix for the package database directories (packages, scripts). +ADM_DIR="$ROOT/var/log" +# If the directories don't exist, "initialize" the package database: +for PKGDBDIR in packages removed_packages removed_scripts scripts setup ; do + if [ ! -d $ADM_DIR/$PKGDBDIR ]; then + rm -rf $ADM_DIR/$PKGDBDIR # make sure it's not a symlink or something stupid + mkdir -p $ADM_DIR/$PKGDBDIR + chmod 755 $ADM_DIR/$PKGDBDIR + fi +done + +# Make sure there's a proper temp directory: +TMP=$ADM_DIR/setup/tmp +# If the $TMP directory doesn't exist, create it: +if [ ! -d $TMP ]; then + rm -rf $TMP # make sure it's not a symlink or something stupid + mkdir -p $TMP + chmod 700 $TMP # no need to leave it open +fi + +# usage(), exit if called with no arguments: +if [ $# = 0 ]; then + usage; + exit +fi + +# If -warn mode was requested, produce the output and then exit: +if [ "$MODE" = "warn" ]; then + while [ -f "$1" ]; do + echo "#### Scanning the contents of $1..." + mkdir -p $TMP/scan$$ + # Determine extension: + packageext="$( echo $1 | rev | cut -f 1 -d . | rev)" + # Determine compressor utility: + case $packageext in + 'tgz' ) + packagecompression=gzip + ;; + 'tbz' ) + packagecompression=bzip2 + ;; + 'tlz' ) + packagecompression=lzma + ;; + 'txz' ) + packagecompression=xz + ;; + esac + ( cd $TMP/scan$$ ; $packagecompression -dc | $TAR xf - install ) < $1 2> /dev/null + if [ -r $TMP/scan$$/install/doinst.sh ]; then + if cat $TMP/scan$$/install/doinst.sh | grep ' rm -rf ' 1>/dev/null 2>/dev/null ; then + cat $TMP/scan$$/install/doinst.sh | grep ' rm -rf ' > $TMP/scan$$/install/delete + echo "The following locations will be completely WIPED OUT to allow symbolic" + echo "links to be made. (We're talking 'rm -rf') These locations may be files," + echo "or entire directories. Be sure you've backed up anything at these" + echo "locations that you want to save before you install this package:" + cat $TMP/scan$$/install/delete | cut -f 3,7 -d ' ' | tr ' ' '/' + fi + if [ -d $TMP/scan$$ ]; then + ( cd $TMP/scan$$ ; rm -rf install ) 2> /dev/null + ( cd $TMP ; rmdir scan$$ ) 2> /dev/null + fi + fi + echo "The following files will be overwritten when installing this package." + echo "Be sure they aren't important before you install this package:" + ( $packagecompression -dc | $TAR tvvf - ) < $1 | grep -v 'drwx' + echo + shift 1 + done + exit +fi + +# Main loop: +for package in $* ; do + + # Simple package integrity check: + if [ ! -f $package ]; then + EXITSTATUS=4 + if [ "$MODE" = "install" ]; then + echo "Cannot install $package: file not found" + fi + continue; + fi + + # "shortname" isn't really THAT short... + # it's just the full name without ".t{gz,bz,lz,xz}" + shortname="$(pkgbase $package)" + packagedir="$(dirname $package)" + # This is the base package name, used for grepping tagfiles and descriptions: + packagebase="$(package_name $shortname)" + + # Reject package if it does not end in '.t{gz,bz,lz,xz}': + if [ "$shortname" = "$(basename $package)" ]; then + EXITSTATUS=3 + if [ "$MODE" = "install" ]; then + echo "Cannot install $package: file does not end in .tgz, .tbz, .tlz, or .txz" + fi + continue; + fi + + # Determine extension: + packageext="$(echo $package | rev | cut -f 1 -d . | rev)" + + # Determine compressor utility: + case $packageext in + 'tgz' ) + packagecompression=gzip + ;; + 'tbz' ) + packagecompression=bzip2 + ;; + 'tlz' ) + packagecompression=lzma + ;; + 'txz' ) + packagecompression=xz + ;; + esac + + # Test presence of external compression utility: + if ! $packagecompression --help 1> /dev/null 2> /dev/null ; then + EXITSTATUS=5 + if [ "$MODE" = "install" ]; then + echo "Cannot install $package: external compression utility $packagecompression missing" + fi + continue; + fi + + # Determine package's priority: + unset PRIORITY + if [ "$USERTAGFILE" = "" ]; then + TAGFILE="$packagedir/tagfile" + else + TAGFILE="$USERTAGFILE" + fi + if [ ! -r "$TAGFILE" ]; then + TAGFILE=/dev/null + fi + if grep "^$packagebase:" "$TAGFILE" | grep ADD > /dev/null 2> /dev/null ; then + PRIORITY="ADD" + elif grep "^$packagebase:" "$TAGFILE" | grep REC > /dev/null 2> /dev/null ; then + PRIORITY="REC" + elif grep "^$packagebase:" "$TAGFILE" | grep OPT > /dev/null 2> /dev/null ; then + PRIORITY="OPT" + elif grep "^$packagebase:" "$TAGFILE" | grep SKP > /dev/null 2> /dev/null ; then + PRIORITY="SKP" + fi + if [ "$PRIORITY" = "ADD" ]; then + PMSG="[ADD]" + elif [ "$PRIORITY" = "REC" ]; then + PMSG="[REC]" + elif [ "$PRIORITY" = "OPT" ]; then + PMSG="[OPT]" + elif [ "$PRIORITY" = "SKP" ]; then + PMSG="[SKP]" + else + PMSG="" + fi + + # If a tagfile wants this package to be skipped, do that now before + # wasting any more CPU on it: + if [ "$PRIORITY" = "SKP" -a ! "$ALWAYSASK" = "yes" ]; then + continue # next package + fi + + # Figure out some package information, like the compressed and uncompressed + # sizes, and where to find the package description: + COMPRESSED="$(du -s $package | cut -f 1)K" + DESCRIPTION="" + # First check for .txt file next to the package, since this is faster: + if grep "^$packagebase:" "$packagedir/$shortname.txt" 1> /dev/null 2> /dev/null ; then + DESCRIPTION="$packagedir/$shortname.txt" + elif grep "^$shortname:" "$packagedir/$shortname.txt" 1> /dev/null 2> /dev/null ; then + DESCRIPTION="$packagedir/$shortname.txt" + fi + + # Test tarball integrity and get uncompressed package size: + 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 + 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$$ + continue + fi + UNCOMPRESSED="$(expr $(cat $TMP/tmpsize$$ | head -n 1 | cut -f 1 -d +) / 2)K" + rm -f $TMP/tmpsize$$ + + # 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" + fi + fi + + if [ "$DESCRIPTION" = "" ]; then + #echo "WARNING NO SLACK-DESC" + DESCRIPTION="/dev/null" + fi + + # Gather package infomation into a temporary file: + cat $DESCRIPTION | grep "^$packagebase:" | cut -f 2- -d : | cut -b2- 1> $TMP/tmpmsg$$ 2> /dev/null + if [ "$shortname" != "$packagebase" ]; then + cat $DESCRIPTION | grep "^$shortname:" | cut -f 2- -d : | cut -b2- 1>> $TMP/tmpmsg$$ 2> /dev/null + fi + # Adjust the length here. This allows a slack-desc to be any size up to 13 lines instead of fixed at 11. + LENGTH=$(cat $TMP/tmpmsg$$ | wc -l) + while [ $LENGTH -lt 12 ]; do + echo >> $TMP/tmpmsg$$ + LENGTH=$(expr $LENGTH + 1) + done + echo "Size: Compressed: ${COMPRESSED}, uncompressed: ${UNCOMPRESSED}." >> $TMP/tmpmsg$$ + # 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$$ +\n +\n +\n +\n +\n +\n +\n +\n +\n +\n +\n +\n +\n +EOF + paste -d "" $TMP/tmpmsg$$ $TMP/controlns$$ > $TMP/pasted$$ + rm -f $TMP/controlns$$ + mv $TMP/pasted$$ $TMP/tmpmsg$$ + # Emit information to the console: + if [ "$MODE" = "install" ]; then + if [ "$PMSG" = "" ]; then + echo "Installing package $(basename $package):" + else + echo "Installing package $(basename $package) $PMSG:" + fi + echo "PACKAGE DESCRIPTION:" + cat $DESCRIPTION | grep "^$packagebase:" | uniq | sed "s/^$packagebase:/#/g" + if [ "$shortname" != "$packagebase" ]; then + cat $DESCRIPTION | grep "^$shortname:" | uniq | sed "s/^$shortname:/#/g" + fi + elif [ "$MODE" = "infobox" ]; then # install infobox package + dialog --title "Installing package $shortname $PMSG" --infobox "$(cat $TMP/tmpmsg$$)" 0 0 + elif [ "$MODE" = "menu" -a "$PRIORITY" = "ADD" -a ! "$ALWAYSASK" = "yes" ]; then # ADD overrides menu mode unless -ask was used + dialog --title "Installing package $shortname $PMSG" --infobox "$(cat $TMP/tmpmsg$$)" 0 0 + elif [ "$MODE" = "menu" -a "$USERPRIORITY" = "ADD" ]; then # install no matter what $PRIORITY + dialog --title "Installing package $shortname $PMSG" --infobox "$(cat $TMP/tmpmsg$$)" 0 0 + 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$$ + if [ "$REPLY" = "Quit" ]; then + exit 99 # EXIT STATUS 99 = ABORT! + elif [ "$REPLY" = "No" ]; then + continue # skip the package + fi + fi + + # Make sure there are no symbolic links sitting in the way of + # incoming package files: + cat $TMP/tmplist$$ | grep -v "/$" | while read file ; do + if [ -L "$ROOT/$file" ]; then + rm -f "$ROOT/$file" + fi + done + rm -f $TMP/tmplist$$ + + # Write the package file database entry and install the package: + echo "PACKAGE NAME: $shortname" > $ADM_DIR/packages/$shortname + echo "COMPRESSED PACKAGE SIZE: $COMPRESSED" >> $ADM_DIR/packages/$shortname + echo "UNCOMPRESSED PACKAGE SIZE: $UNCOMPRESSED" >> $ADM_DIR/packages/$shortname + echo "PACKAGE LOCATION: $package" >> $ADM_DIR/packages/$shortname + # Record the md5sum if that's a selected option: + if [ $MD5SUM = 1 ]; then + echo "PACKAGE MD5SUM: $(md5sum $package | cut -f 1 -d ' ')" >> $ADM_DIR/packages/$shortname + fi + echo "PACKAGE DESCRIPTION:" >> $ADM_DIR/packages/$shortname + cat $DESCRIPTION | grep "^$packagebase:" >> $ADM_DIR/packages/$shortname 2> /dev/null + if [ "$shortname" != "$packagebase" ]; then + cat $DESCRIPTION | grep "^$shortname:" >> $ADM_DIR/packages/$shortname 2> /dev/null + fi + echo "FILE LIST:" >> $ADM_DIR/packages/$shortname + ( cd $ROOT/ ; $packagecompression -dc | $TAR -xlUpvf - ) < $package >> $TMP/$shortname 2> /dev/null + if [ "$(cat $TMP/$shortname | grep '^\./' | wc -l | tr -d ' ')" = "1" ]; then + # 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 + 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 + fi + + if [ -f $ROOT/install/doinst.sh ]; then + if [ "$MODE" = "install" ]; then + echo "Executing install script for $(basename $package)." + fi + ( cd $ROOT/ ; sh install/doinst.sh -install; ) + 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 + 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 + fi + # If we used a scan directory, get rid of it: + if [ -d "$TMP/scan$$" ]; then + rm -rf "$TMP/scan$$" + fi + rm -f $TMP/tmpmsg$$ $TMP/reply$$ + if [ "$MODE" = "install" ]; then + echo "Package $(basename $package) installed." + echo + fi +done + +exit $EXITSTATUS diff --git a/source/a/pkgtools/scripts/makebootdisk b/source/a/pkgtools/scripts/makebootdisk new file mode 100644 index 00000000..86b843a8 --- /dev/null +++ b/source/a/pkgtools/scripts/makebootdisk @@ -0,0 +1,444 @@ +#!/bin/sh +# Copyright 1995, 1998, 2002, 2005 Patrick Volkerding, Moorhead, 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. +# + +if [ ! "$UID" = "0" ]; then + echo "You need to be root to run this script." + exit 1 +fi + +# Was a kernel specified on the command line? +if [ -r "$1" ]; then + KERNEL=$1 + KMSG="Using kernel $KERNEL" +else + KMSG="No kernel selected yet" +fi + +# Make sure there's a proper temp directory: +TMP=/var/log/setup/tmp +# If the $TMP directory doesn't exist, create it: +if [ ! -d $TMP ]; then + rm -rf $TMP # make sure it's not a symlink or something stupid + mkdir -p $TMP + chmod 700 $TMP # no need to leave it open +fi + +ROOT_DEVICE="`mount | grep ' on / ' | cut -f 1 -d ' '`" + +if mount | grep ' on / ' | grep umsdos 1> /dev/null 2> /dev/null ; then + MOUNT="read-write" +else + MOUNT="read-only" +fi + +make_root_device() { +# Make a device: +makedev() { + if [ ! -b $1 ]; then + mknod $1 b $2 $3 + chown root.disk $1 + chmod 640 $1 + fi +} + +# Make ide device +# make ide major minor hd1 hd2 (2 base devs for major) +make_ide() { + # Handle base devices: + if [ "$2" = "0" ]; then + makedev $TMP/lilo/dev/$3 $1 $2 + return 0 + elif [ "$2" = "64" ]; then + makedev $TMP/lilo/dev/$4 $1 $2 + return 0 + fi + # Must be a partition: + if [ "`expr $2 / 64`" = "0" ]; then + DEV=$3 + NUM=$2 + else + DEV=$4 + NUM=`expr $2 - 64` + fi + makedev $TMP/lilo/dev/$DEV$NUM $1 $2 +} + +# Make SCSI device +make_scsi() { + # find drive # 0 - 15 + DRV=`expr $1 / 16` + NUM=`expr $1 % 16` + if [ "$NUM" = "0" ]; then + NUM="" + fi + if [ "$DRV" = "0" ]; then + makedev $TMP/lilo/dev/sda$NUM 8 $1 + elif [ "$DRV" = "1" ]; then + makedev $TMP/lilo/dev/sdb$NUM 8 $1 + elif [ "$DRV" = "2" ]; then + makedev $TMP/lilo/dev/sdc$NUM 8 $1 + elif [ "$DRV" = "3" ]; then + makedev $TMP/lilo/dev/sdd$NUM 8 $1 + elif [ "$DRV" = "4" ]; then + makedev $TMP/lilo/dev/sde$NUM 8 $1 + elif [ "$DRV" = "5" ]; then + makedev $TMP/lilo/dev/sdf$NUM 8 $1 + elif [ "$DRV" = "6" ]; then + makedev $TMP/lilo/dev/sdg$NUM 8 $1 + elif [ "$DRV" = "7" ]; then + makedev $TMP/lilo/dev/sdh$NUM 8 $1 + elif [ "$DRV" = "8" ]; then + makedev $TMP/lilo/dev/sdi$NUM 8 $1 + elif [ "$DRV" = "9" ]; then + makedev $TMP/lilo/dev/sdj$NUM 8 $1 + elif [ "$DRV" = "10" ]; then + makedev $TMP/lilo/dev/sdk$NUM 8 $1 + elif [ "$DRV" = "11" ]; then + makedev $TMP/lilo/dev/sdl$NUM 8 $1 + elif [ "$DRV" = "12" ]; then + makedev $TMP/lilo/dev/sdm$NUM 8 $1 + elif [ "$DRV" = "13" ]; then + makedev $TMP/lilo/dev/sdn$NUM 8 $1 + elif [ "$DRV" = "14" ]; then + makedev $TMP/lilo/dev/sdo$NUM 8 $1 + elif [ "$DRV" = "15" ]; then + makedev $TMP/lilo/dev/sdp$NUM 8 $1 + fi +} + +if cat /proc/partitions | grep / 1> /dev/null 2> /dev/null ; then # new + cat /proc/partitions | grep / | while read line ; do + SMASHED_LINE=$line + MAJOR=`echo $SMASHED_LINE | cut -f 1 -d ' '` + MINOR=`echo $SMASHED_LINE | cut -f 2 -d ' '` + if [ "$MAJOR" = "3" ]; then + make_ide $MAJOR $MINOR hda hdb + elif [ "$MAJOR" = "8" ]; then + make_scsi $MINOR + elif [ "$MAJOR" = "22" ]; then + make_ide $MAJOR $MINOR hdc hdd + elif [ "$MAJOR" = "33" ]; then + make_ide $MAJOR $MINOR hde hdf + elif [ "$MAJOR" = "34" ]; then + make_ide $MAJOR $MINOR hdg hdh + elif [ "$MAJOR" = "56" ]; then + make_ide $MAJOR $MINOR hdi hdj + fi + done +else # old format + cat /proc/partitions | grep d | while read line ; do + SMASHED_LINE=$line + MAJOR=`echo $SMASHED_LINE | cut -f 1 -d ' '` + MINOR=`echo $SMASHED_LINE | cut -f 2 -d ' '` + DEVNAME=`echo $SMASHED_LINE | cut -f 4 -d ' '` + makedev $TMP/lilo/dev/$DEVNAME $MAJOR $MINOR + done +fi +} + +choose_kernel() { +while [ 0 ]; do # input loop +cat << EOF > $TMP/tmpmsg + +Some possible paths to kernels are these: + +/boot/vmlinuz +/usr/src/linux/arch/i386/boot/bzImage +/usr/src/linux/arch/i386/boot/zImage +/vmlinuz + +Put the path to the kernel you want to use in the box below. + +EOF + + dialog --title "CHOOSE KERNEL" --inputbox "`cat $TMP/tmpmsg`" \ + 16 72 "/boot/vmlinuz" 2> $TMP/return + if [ ! $? = 0 ]; then + exit + fi + + KERNEL="`cat $TMP/return`" + + if [ ! -r "$KERNEL" ]; then + dialog --title "NOT FOUND!" --msgbox "$KERNEL" 5 60 + continue + fi + KMSG="Using kernel $KERNEL" +break +done +} + +format_disk() { + # If anyone still uses 1.2 MB, you'll have to uncomment this. + # It's no longer a default option. + #FDEV=/dev/fd0h1200 + #FDEV=/dev/fd0u1400 + FDEV=/dev/fd0u1680 + if [ "$FDEV" = "/dev/fd0u1680" ]; then + dialog --title "Formatting /dev/fd0u1680" --infobox \ + "Formatting /dev/fd0, 1.68 megabytes." 3 42 + elif [ "$FDEV" = "/dev/fd0u1400" ]; then + dialog --title "Formatting /dev/fd0u1440" --infobox \ + "Formatting /dev/fd0, 1.44 megabytes." 3 42 + elif [ "$FDEV" = "/dev/fd0h1200" ]; then + dialog --title "Formatting /dev/fd0h1200" --infobox \ + "Formatting /dev/fd0, 1.2 megabytes." 3 42 + fi + 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 + return 1 + fi +} + +DEFAULT_ITEM="syslinux" + +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. \ +Which option would you like?" 12 67 2 \ +"syslinux" "Make a SYSLINUX bootdisk" \ +"exit" "Exit this program" 2> $TMP/return + if [ ! $? = 0 ]; then + break; + fi + REPLY=`cat $TMP/return` + rm -f $TMP/return + if [ "$REPLY" = "simple" ]; then # make simple bootdisk + if [ "$KERNEL" = "" ]; then + choose_kernel + fi + kernel_size=`du -Lk $KERNEL | cut -f1` + if [ "$kernel_size" -gt "1023" ]; then +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' +method instead. + +EOF + dialog --title "KERNEL TOO BIG!" --msgbox "`cat $TMP/tmpmsg`" 10 60 + continue + fi + dialog --title "BOOT DISK CREATION" --backtitle "$KMSG" --yesno \ +"\n\ +Now put a formatted floppy in your boot drive. \n\ +This will be made into your Linux boot disk. Use this to\n\ +boot Linux until LILO has been configured to boot from\n\ +the hard drive.\n\n\ +Any data on the target disk will be destroyed.\n\n\ +YES creates the disk, NO aborts.\n" 14 62 + if [ $? = 0 ]; then + format_disk + dialog --title "CREATING DISK" --infobox "Creating boot disk from $KERNEL..." 5 72 + dd if=$KERNEL of=/dev/fd0 2> /dev/null + rdev /dev/fd0 $ROOT_DEVICE + rdev -v /dev/fd0 -1 + if [ "$MOUNT" = "read-only" ]; then + rdev -R /dev/fd0 1 + else + rdev -R /dev/fd0 0 + fi + fi + elif [ "$REPLY" = "syslinux" ]; then # make syslinux bootdisk + DEFAULT_ITEM="exit" + if [ "$KERNEL" = "" ]; then + 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 + if [ $? = 0 ]; then # make the disk + format_disk + if [ ! $? = 0 ]; then + continue + fi + dialog --title "CREATING BOOT FLOPPY" --infobox "Creating SYSLINUX bootdisk for \ +$ROOT_DEVICE in /dev/fd0." 3 64 + mkdosfs -F 12 /dev/fd0u1680 1680 1> /dev/null 2> /dev/null + if [ ! -d $TMP/bootdisk ]; then + mkdir $TMP/bootdisk + fi + mount -t vfat /dev/fd0 $TMP/bootdisk 1> /dev/null 2> /dev/null + cp $KERNEL $TMP/bootdisk/vmlinuz + ## This avoids a syslinux-1.72 bug, and doesn't seem to hurt anything: + #dd if=/dev/zero bs=1k count=1 >> $TMP/bootdisk/vmlinuz 2> /dev/null + 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. \ +This program will now exit." 0 0 + umount /dev/fd0 + rm -rf $TMP/bootdisk + exit 1 + fi + cat << EOF > $TMP/bootdisk/message.txt + +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 +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 +kernel parameters you might need depending on your hardware, and which +drivers are included in your kernel. + +EOF + cat << EOF > $TMP/bootdisk/syslinux.cfg +default vmlinuz ramdisk_size=7000 root=$ROOT_DEVICE vga=normal ro +prompt 1 +timeout 6000 +display message.txt +F1 f1.txt +F2 message.txt +#F3 f3.txt +#F4 f4.txt +#F5 f5.txt +#F6 f6.txt +#F7 f7.txt +label mount + kernel vmlinuz + append ramdisk_size=7000 root=$ROOT_DEVICE vga=normal ro +label ramdisk + kernel vmlinuz + append vmlinuz ramdisk_size=7000 root=/dev/fd0u1440 vga=normal rw +EOF + cat << EOF > $TMP/bootdisk/f1.txt + STANDARD MODES: + To make the kernel prompt for standard video modes use: vga=ask + + 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: + + Colors 640x480 800x600 1024x768 1280x1024 1600x1200 + --------+--------------------------------------------- + 256 | 769 771 773 775 796 + 32,768 | 784 787 790 793 797 + 65,536 | 785 788 791 794 798 + 16.8M | 786 789 792 795 799 + + ...such as this for 1024x768x64k: + vga=791 + + F2 returns to the previous page. + +EOF + umount /dev/fd0 + syslinux-nomtools -s /dev/fd0 + rm -r $TMP/bootdisk + fi + elif [ "$REPLY" = "lilo" ]; then # make lilo bootdisk + DEFAULT_ITEM="exit" + if [ ! -x "`type -path lilo`" ]; then +cat << EOF > $TMP/tmpmsg + +You don't have 'lilo' installed on the system. +I guess you didn't install the lilo package. + +EOF + dialog --title "LILO NOT FOUND" --msgbox "`cat $TMP/tmpmsg`" 8 60 + continue + fi + if [ "$KERNEL" = "" ]; then + 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 + if [ $? = 0 ]; then # make the disk + format_disk + DEV=/dev/fd0u1680 + mknod_fd="-m 0640 $TMP/lilo$DEV b 2 44" + dialog --infobox "Creating LILO bootdisk from $KERNEL for $ROOT_DEVICE..." 4 60 + mke2fs -q -m 0 -i 4096 $DEV 1> /dev/null 2> /dev/null || exit 1 + if [ ! -d $TMP/lilo ]; then + mkdir -p $TMP/lilo + fi + mount -t ext2 $DEV $TMP/lilo 1> /dev/null || exit 1 + rmdir $TMP/lilo/lost+found + cp $KERNEL $TMP/lilo/vmlinuz || exit 1 + mkdir $TMP/lilo/dev + make_root_device + mknod -m 0640 $TMP/lilo/dev/fd0 b 2 0 + mknod -m 0640 $TMP/lilo/dev/fd1 b 2 1 + mknod $mknod_fd + mknod -m 0666 $TMP/lilo/dev/null c 1 3 + mkdir $TMP/lilo/etc + cat << EOF > $TMP/lilo/etc/lilo.conf +boot = $DEV +message=/boot/message +backup=/dev/null +prompt +image = /vmlinuz + label = mount + ramdisk = 0 + root = $ROOT_DEVICE + vga = normal + $MOUNT +EOF + mkdir $TMP/lilo/boot + cp -a /boot/chain.b $TMP/lilo/boot + if [ -f /boot/boot-text.b ]; then + cp -a /boot/boot-text.b $TMP/lilo/boot/boot.b + else + cp -a /boot/boot.b $TMP/lilo/boot + fi + cat << EOF > $TMP/lilo/boot/message + +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 +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 +parameters you might need depending on your hardware, and which drivers are +included in your kernel. + +EOF + lilo -r $TMP/lilo > /dev/null + umount $TMP/lilo + rm -rf $TMP/lilo + fi + elif [ "$REPLY" = "exit" ]; then + break; + fi +done diff --git a/source/a/pkgtools/scripts/makepkg b/source/a/pkgtools/scripts/makepkg new file mode 100644 index 00000000..e6805476 --- /dev/null +++ b/source/a/pkgtools/scripts/makepkg @@ -0,0 +1,347 @@ +#!/bin/sh +# Copyright 1994, 1998, 2008 Patrick Volkerding, Moorhead, Minnesota USA +# Copyright 2003 Slackware Linux, Inc. Concord, CA USA +# Copyright 2009 Patrick J. Volkerding, Sebeka, MN, USA +# 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 Apr 5 21:23:26 CDT 2009 +# Support .tgz, .tbz, .tlz, and .txz packages. <volkerdi> +# +# Wed Mar 18 15:32:33 CST 1998 +# Patched to avoid possible symlink attacks in /tmp. + +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() { + COUNT=1 + LINE="$(sed -n "$COUNT p" $1)" + while [ ! "$LINE" = "" ]; do + LINKGOESIN="$(echo "$LINE" | cut -f 1 -d " ")" + LINKGOESIN="$(dirname $LINKGOESIN)" + LINKNAMEIS="$(echo "$LINE" | cut -f 1 -d ' ')" + LINKNAMEIS="$(basename "$LINKNAMEIS")" + LINKPOINTSTO="$(echo "$LINE" | cut -f 3 -d ' ')" + echo "( cd $LINKGOESIN ; rm -rf $LINKNAMEIS )" + echo "( cd $LINKGOESIN ; ln -sf $LINKPOINTSTO $LINKNAMEIS )" + COUNT=$(expr $COUNT + 1) + LINE="$(sed -n "$COUNT p" $1)" + done +} + +usage() { + cat << EOF + +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 +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) + +If these options are not set, makepkg will prompt as 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. :^) + +# Parse options +while [ 0 ]; do + if [ "$1" = "--linkadd" -o "$1" = "-l" ]; then + if [ "$2" = "y" ]; then + LINKADD=y + elif [ "$2" = "n" ]; then + LINKADD=n + else + usage + exit 2 + fi + shift 2 + elif [ "$1" = "--chown" -o "$1" = "-c" ]; then + if [ "$2" = "y" ]; then + CHOWN=y + elif [ "$2" = "n" ]; then + CHOWN=n + else + usage + exit 2 + fi + shift 2 + elif [ "$1" = "-p" -o "$1" = "--prepend" ]; then + PREPEND=y + shift 1 + elif [ "$1" = "-h" -o "$1" = "-H" -o "$1" = "--help" -o $# = 0 ]; then + usage + exit 0 + else + break + fi +done + +PACKAGE_NAME="$1" +TARGET_NAME="$(dirname $PACKAGE_NAME)" +PACKAGE_NAME="$(basename $PACKAGE_NAME)" + +# Identify package extension: +if [ ! "$(basename $PACKAGE_NAME .tgz)" = "$PACKAGE_NAME" ]; then + EXTENSION="tgz" +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" +elif [ ! "$(basename $PACKAGE_NAME .tbz)" = "$PACKAGE_NAME" ]; then + EXTENSION="tbz" +elif [ ! "$(basename $PACKAGE_NAME .tar.bz2)" = "$PACKAGE_NAME" ]; then + EXTENSION="tar.bz2" +elif [ ! "$(basename $PACKAGE_NAME .tlz)" = "$PACKAGE_NAME" ]; then + EXTENSION="tlz" +elif [ ! "$(basename $PACKAGE_NAME .tar.lzma)" = "$PACKAGE_NAME" ]; then + EXTENSION="tar.lzma" +elif [ ! "$(basename $PACKAGE_NAME .txz)" = "$PACKAGE_NAME" ]; then + EXTENSION="txz" +elif [ ! "$(basename $PACKAGE_NAME .tar.xz)" = "$PACKAGE_NAME" ]; then + EXTENSION="tar.xz" +else + EXTENSION="$(echo $PACKAGE_NAME | rev | cut -f 1 -d . | rev)" + echo "ERROR: Package extension .$EXTENSION is not supported." + exit 1 +fi + +TAR_NAME="$(basename $PACKAGE_NAME .$EXTENSION)" + +# Sanity check -- we can't make the package in the current directory: +if [ "$CWD" = "$TARGET_NAME" -o "." = "$TARGET_NAME" ]; then + echo "ERROR: Can't make output package in current directory." + 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.14159." +echo +echo "Searching for symbolic links:" +# Get rid of possible pre-existing trouble: +INST=$(mktemp $TMP/makepkg.XXXXXX) +# This requires the ls from coreutils-5.0 (or newer): +find . -type l -exec ls -l --time-style=long-iso {} \; | while read foo ; do echo $foo ; done | cut -f 8- -d ' ' | cut -b3- | tee $INST +if [ ! "$(cat $INST)" = "" ]; then + echo + echo "Making symbolic link creation script:" + make_install_script $INST | tee doinst.sh +fi +echo +if [ ! "$(cat $INST)" = "" ]; then + if [ -r install/doinst.sh ]; then + echo "Unless your existing installation script already contains the code" + echo "to create these links, you should append these lines to your existing" + echo "install script. Now's your chance. :^)" + echo + echo "Would you like to add this stuff to the existing install script and" + echo -n "remove the symbolic links ([y]es, [n]o)? " + else + echo "It is recommended that you make these lines your new installation script." + echo + echo "Would you like to make this stuff the install script for this package" + echo -n "and remove the symbolic links ([y]es, [n]o)? " + fi + if [ ! "$LINKADD" ]; then + read LINKADD; + echo + else + echo $LINKADD + echo + fi + if [ "$LINKADD" = "y" ]; then + if [ -r install/doinst.sh ]; then + UPDATE="t" + if [ "$PREPEND" = "y" ]; then + touch install/doinst.sh + mv install/doinst.sh install/doinst.sh.shipped + cat doinst.sh > install/doinst.sh + echo "" >> install/doinst.sh + cat install/doinst.sh.shipped >> install/doinst.sh + rm -f install/doinst.sh.shipped + else + cat doinst.sh >> install/doinst.sh + fi + else + mkdir -p install + cat doinst.sh > install/doinst.sh + fi + echo + echo "Removing symbolic links:" + find . -type l -exec rm -v {} \; + echo + if [ "$UPDATE" = "t" ]; then + if [ "$PREPEND" = "y" ]; then + echo "Updating your ./install/doinst.sh (prepending symlinks)..." + else + echo "Updating your ./install/doinst.sh..." + fi + else + echo "Creating your new ./install/doinst.sh..." + fi + fi +else + echo "No symbolic links were found, so we won't make an installation script." + echo "You can make your own later in ./install/doinst.sh and rebuild the" + echo "package if you like." +fi +rm -f doinst.sh $INST +echo +echo "This next step is optional - you can set the directories in your package" +echo "to some sane permissions. If any of the directories in your package have" +echo "special permissions, then DO NOT reset them here!" +echo +echo "Would you like to reset all directory permissions to 755 (drwxr-xr-x) and" +echo -n "directory ownerships to root.root ([y]es, [n]o)? " +if [ ! "$CHOWN" ]; then + read CHOWN; + echo +else + echo $CHOWN + echo +fi +if [ "$CHOWN" = "y" ]; then + find . -type d -exec chmod -v 755 {} \; + find . -type d -exec chown -v root.root {} \; +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 + +# Warn of zero-length files: +find . -type f -size 0c | while read file ; do + echo "WARNING: zero length file $(echo $file | cut -b3-)" +done + +# Warn of corrupt or empty gzip files: +find . -type f -name '*.gz' | while read file ; do + if ! gzip -t $file 1> /dev/null 2> /dev/null ; then + echo "WARNING: gzip test failed on $(echo $file | cut -b3-)" + else + if [ "$(gzip -l $file | tail -n 1 | tr -s ' ' | cut -f 3 -d ' ')" -eq 0 ]; then + echo "WARNING: $(echo $file | cut -b3-) is an empty gzipped file" + fi + fi +done + +# Some more handy warnings: +if [ -d usr/share/man ]; then + echo "WARNING: /usr/share/man (with possibly not gzipped man pages) detected" +fi + +if [ -d usr/share/info ]; then + echo "WARNING: /usr/share/info (with possibly not gzipped info pages) detected" +fi + +if find . | grep site_perl 1> /dev/null ; then + echo "WARNING: site_perl directory detected (this is fine for a local package build)" +fi + +echo +echo "Slackware package ${TARGET_NAME}/${TAR_NAME}.${EXTENSION} created." +echo diff --git a/source/a/pkgtools/scripts/pkgtool b/source/a/pkgtools/scripts/pkgtool new file mode 100644 index 00000000..6191e36e --- /dev/null +++ b/source/a/pkgtools/scripts/pkgtool @@ -0,0 +1,754 @@ +#!/bin/sh +# +# 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 Patrick Volkerding, Sebeka, MN, USA +# +# 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. +# + +# Sat Apr 25 21:18:53 UTC 2009 +# Converted to use new pkgbase() function to remove pathname and +# valid package extensions. +# +# Wed Oct 31 16:28:46 CDT 2007 +# * Thanks to Gabriele Inghirami for a patch allowing this script to work +# with much larger numbers of installed packages. +# Wed, 27 Apr 1994 00:06:50 -0700 (PDT) +# * Optimization by David Hinds. +# Sun Oct 24 23:11:40 BST 2004 +# * Further optimisations by Jim Hawkins <jawkins@armedslack.org> +# - dramatically improved the speed of the "View" option +# Thu Nov 04 12:19:56 BST 2004 +# * More optimisations by Jim Hawkins +# - improved "Remove" speed in a similar manner to "View" +# Wed Jan 12 16:53:48 GMT 2005 +# * Fixed quoting bug thanks to Lasse Collin +# Wed Jan 26 23:06:22 GMT 2005 +# * Fix for non-standard package descriptions by Jim Hawkins + +# Return a package name that has been stripped of the dirname portion +# and any of the valid extensions (only): +pkgbase() { + PKGEXT=$(echo $1 | rev | cut -f 1 -d . | rev) + case $PKGEXT in + 'tgz' ) + PKGRETURN=$(basename $1 .tgz) + ;; + 'tbz' ) + PKGRETURN=$(basename $1 .tbz) + ;; + 'tlz' ) + PKGRETURN=$(basename $1 .tlz) + ;; + 'txz' ) + PKGRETURN=$(basename $1 .txz) + ;; + *) + PKGRETURN=$(basename $1) + ;; + esac + echo $PKGRETURN +} + +SOURCE_DIR=/var/log/mount +ASK="tagfiles" +if [ -L /bin/chmod -a -L /bin/chown ]; then # probably on the bootdisk using busybox + TARGET_DIR=/mnt + TMP=/mnt/var/log/setup/tmp + if mount | grep "on /mnt" 1> /dev/null 2>&1 ; then # good + true + else # bad + 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 of this:" + echo + echo "If your root partition is /dev/hda1, and is using ext2fs, you would type:" + echo "mount /dev/hda1 /mnt -t ext2" + echo + echo "Then, supposing your /usr partition is /dev/hda2, you must do this:" + echo "mount /dev/hda2 /mnt/usr -t ext2" + echo + echo "Please mount your Linux partitions and then run pkgtool again." + echo + exit + fi +else + TARGET_DIR=/ + TMP=/var/log/setup/tmp +fi +if [ ! -d $TMP ]; then + mkdir -p $TMP + chmod 700 $TMP + fi +ADM_DIR=$TARGET_DIR/var/log +LOG=$TMP/PKGTOOL.REMOVED + +# remove whitespace +crunch() { + while read FOO ; do + echo $FOO + done +} + +package_name() { + STRING=$(pkgbase $1) + # Check for old style package name with one segment: + if [ "$(echo $STRING | cut -f 1 -d -)" = "$(echo $STRING | cut -f 2 -d -)" ]; then + echo $STRING + else # has more than one dash delimited segment + # Count number of segments: + INDEX=1 + while [ ! "$(echo $STRING | cut -f $INDEX -d -)" = "" ]; do + INDEX=$(expr $INDEX + 1) + done + INDEX=$(expr $INDEX - 1) # don't include the null value + # If we don't have four segments, return the old-style (or out of spec) package name: + if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then + echo $STRING + else # we have four or more segments, so we'll consider this a new-style name: + NAME=$(expr $INDEX - 3) + NAME="$(echo $STRING | cut -f 1-$NAME -d -)" + echo $NAME + # cruft for later ;) + #VER=$(expr $INDEX - 2) + #VER="$(echo $STRING | cut -f $VER -d -)" + #ARCH=$(expr $INDEX - 1) + #ARCH="$(echo $STRING | cut -f $ARCH -d -)" + #BUILD="$(echo $STRING | cut -f $INDEX -d -)" + fi + fi +} + +remove_packages() { + for pkg_name in $(cat $TMP/return | tr -d "\042") + do + if [ -r $ADM_DIR/packages/$pkg_name ]; then + dialog --title "PACKAGE REMOVAL IN PROGRESS" --cr-wrap --infobox \ +"\nRemoving package $pkg_name.\n\ +\n\ +Since each file must be checked \ +against the contents of every other installed package to avoid wiping out \ +areas of overlap, this process can take quite some time. If you'd like to \ +watch the progress, flip over to another virtual console and type:\n\ +\n\ +tail -f $TMP/PKGTOOL.REMOVED\n" 13 60 + export ROOT=$TARGET_DIR + removepkg $pkg_name >> $LOG 2> /dev/null + else + echo "No such package: $pkg_name. Can't remove." >> $LOG + fi + done +} + +create_list_of_installed_packages() +{ + FILES=$(ls $ADM_DIR/packages) + if [ -n "$FILES" ]; then + cd $ADM_DIR/packages + { grep '^PACKAGE DESCRIPTION:$' -Z -H -m1 -A1 $FILES; echo; } \ + | sed -n 'h;n;/\x00/{h;n;};x;s/ */ /g;s/ $//;s/[\"`$]/\\&/g + s/\(.*\)\x00\([^:]*:\)\? *\(.*\)/ "\1" "\3" "View information about package \1" \\/;p' > $TMP/list_of_installed_packages \ + + fi +} + + create_list_of_files_to_remove () +{ +FILES=$(ls $ADM_DIR/packages) + if [ -n "$FILES" ]; then + cd $ADM_DIR/packages + { grep '^PACKAGE DESCRIPTION:$' -Z -H -m1 -A1 $FILES; echo; } \ + | sed -n 'h;n;/\x00/{h;n;};x;s/ */ /g;s/ $//;s/[\"`$]/\\&/g + s/\(.*\)\x00\([^:]*:\)\? *\(.*\)/ "\1" "\3" off "Select\/Unselect removing package \1" \\/;p' > $TMP/temporary_list \ + + fi +} + +# Here, we read the list of arguments passed to the pkgtool script. +if [ $# -gt 0 ]; then # there are arguments to the command + while [ $# -gt 0 ]; do + case "$1" in + -sets | --sets) + DISK_SETS=$(echo $2 | tr "[A-Z]" "[a-z]") ; shift 2 ;; + -source_mounted | --source-mounted) + SOURCE_MOUNTED="always" ; shift 1 ;; + -ignore_tagfiles | --ignore-tagfiles) + ASK="never" ; shift 1 ;; + -tagfile | --tagfile) + USETAG=$2 ; shift 2 ;; + -source_dir | --source_dir) + SOURCE_DIR=$2 ; shift 2 ;; + -target_dir | --target_dir) + TARGET_DIR=$2 + ADM_DIR=$TARGET_DIR/var/log + shift 2 ;; + -source_device | --source_device) + SOURCE_DEVICE=$2 ; shift 2 ;; + esac + done +else # there were no arguments, so we'll get the needed information from the + # user and then go on. + CMD_START="true" + rm -f $TMP/SeT* + while [ 0 ]; do + dialog --title "Slackware Package Tool (pkgtool version 13.0)" \ +--menu "\nWelcome to the Slackware package tool.\n\ +\nWhich option would you like?\n" 17 75 7 \ +"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" \ +"Exit" "Exit Pkgtool" 2> $TMP/reply + if [ ! $? = 0 ]; then + rm -f $TMP/reply + dialog --clear + exit + fi + REPLY="$(cat $TMP/reply)" + rm -f $TMP/reply + if [ "$REPLY" = "Exit" ]; then + dialog --clear + exit + 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 \ +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-) + if [ "$BLURB" = "" ]; then + BLURB="\"\"" + fi + echo " \"$(basename $script | cut -f2- -d .)\" $BLURB \"no\" $BLURB \\" >> $TMP/setupscr + done + echo "2> $TMP/return" >> $TMP/setupscr + . $TMP/setupscr + if [ ! "$(cat $TMP/return)" = "" ]; then + # Run each script: + for script in $(cat $TMP/return) ; do + scrpath=$ADM_DIR/setup/setup.$(echo $script | tr -d \") + rootdevice="$(mount | head -n 1 | cut -f 1 -d ' ')" + ( COLOR=on ; cd $TARGET_DIR ; . $scrpath / $rootdevice ) + done + fi + rm -f $TMP/return $TMP/setupscr + continue + fi # end Setup + + if [ "$REPLY" = "View" ]; then +create_list_of_installed_packages + DEFITEM="" + export DEFITEM + #dialog --title "SCANNING" --infobox "Please wait while \ +#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" + ) > $TMP/viewscr + while [ 0 ]; do + . $TMP/viewscr + if [ ! "$(cat $TMP/return)" = "" ]; then + DEFITEM="--default-item $(cat $TMP/return)" + dialog --title "CONTENTS OF PACKAGE: $(cat $TMP/return)" --no-shadow --textbox "$ADM_DIR/packages/$(cat $TMP/return)" \ + 0 0 2> /dev/null + else + break + fi + done + rm -f $TMP/return $TMP/viewscr $TMP/tmpmsg $TMP/list_of_installed_packages + # This will clean up after most defective packages: + chmod 755 / + chmod 1777 /tmp + continue + fi + + if [ "$REPLY" = "Remove" ]; then + #dialog --title "SCANNING" --infobox "Please wait while Pkgtool scans \ +#your system to determine which packages you have installed and prepares \ +#a list for you." 0 0 + # end section + ( +create_list_of_files_to_remove #call the function to create a list of installed packages + cat << EOF +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 \\ +EOF + echo "2> $TMP/return" + ) > $TMP/rmscript + if [ -L $LOG -o -r $LOG ]; then + rm -f $LOG + fi + cat /dev/null > $LOG + chmod 600 $LOG + chmod 700 $TMP/rmscript + export ADM_DIR; + $TMP/rmscript + remove_packages + if [ "$(cat $TMP/PKGTOOL.REMOVED)" = "" ]; then + rm -f $TMP/PKGTOOL.REMOVED + dialog --title "NO PACKAGES REMOVED" --msgbox "Hit OK to return \ +to the main menu." 5 40 + else + dialog --title "PACKAGE REMOVAL COMPLETE" --msgbox "The packages have \ +been removed. A complete log of the files that were removed has been created \ +in $TMP: PKGTOOL.REMOVED." 0 0 + fi + rm -f $TMP/rmscript $TMP/return $TMP/tmpmsg $TMP/SeT* $TMP/temporary_list + chmod 755 / + 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 + if [ $? = 1 ]; then + rm -f $TMP/pkgdir $TMP/SeT* + dialog --clear + exit + fi + SOURCE_DIR="$(cat $TMP/pkgdir)" + SOURCE_MOUNTED="always" + DISK_SETS="disk" + chmod 755 $TARGET_DIR + chmod 1777 $TARGET_DIR/tmp + rm -f $TMP/pkgdir + if [ ! -d $SOURCE_DIR ]; then + dialog --title "DIRECTORY NOT FOUND" --msgbox "The directory you want to \ +install from ($SOURCE_DIR) \ +does not seem to exist. Please check the directory and then try again." \ +10 50 + dialog --clear + exit + fi + break; + else # installing from current directory + SOURCE_MOUNTED="always" + SOURCE_DIR="$PWD" + DISK_SETS="disk" + chmod 755 $TARGET_DIR + chmod 1777 $TARGET_DIR/tmp + break; + fi + done +fi +if [ "$DISK_SETS" = "disk" ]; then + ASK="always" +fi + +mount_the_source() { + # is the source supposed to be mounted already? + if [ "$SOURCE_MOUNTED" = "always" ]; then + # The source should already be mounted, so we test it + if [ ! -d $SOURCE_DIR ]; then # the directory is missing + cat << EOF > $TMP/tmpmsg + +Your source device cannot be accessed properly. + +Please be sure that it is mounted on $SOURCE_DIR, +and that the Slackware disks are found in subdirectories +of $SOURCE_DIR like specified. + +EOF + dialog --title "MOUNT ERROR" --msgbox "$(cat $TMP/tmpmsg)" 11 67 + rm -f $TMP/tmpmsg + exit 1; + fi + return 0; + fi + dialog --title "INSERT DISK" --menu "Please insert disk $1 and \ +press ENTER to continue." \ +11 50 3 \ +"Continue" "Continue with the installation" \ +"Skip" "Skip the current disk series" \ +"Quit" "Abort the installation process" 2> $TMP/reply + if [ ! $? = 0 ]; then + REPLY="Quit" + else + REPLY="$(cat $TMP/reply)" + fi + rm -f $TMP/reply + if [ "$REPLY" = "Skip" ]; then + return 1; + fi + if [ "$REPLY" = "Quit" ]; then + dialog --title "ABORTING" --msgbox "Aborting software installation." 5 50 + chmod 755 $TARGET_DIR + chmod 1777 $TARGET_DIR/tmp + exit 1; + fi; + # Old line: + # mount -r -t msdos $SOURCE_DEVICE $SOURCE_DIR + # New ones: (thanks to Andy Schwierskott!) + go_on=y + not_successfull_mounted=1 + while [ "$go_on" = y -a "$not_successfull_mounted" = 1 ]; do + mount -r -t msdos $SOURCE_DEVICE $SOURCE_DIR + not_successfull_mounted=$? + if [ "$not_successfull_mounted" = 1 ]; then + mount_answer=x + while [ "$mount_answer" != "y" -a "$mount_answer" != "q" ] ; do + dialog --title "MOUNT PROBLEM" --menu "Media was not successfully \ +mounted! Do you want to \ +retry, or quit?" 10 60 2 \ +"Yes" "Try to mount the disk again" \ +"No" "No, abort." 2> $TMP/mntans + mount_answer="$(cat $TMP/mntans)" + rm -f $TMP/mntans + if [ "$mount_answer" = "Yes" ]; then + mount_answer="y" + else + mount_answer="q" + fi + done + go_on=$mount_answer + fi + done + test $not_successfull_mounted = 0 +} + +umount_the_source() { + if [ ! "$SOURCE_MOUNTED" = "always" ]; then + umount $SOURCE_DEVICE 1> /dev/null 2>&1 + fi; +} + +install_disk() { + mount_the_source $1 + if [ $? = 1 ]; then + umount_the_source; + return 1; + fi + CURRENT_DISK_NAME="$1" + PACKAGE_DIR=$SOURCE_DIR + if [ "$SOURCE_MOUNTED" = "always" -a ! "$DISK_SETS" = "disk" ]; then + PACKAGE_DIR=$PACKAGE_DIR/$1 + fi + + # If this directory is missing or contains no *.t?z files, bail. + if [ ! -d $PACKAGE_DIR ]; then + return 1 + fi + if ! ls $PACKAGE_DIR/*.t?z 1> /dev/null 2> /dev/null ; then + return 1 + fi + + # + # look for tagfile for this series and copy into $TMP/tagfile + # + touch $TMP/tagfile + if [ ! "$DISK_SETS" = "disk" ]; then + if [ -r $TMP/SeTtagext ]; then + if [ -r $PACKAGE_DIR/tagfile$(cat $TMP/SeTtagext) ]; then + cat $PACKAGE_DIR/tagfile$(cat $TMP/SeTtagext) >> $TMP/tagfile + else + if [ -r $PACKAGE_DIR/tagfile ]; then + cat $PACKAGE_DIR/tagfile >> $TMP/tagfile + fi + fi + + # + # Do we need to follow a custom path to the tagfiles? + # + elif [ -r $TMP/SeTtagpath ]; then + custom_path=$(cat $TMP/SeTtagpath) + short_path=$(basename $PACKAGE_DIR) + + # If tagfile exists at the specified custom path, copy it over. + if [ -r $custom_path/$short_path/tagfile ]; then + cat $custom_path/$short_path/tagfile >> $TMP/tagfile + + else # well, I guess we'll use the default one then. + if [ -r $PACKAGE_DIR/tagfile ]; then + cat $PACKAGE_DIR/tagfile >> $TMP/tagfile + fi + fi + # + # We seem to be testing for this too often... maybe this code should + # be optimized a little... + # + elif [ -r $PACKAGE_DIR/tagfile ]; then + cat $PACKAGE_DIR/tagfile >> $TMP/tagfile + fi + + # + # Execute menus if in QUICK mode: + # + if [ -r $TMP/SeTQUICK -a -r $PACKAGE_DIR/maketag ]; then + if [ ! "$MAKETAG" = "" -a -r $PACKAGE_DIR/$MAKETAG ]; then # use alternate maketag + sh $PACKAGE_DIR/$MAKETAG + else + sh $PACKAGE_DIR/maketag + fi + if [ -r $TMP/SeTnewtag ]; then + mv $TMP/SeTnewtag $TMP/tagfile + fi + fi + + # + # Protect tagfile from hacker attack: + # + if [ -r $TMP/tagfile ]; then + chmod 600 $TMP/tagfile + fi + + fi # ! "$DISK_SETS" = "disk" + + # 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 + fi + + # If there's a catalog file present, use it to check for missing files. + # If not, forget about that and install whatever's there. + if [ "$1" = "single_disk" -o -r $PACKAGE_DIR/disk$1 -o -r $PACKAGE_DIR/package-list.txt ]; then + if [ -r $PACKAGE_DIR/package-list.txt ]; then + CATALOG_FILE=$PACKAGE_DIR/package-list.txt + else + CATALOG_FILE=$(basename $PACKAGE_DIR/disk*); + fi + if [ -r $PACKAGE_DIR/$CATALOG_FILE -a ! -d $PACKAGE_DIR/$CATALOG_FILE ]; then + if grep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE 1> /dev/null 2>&1 ; then + # First we check for missing packages... + for PKGTEST in $(grep "^CONTENTS:" $PACKAGE_DIR/$CATALOG_FILE | cut -f2- -d : 2> /dev/null) ; do + # This is not a perfect test. (say emacs is missing but emacs-nox is not) + if ls $PACKAGE_DIR/$PKGTEST*.t?z 1> /dev/null 2> /dev/null ; then # found something like it + true + else + cat << EOF > $TMP/tmpmsg + +WARNING!!! + +While looking through your index file ($CATALOG_FILE), +I noticed that you might be missing a package: + +$PKGTEST-\*-\*-\*.t?z + +that is supposed to be on this disk (disk $1). You may go +on with the installation if you wish, but if this is a +crucial file I'm making no promises that your machine will +boot. + +EOF + dialog --title "FILE MISSING FROM YOUR DISK" --msgbox \ +"$(cat $TMP/tmpmsg)" 17 67 + fi + done # checking for missing packages + # Now we test for extra packages: + ALLOWED="$(grep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE | cut -b10- 2> /dev/null)" + for PACKAGE_FILENAME in $PACKAGE_DIR/*.t?z; do + BASE=$(pkgbase $PACKAGE_FILENAME) + BASE="$(package_name $BASE)" + if echo $ALLOWED | grep $BASE 1> /dev/null 2>&1 ; then + true + else + cat << EOF > $TMP/tmpmsg + +WARNING!!! + +While looking through your index file ($CATALOG_FILE), +I noticed that you have this extra package: + +($BASE.t?z) + +that I don't recognize. Please be sure this package is +really supposed to be here, and is not left over from an +old version of Slackware. Sometimes this can happen at the +archive sites. + +EOF + dialog --title "EXTRA FILE FOUND ON YOUR DISK" \ +--msgbox "$(cat $TMP/tmpmsg)" 17 67 + rm -f $TMP/tmpmsg + fi + done + fi + fi + fi # check for missing/extra packages + + # Install the packages: + for PACKAGE_FILENAME in $PACKAGE_DIR/*.t?z; do + if [ "$PACKAGE_FILENAME" = "$PACKAGE_DIR/*.t?z" ]; then + continue; + fi + if [ "$ASK" = "never" ]; then # install the package + installpkg -root $TARGET_DIR -infobox -tagfile $TMP/tagfile $PACKAGE_FILENAME + ERROR=$? + elif [ "$ASK" = "tagfiles" ]; then + installpkg -root $TARGET_DIR -menu -tagfile $TMP/tagfile $PACKAGE_FILENAME + ERROR=$? + else # ASK should be = always here, and that's how we'll treat it + installpkg -root $TARGET_DIR -menu -ask -tagfile $TMP/tagfile $PACKAGE_FILENAME + ERROR=$? + fi + # Check for abort: + if [ "$ERROR" = "99" ]; then + umount_the_source; + chmod 755 $TARGET_DIR + chmod 1777 $TARGET_DIR/tmp + exit 1; + fi + done + OUTTAHERE="false" + if [ -r $PACKAGE_DIR/install.end ]; then + OUTTAHERE="true" + fi + umount_the_source; + if [ "$OUTTAHERE" = "true" ]; then + return 1; + fi +} + +install_disk_set() { # accepts one argument: the series name in lowercase. + SERIES_NAME=$1 + CURRENT_DISK_NUMBER="1"; + while [ 0 ]; do + # Don't start numbering the directories until 2: + if [ $CURRENT_DISK_NUMBER = 1 ]; then + DISKTOINSTALL=$SERIES_NAME + else + DISKTOINSTALL=$SERIES_NAME$CURRENT_DISK_NUMBER + fi + install_disk $DISKTOINSTALL + if [ ! $? = 0 ]; then # install.end was found, or the user chose + # to quit installing packages. + return 0; + fi + CURRENT_DISK_NUMBER=$(expr $CURRENT_DISK_NUMBER + 1) + done; +} + +# /* main() */ ;) +if [ "$DISK_SETS" = "disk" ]; then + install_disk single_disk; + ASK="always" +else + touch $TMP/tagfile + chmod 600 $TMP/tagfile + if echo $DISK_SETS | grep "#a#" 1> /dev/null 2>&1; then + A_IS_NEEDED="true" + else + A_IS_NEEDED="false" + fi + while [ 0 ]; + do + while [ 0 ]; # strip leading '#'s + do + if [ "$(echo $DISK_SETS | cut -b1)" = "#" ]; then + DISK_SETS="$(echo $DISK_SETS | cut -b2-)" + else + break; + fi + done + if [ "$A_IS_NEEDED" = "true" ]; then + cat << EOF > $TMP/tmpmsg + +--- Installing package series ==>a<== + +EOF + dialog --infobox "$(cat $TMP/tmpmsg)" 5 45 + sleep 1 + rm -f $TMP/tmpmsg + install_disk_set a; + A_IS_NEEDED="false" + fi + count="1" + if [ "$(echo $DISK_SETS | cut -b$count)" = "" ]; then + break; # we be done here :^) + else + count="2" + while [ 0 ]; do + if [ "$(echo $DISK_SETS | cut -b$count)" = "" -o "$(echo $DISK_SETS | cut -b$count)" = "#" ]; then + count="$(expr $count - 1)" + break; + else + count="$(expr $count + 1)" + fi + done + fi + diskset="$(echo $DISK_SETS | cut -b1-$count)" + count="$(expr $count + 1)" + DISK_SETS="$(echo $DISK_SETS | cut -b$count-)" + if [ "$diskset" = "a" ]; then + continue; # we expect this to be done elsewhere + fi + cat << EOF > $TMP/tmpmsg + +Installing package series ==>$diskset<== + +EOF + dialog --infobox "$(cat $TMP/tmpmsg)" 5 45 + sleep 1 + rm -f $TMP/tmpmsg + install_disk_set $diskset; + done +fi + +if [ "$DISK_SETS" = "disk" -o "$CMD_START" = "true" ]; then + if [ -r $TMP/tagfile ]; then + rm $TMP/tagfile + fi + dialog --clear +fi +chmod 755 $TARGET_DIR $TARGET_DIR/var $TARGET_DIR/usr +chmod 1777 $TARGET_DIR/tmp diff --git a/source/a/pkgtools/scripts/removepkg b/source/a/pkgtools/scripts/removepkg new file mode 100644 index 00000000..8b5a911d --- /dev/null +++ b/source/a/pkgtools/scripts/removepkg @@ -0,0 +1,430 @@ +#!/bin/sh +# Slackware remove package script +# +# Sat Apr 25 21:18:53 UTC 2009 (12.34567890b) +# Converted to use new pkgbase() function to remove pathname and +# valid package extensions. +# +# Revision 12.34567890 Sun Apr 5 20:59:32 CDT 2009 <volkerdi> +# - Support packages with the extensions: .tgz, .tbz, .tlz, .txz +# +# Revision 1.9 Wed Oct 31 14:04:28 CDT 2007 volkerding +# - Fix problem removing packages with a large number of fields. +# Thanks to Niki Kovacs for noticing this, and to Piter Punk +# for the patch. +# - Use LC_ALL=C locale, which is much faster with "sort". +# Thanks to Tsomi. +# - Don't try to remove any package that starts with '-'. This +# is not a proper package name (usually a typo), and results +# in the package database being broken. Thanks to Jef Oliver. +# - Patched cat_except() to allow the last Slackware package on +# a partition to be removed (using ROOT=, of course) +# Thanks to Selkfoster for the patch, and to everyone else who +# proposed solutions before. This issue really wasn't given +# the highest priority before, but I figured while I'm in here... +# +# Revision 1.8 Thu Nov 22 14:00:13 PST 2001 volkerding Rel $ +# - Move $TMP underneath $ROOT +# - Understand the idea of a base package name, so that packages +# can be removed with any of these notations: +# removepkg foo-1.0-i386-1.tgz +# removepkg foo-1.0-i386-1 +# removepkg foo.tgz +# removepkg foo +# +# Revision 1.7 2001/03/30 12:36:28 volkerding +# - Strip extra ".tgz" from input names. +# +# Revision 1.6 1999/03/25 18:26:41 volkerding +# - Use external $ROOT variable, like installpkg. +# +# Revision 1.5.1 1998/03/18 15:37:28 volkerding +# - Since removepkg is always run by root, the temp directory has been +# moved from /tmp to a private directory to avoid symlink attacks from +# malicious users. +# +# Revision 1.5 1997/06/26 12:09:53 franke +# - Fixed old bug in TRIGGER regex setting +# - -preserve/-copy options now preserve non-unique files +# and empty directories also +# +# Revision 1.4 1997/06/09 13:21:36 franke +# - Package file preserve (-preserve, -copy) added. +# - Don't execute "rm -rf" lines from doinst.sh, removing links explicit. +# - Warning on no longer existing files added. +# - Warning on files changed after package installation added. +# - Intermediate file preserve (-keep) added. +# - Check for required files/links now done on a combined list. +# - Write access to /var/log/{packages,scripts} no longer necessary for -warn. +# +# Revision 1.3 1997/06/08 13:03:05 franke +# Merged with revision 1.1.1.1 +# +# Revision 1.2 1996/06/01 20:04:26 franke +# Delete empty directories & formated manual pages added +# +# Revision 1.1.1.1 1995/12/18 21:20:42 volkerding +# Original Version from Slackware 3.1 +# +# Revision 1.1 1995/06/05 22:49:11 volkerding +# 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 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. +# + +# Return a package name that has been stripped of the dirname portion +# and any of the valid extensions (only): +pkgbase() { + PKGEXT=$(echo $1 | rev | cut -f 1 -d . | rev) + case $PKGEXT in + 'tgz' ) + PKGRETURN=$(basename $1 .tgz) + ;; + 'tbz' ) + PKGRETURN=$(basename $1 .tbz) + ;; + 'tlz' ) + PKGRETURN=$(basename $1 .tlz) + ;; + 'txz' ) + PKGRETURN=$(basename $1 .txz) + ;; + *) + PKGRETURN=$(basename $1) + ;; + esac + echo $PKGRETURN +} + +# This makes "sort" run much faster: +export LC_ALL=C + +# Make sure there's a proper temp directory: +TMP=$ROOT/var/log/setup/tmp +# If the $TMP directory doesn't exist, create it: +if [ ! -d $TMP ]; then + rm -rf $TMP # make sure it's not a symlink or something stupid + mkdir -p $TMP + chmod 700 $TMP # no need to leave it open +fi +ADM_DIR=$ROOT/var/log +PRES_DIR=$TMP/preserved_packages + +# This simple cat_except() should be used on the installer, +# since the busybox "find" can't handle the complex find +# syntax: +#cat_except() { +# ( cd "$1" && cat $(ls * | sed "/^$2\$/d")) +#} + +# This version of cat_except() allows the last package to be +# 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") + fi + ) +} + +extract_links() { + sed -n 's,^( *cd \([^ ;][^ ;]*\) *; *rm -rf \([^ )][^ )]*\) *) *$,\1/\2,p' +} + +preserve_file() { + if [ "$PRESERVE" = "true" ]; then + F="$(basename "$1")" + D="$(dirname "$1")" + if [ ! -d "$PRES_DIR/$PKGNAME/$D" ]; then + mkdir -p "$PRES_DIR/$PKGNAME/$D" || return 1 + fi + cp -p "$ROOT/$D/$F" "$PRES_DIR/$PKGNAME/$D" || return 1 + fi + return 0 +} + +preserve_dir() { + if [ "$PRESERVE" = "true" ]; then + if [ ! -d "$PRES_DIR/$PKGNAME/$1" ]; then + mkdir -p "$PRES_DIR/$PKGNAME/$1" || return 1 + fi + fi + return 0 +} + +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." + preserve_file "$FILE" + else + if [ "$(echo $FILE | cut -b1-8)" != "install/" ]; then + echo "WARNING: Nonexistent $ROOT/$FILE was found in another package. Skipping." + fi + fi + else + preserve_dir "$FILE" + fi + done +} + +keep_links() { + while read LINK ; do + if [ -L "$ROOT/$LINK" ]; then + echo " --> $ROOT/$LINK (symlink) was found in another package. Skipping." + else + echo "WARNING: Nonexistent $ROOT/$LINK (symlink) was found in another package. Skipping." + fi + done +} + +delete_files() { + while read FILE ; do + 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." + fi + if [ ! "$WARN" = "true" ]; then + echo " --> Deleting $ROOT/$FILE" + preserve_file "$FILE" && rm -f "$ROOT/$FILE" + else + echo " --> $ROOT/$FILE would be deleted" + preserve_file "$FILE" + fi + else + echo " --> $ROOT/$FILE no longer exists. Skipping." + fi + else + preserve_dir "$FILE" + fi + done +} + +delete_links() { + while read LINK ; do + if [ -L "$ROOT/$LINK" ]; then + if [ ! "$WARN" = "true" ]; then + echo " --> Deleting symlink $ROOT/$LINK" + rm -f $ROOT/$LINK + else + echo " --> $ROOT/$LINK (symlink) would be deleted" + fi + else + echo " --> $ROOT/$LINK (symlink) no longer exists. Skipping." + fi + done +} + +delete_dirs() { + sort -r | \ + while read DIR ; do + 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" + rmdir "$ROOT/$DIR" + else + echo "WARNING: Unique directory $ROOT/$DIR contains new files" + fi + else + echo " --> $ROOT/$DIR (dir) would be deleted if empty" + fi + fi + done +} + +delete_cats() { + sed -n 's,/man\(./[^/]*$\),/cat\1,p' | \ + while read FILE ; do + if [ -f "$ROOT/$FILE" ]; then + if [ ! "$WARN" = "true" ]; then + echo " --> Deleting $ROOT/$FILE (fmt man page)" + rm -f $ROOT/$FILE + else + echo " --> $ROOT/$FILE (fmt man page) would be deleted" + fi + fi + done +} + +package_name() { + STRING=$(pkgbase $1) + # If we don't do this, commands run later will take the '-' to be an option + # and will destroy the package database. Packages should not contain spaces + # in them. Normally this type of problem results from a command line typo. + if [ "$(echo $STRING | cut -b 1)" = "-" ]; then + STRING="malformed-package-name-detected" + fi + # Check for old style package name with one segment: + if [ "$(echo $STRING | cut -f 1 -d -)" = "$(echo $STRING | cut -f 2 -d -)" ]; then + echo $STRING + else # has more than one dash delimited segment + # Count number of segments: + INDEX=1 + while [ ! "$(echo $STRING | cut -f $INDEX -d -)" = "" ]; do + INDEX=$(expr $INDEX + 1) + done + INDEX=$(expr $INDEX - 1) # don't include the null value + # If we don't have four segments, return the old-style (or out of spec) package name: + if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then + echo $STRING + else # we have four or more segments, so we'll consider this a new-style name: + NAME=$(expr $INDEX - 3) + NAME="$(echo $STRING | cut -f 1-$NAME -d -)" + echo $NAME + # cruft for later ;) + #VER=$(expr $INDEX - 2) + #VER="$(echo $STRING | cut -f $VER -d -)" + #ARCH=$(expr $INDEX - 1) + #ARCH="$(echo $STRING | cut -f $ARCH -d -)" + #BUILD="$(echo $STRING | cut -f $INDEX -d -)" + fi + fi +} + +# Conversion to 'comm' utility by Mark Wisdom. +# is pretty nifty! :^) +remove_packages() { + 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, + # there should only be one package installed with a given basename, but + # we don't enforce this policy. If there's more than one, only one will + # 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) + fi + fi + + if [ -r $ADM_DIR/packages/$PKGNAME ]; then + if [ ! "$WARN" = true ]; then + echo "Removing package $ADM_DIR/packages/$PKGNAME..." + fi + if fgrep "./" $ADM_DIR/packages/$PKGNAME 1> /dev/null 2>&1; then + TRIGGER="^\.\/" + else + TRIGGER="FILE LIST:" + fi + if [ ! "$WARN" = true ]; then + echo "Removing files:" + fi + sed -n "/$TRIGGER/,/^$/p" < $ADM_DIR/packages/$PKGNAME | \ + fgrep -v "FILE LIST:" | sort -u > $TMP/delete_list$$ + # Pat's new-new && improved pre-removal routine. + cat_except $ADM_DIR/packages $PKGNAME | sort -u > $TMP/required_list$$ + if [ -r $ADM_DIR/scripts/$PKGNAME ]; then + extract_links < $ADM_DIR/scripts/$PKGNAME | sort -u > $TMP/del_link_list$$ + cat_except $ADM_DIR/scripts $PKGNAME | 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$$ + 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 | \ + sort -u > $TMP/required_links$$ + mv $TMP/required_list$$ $TMP/required_files$$ + sort -u $TMP/required_links$$ $TMP/required_files$$ >$TMP/required_list$$ + fi + comm -12 $TMP/delete_list$$ $TMP/required_list$$ | keep_files + comm -23 $TMP/delete_list$$ $TMP/required_list$$ > $TMP/uniq_list$$ + delete_files < $TMP/uniq_list$$ + delete_dirs < $TMP/uniq_list$$ + delete_cats < $TMP/uniq_list$$ + if [ ! "$KEEP" = "true" ]; then + rm -f $TMP/delete_list$$ $TMP/required_files$$ $TMP/uniq_list$$ + rm -f $TMP/del_link_list$$ $TMP/required_links$$ $TMP/required_list$$ + fi + if [ "$PRESERVE" = "true" ]; then + if [ -r $ADM_DIR/scripts/$PKGNAME ]; then + if [ ! -d "$PRES_DIR/$PKGNAME/install" ]; then + mkdir -p "$PRES_DIR/$PKGNAME/install" + fi + cp -p $ADM_DIR/scripts/$PKGNAME $PRES_DIR/$PKGNAME/install/doinst.sh + 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 + 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." + fi + done +} + +if [ "$#" = "0" ]; then + echo "Usage: $(basename $0) [-copy] [-keep] [-preserve] [-warn] packagename ..."; exit 1 +fi + +while : ; do + case "$1" in + -copy | --copy) WARN=true; PRESERVE=true; shift;; + -keep | --keep) KEEP=true; shift;; + -preserve | --preserve) PRESERVE=true; shift;; + -warn | --warn) WARN=true; shift;; + -* | --*) echo "Usage: $(basename $0) [-copy] [-keep] [-preserve] [-warn] packagename ..."; exit 1;; + *) break + esac +done + +if [ "$WARN" = "true" ]; then + echo "Only warning... not actually removing any files." + if [ "$PRESERVE" = "true" ]; then + echo "Package contents is copied to $PRES_DIR." + fi + echo "Here's what would be removed (and left behind) if you" + echo "removed the package(s):" + echo +else + if [ "$PRESERVE" = "true" ]; then + echo "Package contents is copied to $PRES_DIR." + fi +fi + +remove_packages $* + diff --git a/source/a/pkgtools/scripts/setup.70.install-kernel b/source/a/pkgtools/scripts/setup.70.install-kernel new file mode 100644 index 00000000..8edf6477 --- /dev/null +++ b/source/a/pkgtools/scripts/setup.70.install-kernel @@ -0,0 +1,5 @@ +# Install the bootdisk or CD-ROM's Linux kernel: +#BLURB="Install a Linux kernel from a bootdisk" +if [ -x /usr/lib/setup/SeTkernel ]; then + . /usr/lib/setup/SeTkernel +fi diff --git a/source/a/pkgtools/scripts/setup.80.make-bootdisk b/source/a/pkgtools/scripts/setup.80.make-bootdisk new file mode 100644 index 00000000..d9b4012f --- /dev/null +++ b/source/a/pkgtools/scripts/setup.80.make-bootdisk @@ -0,0 +1,175 @@ +#!/bin/sh +#BLURB="Create a USB Linux boot stick" +RDIR=/dev/tty4 +NDIR=/dev/null +TMP=/var/log/setup/tmp + +if [ ! -d $TMP ]; then + mkdir -p $TMP +fi +T_PX="$1" +ROOT_DEVICE="$2" + +while [ 0 ]; do # the bootdisk menu loop + # Run "rescan-scsi-bus -l" to get an up to date overview of devices: + /sbin/rescan-scsi-bus -l 1>$RDIR 2>$RDIR + # Get a list of removable block devices before the USB stick is inserted: + echo "" > $TMP/remov_prior + for BDEV in $(ls --indicator-style none /sys/block | egrep -v "loop|ram"); do + [ -r /sys/block/$BDEV/removable -a "$(cat /sys/block/$BDEV/removable)" == "1" ] \ + && echo $BDEV >> $TMP/remov_prior + done + dialog --title "MAKE USB FLASH BOOT" --default-item "Skip" --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 \ +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\ +\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" \ + 2> $TMP/return + REPLY=`cat $TMP/return` + rm -f $TMP/return + if [ "$REPLY" = "Create" ]; then + # Run "rescan-scsi-bus -l" to discover our USB stick if needed: + /sbin/rescan-scsi-bus -l 1>$RDIR 2>$RDIR + # Get a list of removable block devices after the USB stick is inserted: + echo "" > $TMP/remov_after + for BDEV in $(ls --indicator-style none /sys/block | egrep -v "loop|ram"); do + [ -r /sys/block/$BDEV/removable -a "$(cat /sys/block/$BDEV/removable)" == "1" ] \ + && echo $BDEV >> $TMP/remov_after + done + ADDED=$(diff -u $TMP/remov_prior $TMP/remov_after | sed -n 's/^\+//p' | grep -v '^+') + REMVD=$(diff -u $TMP/remov_prior $TMP/remov_after | sed -n 's/^\+//p' | grep -v '^+') + if [ -n "$ADDED" ] ; then STICK=$ADDED ; else STICK="" ; fi + rm $TMP/remov_prior $TMP/remov_after + if [ ! -n "$STICK" ]; then + dialog --title "NO NEW DEVICE DETECTED" --ok-label Restart --msgbox \ +"No new USB device was detected. +If you had already inserted your USB stick, please remove it now. \ +Then select 'Restart'." 7 70 + continue + else + VENDOR="Vendor : $(cat /sys/block/$STICK/device/vendor)" + MODEL="Model : $(cat /sys/block/$STICK/device/model)" + SIZE="Size : $(( $(cat /sys/block/$STICK/size) / 2048)) MB" + dialog --title "NEW DEVICE DETECTED" --yesno \ +"A new USB device '/dev/$STICK' was detected with specifications: + +-- $VENDOR +-- $MODEL +-- $SIZE + +If this is the USB stick to use, select 'Yes', +otherwise select 'No'." 12 70 + if [ $? -eq 1 ]; then + continue + fi + fi + + dialog --title "CREATING USB BOOT STICK" --infobox "Creating SYSLINUX bootdisk for \ +$ROOT_DEVICE on /dev/$STICK." 3 64 + # Determine max size of the filesystem (in KB) we want to create: + USBSIZE=$(( $(cat /sys/block/$STICK/size) / 2048)) + if [ $USBSIZE -lt 512 ]; then DOSSIZE=$(($USBSIZE*1024)) + else DOSSIZE=$((512*1024)) + fi + # Hack from Pat. If we're wasting a whole stick, who cares if the partition is + # extra-small, as long as the kernel fits? Also, FAT12 is the least problematic. + DOSSIZE=15861 + if [ -x /sbin/mkdosfs ]; then + /sbin/mkdosfs -I -n USBSLACK -F 12 /dev/$STICK $DOSSIZE 1> /dev/null 2> /dev/null + else + chroot $T_PX /sbin/mkdosfs -I -n USBSLACK -F 12 /dev/$STICK $DOSSIZE 1> /dev/null 2> /dev/null + fi + if [ ! -d $TMP/bootdisk ]; then + mkdir $TMP/bootdisk + fi + mount -t vfat /dev/$STICK $TMP/bootdisk 1> /dev/null 2> /dev/null + if [ -r $T_PX/vmlinuz ]; then + cp $T_PX/vmlinuz $TMP/bootdisk/vmlinuz + elif [ -r $T_PX/boot/vmlinuz ]; then + cp $T_PX/boot/vmlinuz $TMP/bootdisk/vmlinuz + fi + # We don't need the isolinux bootloader with syslinux do we? + #cp $T_PX/usr/share/syslinux/isolinux.bin $TMP/bootdisk/ + cat << EOF > $TMP/bootdisk/message.txt + +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 +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 +kernel parameters you might need depending on your hardware, and which +drivers are included in your kernel. + +EOF + cat << EOF > $TMP/bootdisk/syslinux.cfg +default vmlinuz root=$ROOT_DEVICE vga=normal ro +prompt 1 +timeout 6000 +display message.txt +F1 f1.txt +F2 message.txt +#F3 f3.txt +#F4 f4.txt +#F5 f5.txt +#F6 f6.txt +#F7 f7.txt +label mount + kernel vmlinuz + append root=$ROOT_DEVICE vga=normal ro +EOF + cat << EOF > $TMP/bootdisk/f1.txt + STANDARD MODES: + To make the kernel prompt for standard video modes use: vga=ask + + 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: + + Colors 640x480 800x600 1024x768 1280x1024 1600x1200 + --------+--------------------------------------------- + 256 | 769 771 773 775 796 + 32,768 | 784 787 790 793 797 + 65,536 | 785 788 791 794 798 + 16.8M | 786 789 792 795 799 + + ...such as this for 1024x768x64k: + vga=791 + + F2 returns to the previous page. + +EOF + umount /dev/$STICK + rm -r $TMP/bootdisk + # Make the device bootable: + syslinux -s /dev/$STICK 1> /dev/null 2> /dev/null + dialog --title "USB BOOT STICK CREATED" --ok-label Continue --cancel-label Create --menu \ +"The USB boot stick has been successfully created in /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 70 2 \ + "Continue" "Continue the configuration (done making boot sticks)" \ + "Create" "Make a spare Linux boot stick in /dev/$STICK" \ + 2> $TMP/return + REPLY=`cat $TMP/return` + rm -f $TMP/return + if [ "$REPLY" = "Create" ]; then + continue + else + break + fi + else # ! Create + break + fi +done diff --git a/source/a/pkgtools/scripts/setup.htmlview b/source/a/pkgtools/scripts/setup.htmlview new file mode 100644 index 00000000..2fd9930a --- /dev/null +++ b/source/a/pkgtools/scripts/setup.htmlview @@ -0,0 +1,33 @@ +#!/bin/sh +#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, +# this is not a Linux standard that could be locating +# 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. ;-) + +# 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 +# the initial installation? + +for browser in firefox seamonkey konqueror galeon epiphany links lynx ; do + if [ ! -e usr/bin/htmlview -a -x usr/bin/$browser ]; then + cat << EOF > usr/bin/htmlview +#!/bin/sh +exec $browser "\$@" +EOF + fi +done +if [ -e usr/bin/htmlview ]; then + chmod 755 usr/bin/htmlview +fi + diff --git a/source/a/pkgtools/scripts/setup.services b/source/a/pkgtools/scripts/setup.services new file mode 100644 index 00000000..aee2599f --- /dev/null +++ b/source/a/pkgtools/scripts/setup.services @@ -0,0 +1,287 @@ +#!/bin/sh +#BLURB="Select/deselect system daemons (services)" +TMP=/var/log/setup/tmp +if [ ! -d $TMP ]; then + mkdir -p $TMP +fi +T_PX="$1" +cd $T_PX +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 \\ +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. \\ +Press the ENTER key when you are finished." \\ +20 75 7 \\ +EOF + +if [ -r etc/rc.d/rc.atalk ]; then + if [ -x etc/rc.d/rc.atalk ]; then + RC_ATALK=on + else + RC_ATALK=off + fi + cat << EOF >> $TMP/tmpscript + "rc.atalk" "Netatalk Appletalk file/print server" $RC_ATALK "The Netatalk server is a file and print server for Macintosh networks." \\ +EOF +fi + +if [ -r etc/rc.d/rc.bind ]; then + if [ -x etc/rc.d/rc.bind ]; then + RC_BIND=on + else + RC_BIND=off + fi + cat << EOF >> $TMP/tmpscript + "rc.bind" "BIND (Domain Name System) server" $RC_BIND "BIND (Berkeley Internet Name Domain) is a Domain Name System (DNS) server." \\ +EOF +fi + +if [ -r etc/rc.d/rc.cups ]; then + if [ -x etc/rc.d/rc.cups ]; then + RC_CUPS=on + else + RC_CUPS=off + fi + cat << EOF >> $TMP/tmpscript + "rc.cups" "CUPS print server" $RC_CUPS "The Common UNIX Printing system (print spooler choice #1)." \\ +EOF +fi + +if [ -r etc/rc.d/rc.dnsmasq ]; then + if [ -x etc/rc.d/rc.dnsmasq ]; then + RC_DNSMASQ=on + else + RC_DNSMASQ=off + fi + cat << EOF >> $TMP/tmpscript + "rc.dnsmasq" "dnsmasq DHCP/DNS server" $RC_DNSMASQ "dnsmasq provides DNS and DHCP service to a LAN." \\ +EOF +fi + +if [ -r etc/rc.d/rc.fuse ]; then + if [ -x etc/rc.d/rc.fuse ]; then + RC_FUSE=on + else + RC_FUSE=off + fi + cat << EOF >> $TMP/tmpscript + "rc.fuse" "Filesystem in Userspace library" $RC_FUSE "FUSE is an interface to allow userspace programs to use filesystems." \\ +EOF +fi + +if [ -r etc/rc.d/rc.hald ]; then + if [ -x etc/rc.d/rc.hald ]; then + RC_HALD=on + else + RC_HALD=off + fi + cat << EOF >> $TMP/tmpscript + "rc.hald" "Hardware Abstraction Layer" $RC_HALD "HAL makes access to CD/DVD drives and USB devices easier." \\ +EOF +fi + +if [ -r etc/rc.d/rc.hplip ]; then + if [ -x etc/rc.d/rc.hplip ]; then + RC_HPLIP=on + else + RC_HPLIP=off + fi + cat << EOF >> $TMP/tmpscript + "rc.hplip" "HP printer/scanner daemons" $RC_HPLIP "Programs used to run printers and scanners from Hewlett Packard." \\ +EOF +fi + +if [ -r etc/rc.d/rc.httpd ]; then + if [ -x etc/rc.d/rc.httpd ]; then + RC_HTTPD=on + else + RC_HTTPD=off + fi + cat << EOF >> $TMP/tmpscript + "rc.httpd" "The Apache web server" $RC_HTTPD "Apache, the most widely used web server on the net." \\ +EOF +fi + +if [ -r etc/rc.d/rc.inetd ]; then + if [ -x etc/rc.d/rc.inetd ]; then + RC_INETD=on + else + RC_INETD=off + fi + cat << EOF >> $TMP/tmpscript + "rc.inetd" "The BSD Inetd daemon" $RC_INETD "Inetd daemon (this allows: time, ftp, comsat, talk, finger, and auth)." \\ +EOF +fi + +if [ -r etc/rc.d/rc.ip_forward ]; then + if [ -x etc/rc.d/rc.ip_forward ]; then + RC_IP_FORWARD=on + else + RC_IP_FORWARD=off + fi + cat << EOF >> $TMP/tmpscript + "rc.ip_forward" "Activate IP packet forwarding" $RC_IP_FORWARD "Packet forwarding allows your Linux machine to act as a router." \\ +EOF +fi + +if [ -r etc/rc.d/rc.lprng ]; then + if [ -x etc/rc.d/rc.lprng ]; then + RC_LPRNG=on + else + RC_LPRNG=off + fi + cat << EOF >> $TMP/tmpscript + "rc.lprng" "LPRng print server" $RC_LPRNG "The LPRng printing system (print spooler choice #2)." \\ +EOF +fi + +if [ -r etc/rc.d/rc.messagebus ]; then + if [ -x etc/rc.d/rc.messagebus ]; then + RC_MESSAGEBUS=on + else + RC_MESSAGEBUS=off + fi + cat << EOF >> $TMP/tmpscript + "rc.messagebus" "D-Bus system message bus" $RC_MESSAGEBUS "Used for communication by HAL and other programs." \\ +EOF +fi + +if [ -r etc/rc.d/rc.mysqld ]; then + if [ -x etc/rc.d/rc.mysqld ]; then + RC_MYSQLD=on + else + RC_MYSQLD=off + fi + cat << EOF >> $TMP/tmpscript + "rc.mysqld" "The MySQL database server" $RC_MYSQLD "MySQL, an SQL-based relational database daemon." \\ +EOF +fi + +if [ -r etc/rc.d/rc.ntpd ]; then + if [ -x etc/rc.d/rc.ntpd ]; then + RC_NTPD=on + else + RC_NTPD=off + fi + cat << EOF >> $TMP/tmpscript + "rc.ntpd" "The network time server" $RC_NTPD "NTP synchronizes your time to/from other NTP servers." \\ +EOF +fi + +if [ -r etc/rc.d/rc.pcmcia ]; then + if [ -x etc/rc.d/rc.pcmcia ]; then + RC_PCMCIA=on + else + RC_PCMCIA=off + fi + cat << EOF >> $TMP/tmpscript + "rc.pcmcia" "PCMCIA/Cardbus card services" $RC_PCMCIA "This supports PCMCIA or Cardbus cards used with laptops." \\ +EOF +fi + +if [ -r etc/rc.d/rc.rpc ]; then + if [ -x etc/rc.d/rc.rpc ]; then + RC_RPC=on + else + RC_RPC=off + fi + cat << EOF >> $TMP/tmpscript + "rc.rpc" "RPC (NFS) daemons" $RC_RPC "Needed to serve or mount NFS (Network File System) partitions." \\ +EOF +fi + +if [ -r etc/rc.d/rc.samba ]; then + if [ -x etc/rc.d/rc.samba ]; then + RC_SAMBA=on + else + RC_SAMBA=off + fi + cat << EOF >> $TMP/tmpscript + "rc.samba" "The Samba file/print server" $RC_SAMBA "Samba is a file and print server for Windows networks." \\ +EOF +fi + +if [ -r etc/rc.d/rc.saslauthd ]; then + if [ -x etc/rc.d/rc.saslauthd ]; then + RC_SASLAUTHD=on + else + RC_SASLAUTHD=off + fi + cat << EOF >> $TMP/tmpscript + "rc.saslauthd" "The SASL authentication server" $RC_SASLAUTHD "SASL is an authentication method often used by mail servers." \\ +EOF +fi + +if [ -r etc/rc.d/rc.sendmail ]; then + if [ -x etc/rc.d/rc.sendmail ]; then + RC_SENDMAIL=on + else + RC_SENDMAIL=off + fi + cat << EOF >> $TMP/tmpscript + "rc.sendmail" "The Sendmail mail server" $RC_SENDMAIL "The Sendmail server allows your machine to send and receive mail." \\ +EOF +fi + +if [ -r etc/rc.d/rc.snmpd ]; then + if [ -x etc/rc.d/rc.snmpd ]; then + RC_SNMPD=on + else + RC_SNMPD=off + fi + cat << EOF >> $TMP/tmpscript + "rc.snmpd" "Net-SNMP daemon" $RC_SNMPD "SNMP daemon that receives and logs SNMP TRAP and INFORM messages." \\ +EOF +fi + +if [ -r etc/rc.d/rc.syslog ]; then + if [ -x etc/rc.d/rc.syslog ]; then + RC_SYSLOGD=on + else + RC_SYSLOGD=off + fi + cat << EOF >> $TMP/tmpscript + "rc.syslog" "The Linux system logging utilities" $RC_SYSLOGD "The syslogd and klogd daemons log important messages under /var/log." \\ +EOF +fi + +if [ -r etc/rc.d/rc.sshd ]; then + if [ -x etc/rc.d/rc.sshd ]; then + RC_SSHD=on + else + RC_SSHD=off + fi + cat << EOF >> $TMP/tmpscript + "rc.sshd" "The SSHD (secure shell) daemon" $RC_SSHD "SSHD allows secure encrypted logins to your machine." \\ +EOF +fi + +cat << EOF >> $TMP/tmpscript + 2> $TMP/reply +EOF + +. $TMP/tmpscript + +if [ ! $? = 0 ]; then + rm -f $TMP/reply $TMP/tmpscript + 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 + if [ -f etc/rc.d/$service ]; then + if grep -w $service $TMP/reply 1> /dev/null ; then + chmod 755 etc/rc.d/$service + else + chmod 644 etc/rc.d/$service + fi + fi +done + +rm -f $TMP/reply $TMP/tmpscript + diff --git a/source/a/pkgtools/scripts/upgradepkg b/source/a/pkgtools/scripts/upgradepkg new file mode 100644 index 00000000..cc3250da --- /dev/null +++ b/source/a/pkgtools/scripts/upgradepkg @@ -0,0 +1,387 @@ +#!/bin/sh +# Copyright 1999 Patrick Volkerding, Moorhead, Minnesota, USA +# Copyright 2001, 2002, 2003 Slackware Linux, Inc., Concord, California, USA +# Copyright 2009 Patrick J. Volkerding, Sebeka, MN, USA +# 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. +# +# Modified to handle either old 8.3 or new package-version-arch-build.tgz +# packages, Sat Nov 17 14:25:58 PST 2001 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 +# +# 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 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. + +# Return a package name that has been stripped of the dirname portion +# and any of the valid extensions (only): +pkgbase() { + PKGEXT=$(echo $1 | rev | cut -f 1 -d . | rev) + case $PKGEXT in + 'tgz' ) + PKGRETURN=$(basename $1 .tgz) + ;; + 'tbz' ) + PKGRETURN=$(basename $1 .tbz) + ;; + 'tlz' ) + PKGRETURN=$(basename $1 .tlz) + ;; + 'txz' ) + PKGRETURN=$(basename $1 .txz) + ;; + *) + PKGRETURN=$(basename $1) + ;; + esac + echo $PKGRETURN +} + +usage() { + cat << EOF + +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 +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 +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 +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 +to be installed, remove the old ones manually prior to running upgradepkg. + +To upgrade in a directory other than / (such as /mnt): + + ROOT=/mnt upgradepkg package.tgz (or .tbz, .tlz, .txz) + +EOF +} + +# Make sure there's a proper temp directory: +TMP=$ROOT/var/log/setup/tmp +# If the $TMP directory doesn't exist, create it: +if [ ! -d $TMP ]; then + rm -rf $TMP # make sure it's not a symlink or something stupid + mkdir $TMP + chmod 700 $TMP # no need to leave it open +fi + +# This script expects an 022 umask: +umask 022 + +# $ROOT defined? +if [ -d "$ROOT" ]; then + export ROOT +fi + +# --help or no args? +if [ "$1" = "" -o "$1" = "--help" -o "$1" = "-?" ]; then + usage; + exit 1; +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 + # managed and now is moved into place, using --no-paranoia will cause + # 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 + # 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 + # Reinstall packages even if the installed one is the same version. + REINSTALL="true" + shift 1 + elif [ "$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 + # Output a report about which packages would be installed or upgraded + # but don't actually perform the upgrades. + DRY_RUN="true" + shift 1 + else # no more args + break; + fi +done # processing args + +# 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 +# old package. + +package_name() { + STRING=$(pkgbase $1) + # Check for old style package name with one segment: + if [ "$(echo $STRING | cut -f 1 -d -)" = "$(echo $STRING | cut -f 2 -d -)" ]; then + echo $STRING + else # has more than one dash delimited segment + # Count number of segments: + INDEX=1 + while [ ! "$(echo $STRING | cut -f $INDEX -d -)" = "" ]; do + INDEX=$(expr $INDEX + 1) + done + INDEX=$(expr $INDEX - 1) # don't include the null value + # If we don't have four segments, return the old-style (or out of spec) package name: + if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then + echo $STRING + else # we have four or more segments, so we'll consider this a new-style name: + NAME=$(expr $INDEX - 3) + NAME="$(echo $STRING | cut -f 1-$NAME -d -)" + echo $NAME + # cruft for later ;) + #VER=$(expr $INDEX - 2) + #VER="$(echo $STRING | cut -f $VER -d -)" + #ARCH=$(expr $INDEX - 1) + #ARCH="$(echo $STRING | cut -f $ARCH -d -)" + #BUILD="$(echo $STRING | cut -f $INDEX -d -)" + fi + fi +} + +ERRCODE=0 + +# Main processing loop: +while [ ! "$1" = "" ]; do + +# Simple package integrity check: +if [ ! -f $(echo $1 | cut -f 2 -d '%') ]; then + ERRCODE=4 + echo "Cannot install $1: file not found" + shift 1 + continue; +fi + +# Figure out the names of the old and new packages: +OLD=$(echo $1 | cut -f 1 -d '%') +NEW=$(echo $1 | cut -f 2 -d '%') +INCOMINGDIR=$(dirname $NEW) +# These are the package names with the extension: +NNAME=$(basename $NEW) +ONAME=$(basename $OLD) +# These are the package names without the extension: +OLD=$(pkgbase $OLD) +NEW=$(pkgbase $NEW) + +# Make sure the extension is valid: +if [ "$NNAME" = "$NEW" ]; then + # We won't throw an ERRCODE for this, but the package is skipped: + echo "Cannot install $1: invalid package extension" + shift 1 + continue; +fi + +# Check and fix the old package name: +SHORT="$(package_name $OLD)" +if [ ! -r $ROOT/var/log/packages/$OLD ]; then + if ls $ROOT/var/log/packages/$SHORT* 1> /dev/null 2> /dev/null ; then + for installed_package in $ROOT/var/log/packages/$SHORT* ; do + if [ "$(package_name $installed_package)" = "$SHORT" ]; then # found one + OLD="$(basename $installed_package)" + break + fi + done + fi +fi + +# Test to see if both the old and new packages are where we expect them +# to be -- skip to the next package (or package pair) if anything's wrong: + +if [ ! -r $ROOT/var/log/packages/$OLD ]; then + if [ ! "$INSTALL_NEW" = "yes" ]; then + if [ "$DRY_RUN" = "true" ]; then + echo "$OLD would not be upgraded (no installed package named $SHORT)." + else + echo + echo "Error: there is no installed package named $OLD." + echo " (looking for $ROOT/var/log/packages/$OLD)" + echo + fi + ERRCODE=1 + else # --install-new was given, so install the new package: + if [ "$DRY_RUN" = "true" ]; then + echo "$NEW would be installed (new package)." + else + cat << EOF + ++============================================================================== +| Installing new package $INCOMINGDIR/$NNAME ++============================================================================== + +EOF + installpkg $INCOMINGDIR/$NNAME + fi + fi + shift 1 + continue; +elif [ ! -r "$INCOMINGDIR/$NNAME" ]; then + if [ "$DRY_RUN" = "true" ]; then + echo "$NEW incoming package not found (command line)." + else + echo + echo "Error: incoming package $INCOMINGDIR/$NNAME not found." + echo + fi + shift 1 + ERRCODE=1 + continue; +fi + +# Unless --reinstall was given, compare the package names +# and skip any exact matches: +if [ ! "$REINSTALL" = "true" ]; then + if [ "$OLD" = "$NEW" ]; then + if [ "$DRY_RUN" = "true" ]; then + echo "$NEW would be skipped (already installed)." + else + cat << EOF + ++============================================================================== +| Skipping package $NEW (already installed) ++============================================================================== + +EOF + fi + shift 1 + continue; + fi +fi + +# Showtime. Let's do the upgrade. First, we will rename all the +# installed packages with this basename to make them easy to remove later: + +TIMESTAMP=$(date +%Y-%m-%d,%T) +SHORT="$(package_name $OLD)" +if [ "$DRY_RUN" = "true" ]; then + echo -n "$NEW would upgrade: " + for installed_package in $ROOT/var/log/packages/$SHORT* ; do + if [ "$(package_name $installed_package)" = "$SHORT" ]; then + echo -n "$(pkgbase $installed_package)" + fi + done + echo + shift 1 + continue +fi +for installed_package in $ROOT/var/log/packages/$SHORT* ; do + if [ "$(package_name $installed_package)" = "$SHORT" ]; then + mv $installed_package ${installed_package}-upgraded-$TIMESTAMP + fi +done +for installed_script in $ROOT/var/log/scripts/$SHORT* ; do + if [ "$(package_name $installed_script)" = "$SHORT" ]; then + if [ -r $installed_script ]; then + mv $installed_script ${installed_script}-upgraded-$TIMESTAMP + fi + fi +done + +# Print a banner for the current upgrade: +cat << EOF + ++============================================================================== +| Upgrading $OLD package using $INCOMINGDIR/$NNAME ++============================================================================== + +EOF + +# Next, the new package is pre-installed: +if [ "$VERBOSE" = "verbose" ]; then + installpkg $INCOMINGDIR/$NNAME + RETCODE=$? +else + echo "Pre-installing package $NEW..." + installpkg $INCOMINGDIR/$NNAME 1> /dev/null + RETCODE=$? +fi +# Make sure that worked: +if [ ! $RETCODE = 0 ]; then + echo "ERROR: Package $INCOMINGDIR/$NNAME did not install" + echo "correctly. You may need to reinstall your old package" + echo "to avoid problems. Make sure the new package is not" + echo "corrupted." + sleep 30 + # Skip this package, but still try to proceed. Good luck... + shift 1 + continue; +fi + +# Now, the leftovers from the old package(s) can go. Pretty simple, huh? :) +if [ -d "$ROOT" ]; then + ( cd $ROOT/var/log/packages + for rempkg in *-$TIMESTAMP ; do + if [ "$VERBOSE" = "verbose" ]; then + ROOT=$ROOT removepkg $rempkg + else + ROOT=$ROOT removepkg $rempkg | grep -v "Skipping\." | grep -v "Removing files:" + fi + done + ) +else + ( cd /var/log/packages + for rempkg in *-$TIMESTAMP ; do + if [ "$VERBOSE" = "verbose" ]; then + removepkg $rempkg + else + removepkg $rempkg | grep -v "Skipping\." | grep -v "Removing files:" + fi + done + ) +fi +echo + +# Again! Again! +# Seriously, the reinstalling of a package can be crucial if any files +# shift location, so we should always reinstall as the final step: +if [ ! "$NOT_PARANOID" = "true" ]; then + installpkg $INCOMINGDIR/$NNAME +fi + +echo "Package $OLD upgraded with new package $INCOMINGDIR/$NNAME." +ERRCODE=0 + +# Process next parameter: +shift 1 + +done + +if [ ! "$DRY_RUN" = "true" ]; then + echo +fi +exit $ERRCODE |