summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorerh <erh@pkgsrc.org>2004-07-14 16:08:48 +0000
committererh <erh@pkgsrc.org>2004-07-14 16:08:48 +0000
commita909f34b22d874ef77a24854f913c34bbed0531f (patch)
tree47656410c509da4a35e74f81af948ea3eaac7fa6 /pkgtools
parent01482c0d5321c677af7ccd825c619d4deddfe66a (diff)
downloadpkgsrc-a909f34b22d874ef77a24854f913c34bbed0531f.tar.gz
Update pkg_tarup to 1.6.
Add several command line options to control how and where pkg_tarup creates packages. pkg_tarup is now functional enough that pkg_tarup_all just runs it. Add various bits of quoting to make packages that contain filenames with spaces more likely to work. Add a man page.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkg_tarup/Makefile12
-rw-r--r--pkgtools/pkg_tarup/PLIST3
-rw-r--r--pkgtools/pkg_tarup/files/pkg_tarup159
-rw-r--r--pkgtools/pkg_tarup/files/pkg_tarup.1109
-rw-r--r--pkgtools/pkg_tarup/files/pkg_tarup_all30
5 files changed, 235 insertions, 78 deletions
diff --git a/pkgtools/pkg_tarup/Makefile b/pkgtools/pkg_tarup/Makefile
index 629fb82799c..e5ee18cf36d 100644
--- a/pkgtools/pkg_tarup/Makefile
+++ b/pkgtools/pkg_tarup/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.19 2004/04/20 16:26:07 wiz Exp $
+# $NetBSD: Makefile,v 1.20 2004/07/14 16:08:48 erh Exp $
-DISTNAME= pkg_tarup-1.5.2
+DISTNAME= pkg_tarup-1.6
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
@@ -15,14 +15,16 @@ NO_BUILD= yes
NO_MTREE= yes
# Set SCRIPT_SUBST to substitute "@VARIABLE@" with "value"
-SCRIPT_SUBST+= AWK=${AWK:Q} \
+SCRIPT_SUBST+= \
ECHO=${ECHO:Q} \
+ GREP=${GREP:Q} \
HEAD=${HEAD:Q} \
ID=${ID:Q} \
PKG_DBDIR=${PKG_DBDIR:Q} \
PKG_SUFX=${PKG_SUFX:Q} \
PREFIX=${PREFIX:Q} \
PKG_TOOLS_BIN=${PKG_TOOLS_BIN:Q} \
+ SED=${SED:Q} \
SH=${SH:Q} \
SU=${SU:Q}
@@ -37,9 +39,13 @@ do-configure:
${SED} ${SCRIPT_SUBST_SED} \
< ${FILESDIR}/pkg_tarup_all \
> ${WRKSRC}/pkg_tarup_all
+ ${SED} ${SCRIPT_SUBST_SED} \
+ < ${FILESDIR}/pkg_tarup.1 \
+ > ${WRKSRC}/pkg_tarup.1
do-install:
${INSTALL_SCRIPT} ${WRKSRC}/pkg_tarup ${PREFIX}/bin
${INSTALL_SCRIPT} ${WRKSRC}/pkg_tarup_all ${PREFIX}/bin
+ ${INSTALL_MAN} ${WRKSRC}/pkg_tarup.1 ${PREFIX}/man/man1
.include "../../mk/bsd.pkg.mk"
diff --git a/pkgtools/pkg_tarup/PLIST b/pkgtools/pkg_tarup/PLIST
index add334b1432..1fccc07bd85 100644
--- a/pkgtools/pkg_tarup/PLIST
+++ b/pkgtools/pkg_tarup/PLIST
@@ -1,3 +1,4 @@
-@comment $NetBSD: PLIST,v 1.2 2003/05/28 14:53:43 hubertf Exp $
+@comment $NetBSD: PLIST,v 1.3 2004/07/14 16:08:48 erh Exp $
bin/pkg_tarup
bin/pkg_tarup_all
+man/man1/pkg_tarup.1
diff --git a/pkgtools/pkg_tarup/files/pkg_tarup b/pkgtools/pkg_tarup/files/pkg_tarup
index 67bbce8e0ab..b0d87eb90d3 100644
--- a/pkgtools/pkg_tarup/files/pkg_tarup
+++ b/pkgtools/pkg_tarup/files/pkg_tarup
@@ -1,6 +1,6 @@
#! @SH@
#
-# $Id: pkg_tarup,v 1.12 2004/04/20 16:26:07 wiz Exp $
+# $Id: pkg_tarup,v 1.13 2004/07/14 16:08:48 erh Exp $
#
# Tar up installed package
#
@@ -16,16 +16,17 @@ export PATH
OS=`uname -s`
-AWK=${AWK:-@AWK@}
ECHO=${ECHO:-@ECHO@}
HEAD=${HEAD:-@HEAD@}
ID=${ID:-@ID@}
+SED=${SED:-@SED@}
SU=${SU:-@SU@}
+GREP=${GREP:-@GREP@}
if [ `${ID} -u` != 0 ]; then
${ECHO} "Becoming root@`/bin/hostname` to create a binary package"
- ${ECHO} -n "`${ECHO} ${SU} | ${AWK} '{ print $1 }'` ";\
- exec ${SU} root -c "$0 $@"
+ ${ECHO} -n "`${ECHO} ${SU} | ${SED} -e's/[[:space:]].*//'` ";\
+ exec ${SU} root -c "$0 \"\$@\"" "$0" "$@"
fi
PKG_DBDIR=${PKG_DBDIR:-@PKG_DBDIR@}
@@ -33,9 +34,20 @@ PKG_SUFX=${PKG_SUFX:-@PKG_SUFX@}
PKGREPOSITORY=${PKGREPOSITORY:-/tmp}
+# XXX Force pkg_info to ignore .tgz files.
+export PKG_PATH=
+
+# Set to 1 if we also want to tar up dependencies also
+GETDEPS=0
+
usage()
{
- ${ECHO} "Usage: $1 installed_pkg|pattern [...]"
+ ${ECHO} "Usage: $1 [-a] [-K pkg_dbdir] [-d pkgrepository] [-s pkg_sufx] installed_pkg|pattern [...]"
+ ${ECHO} "The following environment variables are used:"
+ ${ECHO} " (unless overriden by command line parameters)"
+ ${ECHO} " PKGREPOSITORY - A destination directory for packages (/tmp)"
+ ${ECHO} " PKG_DBDIR - The location of the package database directory"
+ ${ECHO} " PKG_SUFX - The suffix to append to the package (.tgz)"
exit 1
}
@@ -51,7 +63,7 @@ check_and_add()
if [ -f "$file" ]
then
- PKG_ARGS="${PKG_ARGS} ${opt} ${file}"
+ PKG_ARGS="${PKG_ARGS} \"${opt}\" \"${file}\""
fi
}
@@ -61,35 +73,35 @@ create_package()
PKG_ARGS=
${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#
+ 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 \
+ ${SED} -n \
-e '/^@comment MD5:/d' \
-e '/^@cwd \.$/,$d' \
-e '/\$NetBSD/,$p' \
- <${PKG_DBDIR}/${PKG}/+CONTENTS >$PLIST
+ <"${PKG_DBDIR}/${PKG}/+CONTENTS" >"${PLIST}"
# Duplicate first @cwd (work around pkg_create "feature" ...)
- grep '^@cwd' $PLIST | ${HEAD} -1 >$PLIST.1
- if [ -s ${PLIST}.1 ]
+ ${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}
+ ${SED} \
+ -e "/`cat \"${PLIST}.1\" | ${SED} 's,/,\\\\/,g'`/r${PLIST}.1" \
+ <"${PLIST}" >"${PLIST}.2"
+ mv "${PLIST}.2" "${PLIST}"
fi
- rm ${PLIST}.1
+ rm "${PLIST}.1"
# ${ECHO} -----
# cat $PLIST
@@ -98,39 +110,94 @@ create_package()
# 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}
-
- rm -f ${PLIST}
+
+ # It's kind of silly to jump through hoops to get stuff with spaces
+ # here, since we have no way to pass it to pkg_create, but maybe someone
+ # will care enough to fix the rest of this.
+ PKG_PREFIX=`pkg_info -qp "${PKG}" | ${HEAD} -1 | ${SED} -e's/^@cwd[[:space:]]*//'`
+ PKG_DEPS=`pkg_info -qf "${PKG}" | ${GREP} "^@pkgdep" | ${SED} -e's/^@pkgdep[[:space:]]*//'`
+ PKG_CONFLICT=`pkg_info -qf "${PKG}" | ${GREP} "^@pkgcfl" | ${SED} -e's/^@pkgcfl[[:space:]]*//'`
+
+ PKG_ARGS="${PKG_ARGS} -v"
+ PKG_ARGS="${PKG_ARGS} -f \"${PLIST}\""
+ PKG_ARGS="${PKG_ARGS} -l"
+ PKG_ARGS="${PKG_ARGS} -p \"${PKG_PREFIX}\""
+ PKG_ARGS="${PKG_ARGS} -P \"${PKG_DEPS}\""
+ PKG_ARGS="${PKG_ARGS} -C \"${PKG_CONFLICT}\""
+ PKG_ARGS="${PKG_ARGS} \"${PKGREPOSITORY}/${PKG}${PKG_SUFX}\""
+ eval pkg_create "${PKG_ARGS}"
+
+ rm -f "${PLIST}"
return 0
}
-while [ $# -gt 0 ] ; do
- rPKG="`pkg_info -e \"$1\"`"
+add_to_list()
+{
+ # Get expanded name, and escape quotes
+ rPKG=`pkg_info -e "$1" | ${SED} -e's/\"/\\\"/g'`
if [ -z "$rPKG" -o -f "${PKG_DBDIR}/${rPKG}" ] ; then
${ECHO} "Error: package $1 not found"
usage "$0"
fi
- PKGS="$PKGS $rPKG"
+ if ! ${ECHO} "${PKGS}" | ${GREP} -q "\"${rPKG}\"" ; then
+ PKGS="${PKGS} \"${rPKG}\""
+ fi
+}
+
+
+while [ $# -gt 0 ] ; do
+ case "$1" in
+ -a)
+ GETDEPS=1
+ shift
+ ;;
+ -d)
+ PKGREPOSITORY="$2"
+ shift 2
+ ;;
+ -h)
+ usage
+ exit 0
+ ;;
+ -K)
+ PKG_DBDIR="$2"
+ shift 2
+ ;;
+ -s)
+ PKG_SUFX="$2"
+ shift 2
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+while [ $# -gt 0 ] ; do
+ add_to_list "$1"
+ if [ $GETDEPS -eq 1 ] ; then
+ # Make the input separator only a newline so spaces are allowed
+ oIFS="$IFS"
+ IFS="
+"
+ for f in `pkg_info -qf "$1" | ${GREP} @pkgdep | ${SED} -e's/^@pkgdep[[:space:]]*//' ` ; do
+ add_to_list "$f"
+ done
+ IFS="$oIFS"
+ fi
shift
done
-if [ -z "$PKGS" ] ; then
+if [ -z "${PKGS}" ] ; then
usage "$0"
fi
-for xPKG in $PKGS ; do
- create_package "$xPKG"
- if [ $? -ne 0 ] ; then
+FOR="
+for xPKG in ${PKGS} ; do
+ create_package \"\${xPKG}\"
+ if [ \$? -ne 0 ] ; then
exit 1
fi
-done
+done"
+eval "${FOR}"
exit 0
diff --git a/pkgtools/pkg_tarup/files/pkg_tarup.1 b/pkgtools/pkg_tarup/files/pkg_tarup.1
new file mode 100644
index 00000000000..cab9c72a30b
--- /dev/null
+++ b/pkgtools/pkg_tarup/files/pkg_tarup.1
@@ -0,0 +1,109 @@
+.\" $NetBSD: pkg_tarup.1,v 1.1 2004/07/14 16:08:48 erh Exp $
+.Dd July 14, 2004
+.Dt PKG_TARUP 1
+.Os
+.Sh NAME
+.Nm pkg_tarup
+.Nd a utility for tarring up installed software packages
+.Sh SYNOPSIS
+.Nm
+.Op Fl a
+.Bk -words
+.Op Fl K Ar pkg_dbdir
+.Ek
+.Bk -words
+.Op Fl d Ar pkgrepository
+.Ek
+.Bk -words
+.Op Fl s Ar pkg_sufx
+.Ek
+.Ar pkg-name-or-pattern
+.Op Ar ...
+.Sh DESCRIPTION
+The
+.Nm
+command is used to create a packed up file from an installed package.
+It can be used to tar up one or more packages, including dependant packges,
+if desired.
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl a
+Create packages for all dependant packages too.
+.It Fl K Ar pkg_dbdir
+Set
+.Ar pkg_dbdir
+as the package database directory.
+If this option isn't specified, then the package database directory is
+taken from the value of the environment variable
+.Ev PKG_DBDIR
+if it's set, otherwise it defaults to
+.Pa @PKG_DBDIR@ .
+.It Fl d Ar pkgrepository
+Set
+.Ar pkgrepository
+as the destination directory for the created package file(s).
+If this option isn't specified, then /tmp is used.
+.It Fl s Ar pkg_sufx
+Set
+.Ar pkg_sufx
+as the extension used for the created package file(s).
+If this option isn't specified, then .tgz is used.
+.El
+.Sh EXIT STATUS
+The
+.Nm
+utility exits 0 on success.
+.Sh ENVIRONMENT
+The following environment variables affect the execution of
+.Nm :
+.Bl -tag -width indent
+.It Ev PREFIX
+Package binaries installation prefix used to build the path.
+Defaults to
+.Pa @PREFIX@ .
+.It Ev ECHO, ID, SED, SU, GREP
+Actual commands to use. These default to
+.Pa @ECHO@ ,
+.Pa @ID@ ,
+.Pa @SED@ ,
+.Pa @SU@
+and
+.Pa @GREP@ .
+.It Ev PKG_DBDIR
+If the
+.Fl K
+flag isn't given, then
+.Ev PKG_DBDIR
+is the location of the package database directory.
+The default package database directory is
+.Pa @PKG_DBDIR@ .
+.It Ev PKG_SUFX
+If the
+.Fl s
+flag isn't given, then
+.Ev PKG_SUFX
+is the suffix of the created package file.
+The default is
+.Pa @PKG_SUFX@ .
+.It Ev PKGREPOSITORY
+If the
+.Fl d
+flag isn't given, then
+.Ev PKGREPOSITORY
+is the destination directory for the created package file(s).
+The default is
+.Pa /tmp .
+.El
+.Pp
+Any variable that affects
+.Xr pkg_info 1
+or
+.Xr pkg_create 1 .
+.Sh SEE ALSO
+.Xr pkg_info 1 ,
+.Xr pkg_create 1 ,
+.Xr packages 7
+.Sh BUGS
+Packages that contain files with spaces in their names probably won't work.
+There is no way to safely tell pkg_create about these files.
diff --git a/pkgtools/pkg_tarup/files/pkg_tarup_all b/pkgtools/pkg_tarup/files/pkg_tarup_all
index abadb621afa..5dbbf375df3 100644
--- a/pkgtools/pkg_tarup/files/pkg_tarup_all
+++ b/pkgtools/pkg_tarup/files/pkg_tarup_all
@@ -1,35 +1,9 @@
#! @SH@
-#
-# $Id: pkg_tarup_all,v 1.3 2004/04/20 16:26:07 wiz Exp $
-#
-# Tar up installed package plus dependencies
-#
-# (c) Copyright 2003 Hubert Feyrer <hubert@feyrer.de>
-#
+# $NetBSD: pkg_tarup_all,v 1.4 2004/07/14 16:08:48 erh Exp $
PREFIX=${PREFIX:-@PREFIX@}
PATH=/sbin:/usr/sbin:/bin:/usr/bin:${PREFIX}/sbin:${PREFIX}/bin:@PKG_TOOLS_BIN@
export PATH
-AWK=${AWK:-@AWK@}
-ECHO=${ECHO:-@ECHO@}
-HEAD=${HEAD:-@HEAD@}
-ID=${ID:-@ID@}
-SU=${SU:-@SU@}
-PKG_INFO=${PKG_INFO:-@PKG_INFO@}
-
-if [ `${ID} -u` != 0 ]; then
- ${ECHO} "Becoming root@`/bin/hostname` to create binary packages"
- ${ECHO} -n "`${ECHO} ${SU} | ${AWK} '{ print $1 }'` ";\
- exec ${SU} root -c "$0 $@"
-fi
-
-# 1. dependencies
-pkg_info -qf "$1" \
-| grep @pkgdep \
-| ${AWK} '{print $2}' \
-| xargs ${PREFIX}/bin/pkg_tarup
-
-# 2. the pkg itself
-${PREFIX}/bin/pkg_tarup "$1"
+${PREFIX}/bin/pkg_tarup -a "$@"