summaryrefslogtreecommitdiff
path: root/source/a/pkgtools/scripts/removepkg
diff options
context:
space:
mode:
Diffstat (limited to 'source/a/pkgtools/scripts/removepkg')
-rw-r--r--source/a/pkgtools/scripts/removepkg63
1 files changed, 14 insertions, 49 deletions
diff --git a/source/a/pkgtools/scripts/removepkg b/source/a/pkgtools/scripts/removepkg
index 8b5a911d..2813fc3c 100644
--- a/source/a/pkgtools/scripts/removepkg
+++ b/source/a/pkgtools/scripts/removepkg
@@ -1,6 +1,12 @@
#!/bin/sh
# Slackware remove package script
#
+# Thu Sep 24 03:31:58 UTC 2015 <alphageek>
+# extract_links() sed adjusted to handle symlinks with spaces.
+#
+# Sun Sep 6 21:58:36 BST 2009
+# Replaced pkgbase & package_name code with 'sed' script by Jim Hawkins.
+#
# Sat Apr 25 21:18:53 UTC 2009 (12.34567890b)
# Converted to use new pkgbase() function to remove pathname and
# valid package extensions.
@@ -72,7 +78,7 @@
# Copyright 1994, 1995, 1998 Patrick Volkerding, Moorhead, Minnesota USA
# Copyright 2001, Slackware Linux, Inc., Concord, CA USA
-# Copyright 2009 Patrick J. Volkerding, Sebeka, MN, USA
+# Copyright 2009, 2015 Patrick J. Volkerding, Sebeka, MN, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
@@ -96,25 +102,8 @@
# Return a package name that has been stripped of the dirname portion
# and any of the valid extensions (only):
pkgbase() {
- PKGEXT=$(echo $1 | rev | cut -f 1 -d . | rev)
- case $PKGEXT in
- 'tgz' )
- PKGRETURN=$(basename $1 .tgz)
- ;;
- 'tbz' )
- PKGRETURN=$(basename $1 .tbz)
- ;;
- 'tlz' )
- PKGRETURN=$(basename $1 .tlz)
- ;;
- 'txz' )
- PKGRETURN=$(basename $1 .txz)
- ;;
- *)
- PKGRETURN=$(basename $1)
- ;;
- esac
- echo $PKGRETURN
+ # basename + strip extensions .tbz, .tgz, .tlz and .txz
+ echo "$1" | sed 's?.*/??;s/\.t[bglx]z$//'
}
# This makes "sort" run much faster:
@@ -149,7 +138,7 @@ cat_except() {
}
extract_links() {
- sed -n 's,^( *cd \([^ ;][^ ;]*\) *; *rm -rf \([^ )][^ )]*\) *) *$,\1/\2,p'
+ sed -n 's,^[ ]*( [ ]*cd[ ]* \(.*\) [ ]*; [ ]*rm [ ]*-rf[ ]* \(.*\) [ ]*)[ ]*$,\1/\2,p'
}
preserve_file() {
@@ -228,7 +217,7 @@ delete_links() {
if [ -L "$ROOT/$LINK" ]; then
if [ ! "$WARN" = "true" ]; then
echo " --> Deleting symlink $ROOT/$LINK"
- rm -f $ROOT/$LINK
+ rm -f "$ROOT/$LINK"
else
echo " --> $ROOT/$LINK (symlink) would be deleted"
fi
@@ -271,38 +260,14 @@ delete_cats() {
}
package_name() {
- STRING=$(pkgbase $1)
+ STRING=$(pkgbase $1 | sed 's?-[^-]*-[^-]*-[^-]*$??')
# If we don't do this, commands run later will take the '-' to be an option
# and will destroy the package database. Packages should not contain spaces
# in them. Normally this type of problem results from a command line typo.
if [ "$(echo $STRING | cut -b 1)" = "-" ]; then
STRING="malformed-package-name-detected"
fi
- # Check for old style package name with one segment:
- if [ "$(echo $STRING | cut -f 1 -d -)" = "$(echo $STRING | cut -f 2 -d -)" ]; then
- echo $STRING
- else # has more than one dash delimited segment
- # Count number of segments:
- INDEX=1
- while [ ! "$(echo $STRING | cut -f $INDEX -d -)" = "" ]; do
- INDEX=$(expr $INDEX + 1)
- done
- INDEX=$(expr $INDEX - 1) # don't include the null value
- # If we don't have four segments, return the old-style (or out of spec) package name:
- if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then
- echo $STRING
- else # we have four or more segments, so we'll consider this a new-style name:
- NAME=$(expr $INDEX - 3)
- NAME="$(echo $STRING | cut -f 1-$NAME -d -)"
- echo $NAME
- # cruft for later ;)
- #VER=$(expr $INDEX - 2)
- #VER="$(echo $STRING | cut -f $VER -d -)"
- #ARCH=$(expr $INDEX - 1)
- #ARCH="$(echo $STRING | cut -f $ARCH -d -)"
- #BUILD="$(echo $STRING | cut -f $INDEX -d -)"
- fi
- fi
+ echo $STRING
}
# Conversion to 'comm' utility by Mark Wisdom.
@@ -329,7 +294,7 @@ remove_packages() {
fi
if [ ! -e $ADM_DIR/packages/$PKGNAME ]; then
- long_package=$(ls -1 $ADM_DIR/packages/${PKGNAME}* | grep -m 1 "${PKGNAME}-[^-]*-[^-]*-[^-]*$")
+ long_package=$(ls -1 $ADM_DIR/packages/${PKGNAME}* | grep -m 1 "^${PKGNAME}-[^-]*-[^-]*-[^-]*$")
if [ -e "$long_package" ]; then
PKGNAME=$(basename $long_package)
fi