summaryrefslogtreecommitdiff
path: root/sysutils
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2007-07-12 18:32:49 +0000
committerjlam <jlam@pkgsrc.org>2007-07-12 18:32:49 +0000
commit032306f2fabf94e09615ab96e52591cdf04f29a3 (patch)
tree52b980b2f917b67d7710227751f060129b7679c8 /sysutils
parentd524020c66bca035be2feee1f3d338b1b12050cf (diff)
downloadpkgsrc-032306f2fabf94e09615ab96e52591cdf04f29a3.tar.gz
Update sysutils/install-sh to 20070712. Changes from previous version
include: * Drop support for "-b=..." and "-t=..." which are transformation options that are not supported by BSD install. * Add support for "-b" and "-B fmt" to allow backing up existing files. Only specifying "-b" yields a backup suffix of ".old" and "-B fmt" allows for sprintf(3)-style backup suffices. Number backups are supported using awk(1).
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/install-sh/Makefile4
-rw-r--r--sysutils/install-sh/files/install-sh.in68
2 files changed, 39 insertions, 33 deletions
diff --git a/sysutils/install-sh/Makefile b/sysutils/install-sh/Makefile
index 2e86622d447..f03899b85f0 100644
--- a/sysutils/install-sh/Makefile
+++ b/sysutils/install-sh/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.2 2007/06/20 16:18:36 jlam Exp $
+# $NetBSD: Makefile,v 1.3 2007/07/12 18:32:50 jlam Exp $
-DISTNAME= install-sh-20070620
+DISTNAME= install-sh-20070712
CATEGORIES= sysutils
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/sysutils/install-sh/files/install-sh.in b/sysutils/install-sh/files/install-sh.in
index ccf3df2b3a2..da85432ac62 100644
--- a/sysutils/install-sh/files/install-sh.in
+++ b/sysutils/install-sh/files/install-sh.in
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: install-sh.in,v 1.3 2007/07/04 19:21:22 jlam Exp $
+# $NetBSD: install-sh.in,v 1.4 2007/07/12 18:32:50 jlam Exp $
# This script now also installs multiple files, but might choke on installing
# multiple files with spaces in the file names.
#
@@ -34,6 +34,7 @@ doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
+awkprog="${AWKPROG-awk}"
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
@@ -43,8 +44,6 @@ stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
-transformbasename=""
-transform_arg=""
instcmd="$mvprog"
pathcompchmodcmd="$chmodprog @DEFAULT_INSTALL_MODE@"
chmodcmd="$chmodprog @DEFAULT_INSTALL_MODE@"
@@ -58,9 +57,20 @@ src=""
msrc=""
dst=""
dir_arg=""
+suffix=""
+suffixfmt=""
while [ x"$1" != x ]; do
case $1 in
+ -b) suffix=".old"
+ shift
+ continue;;
+
+ -B) suffixfmt="$2"
+ shift
+ shift
+ continue;;
+
-c) instcmd="$cpprog"
shift
continue;;
@@ -94,14 +104,6 @@ while [ x"$1" != x ]; do
shift
continue;;
- -t=*) transformarg=`echo "$1" | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo "$1" | sed 's/-b=//'`
- shift
- continue;;
-
*) if [ x"$msrc" = x ]
then
msrc="$dst"
@@ -226,8 +228,6 @@ fi
fi
else
-# If we're going to rename the final file, determine the name now.
-
if [ x"$dstisfile" = x ]
then
file=$srcarg
@@ -235,27 +235,28 @@ fi
file=$dst
fi
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename "$file"`
- else
- dstfile=`basename "$file" "$transformbasename" |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename "$file"`
- else
- true
- fi
+ dstfile=`basename "$file"`
+ dstfinal="$dstdir/$dstfile"
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
+# Make a backup file name in the proper directory.
+ case x$suffixfmt in
+ *%*) suffix=`echo x |
+ $awkprog -v bname="$dstfinal" -v fmt="$suffixfmt" '
+ { cnt = 0;
+ do {
+ sfx = sprintf(fmt, cnt++);
+ name = bname sfx;
+ } while (system("test -f " name) == 0);
+ print sfx; }' -`;;
+ x) ;;
+ *) suffix="$suffixfmt";;
+ esac
+ dstbackup="$dstfinal$suffix"
+
# Move or copy the file name to the temp name
$doit $doinst $srcarg "$dsttmp" &&
@@ -275,8 +276,13 @@ fi
# Now rename the file to the real destination.
- $doit $rmcmd -f "$dstdir/$dstfile" &&
- $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+ if [ x"$suffix" != x ] && [ -f "$dstfinal" ]
+ then
+ $doit $mvcmd "$dstfinal" "$dstbackup"
+ else
+ $doit $rmcmd -f "$dstfinal"
+ fi &&
+ $doit $mvcmd "$dsttmp" "$dstfinal"
fi
done &&