pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc Update sysutils/install-sh to 20070712. Changes from ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f978b2a02155
branches:  trunk
changeset: 530865:f978b2a02155
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Thu Jul 12 18:32:49 2007 +0000

description:
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:

 doc/CHANGES-2007                        |   3 +-
 sysutils/install-sh/Makefile            |   4 +-
 sysutils/install-sh/files/install-sh.in |  68 +++++++++++++++++---------------
 3 files changed, 41 insertions(+), 34 deletions(-)

diffs (160 lines):

diff -r add58109229c -r f978b2a02155 doc/CHANGES-2007
--- a/doc/CHANGES-2007  Thu Jul 12 18:27:54 2007 +0000
+++ b/doc/CHANGES-2007  Thu Jul 12 18:32:49 2007 +0000
@@ -1,4 +1,4 @@
-$NetBSD: CHANGES-2007,v 1.1554 2007/07/12 17:13:02 joerg Exp $
+$NetBSD: CHANGES-2007,v 1.1555 2007/07/12 18:32:49 jlam Exp $
 
 Changes to the packages collection and infrastructure in 2007:
 
@@ -2862,3 +2862,4 @@
        Removed www/ap-iasp [jlam 2007-07-12]
        Removed www/iasp [jlam 2007-07-12]
        Updated x11/libXi to 1.1.1 [joerg 2007-07-12]
+       Updated sysutils/install-sh to 20070712 [jlam 2007-07-12]
diff -r add58109229c -r f978b2a02155 sysutils/install-sh/Makefile
--- a/sysutils/install-sh/Makefile      Thu Jul 12 18:27:54 2007 +0000
+++ b/sysutils/install-sh/Makefile      Thu Jul 12 18:32:49 2007 +0000
@@ -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 -r add58109229c -r f978b2a02155 sysutils/install-sh/files/install-sh.in
--- a/sysutils/install-sh/files/install-sh.in   Thu Jul 12 18:27:54 2007 +0000
+++ b/sysutils/install-sh/files/install-sh.in   Thu Jul 12 18:32:49 2007 +0000
@@ -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 @@
 
 # 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 @@
 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 @@
 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 @@
            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
        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 @@
                        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 @@
 
 # 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 &&



Home | Main Index | Thread Index | Old Index