Ensure that (almost) all shell variables in distrib/sets/* scripts are

used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc
This commit is contained in:
apb 2006-01-03 18:31:09 +00:00
parent 3a0b541193
commit 0bee96eab7
12 changed files with 361 additions and 351 deletions

View File

@ -1,28 +1,28 @@
#! /bin/sh --
#
# $NetBSD: checkflist,v 1.28 2006/01/03 16:40:16 apb Exp $
# $NetBSD: checkflist,v 1.29 2006/01/03 18:31:09 apb Exp $
#
# Verify output of makeflist against contents of $DESTDIR.
# Verify output of makeflist against contents of ${DESTDIR}.
if [ -z "$DESTDIR" ]; then
if [ -z "${DESTDIR}" ]; then
echo "DESTDIR must be set"
exit 1
fi
prog=${0##*/}
prog="${0##*/}"
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
. "${rundir}/sets.subr"
SDIR=$(${MKTEMP} -d /tmp/${prog}.XXXXXX)
SDIR="$(${MKTEMP} -d "/tmp/${prog}.XXXXXX")"
es=0
cleanup()
{
/bin/rm -rf $SDIR
if [ $es -gt 255 ] ; then
/bin/rm -rf "${SDIR}"
if [ ${es} -gt 255 ] ; then
es=255
fi
exit $es
exit ${es}
}
trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE
@ -45,7 +45,7 @@ while getopts xbM:em ch; do
xargs="-b"
;;
M)
metalog=${OPTARG}
metalog="${OPTARG}"
;;
e)
allowextra=true
@ -68,12 +68,12 @@ USAGE
done
shift $((${OPTIND} - 1))
if [ -n "$metalog" ]; then
case "$metalog" in
${DESTDIR}/*)
if [ -n "${metalog}" ]; then
case "${metalog}" in
"${DESTDIR}"/*)
# Metalog would be noticed, so make sure it gets
# ignored.
metalog="./${metalog#${DESTDIR}/}"
metalog="./${metalog#"${DESTDIR}"/}"
;;
*)
metalog=""
@ -81,28 +81,28 @@ if [ -n "$metalog" ]; then
fi
${HOST_SH} ./makeflist $xargs $dargs > $SDIR/flist
${HOST_SH} ./makeflist ${xargs} ${dargs} > "${SDIR}/flist"
(
cd $DESTDIR
${FIND} $origin \( -type d -o -type f -o -type l \) -print
cd "${DESTDIR}"
${FIND} ${origin} \( -type d -o -type f -o -type l \) -print
) | (
while read line; do
case "$line" in
$metalog)
case "${line}" in
"${metalog}")
;;
*)
echo $line
echo "${line}"
;;
esac
done
) | ${SORT} > $SDIR/files
) | ${SORT} > "${SDIR}/files"
${COMM} -23 $SDIR/flist $SDIR/files > $SDIR/missing
${COMM} -13 $SDIR/flist $SDIR/files > $SDIR/extra
${COMM} -23 "${SDIR}/flist}" "${SDIR}/files}" > "${SDIR}/missing}"
${COMM} -13 "${SDIR}/flist}" "${SDIR}/files}" > "${SDIR}/extra}"
if [ -s $SDIR/extra ]; then
count=$(${AWK} 'END {print NR}' $SDIR/extra)
if [ -s "${SDIR}/extra" ]; then
count="$(${AWK} 'END {print NR}' "${SDIR}/extra")"
echo ""
echo "============ ${count} extra files ==============="
echo "Files in DESTDIR but missing from flist."
@ -113,13 +113,13 @@ if [ -s $SDIR/extra ]; then
es=1
fi
echo "------------------------------------------"
cat $SDIR/extra
cat "${SDIR}/extra"
echo "========= end of ${count} extra files ==========="
echo ""
fi
if [ -s $SDIR/missing ]; then
count=$(${AWK} 'END {print NR}' $SDIR/missing)
if [ -s "${SDIR}/missing" ]; then
count="$(${AWK} 'END {print NR}' "${SDIR}/missing")"
echo ""
echo "=========== ${count} missing files =============="
echo "Files in flist but missing from DESTDIR."
@ -130,9 +130,9 @@ if [ -s $SDIR/missing ]; then
es=1
fi
echo "------------------------------------------"
cat $SDIR/missing
cat "${SDIR}/missing"
echo "======== end of ${count} missing files =========="
echo ""
fi
exit 0 # cleanup will exit with $es
exit 0 # cleanup will exit with ${es}

View File

@ -19,57 +19,60 @@
# and A D can be derived from A B, B C, C D by transitivity.
#
SCRATCH=$(${MKTEMP} -d /var/tmp/$0.XXXXXX)
NEXTLEFTOVERS=$SCRATCH/leftovers0
LASTJOIN=$SCRATCH/join0
NEXTJOIN=$SCRATCH/join1
prog="${0##*/}"
SCRATCH="$(${MKTEMP} -d "/var/tmp/${prog}.XXXXXX")"
NEXTLEFTOVERS="${SCRATCH}/leftovers0"
LASTJOIN="${SCRATCH}/join0"
NEXTJOIN="${SCRATCH}/join1"
TAB=" "
${SORT} -k 1 > $LASTJOIN
${SORT} -k 1 > "${LASTJOIN}"
LEFTOVERS=$LASTJOIN
LEFTOVERS="${LASTJOIN}"
while [ $(${WC} -l $LASTJOIN | ${AWK} '{ print $1; }') -ne 0 ]; do
while [ "$(${WC} -l "${LASTJOIN}" | ${AWK} '{ print $1; }')" -ne 0 ]; do
#
# From dependencies X-requires-Y in $LEFTOVERS and Y-requires-Z in
# $LASTJOIN, produce dependencies X-requires-Z and write them to
# $NEXTJOIN.
# From dependencies X-requires-Y in ${LEFTOVERS} and Y-requires-Z in
# ${LASTJOIN}, produce dependencies X-requires-Z and write them to
# ${NEXTJOIN}.
#
${SORT} -k 2 < $LEFTOVERS | ${JOIN} -1 2 -2 1 -o '1.1 2.2' - $LASTJOIN | \
${SORT} -u > $NEXTJOIN
${SORT} -k 2 < "${LEFTOVERS}" | \
${JOIN} -1 2 -2 1 -o '1.1 2.2' - "${LASTJOIN}" | \
${SORT} -u > "${NEXTJOIN}"
if [ ${DEBUG:-0} -gt 0 ]; then
echo "### filtered ###" 1>&2
${JOIN} -t "$TAB" $NEXTJOIN $LEFTOVERS | ${SORT} 1>&2
${JOIN} -t "${TAB}" "${NEXTJOIN}" "${LEFTOVERS}" | ${SORT} 1>&2
echo "###" 1>&2
fi
#
# Filter out of $LEFTOVERS all of the dependencies X-requires-Z, which
# Filter out of ${LEFTOVERS} all of the dependencies X-requires-Z, which
# were produced in the previous step. Write the new leftovers to
# $NEXTLEFTOVERS.
# ${NEXTLEFTOVERS}.
#
${JOIN} -v 2 -t "$TAB" $NEXTJOIN $LEFTOVERS | ${SORT} -u > $NEXTLEFTOVERS
${JOIN} -v 2 -t "${TAB}" "${NEXTJOIN}" "${LEFTOVERS}" | \
${SORT} -u > "${NEXTLEFTOVERS}"
#
# Swap output files before repeating.
#
LASTJOIN=$NEXTJOIN
if [ $(basename $NEXTJOIN) = join0 ]; then
NEXTJOIN=$SCRATCH/join1
LASTJOIN="${NEXTJOIN}"
if [ "$(basename "${NEXTJOIN}")" = join0 ]; then
NEXTJOIN="${SCRATCH}/join1"
else
NEXTJOIN=$SCRATCH/join0
NEXTJOIN="${SCRATCH}/join0"
fi
LEFTOVERS=$NEXTLEFTOVERS
if [ $(basename $NEXTLEFTOVERS) = leftovers0 ]; then
NEXTLEFTOVERS=$SCRATCH/leftovers1
LEFTOVERS="${NEXTLEFTOVERS}"
if [ "$(basename "${NEXTLEFTOVERS}")" = leftovers0 ]; then
NEXTLEFTOVERS="${SCRATCH}/leftovers1"
else
NEXTLEFTOVERS=$SCRATCH/leftovers0
NEXTLEFTOVERS="${SCRATCH}/leftovers0"
fi
done
#
# Output all of the dependencies that were not culled and clean up.
#
cat $LEFTOVERS
rm -r $SCRATCH
cat "${LEFTOVERS}"
rm -r "${SCRATCH}"

