pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_tarup Add support for wildcards and mutip...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f1f6656285e8
branches:  trunk
changeset: 461505:f1f6656285e8
user:      erh <erh%pkgsrc.org@localhost>
date:      Tue Sep 16 23:19:46 2003 +0000

description:
Add support for wildcards and mutiple packages on the command line.
Bump version to 1.5.

diffstat:

 pkgtools/pkg_tarup/Makefile            |    4 +-
 pkgtools/pkg_tarup/files/pkg_tarup     |  139 +++++++++++++++++++-------------
 pkgtools/pkg_tarup/files/pkg_tarup_all |    4 +-
 3 files changed, 85 insertions(+), 62 deletions(-)

diffs (203 lines):

diff -r 140d5983a58c -r f1f6656285e8 pkgtools/pkg_tarup/Makefile
--- a/pkgtools/pkg_tarup/Makefile       Tue Sep 16 23:07:31 2003 +0000
+++ b/pkgtools/pkg_tarup/Makefile       Tue Sep 16 23:19:46 2003 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.14 2003/07/17 22:52:16 grant Exp $
+# $NetBSD: Makefile,v 1.15 2003/09/16 23:19:46 erh Exp $
 
-DISTNAME=      pkg_tarup-1.4
+DISTNAME=      pkg_tarup-1.5
 WRKSRC=                ${WRKDIR}
 CATEGORIES=    pkgtools
 MASTER_SITES=  # empty
diff -r 140d5983a58c -r f1f6656285e8 pkgtools/pkg_tarup/files/pkg_tarup
--- a/pkgtools/pkg_tarup/files/pkg_tarup        Tue Sep 16 23:07:31 2003 +0000
+++ b/pkgtools/pkg_tarup/files/pkg_tarup        Tue Sep 16 23:19:46 2003 +0000
@@ -1,9 +1,11 @@
 #! @SH@
 #
-# $Id: pkg_tarup,v 1.9 2003/03/29 04:25:11 jschauma Exp $
+# $Id: pkg_tarup,v 1.10 2003/09/16 23:19:47 erh Exp $
 #
 # Tar up installed package
 #
+# Package names are assumed to not contain spaces.
+#
 # (c) Copyright 2000-2002 Hubert Feyrer <hubert%feyrer.de@localhost>
 #
 
@@ -31,20 +33,14 @@
 
 PKGREPOSITORY=${PKGREPOSITORY:-/tmp}
 
-PKG="$1"
-rPKG="`pkg_info -e \"$PKG\"`"
+usage()
+{
+       ${ECHO} "Usage: $1 installed_pkg|pattern [...]"
+       exit 1
+}
 