View File

@ -1,11 +1,11 @@
#!/bin/sh
#
# $NetBSD: listpkgs,v 1.10 2006/01/03 16:40:16 apb Exp $
# $NetBSD: listpkgs,v 1.11 2006/01/03 18:31:09 apb Exp $
#
# List all packages in the given pkgset by parsing the list files.
#
rundir=${0%/*}
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
. ${rundir}/sets.subr
prefix=/
@ -14,9 +14,9 @@ usage()
{
cat 1>&2 <<USAGE
Usage: ${0##*/} [-a arch] [-m machine] [-s setsdir] [-p prefix] setname
-a arch set arch (e.g, m68k, mips, powerpc) [$MACHINE_ARCH]
-m machine set machine (e.g, amiga, i386, macppc) [$MACHINE]
-s setsdir directory to find sets [$setsdir]
-a arch set arch (e.g, m68k, mips, powerpc) [${MACHINE_ARCH}]
-m machine set machine (e.g, amiga, i386, macppc) [${MACHINE}]
-s setsdir directory to find sets [${setsdir}]
setname set to list packages for
USAGE
exit 1
@ -26,14 +26,14 @@ USAGE
while getopts a:m:s: ch; do
case ${ch} in
a)
MACHINE_ARCH=${OPTARG}
MACHINE_CPU=$(arch_to_cpu ${OPTARG})
MACHINE_ARCH="${OPTARG}"
MACHINE_CPU="$(arch_to_cpu "${OPTARG}")"
;;
m)
MACHINE=${OPTARG}
MACHINE="${OPTARG}"
;;
s)
setsdir=${OPTARG}
setsdir="${OPTARG}"
;;
*)
usage
@ -46,4 +46,4 @@ if [ $# -ne 1 ]; then
fi
setname="$1"
list_set_files $setname | ${AWK} '{print $2}' | ${SORT} -u
list_set_files "${setname}" | ${AWK} '{print $2}' | ${SORT} -u

View File

@ -1,14 +1,14 @@
#!/bin/sh
#
# $NetBSD: makeflist,v 1.72 2006/01/03 16:40:16 apb Exp $
# $NetBSD: makeflist,v 1.73 2006/01/03 18:31:09 apb Exp $
#
# Print out the files in some or all lists.
# Usage: makeflist [-bxlo] [-a arch] [-m machine] [-s setsdir] [setname ...]
#
rundir=${0%/*}
. ${rundir}/sets.subr
lists=$nlists
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
. "${rundir}/sets.subr"
lists="${nlists}"
usage()
{
@ -18,10 +18,10 @@ Usage: ${0##*/} [-bxlo] [-a arch] [-m machine] [-s setsdir] [setname [...]]
-x print make x11 lists
-l just list the selected set names, not the contents
-o only match obsolete files
-a arch set arch (e.g, m68k, mipseb, mipsel, powerpc) [$MACHINE_ARCH]
-m machine set machine (e.g, amiga, i386, macppc) [$MACHINE]
-s setsdir directory to find sets [$setsdir]
[setname [...]] sets to build [$lists]
-a arch set arch (e.g, m68k, mipseb, mipsel, powerpc) [${MACHINE_ARCH}]
-m machine set machine (e.g, amiga, i386, macppc) [${MACHINE}]
-s setsdir directory to find sets [${setsdir}]
[setname [...]] sets to build [${lists}]
USAGE
exit 1
}
@ -30,10 +30,10 @@ USAGE
while getopts bxloa:m:s: ch; do
case ${ch} in
b)
lists="$nlists $xlists"
lists="${nlists} ${xlists}"
;;
x)
lists="$xlists"
lists="${xlists}"
;;
l)
listonly=1
@ -42,14 +42,14 @@ while getopts bxloa:m:s: ch; do
obsolete=1
;;
a)
MACHINE_ARCH=${OPTARG}
MACHINE_CPU=$(arch_to_cpu ${OPTARG})
MACHINE_ARCH="${OPTARG}"
MACHINE_CPU="$(arch_to_cpu "${OPTARG}")"
;;
m)
MACHINE=${OPTARG}
MACHINE="${OPTARG}"
;;
s)
setsdir=${OPTARG}
setsdir="${OPTARG}"
;;
*)
usage
@ -61,9 +61,9 @@ if [ -n "$1" ]; then
lists="$@"
fi
if [ -n "$listonly" ]; then
if [ -n "${listonly}" ]; then
echo ${lists} | tr ' ' '\n'
exit 0
fi
list_set_files $lists | ${AWK} '{print $1}' | ${SORT} -u
list_set_files ${lists} | ${AWK} '{print $1}' | ${SORT} -u

View File

@ -1,14 +1,15 @@
#!/bin/sh
#
# $NetBSD: makeobsolete,v 1.26 2006/01/03 16:40:16 apb Exp $
# $NetBSD: makeobsolete,v 1.27 2006/01/03 18:31:09 apb Exp $
#
# Print out the obsolete files for a set
# Usage: makeobsolete [-b] [-x] [-a arch] [-m machine] [-s setsdir] \
# [-t target] [setname ...]
#
. ${0%/*}/sets.subr
lists=$nlists
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
. "${rundir}/sets.subr"
lists="${nlists}"
target=./dist
obsolete=1
@ -18,10 +19,10 @@ usage()
Usage: ${0##*/} [-a arch] [-m machine] [-s setsdir] [setname ...]
-b make netbsd + x11 lists
-x only make x11 lists
-a arch set arch (e.g, m68k, mips, powerpc) [$MACHINE_ARCH]
-m machine set machine (e.g, amiga, i386, macppc) [$MACHINE]
-s setsdir directory to find sets [$setd]
-t target target directory [$target]
-a arch set arch (e.g, m68k, mips, powerpc) [${MACHINE_ARCH}]
-m machine set machine (e.g, amiga, i386, macppc) [${MACHINE}]
-s setsdir directory to find sets [${setd}]
-t target target directory [${target}]
[setname ...] sets to build
USAGE
exit 1
@ -30,23 +31,23 @@ USAGE
while getopts bxa:m:s:t: ch; do
case ${ch} in
b)
lists="$xlists $nlists"
lists="${xlists} ${nlists}"
;;
x)
lists="$xlists"
lists="${xlists}"
;;
a)
MACHINE_ARCH=${OPTARG}
MACHINE_CPU=$(arch_to_cpu ${OPTARG})
MACHINE_ARCH="${OPTARG}"
MACHINE_CPU="$(arch_to_cpu "${OPTARG}")"
;;
m)
MACHINE=${OPTARG}
MACHINE="${OPTARG}"
;;
s)
setsdir=${OPTARG}
setsdir="${OPTARG}"
;;
t)
target=${OPTARG}
target="${OPTARG}"
;;
*)
usage
@ -58,12 +59,13 @@ if [ -n "$1" ]; then
lists="$*"
fi
if [ ! -d $target ] ; then
echo "target directory [$target] doesn't exist"
if [ ! -d "${target}" ] ; then
echo "target directory [${target}] doesn't exist"
exit 1
fi
for setname in $lists; do
file=$target/${setname}
list_set_files $setname | ${AWK} '{print $1}' | ${SORT} -ru > $file
for setname in ${lists}; do
file="${target}/${setname}"
list_set_files "${setname}" | ${AWK} '{print $1}' | \
${SORT} -ru > ${file}
done

View File

@ -4,18 +4,18 @@
# Usage: makeplist [-a arch] [-m machine] [-s setsdir] [-p prefix] setname pkgname
#
rundir=${0%/*}
. ${rundir}/sets.subr
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
. "${rundir}/sets.subr"
prefix=/
usage()
{
cat 1>&2 <<USAGE
Usage: ${0##*/} [-a arch] [-m machine] [-s setsdir] [-p prefix] setname pkgname
-a arch set arch (e.g, m68k, mips, powerpc) [$MACHINE_ARCH]
-m machine set machine (e.g, amiga, i386, macppc) [$MACHINE]
-s setsdir directory to find sets [$setsdir]
-p prefix prefix for created plist [$prefix]
-a arch set arch (e.g, m68k, mips, powerpc) [${MACHINE_ARCH}]
-m machine set machine (e.g, amiga, i386, macppc) [${MACHINE}]
-s setsdir directory to find sets [${setsdir}]
-p prefix prefix for created plist [${prefix}]
setname pkgname set and package to build plist for
USAGE
exit 1
@ -25,17 +25,17 @@ USAGE
while getopts a:m:p:s: ch; do
case ${ch} in
a)
MACHINE_ARCH=${OPTARG}
MACHINE_CPU=$(arch_to_cpu ${OPTARG})
MACHINE_ARCH="${OPTARG}"
MACHINE_CPU="$(arch_to_cpu "${OPTARG}")"
;;
m)
MACHINE=${OPTARG}
MACHINE="${OPTARG}"
;;
p)
prefix=${OPTARG}
prefix="${OPTARG}"
;;
s)
setsdir=${OPTARG}
setsdir="${OPTARG}"
;;
*)
usage
@ -47,61 +47,61 @@ if [ $# -ne 2 ]; then
usage
fi
setname="$1"
pkgname=$2
pkgname="$2"
filename=/tmp/makeplist.$$
ffilename=/tmp/makeplist.files.$$
dfilename=/tmp/makeplist.dirs.$$
filename="/tmp/makeplist.$$"
ffilename="/tmp/makeplist.files.$$"
dfilename="/tmp/makeplist.dirs.$$"
list_set_files $setname | \
${ENV_CMD} PLISTPKG=$pkgname ${AWK} '
list_set_files "${setname}" | \
${ENV_CMD} PLISTPKG="${pkgname}" ${AWK} '
$2 == ENVIRON["PLISTPKG"] {
sub("^\\./", "", $1);
print $1
}' | ${SORT} -u > $filename
}' | ${SORT} -u > "${filename}"
SELECTDIRS="-prune -type d"
SELECTNONDIRS="! -type d -print -o ( -type d -prune )"
cd $prefix
cd "${prefix}"
#
# Match the directories. Use find(1) to avoid repeat calls to
# 'test -d'.
#
# This is a little clever. I cannot use 'xargs find', because
# find wants for the option arguments to follow the path arguments.
# So I use 'xargs echo $SELECTDIRS' to make a maximum-length proto-command
# So I use 'xargs echo ${SELECTDIRS}' to make a maximum-length proto-command
# line. I use 'read' to peel the options off the front of the
# command-line, and 'find $args $SELECTDIRS' to put them at the end.
# command-line, and 'find ${args} ${SELECTDIRS}' to put them at the end.
#
xargs echo $SELECTDIRS < $filename | \
xargs echo ${SELECTDIRS} < "${filename}" | \
while read ignore ignore ignore args; do
[ -z "$args" ] && break
${FIND} $args $SELECTDIRS
done | ${AWK} '{ print "@dirrm " $1; }' > $dfilename
[ -z "${args}" ] && break
${FIND} ${args} ${SELECTDIRS}
done | ${AWK} '{ print "@dirrm " $1; }' > "${dfilename}"
#
# Match the non-directories. Use find(1) to avoid repeat calls to
# 'test ! -d'. See 'Match the directories' for an explanation of the
# cleverness.
#
xargs echo $SELECTNONDIRS < $filename | \
xargs echo ${SELECTNONDIRS} < "${filename}" | \
while read ignore ignore ignore ignore ignore ignore ignore ignore ignore \
ignore args; do
[ -z "$args" ] && break
${FIND} $args $SELECTNONDIRS
done > $ffilename
[ -z "${args}" ] && break
${FIND} ${args} ${SELECTNONDIRS}
done > "${ffilename}"
cd -
echo "@cwd $prefix"
if [ -s $ffilename ]; then
cat $ffilename
echo "@cwd ${prefix}"
if [ -s "${ffilename}" ]; then
cat "${ffilename}"
fi
if [ -s $dfilename ]; then
${SORT} -r $dfilename
if [ -s "${dfilename}" ]; then
${SORT} -r "${dfilename}"
fi
rm -f $filename $ffilename $dfilename
rm -f "${filename}" "${ffilename}" "${dfilename}"
exit 0