-if [ "$PKG" = "" -o "$rPKG" = "" -o -f "${PKG_DBDIR}/${rPKG}" ]
-then
-     ${ECHO} Usage: $0 installed_pkg
-     exit 1
-fi
-
-PKG=$rPKG
-${ECHO} "Creating binary package: $PKG"
-
-
-check_and_add() {
+check_and_add()
+{
        opt="$1"
        file="$2"
 
@@ -59,55 +55,82 @@
        fi
 }
 
-check_and_add -c ${PKG_DBDIR}/${PKG}/+COMMENT
-check_and_add -d ${PKG_DBDIR}/${PKG}/+DESC
-check_and_add -b ${PKG_DBDIR}/${PKG}/+BUILD_VERSION
-check_and_add -B ${PKG_DBDIR}/${PKG}/+BUILD_INFO
-check_and_add -s ${PKG_DBDIR}/${PKG}/+SIZE_PKG
-check_and_add -S ${PKG_DBDIR}/${PKG}/+SIZE_ALL
-check_and_add -i ${PKG_DBDIR}/${PKG}/+INSTALL
-check_and_add -k ${PKG_DBDIR}/${PKG}/+DEINSTALL
-check_and_add -r ${PKG_DBDIR}/${PKG}/+REQUIRE
-check_and_add -D ${PKG_DBDIR}/${PKG}/+DISPLAY
-check_and_add -m ${PKG_DBDIR}/${PKG}/+MTREE            #NOTYET#
+create_package()
+{
+       PKG="$1"
+       ${ECHO} "Creating binary package: $PKG"
+
+       check_and_add -c ${PKG_DBDIR}/${PKG}/+COMMENT
+       check_and_add -d ${PKG_DBDIR}/${PKG}/+DESC
+       check_and_add -b ${PKG_DBDIR}/${PKG}/+BUILD_VERSION
+       check_and_add -B ${PKG_DBDIR}/${PKG}/+BUILD_INFO
+       check_and_add -s ${PKG_DBDIR}/${PKG}/+SIZE_PKG
+       check_and_add -S ${PKG_DBDIR}/${PKG}/+SIZE_ALL
+       check_and_add -i ${PKG_DBDIR}/${PKG}/+INSTALL
+       check_and_add -k ${PKG_DBDIR}/${PKG}/+DEINSTALL
+       check_and_add -r ${PKG_DBDIR}/${PKG}/+REQUIRE
+       check_and_add -D ${PKG_DBDIR}/${PKG}/+DISPLAY
+       check_and_add -m ${PKG_DBDIR}/${PKG}/+MTREE             #NOTYET#
 
-PLIST=/tmp/+CONTENTS.$$
-sed -n \
-    -e '/^@comment MD5:/d' \
-    -e '/^@cwd \.$/,$d' \
-    -e '/\$NetBSD/,$p' \
-    <${PKG_DBDIR}/${PKG}/+CONTENTS >$PLIST
+       PLIST=/tmp/+CONTENTS.$$
+       sed -n \
+               -e '/^@comment MD5:/d' \
+               -e '/^@cwd \.$/,$d' \
+               -e '/\$NetBSD/,$p' \
+               <${PKG_DBDIR}/${PKG}/+CONTENTS >$PLIST
+
+       # Duplicate first @cwd (work around pkg_create "feature" ...)
+       grep '^@cwd' $PLIST | ${HEAD} -1 >$PLIST.1
+       if [ -s ${PLIST}.1 ]
+       then
+               sed \
+                  -e "/`cat ${PLIST}.1 | sed 's,/,\\\\/,g'`/r${PLIST}.1" \
+                  <${PLIST} >${PLIST}.2
+               mv ${PLIST}.2 ${PLIST}
+       fi
+       rm ${PLIST}.1
 
-# Duplicate first @cwd (work around pkg_create "feature" ...)
-grep '^@cwd' $PLIST | ${HEAD} -1 >$PLIST.1
-if [ -s ${PLIST}.1 ]
-then
-    sed \
-       -e "/`cat ${PLIST}.1 | sed 's,/,\\\\/,g'`/r${PLIST}.1" \
-       <${PLIST} >${PLIST}.2
-    mv ${PLIST}.2 ${PLIST}
-fi
-rm ${PLIST}.1
+       # ${ECHO} -----
+       # cat $PLIST
+       # ${ECHO} -----
+       # exit 0
+
+       # Just for kicks ...
+       # pkg_admin check "${PKG}"
+         
+       pkg_create \
+                       ${PKG_ARGS} \
+               -v \
+               -f ${PLIST} \
+               -l \
+               -p "`pkg_info -qp ${PKG} | ${AWK} 'NR == 1 { print $2; exit }'`" \
+               -P "`pkg_info -qf ${PKG} | ${AWK} '/^@pkgdep/ { print $2 }'`" \
+               -C "`pkg_info -qf ${PKG} | ${AWK} '/^@pkgcfl/ { print $2 }'`" \
+               ${PKGREPOSITORY}/${PKG}${PKG_SUFX}
 
-# ${ECHO} -----
-# cat $PLIST
-# ${ECHO} -----
-# exit 0
+       rm -f ${PLIST}
+       return 0
+}
 
-# Just for kicks ...
-# pkg_admin check "${PKG}"
-  
-pkg_create \
-        ${PKG_ARGS} \
-       -v \
-       -f ${PLIST} \
-       -l \
-       -p "`pkg_info -qp ${PKG} | ${AWK} 'NR == 1 { print $2; exit }'`" \
-       -P "`pkg_info -qf ${PKG} | ${AWK} '/^@pkgdep/ { print $2 }'`" \
-       -C "`pkg_info -qf ${PKG} | ${AWK} '/^@pkgcfl/ { print $2 }'`" \
-       ${PKGREPOSITORY}/${PKG}${PKG_SUFX}
+while [ $# -gt 0 ] ; do
+       rPKG="`pkg_info -e \"$1\"`"
+       if [ -z "$rPKG" -o -f "${PKG_DBDIR}/${rPKG}" ] ; then
+               ${ECHO} "Error: package $1 not found"
+               usage "$0"
+       fi
+       PKGS="$PKGS $rPKG"
+       shift
+done
+if [ -z "$PKGS" ] ; then
+       usage "$0"
+fi
+for xPKG in $PKGS ; do
+       create_package "$xPKG"
+       if [ $? -ne 0 ] ; then
+               exit 1
+       fi
+done
 
-rm -f ${PLIST}
 exit 0
 
 
diff -r 140d5983a58c -r f1f6656285e8 pkgtools/pkg_tarup/files/pkg_tarup_all
--- a/pkgtools/pkg_tarup/files/pkg_tarup_all    Tue Sep 16 23:07:31 2003 +0000
+++ b/pkgtools/pkg_tarup/files/pkg_tarup_all    Tue Sep 16 23:19:46 2003 +0000
@@ -1,6 +1,6 @@
 #! @SH@
 #
-# $Id: pkg_tarup_all,v 1.1 2003/05/28 14:53:43 hubertf Exp $
+# $Id: pkg_tarup_all,v 1.2 2003/09/16 23:19:47 erh Exp $
 #
 # Tar up installed package plus dependencies
 #
@@ -29,7 +29,7 @@
 pkg_info -qf "$1" \
 | grep @pkgdep \
 | ${AWK} '{print $2}' \
-| xargs -n 1 ${PREFIX}/bin/pkg_tarup
+| xargs ${PREFIX}/bin/pkg_tarup
 
 # 2. the pkg itself
 ${PREFIX}/bin/pkg_tarup "$1"



Home | Main Index | Thread Index | Old Index