View File

@ -1,12 +1,12 @@
#! /bin/sh
#
# $NetBSD: makesrctars,v 1.29 2006/01/03 16:40:16 apb Exp $
# $NetBSD: makesrctars,v 1.30 2006/01/03 18:31:09 apb Exp $
#
# makesrctars srcdir setdir
# Create source tarballs in setdir from the source under srcdir.
#
prog=${0##*/}
prog="${0##*/}"
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
. "${rundir}/sets.subr"
@ -33,10 +33,10 @@ USAGE
while getopts N:x: ch; do
case ${ch} in
x)
xsrcdir=${OPTARG}
xsrcdir="${OPTARG}"
;;
N)
PASSWD=${OPTARG}
PASSWD="${OPTARG}"
;;
*)
usage
@ -48,9 +48,9 @@ shift $((${OPTIND} - 1))
if [ $# -ne 2 ]; then
usage
fi
srcdir=$1
setdir=$2
: ${PASSWD:=${srcdir}/etc}
srcdir="$1"
setdir="$2"
: ${PASSWD:="${srcdir}/etc"}
if [ ! -d "${setdir}" ]; then
echo "${setdir} is not a directory"
@ -59,30 +59,31 @@ fi
makeset()
{(
set=$1.tgz
set="${1}.tgz"
shift
dir=$1
dir="$1"
shift
intmp="/tmp/in$$"
echo "Creating ${set}"
if [ "${dir}" != "." ]; then
cd $dir
cd "${dir}"
srcprefix="${srcprefix}/${dir}"
fi
# Gets rid of any obj dirs and things below it
echo "obj" > /tmp/in$$
egrep=$*
if [ "$egrep" = "" ]; then
echo "obj" > "${intmp}"
egrep="$*"
if [ "${egrep}" = "" ]; then
egrep='.'
fi
set -f
${MTREE} -c -X /tmp/in$$ | ${MTREE} -C -k type | \
${EGREP} -v 'type=link' | ${EGREP} $egrep | \
${MTREE} -c -X "${intmp}" | ${MTREE} -C -k type | \
${EGREP} -v 'type=link' | ${EGREP} ${egrep} | \
${SED} -e 's:type=file:& mode=0664:' \
-e 's:type=dir:& mode=0775:' \
-e 's:$: uname=root gname=wsrc:' | \
${PAX} -M -N ${PASSWD} -w -d -s'|^\.|'${srcprefix}'|' | \
${PAX} -M -N "${PASSWD}" -w -d -s'|^\.|'"${srcprefix}"'|' | \
${GZIP_CMD} > "${setdir}/${set}"
rm -f /tmp/in$$
rm -f "${intmp}"
)}
@ -119,7 +120,7 @@ fi
echo "Creating checksum files"
(cd ${setdir}
(cd "${setdir}"
${CKSUM} -o1 *.tgz > BSDSUM
${CKSUM} *.tgz > CKSUM
${CKSUM} -a md5 *.tgz > MD5

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# $NetBSD: makesums,v 1.13 2006/01/03 16:40:16 apb Exp $
# $NetBSD: makesums,v 1.14 2006/01/03 18:31:09 apb Exp $
#
# Make checksum files for files in ``tardir''. Usage:
# makesums [-a] [-t tardir] [setname [...]]
@ -19,12 +19,12 @@
# output files (BSDSUM, CKSUM, MD5, SHA512, SYSVSUM) are produced.
#
prog=${0##*/}
prog="${0##*/}"
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
. "${rundir}/sets.subr"
# set defaults
targetdir=$RELEASEDIR
targetdir="${RELEASEDIR}"
dash_all=no
append=\>
@ -34,7 +34,7 @@ usage()
Usage: ${prog} [-A] [-a] [-t targetdir] [setname [...]]
-A Append to possible existing checksum files
-a checksum all plain files instead of [setname [...]]
-t targetdir \$RELEASEDIR [$targetdir]
-t targetdir \${RELEASEDIR} [${targetdir}]
setname [...] sets to checksum [*.tgz]
USAGE
exit 1
@ -50,7 +50,7 @@ while getopts aAt: ch; do
dash_all=yes
;;
t)
targetdir=${OPTARG}
targetdir="${OPTARG}"
;;
*)
usage
@ -59,24 +59,24 @@ while getopts aAt: ch; do
done
shift $((${OPTIND} - 1))
if [ -z "$targetdir" ]; then
echo 1>&2 '$RELEASEDIR must be set or provided with -t'
if [ -z "${targetdir}" ]; then
echo 1>&2 '${RELEASEDIR} must be set or provided with -t'
exit 1
fi
cd $targetdir
cd "${targetdir}"
pat="$*"
if [ $dash_all = yes ]; then
if [ "${dash_all}" = yes ]; then
pat='*'
elif [ -z "$pat" ]; then
elif [ -z "${pat}" ]; then
pat='*.tgz'
fi
lists=$(${FIND} $pat -prune \( -type f -o -type l \) \
\! -name '*SUM' \! -name MD5 \! -name SHA512 2>/dev/null)
if [ -n "$lists" ]; then
eval ${CKSUM} -o1 $lists $append BSDSUM
eval ${CKSUM} $lists $append CKSUM
eval ${CKSUM} -a md5 $lists $append MD5
eval ${CKSUM} -o2 $lists $append SYSVSUM
eval ${CKSUM} -a sha512 $lists $append SHA512
lists="$(${FIND} ${pat} -prune \( -type f -o -type l \) \
\! -name '*SUM' \! -name MD5 \! -name SHA512 2>/dev/null)"
if [ -n "${lists}" ]; then
eval ${CKSUM} -o1 ${lists} ${append} BSDSUM
eval ${CKSUM} ${lists} ${append} CKSUM
eval ${CKSUM} -a md5 ${lists} ${append} MD5
eval ${CKSUM} -o2 ${lists} ${append} SYSVSUM
eval ${CKSUM} -a sha512 ${lists} ${append} SHA512
fi

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# $NetBSD: maketars,v 1.57 2006/01/03 16:40:16 apb Exp $
# $NetBSD: maketars,v 1.58 2006/01/03 18:31:09 apb Exp $
#
# Make release tar files for some or all lists. Usage:
# maketars [-b] [-x] [-i installdir] [-a arch] [-m machine] [-s setsdir]
@ -14,14 +14,14 @@
# In this case, remove "etc" and "xetc" from the list of default sets.
#
prog=${0##*/}
prog="${0##*/}"
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
. "${rundir}/sets.subr"
# set defaults
lists=$nlists
tars=$RELEASEDIR
dest=$DESTDIR
lists="${nlists}"
tars="${RELEASEDIR}"
dest="${DESTDIR}"
metalog=
installdir=
etcdir=
@ -36,15 +36,15 @@ Usage: ${prog} [-b] [-x] [-i idir] [-a arch] [-m machine] [-s setsdir] [-S]
-x Only make x11 lists
[Default: make netbsd lists]
-i idir Install sets to idir instead of creating tar files
-a arch Set arch (e.g, m68k, mipseb, mipsel, powerpc) [$MACHINE_ARCH]
-m machine Set machine (e.g, amiga, i386, macppc) [$MACHINE]
-s setsdir Directory to find sets [$setsdir]
-S Exit after creating set files $dest/etc/mtree/set.*
-a arch Set arch (e.g, m68k, mipseb, mipsel, powerpc) [${MACHINE_ARCH}]
-m machine Set machine (e.g, amiga, i386, macppc) [${MACHINE}]
-s setsdir Directory to find sets [${setsdir}]
-S Exit after creating set files ${dest}/etc/mtree/set.*
-M metalog metalog file
-N etcdir etc dir for metalog use [$dest/etc]
-d dest \$DESTDIR [$dest]
-t targetdir \$RELEASEDIR [$tars]
[setname ...] Sets to build [$lists]
-N etcdir etc dir for metalog use [${dest}/etc]
-d dest \${DESTDIR} [${dest}]
-t targetdir \${RELEASEDIR} [${tars}]
[setname ...] Sets to build [${lists}]
USAGE
exit 1
}
@ -53,38 +53,38 @@ USAGE
while getopts bxi:a:m:s:SM:N:d:t: ch; do
case ${ch} in
b)
lists="$nlists $xlists"
lists="${nlists} ${xlists}"
;;
x)
lists="$xlists"
lists="${xlists}"
;;
i)
installdir=${OPTARG}
installdir="${OPTARG}"
;;
a)
MACHINE_ARCH=${OPTARG}
MACHINE_CPU=$(arch_to_cpu ${OPTARG})
MACHINE_ARCH="${OPTARG}"
MACHINE_CPU="$(arch_to_cpu "${OPTARG}")"
;;
m)
MACHINE=${OPTARG}
MACHINE="${OPTARG}"
;;
s)
setsdir=${OPTARG}
setsdir="${OPTARG}"
;;
S)
setfilesonly=true
;;
M)
metalog=${OPTARG}
metalog="${OPTARG}"
;;
N)
etcdir=${OPTARG}
etcdir="${OPTARG}"
;;
d)
dest=${OPTARG}
dest="${OPTARG}"
;;
t)
tars=${OPTARG}
tars="${OPTARG}"
;;
*)
usage
@ -92,33 +92,33 @@ while getopts bxi:a:m:s:SM:N:d:t: ch; do
esac
done
shift $((${OPTIND} - 1))
if [ -n "$installdir" ]; then # if -i, remove etc & xetc from the default list
lists=$(echo $lists | ${SED} -e 's/ etc / /;s/ xetc / /')
if [ -n "${installdir}" ]; then # if -i, remove etc & xetc from the default list
lists="$(echo ${lists} | ${SED} -e 's/ etc / /;s/ xetc / /')"
fi
if [ -n "$*" ]; then
lists="$*"
fi
if [ -z "$tars" -a -z "$installdir" ]; then
echo 1>&2 \$RELEASEDIR must be set, or -i must be used
if [ -z "${tars}" -a -z "${installdir}" ]; then
echo 1>&2 \${RELEASEDIR} must be set, or -i must be used
exit 1
fi
if [ -z "$dest" ]; then
echo 1>&2 \$DESTDIR must be set
if [ -z "${dest}" ]; then
echo 1>&2 \${DESTDIR} must be set
exit 1
fi
: ${etcdir:=${dest}/etc}
: ${etcdir:="${dest}/etc"}
SDIR=$(${MKTEMP} -d /tmp/${prog}.XXXXXX)
SDIR="$(${MKTEMP} -d "/tmp/${prog}.XXXXXX")"
setlistdir=${dest}/etc/mtree
setlistdir="${dest}/etc/mtree"
cleanup()
{
es=$?
/bin/rm -rf $SDIR
exit $es
/bin/rm -rf "${SDIR}"
exit ${es}
}
trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE
@ -126,38 +126,39 @@ trap cleanup 0 2 3 13 # EXIT INT QUIT PIPE
# build the setfiles
#
if [ -n "$metalog" ]; then
if [ -n "${metalog}" ]; then
(
cat ${etcdir}/mtree/NetBSD.dist
cat "${etcdir}/mtree/NetBSD.dist"
echo "/unset all"
cat $metalog 2>/dev/null
) | ${MTREE} -C -k all -N ${etcdir} > $SDIR/metalog
cat "${metalog}" 2>/dev/null
) | ${MTREE} -C -k all -N "${etcdir}" > "${SDIR}/metalog"
rv=$?
if [ $rv -ne 0 ]; then
if [ ${rv} -ne 0 ]; then
echo 1>&2 "${prog}: mtree parse of ${metalog} failed"
exit $rv
exit ${rv}
fi
fi
for setname in $lists; do
${HOST_SH} $setsdir/makeflist -a $MACHINE_ARCH -m $MACHINE \
-s $setsdir $setname > $SDIR/flist.$setname
if [ -n "$metalog" ]; then
$setfilesonly && echo "Creating ${setlistdir}/set.${setname}"
${AWK} -f $rundir/getdirs.awk $SDIR/flist.$setname \
| ${SORT} -u > $SDIR/flist.$setname.full
for setname in ${lists}; do
${HOST_SH} "${setsdir}/makeflist" -a "${MACHINE_ARCH}" -m "${MACHINE}" \
-s "${setsdir}" "${setname}" > "${SDIR}/flist.${setname}"
if [ -n "${metalog}" ]; then
${setfilesonly} && echo "Creating ${setlistdir}/set.${setname}"
${AWK} -f "${rundir}/getdirs.awk" "${SDIR}/flist.${setname}" \
| ${SORT} -u > "${SDIR}/flist.${setname}.full"
(
echo "/set uname=root gname=wheel"
${AWK} -f $rundir/join.awk \
$SDIR/flist.$setname.full $SDIR/metalog
${AWK} -f "${rundir}/join.awk" \
"${SDIR}/flist.${setname}.full" \
"${SDIR}/metalog"
echo "./etc/mtree/set.${setname} type=file mode=0444"
) > ${setlistdir}/set.${setname}
elif ! cmp -s ${SDIR}/flist.${setname} \
${setlistdir}/set.${setname} >/dev/null 2>&1; then
rm -f ${setlistdir}/set.${setname}
cp ${SDIR}/flist.${setname} ${setlistdir}/set.${setname}
) > "${setlistdir}/set.${setname}"
elif ! cmp -s "${SDIR}/flist.${setname}" \
"${setlistdir}/set.${setname}" >/dev/null 2>&1; then
rm -f "${setlistdir}/set.${setname}"
cp "${SDIR}/flist.${setname}" "${setlistdir}/set.${setname}"
fi
done
if $setfilesonly; then # exit after creating the set lists
if ${setfilesonly}; then # exit after creating the set lists
exit 0
fi
@ -168,28 +169,30 @@ fi
GZIP=-9 # for pax -z
export GZIP
es=0
for setname in $lists; do
out=$setname.tgz
if [ -n "$installdir" ]; then
echo "Copying set $setname"
( cd $dest ; \
${PAX} -O -rwpe -d -N${etcdir} ${metalog:+-M} \
${installdir} < ${setlistdir}/set.${setname} )
for setname in ${lists}; do
out="${setname}.tgz"
if [ -n "${installdir}" ]; then
echo "Copying set ${setname}"
( cd "${dest}" ; \
${PAX} -O -rwpe -d -N"${etcdir}" ${metalog:+-M} \
"${installdir}" < "${setlistdir}/set.${setname}" )
else
if [ -n "$metalog" -a $tars/$out -nt "$metalog" ]; then
echo "$out is up to date"
if [ -n "${metalog}" -a "${tars}/${out}" -nt "${metalog}" ]
then
echo "${out} is up to date"
continue
fi
echo "Creating $out"
rm -f ${tars}/$out
( cd $dest ; \
${PAX} -O -w -d -z -N${etcdir} ${metalog:+-M} \
< ${setlistdir}/set.${setname} ) > ${tars}/$out.tmp &&
mv ${tars}/$out.tmp ${tars}/$out
echo "Creating ${out}"
rm -f "${tars}/${out}"
( cd "${dest}" ; \
${PAX} -O -w -d -z -N"${etcdir}" ${metalog:+-M} \
< "${setlistdir}/set.${setname}" ) \
> "${tars}/${out}.tmp" &&
mv "${tars}/${out}.tmp" "${tars}/${out}"
fi
es=$(($es + $?))
es=$((${es} + $?))
done
if [ $es -gt 255 ] ; then
if [ ${es} -gt 255 ] ; then
es=255
fi
exit $es
exit ${es}

View File

@ -1,6 +1,6 @@
#! /bin/sh
#
# $NetBSD: regpkg,v 1.7 2006/01/03 16:40:16 apb Exp $
# $NetBSD: regpkg,v 1.8 2006/01/03 18:31:09 apb Exp $
#
# Copyright (c) 2003 Alistair G. Crooks. All rights reserved.
#
@ -35,20 +35,20 @@
# Usage: regpkg set pkgname
rundir=${0%/*}
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
SYSPKGROOT=${PKG_DBDIR:-/var/db/pkg}
SYSPKGROOT="${PKG_DBDIR:-/var/db/pkg}"
case "${SYSPKG_DBDIR}" in
"") ;;
*) SYSPKGROOT=${SYSPKG_DBDIR} ;;
*) SYSPKGROOT="${SYSPKG_DBDIR}" ;;
esac
PLIST=/tmp/.PLIST.$$
PLIST="/tmp/.PLIST.$$"
verbose=""
while [ $# -gt 2 ]; do
case $1 in
-v) verbose=$1 ;;
case "$1" in
-v) verbose="$1" ;;
*) break ;;
esac
shift
@ -59,52 +59,52 @@ if [ $# -ne 2 ]; then
exit 1
fi
pkgset=$1
pkgset="$1"
pkg=$2
pkg="$2"
case $verbose in
-v) echo "Making PLIST for \"$pkgset\" set and \"$pkg\" package" ;;
case "${verbose}" in
-v) echo "Making PLIST for \"${pkgset}\" set and \"${pkg}\" package" ;;
esac
# create the skeleton PLIST from the pkgset description
$rundir/makeplist $pkgset $pkg > $PLIST
"${rundir}/makeplist" "${pkgset}" "${pkg}" > "${PLIST}"
# create the pkg tiny version
case "${SYSPKG_DATES}" in
"") tinyvers=`${AWK} '$1 ~ '/$pkg/' { print $2 }' $rundir/versions`
case "$tinyvers" in
"") tinyvers="$(${AWK} '$1 ~ '/"${pkg}"/' { print $2 }' "${rundir}/versions")"
case "${tinyvers}" in
"") tinyvers=0
;;
esac
if [ -f ../../sys/conf/osrelease.sh ]; then
osvers=`${HOST_SH} ../../sys/conf/osrelease.sh`
osvers="$(${HOST_SH} ../../sys/conf/osrelease.sh)"
method=osreleases
else
osvers=`${UNAME} -r`
osvers="$(${UNAME} -r)"
method=uname
fi
t=$osvers.$tinyvers
t="${osvers}.${tinyvers}"
;;
*) args=`${AWK} '
*) args="$(${AWK} '
/^@cwd/ { prefix = $2; next }
/^@dirrm/ { next }
{ printf("%s%s\n", prefix, $0) }' $PLIST`
{ printf("%s%s\n", prefix, $0) }' "${PLIST}")"
# first try for any RCS identifiers in the files
t=0
case "$args" in
case "${args}" in
"") ;;
*) t=`${IDENT} $args 2>/dev/null | ${AWK} '
*) t="$(${IDENT} ${args} 2>/dev/null | ${AWK} '
BEGIN { last = 0 }
$2 == "crt0.c,v" { next }
NF == 8 { t = $4; gsub("/", "", t); if (t > last) last = t; }
END { print last }'`
END { print last }')"
method=ident
;;
esac
case "$t" in
case "${t}" in
0) # we need the last mtime of the files which make up the package
t=`${ENV_CMD} TZ=UTC LOCALE=C ${LS} -lT $args | ${AWK} '
t="$(${ENV_CMD} TZ=UTC LOCALE=C ${LS} -lT ${args} | ${AWK} '
BEGIN { newest = 0 }
{
t = $9 "";
@ -127,7 +127,7 @@ case "${SYSPKG_DATES}" in
#t = sprintf("%s.%4.4s", t, $8);
if (t > newest) newest = t;
}
END { print newest }'`
END { print newest }')"
method=ls
;;
esac
@ -135,49 +135,49 @@ case "${SYSPKG_DATES}" in
esac
# print version number that we're using
case "$verbose" in
-v) echo "$pkg - $t version using $method method" ;;
case "${verbose}" in
-v) echo "${pkg} - ${t} version using ${method} method" ;;
esac
# create the directory and minimal contents
SYSPKGDIR=${SYSPKGROOT}/$pkg-$t
if [ -d ${SYSPKGDIR} ]; then
echo "There is already a $pkg-$t package installed (${SYSPKGDIR})"
SYSPKGDIR="${SYSPKGROOT}/${pkg}-${t}"
if [ -d "${SYSPKGDIR}" ]; then
echo "There is already a ${pkg}-${t} package installed (${SYSPKGDIR})"
exit 1
fi
mkdir -p ${SYSPKGDIR}
mkdir -p "${SYSPKGDIR}"
# add the dependencies
${AWK} '$1 ~ '/$pkg/' { print $2 }' $rundir/deps | ${SORT} | \
${AWK} '{ print "@pkgdep " $1 "-[0-9]*" }' >> $PLIST
${AWK} '$1 ~ '/"${pkg}"/' { print $2 }' "${rundir}/deps" | ${SORT} | \
${AWK} '{ print "@pkgdep " $1 "-[0-9]*" }' >> "${PLIST}"
# create the comment
comment=`${AWK} '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' \
$rundir/comments`
case "$comment" in
"") echo "***WARNING ***: no comment for \"$pkg\"" 2>&1
comment="System package for $pkg"
comment="$(${AWK} '$1 ~ '/"${pkg}"/' { print substr($0, length($1) + 2) }' \
"${rundir}/comments")"
case "${comment}" in
"") echo "***WARNING ***: no comment for \"${pkg}\"" 2>&1
comment="System package for ${pkg}"
;;
esac
echo "$comment" > ${SYSPKGDIR}/+COMMENT
echo "${comment}" > "${SYSPKGDIR}/+COMMENT"
# create the description
descr=`${AWK} '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' \
$rundir/descrs`
case "$descr" in
"") echo "***WARNING ***: no description for \"$pkg\"" 2>&1
descr="System package for $pkg"
descr="$(${AWK} '$1 ~ '/"${pkg}"/' { print substr($0, length($1) + 2) }' \
"${rundir}/descrs")"
case "${descr}" in
"") echo "***WARNING ***: no description for \"${pkg}\"" 2>&1
descr="System package for ${pkg}"
;;
esac
echo "$descr" > ${SYSPKGDIR}/+DESC
${PRINTF} "\nHomepage:\nhttp://www.NetBSD.org/\n" >> ${SYSPKGDIR}/+DESC
echo "${descr}" > "${SYSPKGDIR}/+DESC"
${PRINTF} "\nHomepage:\nhttp://www.NetBSD.org/\n" >> "${SYSPKGDIR}/+DESC"
# create the build information
if [ x${BUILD_INFO_CACHE} = x ]; then
if [ x"${BUILD_INFO_CACHE}" = x ]; then
{
echo "OPSYS=`${UNAME} -s`"
echo "OS_VERSION=`${UNAME} -r`"
echo "OPSYS=$(${UNAME} -s)"
echo "OS_VERSION=$(${UNAME} -r)"
${MAKE} -f- all <<EOF
.include <bsd.own.mk>
all:
@ -185,30 +185,30 @@ all:
@echo MACHINE_ARCH=${MACHINE_ARCH}
@echo MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH}
EOF
echo "_PKGTOOLS_VER=`${PKG_CREATE} -V`"
} > ${SYSPKGDIR}/+BUILD_INFO
echo "_PKGTOOLS_VER=$(${PKG_CREATE} -V)"
} > "${SYSPKGDIR}/+BUILD_INFO"
else
cp ${BUILD_INFO_CACHE} ${SYSPKGDIR}/+BUILD_INFO
cp "${BUILD_INFO_CACHE}" "${SYSPKGDIR}/+BUILD_INFO"
fi
# test for attributes
args=""
attrs=`${AWK} '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' \
$rundir/attrs`
for a in "$attrs"; do
case "$attrs" in
attrs="$(${AWK} '$1 ~ '/"${pkg}"/' { print substr($0, length($1) + 2) }' \
"${rundir}/attrs")"
for a in "${attrs}"; do
case "${attrs}" in
"") ;;
preserve) echo "$pkg-$t" > ${SYSPKGDIR}/+PRESERVE
args="$args -n ${SYSPKGDIR}/+PRESERVE"
preserve) echo "${pkg}-${t}" > "${SYSPKGDIR}/+PRESERVE"
args="${args} -n ${SYSPKGDIR}/+PRESERVE"
;;
esac
done
${PKG_CREATE} -v -c ${SYSPKGDIR}/+COMMENT \
-d ${SYSPKGDIR}/+DESC \
$args \
-f $PLIST -l -b /dev/null -B ${SYSPKGDIR}/+BUILD_INFO \
-s /dev/null -S /dev/null -O $pkg-$t.tgz \
> ${SYSPKGDIR}/+CONTENTS
${PKG_CREATE} -v -c "${SYSPKGDIR}/+COMMENT" \
-d "${SYSPKGDIR}/+DESC" \
${args} \
-f "${PLIST}" -l -b /dev/null -B "${SYSPKGDIR}/+BUILD_INFO" \
-s /dev/null -S /dev/null -O "${pkg}-${t}.tgz" \
> "${SYSPKGDIR}/+CONTENTS"
rm $PLIST
rm "${PLIST}"

View File

@ -1,6 +1,6 @@
#! /bin/sh
#
# $NetBSD: regpkgset,v 1.4 2006/01/03 16:40:16 apb Exp $
# $NetBSD: regpkgset,v 1.5 2006/01/03 18:31:09 apb Exp $
#
# Copyright (c) 2003 Alistair G. Crooks. All rights reserved.
#
@ -35,15 +35,15 @@
# Usage: regpkgset set
rundir=${0%/*}
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
verbose=""
cache=""
while [ $# -gt 1 ]; do
case $1 in
-v) verbose=$1 ;;
-c) cache=$1 ;;
case "$1" in
-v) verbose="$1" ;;
-c) cache="$1" ;;
*) break ;;
esac
shift
@ -54,17 +54,17 @@ if [ $# -lt 1 ]; then
exit 1
fi
case $1 in
case "$1" in
all) list="base comp etc games man misc text" ;;
*) list=$@ ;;
*) list="$*" ;;
esac
if [ x${cache} != x ]; then
BUILD_INFO_CACHE=$(${MKTEMP} /var/tmp/$(basename $0)-BUILD_INFO.XXXXXX)
if [ x"${cache}" != x ]; then
BUILD_INFO_CACHE="$(${MKTEMP} "/var/tmp/${0##*/}-BUILD_INFO.XXXXXX")"
export BUILD_INFO_CACHE
{
echo "OPSYS=`${UNAME} -s`"
echo "OS_VERSION=`${UNAME} -r`"
echo "OPSYS=$(${UNAME} -s)"
echo "OS_VERSION=$(${UNAME} -r)"
${MAKE} -f- all <<EOF
.include <bsd.own.mk>
all:
@ -72,16 +72,16 @@ all:
@echo MACHINE_ARCH=${MACHINE_ARCH}
@echo MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH}
EOF
echo "_PKGTOOLS_VER=`${PKG_CREATE} -V`"
} > ${BUILD_INFO_CACHE}
echo "_PKGTOOLS_VER=$(${PKG_CREATE} -V)"
} > "${BUILD_INFO_CACHE}"
fi
for pkgset in $list; do
for pkg in `$rundir/listpkgs $pkgset`; do
$rundir/regpkg $verbose $pkgset $pkg
for pkgset in ${list}; do
for pkg in $("${rundir}/listpkgs" "${pkgset}"); do
"${rundir}/regpkg" ${verbose} "${pkgset}" "${pkg}"
done
done
[ x${BUILD_INFO_CACHE} != x ] && rm -f ${BUILD_INFO_CACHE}
[ x"${BUILD_INFO_CACHE}" != x ] && rm -f "${BUILD_INFO_CACHE}"
exit 0

View File

@ -20,10 +20,10 @@ usage()
{
cat 1>&2 <<USAGE
Usage: ${0##*/} [-a arch] [-m machine] [-s setsdir] [-p prefix] setname [...]
-a arch set arch (e.g, m68k, mips, powerpc) [$MACHINE_ARCH]
-m machine set machine (e.g, amiga, i386, macppc) [$MACHINE]
-s setsdir directory to find sets [$setsdir]
-p prefix prefix for created plist [$prefix]
-a arch set arch (e.g, m68k, mips, powerpc) [${MACHINE_ARCH}]
-m machine set machine (e.g, amiga, i386, macppc) [${MACHINE}]
-s setsdir directory to find sets [${setsdir}]
-p prefix prefix for created plist [${prefix}]
setname [...] sets to find dependencies for
USAGE
exit 1
@ -33,17 +33,17 @@ USAGE
while getopts a:m:ps: ch; do
case ${ch} in
a)
MACHINE_ARCH=${OPTARG}
MACHINE_CPU=$(arch_to_cpu ${OPTARG})
MACHINE_ARCH="${OPTARG}"
MACHINE_CPU="$(arch_to_cpu "${OPTARG}")"
;;
m)
MACHINE=${OPTARG}
MACHINE="${OPTARG}"
;;
p)
prefix=${OPTARG}
prefix="${OPTARG}"
;;
s)
setsdir=${OPTARG}
setsdir="${OPTARG}"
;;
*)
usage
@ -55,45 +55,46 @@ if [ $# -lt 1 ]; then
usage
fi
sets=$@
sets="$*"
# TBD clean up
SCRATCH=$(${MKTEMP} -d /var/tmp/$(basename $0).XXXXXX)
SCRATCH="$(${MKTEMP} -d "/var/tmp/${0##*/}.XXXXXX")"
[ $? -ne 0 ] && { echo "Could not create scratch directory." 1>&2 ; exit 1 ; }
PATH_MEMBERSHIP=$SCRATCH/path-membership
PATH_TO_PKGNAME=$SCRATCH/pathpkg.db
PARENT_PKGNAMES=$SCRATCH/parent-pkgnames
PARENT_PATHNAMES=$SCRATCH/parent-pathnames
PATH_MEMBERSHIP="${SCRATCH}/path-membership"
PATH_TO_PKGNAME="${SCRATCH}/pathpkg.db"
PARENT_PKGNAMES="${SCRATCH}/parent-pkgnames"
PARENT_PATHNAMES="${SCRATCH}/parent-pathnames"
echo "indexing packages by pathnames" 1>&2
list_set_files $sets | ${SED} 's/^\.\///' | \
${ENV_CMD} PREFIX=$prefix ${AWK} '{
list_set_files ${sets} | ${SED} 's/^\.\///' | \
${ENV_CMD} PREFIX="${prefix}" ${AWK} '{
if ($1 == ".") {
print ENVIRON["PREFIX"] " " $2;
} else {
print ENVIRON["PREFIX"] $1 " " $2;
}
}' | ${SORT} -k 1 -u > $PATH_MEMBERSHIP
}' | ${SORT} -k 1 -u > "${PATH_MEMBERSHIP}"
$DB -q -w -f - btree $PATH_TO_PKGNAME < $PATH_MEMBERSHIP || echo "shit" 1>&2
${DB} -q -w -f - btree "${PATH_TO_PKGNAME}" < "${PATH_MEMBERSHIP}" || \
echo "shit" 1>&2
echo "computing parent pathnames" 1>&2
while read pathname pkgname; do
# print parent pathname
echo ${pathname%/*}
done < $PATH_MEMBERSHIP > $PARENT_PATHNAMES
echo "${pathname%/*}"
done < "${PATH_MEMBERSHIP}" > "${PARENT_PATHNAMES}"
echo "selecting parent packages using parent pathnames" 1>&2
$DB -q -f - btree $PATH_TO_PKGNAME < $PARENT_PATHNAMES | \
${PASTE} $PATH_MEMBERSHIP - | \
${DB} -q -f - btree "${PATH_TO_PKGNAME}" < "${PARENT_PATHNAMES}" | \
${PASTE} "${PATH_MEMBERSHIP}" - | \
${AWK} '{ if ($2 != $4) print $2 " " $4; }' | \
${SORT} -u | \
$rundir/culldeps
"${rundir}/culldeps"
if [ $? -ne 0 ]; then
echo "error in parent-directory lookup, aborting" 1>&2