Tue Dec 1 15:49:21 2009 UTC ()
There's no point in adding _PKGTOOLS_VER=$(${PKG_CREATE} -V)
to any syspkg +BUILD_INFO files, since we don't use the pkg_* tools
to create syspkgs.  Also remove the definition of PKG_CREATE
from sets.subr, since nothing uses it now.


(apb)
diff -r1.17 -r1.18 src/distrib/sets/regpkg
diff -r1.11 -r1.12 src/distrib/sets/regpkgset
diff -r1.92 -r1.93 src/distrib/sets/sets.subr

cvs diff -r1.17 -r1.18 src/distrib/sets/regpkg (switch to unified diff)

--- src/distrib/sets/regpkg 2009/10/17 23:43:22 1.17
+++ src/distrib/sets/regpkg 2009/12/01 15:49:21 1.18
@@ -1,1075 +1,1071 @@ @@ -1,1075 +1,1071 @@
1#! /bin/sh 1#! /bin/sh
2# 2#
3# $NetBSD: regpkg,v 1.17 2009/10/17 23:43:22 agc Exp $ 3# $NetBSD: regpkg,v 1.18 2009/12/01 15:49:21 apb Exp $
4# 4#
5# Copyright (c) 2003,2009 The NetBSD Foundation, Inc. 5# Copyright (c) 2003,2009 The NetBSD Foundation, Inc.
6# All rights reserved. 6# All rights reserved.
7# 7#
8# This code is derived from software contributed to The NetBSD Foundation 8# This code is derived from software contributed to The NetBSD Foundation
9# by Alistair Crooks (agc@NetBSD.org) 9# by Alistair Crooks (agc@NetBSD.org)
10# 10#
11# Redistribution and use in source and binary forms, with or without 11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions 12# modification, are permitted provided that the following conditions
13# are met: 13# are met:
14# 1. Redistributions of source code must retain the above copyright 14# 1. Redistributions of source code must retain the above copyright
15# notice, this list of conditions and the following disclaimer. 15# notice, this list of conditions and the following disclaimer.
16# 2. Redistributions in binary form must reproduce the above copyright 16# 2. Redistributions in binary form must reproduce the above copyright
17# notice, this list of conditions and the following disclaimer in the 17# notice, this list of conditions and the following disclaimer in the
18# documentation and/or other materials provided with the distribution. 18# documentation and/or other materials provided with the distribution.
19# 19#
20# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30# POSSIBILITY OF SUCH DAMAGE. 30# POSSIBILITY OF SUCH DAMAGE.
31# 31#
32 32
33# Usage: regpkg [options] set pkgname 33# Usage: regpkg [options] set pkgname
34# 34#
35# Registers a syspkg in the database directory, 35# Registers a syspkg in the database directory,
36# and optionally creates a binary package. 36# and optionally creates a binary package.
37# 37#
38# Options: 38# Options:
39# -q Quiet. 39# -q Quiet.
40# -v Verbose. 40# -v Verbose.
41# -f Force. 41# -f Force.
42# -m Ignore errors from missing files. 42# -m Ignore errors from missing files.
43# -u Update. 43# -u Update.
44# -c Use cached information from ${BUILD_INFO_CACHE}. 44# -c Use cached information from ${BUILD_INFO_CACHE}.
45# -d destdir Sets DESTDIR. 45# -d destdir Sets DESTDIR.
46# -t binpkgdir Create a binary package (in *.tgz format) in the 46# -t binpkgdir Create a binary package (in *.tgz format) in the
47# specified directory. Without this option, a binary 47# specified directory. Without this option, a binary
48# package is not created. 48# package is not created.
49# -M metalog Use the specified metalog file to override file 49# -M metalog Use the specified metalog file to override file
50# or directory attributes when creating a binary package. 50# or directory attributes when creating a binary package.
51# -N etcdir Use the specified directory for passwd and group files. 51# -N etcdir Use the specified directory for passwd and group files.
52# 52#
53# When -f is set: If the desired syspkg already exists, it is overwritten. 53# When -f is set: If the desired syspkg already exists, it is overwritten.
54# When -u is set: If the desired syspkg already exists, it might be 54# When -u is set: If the desired syspkg already exists, it might be
55# overwritten or left alone, depending on whether it's older 55# overwritten or left alone, depending on whether it's older
56# or newer than the files that belong to the syspkg. 56# or newer than the files that belong to the syspkg.
57# When neither -u nor -f are set: It's an error for the desired syspkg 57# When neither -u nor -f are set: It's an error for the desired syspkg
58# to already exist. 58# to already exist.
59 59
60prog="${0##*/}" 60prog="${0##*/}"
61toppid=$$ 61toppid=$$
62rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/" 62rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
63. "${rundir}/sets.subr" 63. "${rundir}/sets.subr"
64 64
65bomb() 65bomb()
66{ 66{
67 #echo "${prog}: bomb: start, toppid=${toppid} \$\$=$$" 67 #echo "${prog}: bomb: start, toppid=${toppid} \$\$=$$"
68 kill ${toppid} # in case we were invoked from a subshell 68 kill ${toppid} # in case we were invoked from a subshell
69 #echo "${prog}: bomb: killed ${toppid}" 69 #echo "${prog}: bomb: killed ${toppid}"
70 exit 1 70 exit 1
71} 71}
72 72
73# A literal newline 73# A literal newline
74nl=' 74nl='
75' 75'
76# A literal tab 76# A literal tab
77tab=' ' 77tab=' '
78 78
79# Prefixes for error messages, warnings, and important informational 79# Prefixes for error messages, warnings, and important informational
80# messages. 80# messages.
81ERROR="${prog}: ERROR: " 81ERROR="${prog}: ERROR: "
82WARNING="${prog}: WARNING: " 82WARNING="${prog}: WARNING: "
83NOTE="${prog}: NOTE: " 83NOTE="${prog}: NOTE: "
84ERRWARN="${ERROR}" # may be changed by "-f" (force) command line flag 84ERRWARN="${ERROR}" # may be changed by "-f" (force) command line flag
85ERRWARNNOTE="${ERROR}" # may be changed by "-u" (update) command line flag 85ERRWARNNOTE="${ERROR}" # may be changed by "-u" (update) command line flag
86 86
87# 87#
88# All temporary files will go in ${SCRATCH}, which will be deleted on 88# All temporary files will go in ${SCRATCH}, which will be deleted on
89# exit. 89# exit.
90# 90#
91SCRATCH="$(${MKTEMP} -d "/var/tmp/${0##*/}.XXXXXX")" 91SCRATCH="$(${MKTEMP} -d "/var/tmp/${0##*/}.XXXXXX")"
92if [ $? -ne 0 -o \! -d "${SCRATCH}" ]; then 92if [ $? -ne 0 -o \! -d "${SCRATCH}" ]; then
93 echo >&2 "${prog}: Could not create scratch directory." 93 echo >&2 "${prog}: Could not create scratch directory."
94 bomb 94 bomb
95fi 95fi
96 96
97# 97#
98# cleanup() always deletes the SCRATCH directory, and might also 98# cleanup() always deletes the SCRATCH directory, and might also
99# delete other files or directories. 99# delete other files or directories.
100# 100#
101es=0 101es=0
102cleanup_must_delete_binpkgfile=false 102cleanup_must_delete_binpkgfile=false
103cleanup_must_delete_dbsubdir=false 103cleanup_must_delete_dbsubdir=false
104cleanup() 104cleanup()
105{ 105{
106 trap - 0 106 trap - 0
107 #echo "${prog}: cleanup start" 107 #echo "${prog}: cleanup start"
108 if ${cleanup_must_delete_binpkgfile:-false} && [ -e "${binpkgfile}" ] 108 if ${cleanup_must_delete_binpkgfile:-false} && [ -e "${binpkgfile}" ]
109 then 109 then
110 echo >&2 "${prog}: deleting partially-created ${binpkgfile}" 110 echo >&2 "${prog}: deleting partially-created ${binpkgfile}"
111 rm -f "${binpkgfile}" 111 rm -f "${binpkgfile}"
112 fi 112 fi
113 if ${cleanup_must_delete_dbsubdir:-false} \ 113 if ${cleanup_must_delete_dbsubdir:-false} \
114 && [ -e "${SYSPKG_DB_SUBDIR}" ] 114 && [ -e "${SYSPKG_DB_SUBDIR}" ]
115 then 115 then
116 echo >&2 "${prog}: deleting partially-created ${SYSPKG_DB_SUBDIR}" 116 echo >&2 "${prog}: deleting partially-created ${SYSPKG_DB_SUBDIR}"
117 rm -rf "${SYSPKG_DB_SUBDIR}" 117 rm -rf "${SYSPKG_DB_SUBDIR}"
118 fi 118 fi
119 rm -rf "${SCRATCH}" 119 rm -rf "${SCRATCH}"
120 #echo "${prog}: cleanup done, exit ${es}" 120 #echo "${prog}: cleanup done, exit ${es}"
121 exit ${es} 121 exit ${es}
122} 122}
123trap 'es=128; cleanup' 1 2 3 13 15 # HUP INT QUIT PIPE TERM 123trap 'es=128; cleanup' 1 2 3 13 15 # HUP INT QUIT PIPE TERM
124trap 'es=$?; cleanup' 0 # EXIT 124trap 'es=$?; cleanup' 0 # EXIT
125 125
126# 126#
127# Parse command line args. 127# Parse command line args.
128# 128#
129verbose=false 129verbose=false
130verbosity=0 130verbosity=0
131quiet=false 131quiet=false
132force=false 132force=false
133update=false 133update=false
134allowmissing=false 134allowmissing=false
135DESTDIR="${DESTDIR}" 135DESTDIR="${DESTDIR}"
136binpkgdir="" 136binpkgdir=""
137metalog="" 137metalog=""
138etcdir="" 138etcdir=""
139SYSPKG_DB_TOPDIR="" 139SYSPKG_DB_TOPDIR=""
140pkgset="" 140pkgset=""
141pkg="" 141pkg=""
142parse_args() 142parse_args()
143{ 143{
144 while [ $# -gt 2 ]; do 144 while [ $# -gt 2 ]; do
145 case "$1" in 145 case "$1" in
146 -q) quiet=true; verbose=false ;; 146 -q) quiet=true; verbose=false ;;
147 -v) verbose=true; quiet=false 147 -v) verbose=true; quiet=false
148 verbosity=$(( ${verbosity} + 1 )) 148 verbosity=$(( ${verbosity} + 1 ))
149 ;; 149 ;;
150 -f) force=true ;; 150 -f) force=true ;;
151 -u) update=true ;; 151 -u) update=true ;;
152 -m) allowmissing=true ;; 152 -m) allowmissing=true ;;
153 -c) # The -c option is ignored. The BUILD_INFO_CACHE 153 -c) # The -c option is ignored. The BUILD_INFO_CACHE
154 # environment variable is used instead. 154 # environment variable is used instead.
155 ;; 155 ;;
156 -d) DESTDIR="$2"; shift ;; 156 -d) DESTDIR="$2"; shift ;;
157 -d*) DESTDIR="${1#-?}" ;; 157 -d*) DESTDIR="${1#-?}" ;;
158 -t) binpkgdir="$2"; shift ;; 158 -t) binpkgdir="$2"; shift ;;
159 -t*) binpkgdir="${1#-?}" ;; 159 -t*) binpkgdir="${1#-?}" ;;
160 -M) metalog="$2"; shift ;; 160 -M) metalog="$2"; shift ;;
161 -M*) metalog="${1#-?}" ;; 161 -M*) metalog="${1#-?}" ;;
162 -N) etcdir="$2"; shift ;; 162 -N) etcdir="$2"; shift ;;
163 -N*) etcdir="${1#-?}" ;; 163 -N*) etcdir="${1#-?}" ;;
164 *) break ;; 164 *) break ;;
165 esac 165 esac
166 shift 166 shift
167 done 167 done
168 if ${force}; then 168 if ${force}; then
169 ERRWARN="${WARNING}" 169 ERRWARN="${WARNING}"
170 else 170 else
171 ERRWARN="${ERROR}" 171 ERRWARN="${ERROR}"
172 fi 172 fi
173 if ${update}; then 173 if ${update}; then
174 ERRWARNNOTE="${NOTE}" 174 ERRWARNNOTE="${NOTE}"
175 else 175 else
176 ERRWARNNOTE="${ERRWARN}" 176 ERRWARNNOTE="${ERRWARN}"
177 fi 177 fi
178 DESTDIR="${DESTDIR%/}" # delete trailing "/" if any 178 DESTDIR="${DESTDIR%/}" # delete trailing "/" if any
179 if [ \! -n "${etcdir}" ]; then 179 if [ \! -n "${etcdir}" ]; then
180 etcdir="${DESTDIR}/etc" 180 etcdir="${DESTDIR}/etc"
181 fi 181 fi
182 if [ -n "${binpkgdir}" -a \! -d "${binpkgdir}" ]; then 182 if [ -n "${binpkgdir}" -a \! -d "${binpkgdir}" ]; then
183 echo >&2 "${ERROR}binary pkg directory ${binpkgdir} does not exist" 183 echo >&2 "${ERROR}binary pkg directory ${binpkgdir} does not exist"
184 bomb 184 bomb
185 fi 185 fi
186 # 186 #
187 # SYSPKG_DB_TOPDIR is the top level directory for registering 187 # SYSPKG_DB_TOPDIR is the top level directory for registering
188 # syspkgs. It defaults to ${DESTDIR}/var/db/syspkg, but can be 188 # syspkgs. It defaults to ${DESTDIR}/var/db/syspkg, but can be
189 # overridden by environment variables SYSPKG_DBDIR or PKG_DBDIR. 189 # overridden by environment variables SYSPKG_DBDIR or PKG_DBDIR.
190 # 190 #
191 # Note that this corresponds to the default value of PKG_DBDIR 191 # Note that this corresponds to the default value of PKG_DBDIR
192 # set in .../distrib/syspkg/mk/bsd.syspkg.mk. 192 # set in .../distrib/syspkg/mk/bsd.syspkg.mk.
193 #  193 #
194 SYSPKG_DB_TOPDIR="${SYSPKG_DBDIR:-${PKG_DBDIR:-${DESTDIR}/var/db/syspkg}}" 194 SYSPKG_DB_TOPDIR="${SYSPKG_DBDIR:-${PKG_DBDIR:-${DESTDIR}/var/db/syspkg}}"
195 195
196 if [ $# -ne 2 ]; then 196 if [ $# -ne 2 ]; then
197 echo "Usage: regpkg [options] set pkgname" 197 echo "Usage: regpkg [options] set pkgname"
198 bomb 198 bomb
199 fi 199 fi
200 200
201 pkgset="$1" 201 pkgset="$1"
202 pkg="$2" 202 pkg="$2"
203} 203}
204 204
205# 205#
206# make_PLIST() creates a skeleton PLIST from the pkgset description. 206# make_PLIST() creates a skeleton PLIST from the pkgset description.
207# 207#
208# The result is stored in the file ${PLIST}. 208# The result is stored in the file ${PLIST}.
209# 209#
210PLIST="${SCRATCH}/PLIST" 210PLIST="${SCRATCH}/PLIST"
211make_PLIST() 211make_PLIST()
212{ 212{
213 if ${verbose}; then 213 if ${verbose}; then
214 echo "Making PLIST for \"${pkg}\" package (part of ${pkgset} set)" 214 echo "Making PLIST for \"${pkg}\" package (part of ${pkgset} set)"
215 fi 215 fi
216 prefix="${DESTDIR:-/}" 216 prefix="${DESTDIR:-/}"
217 realprefix=/ 217 realprefix=/
218 ${HOST_SH} "${rundir}/makeplist" -p "${prefix}" -I "${realprefix}" \ 218 ${HOST_SH} "${rundir}/makeplist" -p "${prefix}" -I "${realprefix}" \
219 "${pkgset}" "${pkg}" \ 219 "${pkgset}" "${pkg}" \
220 >"${PLIST}" 2>"${SCRATCH}/makeplist-errors" 220 >"${PLIST}" 2>"${SCRATCH}/makeplist-errors"
221 if ${EGREP} -v '^DEBUG:' "${SCRATCH}/makeplist-errors"; then 221 if ${EGREP} -v '^DEBUG:' "${SCRATCH}/makeplist-errors"; then
222 # "find" invoked from makeplist sometimes reports 222 # "find" invoked from makeplist sometimes reports
223 # errors about missing files or directories, and 223 # errors about missing files or directories, and
224 # makeplist ignores the errors. Catch them here. 224 # makeplist ignores the errors. Catch them here.
225 echo >&2 "${ERROR}makeplist reported errors for ${pkg}:" 225 echo >&2 "${ERROR}makeplist reported errors for ${pkg}:"
226 cat >&2 "${SCRATCH}/makeplist-errors" 226 cat >&2 "${SCRATCH}/makeplist-errors"
227 echo >&2 "${ERROR}see above for errors from makeplist" 227 echo >&2 "${ERROR}see above for errors from makeplist"
228 if ${allowmissing}; then 228 if ${allowmissing}; then
229 echo >&2 "${prog}: ${NOTE}: ignoring above errors, due to '-m' option." 229 echo >&2 "${prog}: ${NOTE}: ignoring above errors, due to '-m' option."
230 else 230 else
231 ${force} || bomb 231 ${force} || bomb
232 fi 232 fi
233 fi 233 fi
234} 234}
235 235
236# 236#
237# init_allfiles() converts the PLIST (which contains relative filenames) 237# init_allfiles() converts the PLIST (which contains relative filenames)
238# into a list of absolute filenames. Directories are excluded from the 238# into a list of absolute filenames. Directories are excluded from the
239# result. 239# result.
240#  240#
241# The result is stored in the variable ${allfiles}. 241# The result is stored in the variable ${allfiles}.
242# 242#
243allfiles='' 243allfiles=''
244init_allfiles() 244init_allfiles()
245{ 245{
246 [ -f "${PLIST}" ] || make_PLIST 246 [ -f "${PLIST}" ] || make_PLIST
247 allfiles="$(${AWK} ' 247 allfiles="$(${AWK} '
248 BEGIN { destdir = "'"${DESTDIR%/}"'" } 248 BEGIN { destdir = "'"${DESTDIR%/}"'" }
249 /^@cwd/ { prefix = $2; next } 249 /^@cwd/ { prefix = $2; next }
250 /^@dirrm/ { next } 250 /^@dirrm/ { next }
251 { printf("%s%s%s\n", destdir, prefix, $0) }' "${PLIST}")" 251 { printf("%s%s%s\n", destdir, prefix, $0) }' "${PLIST}")"
252} 252}
253 253
254# 254#
255# init_newestfile() finds the newest file (most recent mtime). 255# init_newestfile() finds the newest file (most recent mtime).
256# 256#
257# The result is stored in the variable ${newestfile}. 257# The result is stored in the variable ${newestfile}.
258# 258#
259newestfile='' 259newestfile=''
260init_newestfile() 260init_newestfile()
261{ 261{
262 [ -s "${allfiles}" ] || init_allfiles 262 [ -s "${allfiles}" ] || init_allfiles
263 # We assume no shell special characters in ${allfiles}, 263 # We assume no shell special characters in ${allfiles},
264 # and spaces only between file names, not inside file names. 264 # and spaces only between file names, not inside file names.
265 # This should be safe, because it has no no user-specified parts. 265 # This should be safe, because it has no no user-specified parts.
266 newestfile="$(${LS} -1dt ${allfiles} | ${SED} '1q')" 266 newestfile="$(${LS} -1dt ${allfiles} | ${SED} '1q')"
267} 267}
268 268
269# 269#
270# Various ways of getting parts of the syspkg version number: 270# Various ways of getting parts of the syspkg version number:
271# 271#
272# get_osvers() - get the OS version number from osrelease.sh or $(uname -r), 272# get_osvers() - get the OS version number from osrelease.sh or $(uname -r),
273# return it in ${osvers}, and set ${method}. 273# return it in ${osvers}, and set ${method}.
274# get_tinyvers() - get the tiny version number from the "versions" file, 274# get_tinyvers() - get the tiny version number from the "versions" file,
275# and return it in ${tinyvers}. Does not set ${method}. 275# and return it in ${tinyvers}. Does not set ${method}.
276# get_newest_rcsid_date() - get the newest RCS date, 276# get_newest_rcsid_date() - get the newest RCS date,
277# and return it in ${newest}. Does not set ${method}. 277# and return it in ${newest}. Does not set ${method}.
278# get_newest_mtime_date() - get the newest file modification date, 278# get_newest_mtime_date() - get the newest file modification date,
279# and return it in ${newest}. Does not set ${method}. 279# and return it in ${newest}. Does not set ${method}.
280# get_newest_date() - get date from rcsid or mtime, return it in ${newest}, 280# get_newest_date() - get date from rcsid or mtime, return it in ${newest},
281# and set ${method}. 281# and set ${method}.
282# 282#
283get_osvers() 283get_osvers()
284{ 284{
285 if [ -f ../../sys/conf/osrelease.sh ]; then 285 if [ -f ../../sys/conf/osrelease.sh ]; then
286 osvers="$(${HOST_SH} ../../sys/conf/osrelease.sh)" 286 osvers="$(${HOST_SH} ../../sys/conf/osrelease.sh)"
287 method=osreleases 287 method=osreleases
288 else 288 else
289 osvers="$(${UNAME} -r)" 289 osvers="$(${UNAME} -r)"
290 method=uname 290 method=uname
291 fi 291 fi
292 #echo "${osvers}" 292 #echo "${osvers}"
293} 293}
294get_tinyvers() 294get_tinyvers()
295{ 295{
296 tinyvers="$(${AWK} '$1 ~ '/"${pkg}"/' { print $2 }' \ 296 tinyvers="$(${AWK} '$1 ~ '/"${pkg}"/' { print $2 }' \
297 "${rundir}/versions")" 297 "${rundir}/versions")"
298 case "${tinyvers}" in 298 case "${tinyvers}" in
299 "") tinyvers=0 299 "") tinyvers=0
300 ;; 300 ;;
301 esac 301 esac
302 #echo "${tinyvers}" 302 #echo "${tinyvers}"
303} 303}
304get_newest_rcsid_date() 304get_newest_rcsid_date()
305{ 305{
306 [ -s "${allfiles}" ] || init_allfiles 306 [ -s "${allfiles}" ] || init_allfiles
307 307
308 # Old RCS identifiers might have 2-digit years, so we match both 308 # Old RCS identifiers might have 2-digit years, so we match both
309 # YY/MM/DD and YYYY/MM/DD. We also try to deal with the Y10K 309 # YY/MM/DD and YYYY/MM/DD. We also try to deal with the Y10K
310 # problem by allowing >4 digit years. 310 # problem by allowing >4 digit years.
311 newest=0 311 newest=0
312 case "${allfiles}" in 312 case "${allfiles}" in
313 "") ;; 313 "") ;;
314 *) newest="$(${IDENT} ${allfiles} 2>/dev/null | ${AWK} ' 314 *) newest="$(${IDENT} ${allfiles} 2>/dev/null | ${AWK} '
315 BEGIN { last = 0 } 315 BEGIN { last = 0 }
316 $2 == "crt0.c,v" { next } 316 $2 == "crt0.c,v" { next }
317 NF == 8 && \ 317 NF == 8 && \
318 $4 ~ /^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]$/ \ 318 $4 ~ /^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]$/ \
319 { t = "19" $4; gsub("/", "", t); 319 { t = "19" $4; gsub("/", "", t);
320 if (t > last) last = t; } 320 if (t > last) last = t; }
321 NF == 8 && \ 321 NF == 8 && \
322 $4 ~ /^[0-9][0-9][0-9][0-9][0-9]*\/[0-9][0-9]\/[0-9][0-9]$/ \ 322 $4 ~ /^[0-9][0-9][0-9][0-9][0-9]*\/[0-9][0-9]\/[0-9][0-9]$/ \
323 { t = $4; gsub("/", "", t); 323 { t = $4; gsub("/", "", t);
324 if (t > last) last = t; } 324 if (t > last) last = t; }
325 END { print last }')" 325 END { print last }')"
326 method=ident 326 method=ident
327 ;; 327 ;;
328 esac 328 esac
329 #echo "${newest}" 329 #echo "${newest}"
330} 330}
331get_newest_mtime_date() 331get_newest_mtime_date()
332{ 332{
333 [ -s "${newestfile}" ] || init_newestfile 333 [ -s "${newestfile}" ] || init_newestfile
334 334
335 # We could simplify the awk program to take advantage of the 335 # We could simplify the awk program to take advantage of the
336 # fact thet it should have exactly one line of input. 336 # fact thet it should have exactly one line of input.
337 newest="$(${ENV_CMD} TZ=UTC LOCALE=C ${LS} -lT "${newestfile}" \ 337 newest="$(${ENV_CMD} TZ=UTC LOCALE=C ${LS} -lT "${newestfile}" \
338 | ${AWK} ' 338 | ${AWK} '
339 BEGIN { newest = 0 } 339 BEGIN { newest = 0 }
340 { 340 {
341 t = $9 ""; 341 t = $9 "";
342 if ($6 == "Jan") t = t "01"; 342 if ($6 == "Jan") t = t "01";
343 if ($6 == "Feb") t = t "02"; 343 if ($6 == "Feb") t = t "02";
344 if ($6 == "Mar") t = t "03"; 344 if ($6 == "Mar") t = t "03";
345 if ($6 == "Apr") t = t "04"; 345 if ($6 == "Apr") t = t "04";
346 if ($6 == "May") t = t "05"; 346 if ($6 == "May") t = t "05";
347 if ($6 == "Jun") t = t "06"; 347 if ($6 == "Jun") t = t "06";
348 if ($6 == "Jul") t = t "07"; 348 if ($6 == "Jul") t = t "07";
349 if ($6 == "Aug") t = t "08"; 349 if ($6 == "Aug") t = t "08";
350 if ($6 == "Sep") t = t "09"; 350 if ($6 == "Sep") t = t "09";
351 if ($6 == "Oct") t = t "10"; 351 if ($6 == "Oct") t = t "10";
352 if ($6 == "Nov") t = t "11"; 352 if ($6 == "Nov") t = t "11";
353 if ($6 == "Dec") t = t "12"; 353 if ($6 == "Dec") t = t "12";
354 if ($7 < 10) t = t "0"; 354 if ($7 < 10) t = t "0";
355 t = t $7; 355 t = t $7;
356 #these next two lines add the 24h clock onto the date 356 #these next two lines add the 24h clock onto the date
357 #gsub(":", "", $8); 357 #gsub(":", "", $8);
358 #t = sprintf("%s.%4.4s", t, $8); 358 #t = sprintf("%s.%4.4s", t, $8);
359 if (t > newest) newest = t; 359 if (t > newest) newest = t;
360 } 360 }
361 END { print newest }')" 361 END { print newest }')"
362 #echo "${newest}" 362 #echo "${newest}"
363} 363}
364get_newest_date() 364get_newest_date()
365{ 365{
366 get_newest_rcsid_date 366 get_newest_rcsid_date
367 case "${newest}" in 367 case "${newest}" in
368 ""|0) get_newest_mtime_date 368 ""|0) get_newest_mtime_date
369 method=ls 369 method=ls
370 ;; 370 ;;
371 *) method=rcsid 371 *) method=rcsid
372 ;; 372 ;;
373 esac 373 esac
374 #echo "${newest}" 374 #echo "${newest}"
375} 375}
376 376
377# 377#
378# choose_version_number() chooses the syspkg version number, 378# choose_version_number() chooses the syspkg version number,
379# by concatenating several components (OS version, syspkg "tiny" 379# by concatenating several components (OS version, syspkg "tiny"
380# version and date). We end up with something like 380# version and date). We end up with something like
381# osvers="3.99.15", tinyvers="0", newest="20060104", 381# osvers="3.99.15", tinyvers="0", newest="20060104",
382# and t="3.99.15.0.20060104". 382# and t="3.99.15.0.20060104".
383# 383#
384# The result is stored in the variables ${t} and ${method}. 384# The result is stored in the variables ${t} and ${method}.
385# 385#
386method='' 386method=''
387t='' 387t=''
388choose_version_number() 388choose_version_number()
389{ 389{
390 get_osvers; m1="${method}" 390 get_osvers; m1="${method}"
391 get_tinyvers # does not set ${method} 391 get_tinyvers # does not set ${method}
392 get_newest_date; m2="${method}" 392 get_newest_date; m2="${method}"
393 t="${osvers}.${tinyvers}.${newest}" 393 t="${osvers}.${tinyvers}.${newest}"
394 method="${m1}.${m2}" 394 method="${m1}.${m2}"
395 395
396 # print version number that we're using 396 # print version number that we're using
397 if ${verbose}; then 397 if ${verbose}; then
398 echo "${pkg} - ${t} version using ${method} method" 398 echo "${pkg} - ${t} version using ${method} method"
399 fi 399 fi
400} 400}
401 401
402# 402#
403# init_db_opts() sets the dbfile, dbtype and db_opts variables, 403# init_db_opts() sets the dbfile, dbtype and db_opts variables,
404# used for accessing the pkgdb.byfile.db database. 404# used for accessing the pkgdb.byfile.db database.
405# 405#
406init_db_opts() 406init_db_opts()
407{ 407{
408 dbfile="${SYSPKG_DB_TOPDIR}/pkgdb.byfile.db" 408 dbfile="${SYSPKG_DB_TOPDIR}/pkgdb.byfile.db"
409 dbtype="btree" 409 dbtype="btree"
410 db_opts='' 410 db_opts=''
411 : ${TARGET_ENDIANNESS:="$(arch_to_endian "${MACHINE_ARCH}")"} 411 : ${TARGET_ENDIANNESS:="$(arch_to_endian "${MACHINE_ARCH}")"}
412 case "${TARGET_ENDIANNESS}" in 412 case "${TARGET_ENDIANNESS}" in
413 4321) db_opts="${db_opts} -E B" # big-endian 413 4321) db_opts="${db_opts} -E B" # big-endian
414 ;; 414 ;;
415 1234) db_opts="${db_opts} -E L" # little-endian 415 1234) db_opts="${db_opts} -E L" # little-endian
416 ;; 416 ;;
417 *) 417 *)
418 echo >&2 "${WARNING}Unknown or unsupported target endianness" 418 echo >&2 "${WARNING}Unknown or unsupported target endianness"
419 echo >&2 "${NOTE}Using host endianness" 419 echo >&2 "${NOTE}Using host endianness"
420 ;; 420 ;;
421 esac 421 esac
422 if ${update} || ${force}; then 422 if ${update} || ${force}; then
423 # overwriting an existing entry is not an error 423 # overwriting an existing entry is not an error
424 db_opts="${db_opts} -R" 424 db_opts="${db_opts} -R"
425 fi 425 fi
426 if [ ${verbosity} -lt 2 ]; then 426 if [ ${verbosity} -lt 2 ]; then
427 # don't print all the keys added to the database 427 # don't print all the keys added to the database
428 db_opts="${db_opts} -q" 428 db_opts="${db_opts} -q"
429 fi 429 fi
430} 430}
431 431
432# 432#
433# print_dir_exec_lines outputs an "@exec install" line for each 433# print_dir_exec_lines outputs an "@exec install" line for each
434# directory in ${PLIST} 434# directory in ${PLIST}
435# 435#
436print_dir_exec_lines() 436print_dir_exec_lines()
437{ 437{
438 local dir uname gname mode 438 local dir uname gname mode
439 local dot_slash_dir 439 local dot_slash_dir
440 local no_dot_dir 440 local no_dot_dir
441 local word line 441 local word line
442 ${AWK} '/^@dirrm/ { print $2 }' <"${PLIST}" | \ 442 ${AWK} '/^@dirrm/ { print $2 }' <"${PLIST}" | \
443 ${SORT} | \ 443 ${SORT} | \
444 while read dir; do 444 while read dir; do
445 # Sanitise the name. ${dir} could be an absolute or 445 # Sanitise the name. ${dir} could be an absolute or
446 # relative name, with or without a leading "./". 446 # relative name, with or without a leading "./".
447 # ${dot_slash_dir} always has a leading "./" (except when 447 # ${dot_slash_dir} always has a leading "./" (except when
448 # it's exactly equal to "."). ${no_dot_dir} never has a 448 # it's exactly equal to "."). ${no_dot_dir} never has a
449 # leading "." or "/" (except when it's exactly equal to 449 # leading "." or "/" (except when it's exactly equal to
450 # "."). 450 # ".").
451 case "${dir}" in 451 case "${dir}" in
452 .|./|/) dot_slash_dir=. ;; 452 .|./|/) dot_slash_dir=. ;;
453 ./*) dot_slash_dir="${dir}" ;; 453 ./*) dot_slash_dir="${dir}" ;;
454 /*) dot_slash_dir=".${dir}" ;; 454 /*) dot_slash_dir=".${dir}" ;;
455 *) dot_slash_dir="./${dir}" ;; 455 *) dot_slash_dir="./${dir}" ;;
456 esac 456 esac
457 no_dot_dir="${dot_slash_dir#./}" 457 no_dot_dir="${dot_slash_dir#./}"
458 # Get the directory's owner, group, and mode 458 # Get the directory's owner, group, and mode
459 # from the live file system, or let it be overridden 459 # from the live file system, or let it be overridden
460 # by the metalog. 460 # by the metalog.
461 eval "$(${STAT} -f 'uname=%Su gname=%Sg mode=%#OLp' \ 461 eval "$(${STAT} -f 'uname=%Su gname=%Sg mode=%#OLp' \
462 "${DESTDIR}/${dot_slash_dir}")" 462 "${DESTDIR}/${dot_slash_dir}")"
463 if [ -n "${metalog}" ]; then 463 if [ -n "${metalog}" ]; then
464 line="$(echo "${dot_slash_dir}" | \ 464 line="$(echo "${dot_slash_dir}" | \
465 ${AWK} -f "${rundir}/join.awk" \ 465 ${AWK} -f "${rundir}/join.awk" \
466 /dev/stdin "${metalog}")" 466 /dev/stdin "${metalog}")"
467 for word in ${line}; do 467 for word in ${line}; do
468 case "${word}" in 468 case "${word}" in
469 uname=*|gname=*|mode=*) eval "${word}" ;; 469 uname=*|gname=*|mode=*) eval "${word}" ;;
470 esac 470 esac
471 done 471 done
472 fi 472 fi
473 # XXX: Work around yet another pkg_add bug: @cwd lines 473 # XXX: Work around yet another pkg_add bug: @cwd lines
474 # do not actually cause the working directory to change, 474 # do not actually cause the working directory to change,
475 # so file names in @exec lines need to be qualified by 475 # so file names in @exec lines need to be qualified by
476 # %D, which (in our case, since we know there's an 476 # %D, which (in our case, since we know there's an
477 # "@cwd /" line) will be the dir name passed to 477 # "@cwd /" line) will be the dir name passed to
478 # "pkg_add -p PREFIX". 478 # "pkg_add -p PREFIX".
479 case "${no_dot_dir}" in 479 case "${no_dot_dir}" in
480 .) d="%D" ;; 480 .) d="%D" ;;
481 *) d="%D/${no_dot_dir}" ;; 481 *) d="%D/${no_dot_dir}" ;;
482 esac 482 esac
483 cat <<EOF 483 cat <<EOF
484@exec install -d -o ${uname} -g ${gname} -m ${mode} ${d} 484@exec install -d -o ${uname} -g ${gname} -m ${mode} ${d}
485EOF 485EOF
486 done 486 done
487} 487}
488 488
489# 489#
490# register_syspkg() registers the syspkg in ${SYSPKG_DB_TOPDIR}. 490# register_syspkg() registers the syspkg in ${SYSPKG_DB_TOPDIR}.
491# This involves creating the subdirectory ${SYSPKG_DB_SUBDIR} 491# This involves creating the subdirectory ${SYSPKG_DB_SUBDIR}
492# and populating it with several files. 492# and populating it with several files.
493# 493#
494register_syspkg() 494register_syspkg()
495{ 495{
496 cleanup_must_delete_dbsubdir=true 496 cleanup_must_delete_dbsubdir=true
497 [ -n "${SYSPKG_DB_SUBDIR}" ] || bomb 497 [ -n "${SYSPKG_DB_SUBDIR}" ] || bomb
498 mkdir -p "${SYSPKG_DB_SUBDIR}" 498 mkdir -p "${SYSPKG_DB_SUBDIR}"
499 499
500 # 500 #
501 # Guess what versions of other packages to depend on. 501 # Guess what versions of other packages to depend on.
502 # 502 #
503 # If we are using the OS version as part of the pkg 503 # If we are using the OS version as part of the pkg
504 # version, then depend on any version ">=${osvers}". For 504 # version, then depend on any version ">=${osvers}". For
505 # example, etc-sys-etc-1.6ZI.0.20040206 might depend on 505 # example, etc-sys-etc-1.6ZI.0.20040206 might depend on
506 # base-sys-root>=1.6ZI. 506 # base-sys-root>=1.6ZI.
507 # 507 #
508 # Failing that, depend on any version "-[0-9]*". 508 # Failing that, depend on any version "-[0-9]*".
509 # 509 #
510 # XXX: We could extend the format of the "deps" file to carry 510 # XXX: We could extend the format of the "deps" file to carry
511 # this sort of information, so we wouldn't have to guess. 511 # this sort of information, so we wouldn't have to guess.
512 # 512 #
513 case "${t}" in 513 case "${t}" in
514 ${osvers}.*) depversion=">=${osvers}" ;; 514 ${osvers}.*) depversion=">=${osvers}" ;;
515 *) depversion="-[0-9]*" ;; 515 *) depversion="-[0-9]*" ;;
516 esac 516 esac
517 517
518 # 518 #
519 # Add the dependencies. 519 # Add the dependencies.
520 # 520 #
521 # We always add a "@pkgdep" line for each prerequisite package. 521 # We always add a "@pkgdep" line for each prerequisite package.
522 # 522 #
523 # If the prerequisite pkg is already registered (as it should be 523 # If the prerequisite pkg is already registered (as it should be
524 # if our caller is doing things in the right order), then we put 524 # if our caller is doing things in the right order), then we put
525 # its exact version number in a "@blddep" line. 525 # its exact version number in a "@blddep" line.
526 # 526 #
527 ${AWK} '$1 ~ '/"${pkg}"/' { print $2 }' "${rundir}/deps" | ${SORT} | \ 527 ${AWK} '$1 ~ '/"${pkg}"/' { print $2 }' "${rundir}/deps" | ${SORT} | \
528 while read depname; do 528 while read depname; do
529 # ${pkgdepglob} is a shell glob pattern that should match 529 # ${pkgdepglob} is a shell glob pattern that should match
530 # any version of a pkg. ${pkgdep} uses the special syntax 530 # any version of a pkg. ${pkgdep} uses the special syntax
531 # for pkg dependencies, and is not usable as a shell 531 # for pkg dependencies, and is not usable as a shell
532 # glob pattern. 532 # glob pattern.
533 pkgdepglob="${depname}-[0-9]*" 533 pkgdepglob="${depname}-[0-9]*"
534 pkgdep="${depname}${depversion}" 534 pkgdep="${depname}${depversion}"
535 echo "@pkgdep ${pkgdep}" 535 echo "@pkgdep ${pkgdep}"
536 blddep="$(cd "${SYSPKG_DB_TOPDIR}" && echo ${pkgdepglob} \ 536 blddep="$(cd "${SYSPKG_DB_TOPDIR}" && echo ${pkgdepglob} \
537 || bomb)" 537 || bomb)"
538 case "${blddep}" in 538 case "${blddep}" in
539 *\*) # pkgdepglob did not match anything 539 *\*) # pkgdepglob did not match anything
540 echo >&2 "${WARNING}${pkg} depends on '${pkgdep}' but there is no matching syspkg in ${SYSPKG_DB_TOPDIR}" 540 echo >&2 "${WARNING}${pkg} depends on '${pkgdep}' but there is no matching syspkg in ${SYSPKG_DB_TOPDIR}"
541 ;; 541 ;;
542 *\ *) # pkgdepglob matched more than once. 542 *\ *) # pkgdepglob matched more than once.
543 echo >&2 "${ERRWARN}${pkg} depends on '${pkgdep}' but there are multiple matching syspkgs in ${SYSPKG_DB_TOPDIR}" 543 echo >&2 "${ERRWARN}${pkg} depends on '${pkgdep}' but there are multiple matching syspkgs in ${SYSPKG_DB_TOPDIR}"
544 ${force} || bomb 544 ${force} || bomb
545 # If ${force} is set, then assume that the last 545 # If ${force} is set, then assume that the last
546 # match is the most recent. 546 # match is the most recent.
547 # XXX: This might be wrong, because of 547 # XXX: This might be wrong, because of
548 # differences between lexical sorting and 548 # differences between lexical sorting and
549 # numeric sorting. 549 # numeric sorting.
550 lastmatch="${blddep##* }" 550 lastmatch="${blddep##* }"
551 echo "@blddep ${lastmatch}" 551 echo "@blddep ${lastmatch}"
552 ;; 552 ;;
553 *) # exactly one match. 553 *) # exactly one match.
554 # XXX: We ignore the possibility that the 554 # XXX: We ignore the possibility that the
555 # version we found via ${pkgdepglob} might not 555 # version we found via ${pkgdepglob} might not
556 # satisfy ${pkgdep}. We could conceivably use 556 # satisfy ${pkgdep}. We could conceivably use
557 # "pkg_admin pmatch" to check, but that's not a 557 # "pkg_admin pmatch" to check, but that's not a
558 # host tool so we can't assume that it will be 558 # host tool so we can't assume that it will be
559 # available. 559 # available.
560 echo "@blddep ${blddep}" 560 echo "@blddep ${blddep}"
561 ;; 561 ;;
562 esac 562 esac
563 done >>"${PLIST}" 563 done >>"${PLIST}"
564 564
565 # create the comment (should be one line) 565 # create the comment (should be one line)
566 comment="$(${AWK} '$1 ~ '/"${pkg}"/' \ 566 comment="$(${AWK} '$1 ~ '/"${pkg}"/' \
567 { print substr($0, length($1) + 2) }' \ 567 { print substr($0, length($1) + 2) }' \
568 "${rundir}/comments")" 568 "${rundir}/comments")"
569 case "${comment}" in 569 case "${comment}" in
570 "") echo >&2 "${WARNING}no comment for \"${pkg}\" (using placeholder)" 570 "") echo >&2 "${WARNING}no comment for \"${pkg}\" (using placeholder)"
571 comment="System package for ${pkg}" 571 comment="System package for ${pkg}"
572 ;; 572 ;;
573 *"${nl}"*) 573 *"${nl}"*)
574 echo >&2 "${ERRWARN}multi-line comment for \"${pkg}\"" 574 echo >&2 "${ERRWARN}multi-line comment for \"${pkg}\""
575 ${force} || bomb 575 ${force} || bomb
576 ;; 576 ;;
577 esac 577 esac
578 echo "${comment}" > "${SYSPKG_DB_SUBDIR}/+COMMENT" 578 echo "${comment}" > "${SYSPKG_DB_SUBDIR}/+COMMENT"
579 579
580 # create the description (could be multiple lines) 580 # create the description (could be multiple lines)
581 descr="$(${AWK} '$1 ~ '/"${pkg}"/' { 581 descr="$(${AWK} '$1 ~ '/"${pkg}"/' {
582 print substr($0, length($1) + 2) }' \ 582 print substr($0, length($1) + 2) }' \
583 "${rundir}/descrs")" 583 "${rundir}/descrs")"
584 case "${descr}" in 584 case "${descr}" in
585 "") echo >&2 "${WARNING}no description for \"${pkg}\" (re-using comment)" 2>&1 585 "") echo >&2 "${WARNING}no description for \"${pkg}\" (re-using comment)" 2>&1
586 descr="${comment}" 586 descr="${comment}"
587 ;; 587 ;;
588 esac 588 esac
589 echo "${descr}" > "${SYSPKG_DB_SUBDIR}/+DESC" 589 echo "${descr}" > "${SYSPKG_DB_SUBDIR}/+DESC"
590 ${PRINTF} "\nHomepage:\nhttp://www.NetBSD.org/\n" >> "${SYSPKG_DB_SUBDIR}/+DESC" 590 ${PRINTF} "\nHomepage:\nhttp://www.NetBSD.org/\n" >> "${SYSPKG_DB_SUBDIR}/+DESC"
591 591
592 # create the build information 592 # create the build information
593 if [ x"${BUILD_INFO_CACHE}" = x ]; then 593 if [ x"${BUILD_INFO_CACHE}" = x ]; then
594 { 594 {
595 # These variables describe the build 595 # These variables describe the build
596 # environment, not the target. 596 # environment, not the target.
597 echo "OPSYS=$(${UNAME} -s)" 597 echo "OPSYS=$(${UNAME} -s)"
598 echo "OS_VERSION=$(${UNAME} -r)" 598 echo "OS_VERSION=$(${UNAME} -r)"
599 ${MAKE} -B -f- all <<EOF 599 ${MAKE} -B -f- all <<EOF
600.include <bsd.own.mk> 600.include <bsd.own.mk>
601all: 601all:
602 @echo OBJECT_FMT=${OBJECT_FMT} 602 @echo OBJECT_FMT=${OBJECT_FMT}
603 @echo MACHINE_ARCH=${MACHINE_ARCH} 603 @echo MACHINE_ARCH=${MACHINE_ARCH}
604 @echo MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH} 604 @echo MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH}
605EOF 605EOF
606 # XXX: what's the point of reporting _PKGTOOLS_VER 
607 # when we roll everything by hand without using 
608 # the pkg tools? 
609 echo "_PKGTOOLS_VER=$(${PKG_CREATE} -V)" 
610 } > "${SYSPKG_DB_SUBDIR}/+BUILD_INFO" 606 } > "${SYSPKG_DB_SUBDIR}/+BUILD_INFO"
611 else 607 else
612 cp "${BUILD_INFO_CACHE}" "${SYSPKG_DB_SUBDIR}/+BUILD_INFO" 608 cp "${BUILD_INFO_CACHE}" "${SYSPKG_DB_SUBDIR}/+BUILD_INFO"
613 fi 609 fi
614 610
615 # test for attributes 611 # test for attributes
616 args="" 612 args=""
617 attrs="$(${AWK} '$1 ~ '/"${pkg}"/' { \ 613 attrs="$(${AWK} '$1 ~ '/"${pkg}"/' { \
618 print substr($0, length($1) + 2) }' \ 614 print substr($0, length($1) + 2) }' \
619 "${rundir}/attrs")" 615 "${rundir}/attrs")"
620 for a in "${attrs}"; do 616 for a in "${attrs}"; do
621 case "${attrs}" in 617 case "${attrs}" in
622 "") ;; 618 "") ;;
623 preserve) 619 preserve)
624 echo "${pkg}-${t}" >"${SYSPKG_DB_SUBDIR}/+PRESERVE" 620 echo "${pkg}-${t}" >"${SYSPKG_DB_SUBDIR}/+PRESERVE"
625 args="${args} -n ${SYSPKG_DB_SUBDIR}/+PRESERVE" 621 args="${args} -n ${SYSPKG_DB_SUBDIR}/+PRESERVE"
626 ;; 622 ;;
627 esac 623 esac
628 done 624 done
629 625
630 # 626 #
631 # Create ${SYSPKGSIR}/+CONTENTS from ${PLIST}, by adding an 627 # Create ${SYSPKGSIR}/+CONTENTS from ${PLIST}, by adding an
632 # "@name" line and a lot of "@comment MD5:" lines. 628 # "@name" line and a lot of "@comment MD5:" lines.
633 # 629 #
634 { 630 {
635 rcsid='$NetBSD: regpkg,v 1.17 2009/10/17 23:43:22 agc Exp $' 631 rcsid='$NetBSD: regpkg,v 1.18 2009/12/01 15:49:21 apb Exp $'
636 utcdate="$(${ENV_CMD} TZ=UTC LOCALE=C \ 632 utcdate="$(${ENV_CMD} TZ=UTC LOCALE=C \
637 ${DATE} '+%Y-%m-%d %H:%M')" 633 ${DATE} '+%Y-%m-%d %H:%M')"
638 user="${USER:-root}" 634 user="${USER:-root}"
639 host="$(${HOSTNAME})" 635 host="$(${HOSTNAME})"
640 echo "@name ${pkg}-${t}" 636 echo "@name ${pkg}-${t}"
641 echo "@comment Packaged at ${utcdate} UTC by ${user}@${host}" 637 echo "@comment Packaged at ${utcdate} UTC by ${user}@${host}"
642 echo "@comment Packaged using ${prog} ${rcsid}" 638 echo "@comment Packaged using ${prog} ${rcsid}"
643 # XXX: "option extract-in-place" might help to get 639 # XXX: "option extract-in-place" might help to get
644 # pkg_add to create directories. 640 # pkg_add to create directories.
645 # XXX: no, it doesn't work. Yet another pkg_add bug. 641 # XXX: no, it doesn't work. Yet another pkg_add bug.
646 ## echo "@option extract-in-place" 642 ## echo "@option extract-in-place"
647 # Move the @pkgdep and @blddep lines up, so that 643 # Move the @pkgdep and @blddep lines up, so that
648 # they are easy to see when people do "less 644 # they are easy to see when people do "less
649 # ${DESTDIR}/var/db/syspkg/*/+CONTENTS". 645 # ${DESTDIR}/var/db/syspkg/*/+CONTENTS".
650 ${EGREP} '^(@pkgdep|@blddep)' "${PLIST}" || true 646 ${EGREP} '^(@pkgdep|@blddep)' "${PLIST}" || true
651 # Now do the remainder of the file. 647 # Now do the remainder of the file.
652 while read line; do 648 while read line; do
653 case "${line}" in 649 case "${line}" in
654 @pkgdep*|@blddep*) 650 @pkgdep*|@blddep*)
655 # already handled by grep above 651 # already handled by grep above
656 ;; 652 ;;
657 @cwd*) 653 @cwd*)
658 # There should be exactly one @cwd line. 654 # There should be exactly one @cwd line.
659 # Just after it, add an "@exec mkdir" 655 # Just after it, add an "@exec mkdir"
660 # line for every directory. This is to 656 # line for every directory. This is to
661 # work around a pkg-add bug (see 657 # work around a pkg-add bug (see
662 # <http://mail-index.NetBSD.org/tech-pkg/2003/12/11/0018.html>) 658 # <http://mail-index.NetBSD.org/tech-pkg/2003/12/11/0018.html>)
663 echo "${line}" 659 echo "${line}"
664 print_dir_exec_lines 660 print_dir_exec_lines
665 ;; 661 ;;
666 @*)  662 @*)
667 # just pass through all other @foo lines 663 # just pass through all other @foo lines
668 echo "${line}" 664 echo "${line}"
669 ;; 665 ;;
670 *)  666 *)
671 # This should be a file name. Pass it 667 # This should be a file name. Pass it
672 # through, and append "@comment MD5:". 668 # through, and append "@comment MD5:".
673 # XXX why not SHA256 ? 669 # XXX why not SHA256 ?
674 echo "${line}" 670 echo "${line}"
675 file="${DESTDIR}${line}" 671 file="${DESTDIR}${line}"
676 if [ -f "${file}" -a -r "${file}" ]; 672 if [ -f "${file}" -a -r "${file}" ];
677 then 673 then
678 md5sum="$(${CKSUM} -n -m "${file}" \ 674 md5sum="$(${CKSUM} -n -m "${file}" \
679 | ${AWK} '{print $1}' 675 | ${AWK} '{print $1}'
680 )" 676 )"
681 echo "@comment MD5:${md5sum}" 677 echo "@comment MD5:${md5sum}"
682 fi 678 fi
683 ;; 679 ;;
684 esac 680 esac
685 done <"${PLIST}" 681 done <"${PLIST}"
686 } >"${SYSPKG_DB_SUBDIR}/+CONTENTS" 682 } >"${SYSPKG_DB_SUBDIR}/+CONTENTS"
687 683
688 # 684 #
689 # Update ${SYSPKG_DB_TOPDIR}/pkgdb.byfile.db. 685 # Update ${SYSPKG_DB_TOPDIR}/pkgdb.byfile.db.
690 # 686 #
691 { 687 {
692 init_db_opts # sets dbfile, dbtype, and db_opts 688 init_db_opts # sets dbfile, dbtype, and db_opts
693 689
694 # Transform ${PLIST} into a form to be used as keys in 690 # Transform ${PLIST} into a form to be used as keys in
695 # ${dbfile}. The results look like absolute paths, 691 # ${dbfile}. The results look like absolute paths,
696 # but they are really relative to ${DESTDIR}. 692 # but they are really relative to ${DESTDIR}.
697 # 693 #
698 # "@dirrm ." -> "/" 694 # "@dirrm ." -> "/"
699 # "@dirrm foo/bar" -> "/foo/bar" 695 # "@dirrm foo/bar" -> "/foo/bar"
700 # "@dirrm ./foo/bar" -> "/foo/bar" 696 # "@dirrm ./foo/bar" -> "/foo/bar"
701 # "foo/bar/baz" -> "/foo/bar/baz" 697 # "foo/bar/baz" -> "/foo/bar/baz"
702 # "./foo/bar/baz" -> "/foo/bar/baz" 698 # "./foo/bar/baz" -> "/foo/bar/baz"
703 # 699 #
704 dblist="${SCRATCH}/dblist" 700 dblist="${SCRATCH}/dblist"
705 ${AWK} '/^@dirrm \.\// {gsub("^.", "", $2); print $2; next} 701 ${AWK} '/^@dirrm \.\// {gsub("^.", "", $2); print $2; next}
706 /^@dirrm \.$/ {print "/"; next} 702 /^@dirrm \.$/ {print "/"; next}
707 /^@dirrm/ {print "/" $2; next} 703 /^@dirrm/ {print "/" $2; next}
708 /^@/ {next} 704 /^@/ {next}
709 /^\.\// {gsub("^.", "", $0); print $0; next} 705 /^\.\// {gsub("^.", "", $0); print $0; next}
710 /./ {print "/" $0; next}' \ 706 /./ {print "/" $0; next}' \
711 <"${PLIST}" >"${dblist}" 707 <"${PLIST}" >"${dblist}"
712 # Add all the path names to the database. 708 # Add all the path names to the database.
713 ${AWK} '{print $1 "\t" "'"${pkg}-${t}"'"}' <"${dblist}" \ 709 ${AWK} '{print $1 "\t" "'"${pkg}-${t}"'"}' <"${dblist}" \
714 | ${DB} -w ${db_opts} -F "${tab}" -f - "${dbtype}" "${dbfile}" 710 | ${DB} -w ${db_opts} -F "${tab}" -f - "${dbtype}" "${dbfile}"
715 } 711 }
716 712
717 if ${verbose}; then 713 if ${verbose}; then
718 echo "Registered ${pkg}-${t} in ${SYSPKG_DB_TOPDIR}" 714 echo "Registered ${pkg}-${t} in ${SYSPKG_DB_TOPDIR}"
719 elif ! ${quiet}; then 715 elif ! ${quiet}; then
720 echo "Registered ${pkg}-${t}" 716 echo "Registered ${pkg}-${t}"
721 fi 717 fi
722 718
723 cleanup_must_delete_dbsubdir=false 719 cleanup_must_delete_dbsubdir=false
724} 720}
725 721
726# 722#
727# create_syspkg_tgz() creates the *.tgz file for the package. 723# create_syspkg_tgz() creates the *.tgz file for the package.
728# 724#
729# The output file is ${binpkgdir}/${pkg}-${t}.tgz. 725# The output file is ${binpkgdir}/${pkg}-${t}.tgz.
730# 726#
731create_syspkg_tgz() 727create_syspkg_tgz()
732{ 728{
733 # 729 #
734 # pkg_create does not understand metalog files, so we have to 730 # pkg_create does not understand metalog files, so we have to
735 # use pax directly. 731 # use pax directly.
736 # 732 #
737 # We create two specfiles: specfile_overhead describes the 733 # We create two specfiles: specfile_overhead describes the
738 # special files that are part of the package system's metadata 734 # special files that are part of the package system's metadata
739 # (+CONTENTS, +COMMENT, +DESCR, and more); and specfile_payload 735 # (+CONTENTS, +COMMENT, +DESCR, and more); and specfile_payload
740 # describes the files and directories that we actually want as 736 # describes the files and directories that we actually want as
741 # part of the package's payload. 737 # part of the package's payload.
742 # 738 #
743 # We then use the specfiles to create a compressed tarball that 739 # We then use the specfiles to create a compressed tarball that
744 # contains both the overhead files and the payload files. 740 # contains both the overhead files and the payload files.
745 # 741 #
746 # There's no trivial way to get a single pax run to do 742 # There's no trivial way to get a single pax run to do
747 # everything we want, so we run pax twice, with a different 743 # everything we want, so we run pax twice, with a different
748 # working directory and a different specfile each time. 744 # working directory and a different specfile each time.
749 # 745 #
750 # We could conceivably make clever use of pax's "-s" option to 746 # We could conceivably make clever use of pax's "-s" option to
751 # get what we want from a single pax run with a single (more 747 # get what we want from a single pax run with a single (more
752 # complicated) specfile, but the extra trouble doesn't seem 748 # complicated) specfile, but the extra trouble doesn't seem
753 # warranted. 749 # warranted.
754 # 750 #
755 cleanup_must_delete_binpkgfile=true 751 cleanup_must_delete_binpkgfile=true
756 specfile_overhead="${SCRATCH}/spec_overhead" 752 specfile_overhead="${SCRATCH}/spec_overhead"
757 specfile_payload="${SCRATCH}/spec_payload" 753 specfile_payload="${SCRATCH}/spec_payload"
758 tarball_uncompressed="${SCRATCH}/tarball_uncompressed" 754 tarball_uncompressed="${SCRATCH}/tarball_uncompressed"
759 755
760 # Create a specfile for all the overhead files (+CONTENTS and 756 # Create a specfile for all the overhead files (+CONTENTS and
761 # friends). 757 # friends).
762 { 758 {
763 plusnames_first="${SCRATCH}/plusnames_first" 759 plusnames_first="${SCRATCH}/plusnames_first"
764 plusnames_rest="${SCRATCH}/plusnames_rest" 760 plusnames_rest="${SCRATCH}/plusnames_rest"
765 761
766 # Ensure that the first few files are in the same order 762 # Ensure that the first few files are in the same order
767 # that "pkg_create" would have used, just in case anything 763 # that "pkg_create" would have used, just in case anything
768 # depends on that. Other files in alphabetical order. 764 # depends on that. Other files in alphabetical order.
769 SHOULD_BE_FIRST="+CONTENTS +COMMENT +DESC" 765 SHOULD_BE_FIRST="+CONTENTS +COMMENT +DESC"
770 ( 766 (
771 cd "${SYSPKG_DB_SUBDIR}" || bomb 767 cd "${SYSPKG_DB_SUBDIR}" || bomb
772 for file in ${SHOULD_BE_FIRST}; do 768 for file in ${SHOULD_BE_FIRST}; do
773 [ -e "./${file}" ] && echo "${file}" 769 [ -e "./${file}" ] && echo "${file}"
774 done >"${plusnames_first}" 770 done >"${plusnames_first}"
775 ${LS} -1 | ${FGREP} -v -f "${plusnames_first}" \ 771 ${LS} -1 | ${FGREP} -v -f "${plusnames_first}" \
776 >"${plusnames_rest}" \ 772 >"${plusnames_rest}" \
777 || true 773 || true
778 ) 774 )
779 775
780 # Convert the file list to specfile format, and override the 776 # Convert the file list to specfile format, and override the
781 # uid/gid/mode. 777 # uid/gid/mode.
782 { 778 {
783 echo ". optional type=dir" 779 echo ". optional type=dir"
784 ${AWK} '{print "./" $0 " type=file uid=0 gid=0 mode=0444" 780 ${AWK} '{print "./" $0 " type=file uid=0 gid=0 mode=0444"
785 }' "${plusnames_first}" "${plusnames_rest}" 781 }' "${plusnames_first}" "${plusnames_rest}"
786 } >"${specfile_overhead}" 782 } >"${specfile_overhead}"
787 } 783 }
788 784
789 # Create a specfile for the payload of the package. 785 # Create a specfile for the payload of the package.
790 { 786 {
791 spec1="${SCRATCH}/spec1" 787 spec1="${SCRATCH}/spec1"
792 spec2="${SCRATCH}/spec2" 788 spec2="${SCRATCH}/spec2"
793 789
794 # Transform ${PLIST} into simple specfile format: 790 # Transform ${PLIST} into simple specfile format:
795 # 791 #
796 # "@dirrm ." -> ". type=dir" 792 # "@dirrm ." -> ". type=dir"
797 # "@dirrm foo/bar" -> "./foo/bar type=dir" 793 # "@dirrm foo/bar" -> "./foo/bar type=dir"
798 # "@dirrm ./foo/bar" -> "./foo/bar type=dir" 794 # "@dirrm ./foo/bar" -> "./foo/bar type=dir"
799 # "foo/bar/baz" -> "./foo/bar/baz" 795 # "foo/bar/baz" -> "./foo/bar/baz"
800 # "./foo/bar/baz" -> "./foo/bar/baz" 796 # "./foo/bar/baz" -> "./foo/bar/baz"
801 # 797 #
802 # Ignores @cwd lines. This should be safe, given how 798 # Ignores @cwd lines. This should be safe, given how
803 # makeplist works. 799 # makeplist works.
804 ${AWK} '/^@dirrm \.\// {print $2 " type=dir"; next} 800 ${AWK} '/^@dirrm \.\// {print $2 " type=dir"; next}
805 /^@dirrm \.$/ {print ". type=dir"; next} 801 /^@dirrm \.$/ {print ". type=dir"; next}
806 /^@dirrm/ {print "./" $2 " type=dir"; next} 802 /^@dirrm/ {print "./" $2 " type=dir"; next}
807 /^@/ {next} 803 /^@/ {next}
808 /^\.\// {print $0; next} 804 /^\.\// {print $0; next}
809 /./ {print "./" $0; next}' \ 805 /./ {print "./" $0; next}' \
810 <"${PLIST}" >"${spec1}" 806 <"${PLIST}" >"${spec1}"
811 807
812 # If metalog was specified, attributes from metalog override 808 # If metalog was specified, attributes from metalog override
813 # attributes in the file system. We also fake up an 809 # attributes in the file system. We also fake up an
814 # entry for the ./etc/mtree/set.${pkgset} file. 810 # entry for the ./etc/mtree/set.${pkgset} file.
815 { 811 {
816 if [ -n "${metalog}" ]; then 812 if [ -n "${metalog}" ]; then
817 ${AWK} -f "${rundir}/join.awk" \ 813 ${AWK} -f "${rundir}/join.awk" \
818 "${spec1}" "${metalog}" 814 "${spec1}" "${metalog}"
819 ${AWK} -f "${rundir}/join.awk" \ 815 ${AWK} -f "${rundir}/join.awk" \
820 "${spec1}" /dev/stdin <<EOF 816 "${spec1}" /dev/stdin <<EOF
821./etc/mtree/set.${pkgset} type=file mode=0444 uname=root gname=wheel 817./etc/mtree/set.${pkgset} type=file mode=0444 uname=root gname=wheel
822EOF 818EOF
823 else 819 else
824 cat "${spec1}" 820 cat "${spec1}"
825 fi 821 fi
826 } >"${spec2}" 822 } >"${spec2}"
827 823
828 # 824 #
829 # If a file or directory to was mentioned explicitly 825 # If a file or directory to was mentioned explicitly
830 # in ${PLIST} but not mentioned in ${metalog}, then the 826 # in ${PLIST} but not mentioned in ${metalog}, then the
831 # file or directory will not be mentioned in ${spec2}. 827 # file or directory will not be mentioned in ${spec2}.
832 # This is an error, and means that the metalog was 828 # This is an error, and means that the metalog was
833 # not built correctly. 829 # not built correctly.
834 # 830 #
835 if [ -n "${metalog}" ]; then 831 if [ -n "${metalog}" ]; then
836 names1="${SCRATCH}/names1" 832 names1="${SCRATCH}/names1"
837 names2="${SCRATCH}/names2" 833 names2="${SCRATCH}/names2"
838 ${AWK} '{print $1}' <"${spec1}" | ${SORT} >"${names1}" 834 ${AWK} '{print $1}' <"${spec1}" | ${SORT} >"${names1}"
839 ${AWK} '{print $1}' <"${spec2}" | ${SORT} >"${names2}" 835 ${AWK} '{print $1}' <"${spec2}" | ${SORT} >"${names2}"
840 if ${FGREP} -v -f "${names2}" "${spec1}" >/dev/null 836 if ${FGREP} -v -f "${names2}" "${spec1}" >/dev/null
841 then 837 then
842 cat >&2 <<EOM 838 cat >&2 <<EOM
843${ERRWARN}The metalog file (${metalog}) does not 839${ERRWARN}The metalog file (${metalog}) does not
844 contain entries for the following files or directories 840 contain entries for the following files or directories
845 which should be part of the ${pkg} syspkg: 841 which should be part of the ${pkg} syspkg:
846EOM 842EOM
847 ${FGREP} -v -f "${names2}" "${spec1}" >&2 843 ${FGREP} -v -f "${names2}" "${spec1}" >&2
848 ${force} || bomb 844 ${force} || bomb
849 fi 845 fi
850 if ${FGREP} -v -f "${names1}" "${spec2}" >/dev/null 846 if ${FGREP} -v -f "${names1}" "${spec2}" >/dev/null
851 then 847 then
852 cat >&2 <<EOM 848 cat >&2 <<EOM
853${ERRWARN}The following lines are in the metalog file 849${ERRWARN}The following lines are in the metalog file
854 (${metalog}), and the corresponding files or directories 850 (${metalog}), and the corresponding files or directories
855 should be in the ${pkg} syspkg, but something is wrong: 851 should be in the ${pkg} syspkg, but something is wrong:
856EOM 852EOM
857 ${FGREP} -v -f "${names1}" "${spec2}" >&2 853 ${FGREP} -v -f "${names1}" "${spec2}" >&2
858 bomb 854 bomb
859 fi 855 fi
860 fi 856 fi
861 857
862 # Add lines (tagged "optional") for any implicit directories. 858 # Add lines (tagged "optional") for any implicit directories.
863 # 859 #
864 # For example, if we have a file ./foo/bar/baz, then we add 860 # For example, if we have a file ./foo/bar/baz, then we add
865 # "./foo/bar optional type=dir", "./foo optional type=dir", 861 # "./foo/bar optional type=dir", "./foo optional type=dir",
866 # and ". optional type=dir", unless those directories were 862 # and ". optional type=dir", unless those directories were
867 # already mentioned explicitly. 863 # already mentioned explicitly.
868 # 864 #
869 ${AWK} -f "${rundir}/getdirs.awk" "${spec2}" \ 865 ${AWK} -f "${rundir}/getdirs.awk" "${spec2}" \
870 | ${SORT} -u >"${specfile_payload}" 866 | ${SORT} -u >"${specfile_payload}"
871 } 867 }
872 868
873 # Use two pax invocations followed by gzip to create 869 # Use two pax invocations followed by gzip to create
874 # the tgz file. 870 # the tgz file.
875 # 871 #
876 # Remove any leading "./" from path names, because that 872 # Remove any leading "./" from path names, because that
877 # could confuse tools that work with binary packages. 873 # could confuse tools that work with binary packages.
878 ( 874 (
879 cd "${SYSPKG_DB_SUBDIR}" && \ 875 cd "${SYSPKG_DB_SUBDIR}" && \
880 ${PAX} -O -w -d -N"${etcdir}" -M '-s,^\./,,' \ 876 ${PAX} -O -w -d -N"${etcdir}" -M '-s,^\./,,' \
881 -f "${tarball_uncompressed}" \ 877 -f "${tarball_uncompressed}" \
882 <"${specfile_overhead}" \ 878 <"${specfile_overhead}" \
883 || bomb 879 || bomb
884 ) 880 )
885 ( 881 (
886 cd "${DESTDIR:-/}" && \ 882 cd "${DESTDIR:-/}" && \
887 ${PAX} -O -w -d -N"${etcdir}" -M '-s,^\./,,' \ 883 ${PAX} -O -w -d -N"${etcdir}" -M '-s,^\./,,' \
888 -a -f "${tarball_uncompressed}" \ 884 -a -f "${tarball_uncompressed}" \
889 <"${specfile_payload}" \ 885 <"${specfile_payload}" \
890 || bomb 886 || bomb
891 ) 887 )
892 ${GZIP_CMD} -9n <"${tarball_uncompressed}" >"${binpkgfile}" || bomb 888 ${GZIP_CMD} -9n <"${tarball_uncompressed}" >"${binpkgfile}" || bomb
893 889
894 # (Extra space is to make message line up with "Registered" message.) 890 # (Extra space is to make message line up with "Registered" message.)
895 if ${verbose}; then 891 if ${verbose}; then
896 echo " Packaged ${binpkgfile}" 892 echo " Packaged ${binpkgfile}"
897 elif ! ${quiet}; then 893 elif ! ${quiet}; then
898 echo " Packaged ${binpkgfile##*/}" 894 echo " Packaged ${binpkgfile##*/}"
899 fi 895 fi
900 896
901 cleanup_must_delete_binpkgfile=false 897 cleanup_must_delete_binpkgfile=false
902 898
903} 899}
904 900
905# 901#
906# do_register_syspkg() registers the syspkg if appropriate. 902# do_register_syspkg() registers the syspkg if appropriate.
907# 903#
908# If SYSPKG_DB_SUBDIR already exists, that might be an error, depending 904# If SYSPKG_DB_SUBDIR already exists, that might be an error, depending
909# on ${force} and ${update} flags. 905# on ${force} and ${update} flags.
910# 906#
911do_register_syspkg() 907do_register_syspkg()
912{ 908{
913 # Check that necessary variables are defined 909 # Check that necessary variables are defined
914 [ -n "${SYSPKG_DB_TOPDIR}" ] || bomb 910 [ -n "${SYSPKG_DB_TOPDIR}" ] || bomb
915 [ -n "${SYSPKG_DB_SUBDIR}" ] || bomb 911 [ -n "${SYSPKG_DB_SUBDIR}" ] || bomb
916 912
917 # Create SYSPKG_DB_TOPDIR if necessary 913 # Create SYSPKG_DB_TOPDIR if necessary
918 [ -d "${SYSPKG_DB_TOPDIR}" ] || mkdir -p "${SYSPKG_DB_TOPDIR}" || bomb 914 [ -d "${SYSPKG_DB_TOPDIR}" ] || mkdir -p "${SYSPKG_DB_TOPDIR}" || bomb
919 915
920 # A function to delete db entries referring to any version of ${pkg} 916 # A function to delete db entries referring to any version of ${pkg}
921 delete_old_db_entries() 917 delete_old_db_entries()
922 { 918 {
923 init_db_opts # sets dbfile, dbtype, and db_opts 919 init_db_opts # sets dbfile, dbtype, and db_opts
924 dblist="${SCRATCH}/dblist" 920 dblist="${SCRATCH}/dblist"
925 ${DB} ${db_opts} -O "${tab}" "${dbtype}" "${dbfile}" \ 921 ${DB} ${db_opts} -O "${tab}" "${dbtype}" "${dbfile}" \
926 | ${AWK} -F "${tab}" '$2 ~ /^'"${pkg}"'-[0-9]/ { print $1 }' \ 922 | ${AWK} -F "${tab}" '$2 ~ /^'"${pkg}"'-[0-9]/ { print $1 }' \
927 >"${dblist}" 923 >"${dblist}"
928 ${DB} -d ${db_opts} -f "${dblist}" "${dbtype}" "${dbfile}" 924 ${DB} -d ${db_opts} -f "${dblist}" "${dbtype}" "${dbfile}"
929 } 925 }
930 926
931 # A function to delete any old version of ${pkg} 927 # A function to delete any old version of ${pkg}
932 delete_old_pkg() 928 delete_old_pkg()
933 { 929 {
934 pattern="${pkg}-[0-9]*" 930 pattern="${pkg}-[0-9]*"
935 matches="$(cd "${SYSPKG_DB_TOPDIR}" && echo ${pattern} \ 931 matches="$(cd "${SYSPKG_DB_TOPDIR}" && echo ${pattern} \
936 || bomb)" 932 || bomb)"
937 echo >&2 "${NOTE}deleting old pkg (${matches})" 933 echo >&2 "${NOTE}deleting old pkg (${matches})"
938 cleanup_must_delete_dbsubdir=true 934 cleanup_must_delete_dbsubdir=true
939 delete_old_db_entries 935 delete_old_db_entries
940 ( cd "${SYSPKG_DB_TOPDIR}" && rm -rf ${matches} ) 936 ( cd "${SYSPKG_DB_TOPDIR}" && rm -rf ${matches} )
941 } 937 }
942 938
943 # Check whether another version of ${pkg} is already registered. 939 # Check whether another version of ${pkg} is already registered.
944 pattern="${pkg}-[0-9]*" 940 pattern="${pkg}-[0-9]*"
945 matches="$(cd "${SYSPKG_DB_TOPDIR}" && echo ${pattern} || bomb)" 941 matches="$(cd "${SYSPKG_DB_TOPDIR}" && echo ${pattern} || bomb)"
946 case "${matches}" in 942 case "${matches}" in
947 *\*) ;; # wildcard did not match anything 943 *\*) ;; # wildcard did not match anything
948 "${pkg}-${t}") ;; # exact match 944 "${pkg}-${t}") ;; # exact match
949 *) echo >&2 "${ERRWARNNOTE}another version of ${pkg} is already registered" 945 *) echo >&2 "${ERRWARNNOTE}another version of ${pkg} is already registered"
950 ${verbose} && echo >&2 " in ${SYSPKG_DB_TOPDIR}" 946 ${verbose} && echo >&2 " in ${SYSPKG_DB_TOPDIR}"
951 ${verbose} && echo >&2 " (while registering ${pkg}-${t})" 947 ${verbose} && echo >&2 " (while registering ${pkg}-${t})"
952 ${force} || ${update} || bomb 948 ${force} || ${update} || bomb
953 delete_old_pkg 949 delete_old_pkg
954 ;; 950 ;;
955 esac 951 esac
956 952
957 # Check whether the desired version of ${pkg} is already registered, 953 # Check whether the desired version of ${pkg} is already registered,
958 # and create it if appropriate. 954 # and create it if appropriate.
959 if [ -d "${SYSPKG_DB_SUBDIR}" ]; then 955 if [ -d "${SYSPKG_DB_SUBDIR}" ]; then
960 echo >&2 "${ERRWARNNOTE}${pkg}-${t} is already registered" 956 echo >&2 "${ERRWARNNOTE}${pkg}-${t} is already registered"
961 ${verbose} && echo >&2 " in ${SYSPKG_DB_TOPDIR}" 957 ${verbose} && echo >&2 " in ${SYSPKG_DB_TOPDIR}"
962 if ${force}; then 958 if ${force}; then
963 delete_old_pkg 959 delete_old_pkg
964 register_syspkg 960 register_syspkg
965 elif ${update}; then 961 elif ${update}; then
966 # 962 #
967 # If all files in SYSPKG_DB_SUBDIR are newer 963 # If all files in SYSPKG_DB_SUBDIR are newer
968 # than all files in the pkg, then do nothing. 964 # than all files in the pkg, then do nothing.
969 # Else delete and re-register the pkg. 965 # Else delete and re-register the pkg.
970 # 966 #
971 [ -n "${newestfile}" ] || init_newestfile 967 [ -n "${newestfile}" ] || init_newestfile
972 if [ -n "${newestfile}" ]; then 968 if [ -n "${newestfile}" ]; then
973 case "$(${FIND} "${SYSPKG_DB_SUBDIR}" -type f \ 969 case "$(${FIND} "${SYSPKG_DB_SUBDIR}" -type f \
974 ! -newer "${newestfile}" -print)" \ 970 ! -newer "${newestfile}" -print)" \
975 in 971 in
976 "") ;; 972 "") ;;
977 *) 973 *)
978 echo >&2 "${NOTE}some files are newer but pkg version is unchanged" 974 echo >&2 "${NOTE}some files are newer but pkg version is unchanged"
979 delete_old_pkg 975 delete_old_pkg
980 register_syspkg 976 register_syspkg
981 ;; 977 ;;
982 esac 978 esac
983 979
984 else 980 else
985 # No files in the pkg? (This could happen 981 # No files in the pkg? (This could happen
986 # if a pkg contains only directories.) 982 # if a pkg contains only directories.)
987 # Do nothing (keep the already-registered pkg). 983 # Do nothing (keep the already-registered pkg).
988 fi 984 fi
989 else 985 else
990 bomb 986 bomb
991 fi 987 fi
992 else 988 else
993 register_syspkg 989 register_syspkg
994 fi 990 fi
995} 991}
996 992
997# 993#
998# do_create_syspkg_tgz() creates the the binary pkg (*.tgz) if 994# do_create_syspkg_tgz() creates the the binary pkg (*.tgz) if
999# appropriate. 995# appropriate.
1000# 996#
1001# If binpkgfile already exists, that might be an error, depending on 997# If binpkgfile already exists, that might be an error, depending on
1002# ${force} and ${update} flags. 998# ${force} and ${update} flags.
1003# 999#
1004do_create_syspkg_tgz() 1000do_create_syspkg_tgz()
1005{ 1001{
1006 [ -n "${binpkgfile}" ] || bomb 1002 [ -n "${binpkgfile}" ] || bomb
1007 1003
1008 delete_and_recreate() 1004 delete_and_recreate()
1009 { 1005 {
1010 echo >&2 "${ERRWARNNOTE}deleting and re-creating ${pkg}-${t}.tgz" 1006 echo >&2 "${ERRWARNNOTE}deleting and re-creating ${pkg}-${t}.tgz"
1011 rm -f "${binpkgfile}" 1007 rm -f "${binpkgfile}"
1012 create_syspkg_tgz 1008 create_syspkg_tgz
1013 } 1009 }
1014 1010
1015 # Check whether another version of ${pkg} already exists. 1011 # Check whether another version of ${pkg} already exists.
1016 pattern="${pkg}-[0-9]*" 1012 pattern="${pkg}-[0-9]*"
1017 matches="$(cd "${binpkgdir}" && echo ${pattern} || bomb)" 1013 matches="$(cd "${binpkgdir}" && echo ${pattern} || bomb)"
1018 case "${matches}" in 1014 case "${matches}" in
1019 *\*) ;; # wildcard did not match anything 1015 *\*) ;; # wildcard did not match anything
1020 "${pkg}-${t}.tgz") ;; # exact match 1016 "${pkg}-${t}.tgz") ;; # exact match
1021 *) echo >&2 "${ERRWARNNOTE}another version of ${pkg} binary pkg already exists" 1017 *) echo >&2 "${ERRWARNNOTE}another version of ${pkg} binary pkg already exists"
1022 ${verbose} && echo >&2 " in ${binpkgdir}" 1018 ${verbose} && echo >&2 " in ${binpkgdir}"
1023 ${verbose} && echo >&2 " (while creating ${pkg}-${t}.tgz)" 1019 ${verbose} && echo >&2 " (while creating ${pkg}-${t}.tgz)"
1024 # If neither force nor update, this is a fatal error. 1020 # If neither force nor update, this is a fatal error.
1025 # If force but not update, then leave old .tgz in place. 1021 # If force but not update, then leave old .tgz in place.
1026 # If update, then delete the old .tgz. 1022 # If update, then delete the old .tgz.
1027 ${force} || ${update} || bomb 1023 ${force} || ${update} || bomb
1028 if ${update}; then 1024 if ${update}; then
1029 echo >&2 "${NOTE}deleting old binary pkg (${matches})" 1025 echo >&2 "${NOTE}deleting old binary pkg (${matches})"
1030 ( cd "${binpkgdir}" && rm -f ${matches} || bomb ) 1026 ( cd "${binpkgdir}" && rm -f ${matches} || bomb )
1031 fi 1027 fi
1032 ;; 1028 ;;
1033 esac 1029 esac
1034 1030
1035 # Check whether the desired version of ${pkg} already exists, 1031 # Check whether the desired version of ${pkg} already exists,
1036 # and create it if appropriate. 1032 # and create it if appropriate.
1037 if [ -e "${binpkgfile}" ]; then 1033 if [ -e "${binpkgfile}" ]; then
1038 echo >&2 "${ERRWARNNOTE}${pkg}-${t}.tgz already exists" 1034 echo >&2 "${ERRWARNNOTE}${pkg}-${t}.tgz already exists"
1039 ${verbose} && echo >&2 " in ${binpkgdir}" 1035 ${verbose} && echo >&2 " in ${binpkgdir}"
1040 if ${force}; then 1036 if ${force}; then
1041 delete_and_recreate 1037 delete_and_recreate
1042 elif ${update}; then 1038 elif ${update}; then
1043 # 1039 #
1044 # If all files in SYSPKG_DB_SUBDIR are older 1040 # If all files in SYSPKG_DB_SUBDIR are older
1045 # than ${binpkgfile}, then do nothing. 1041 # than ${binpkgfile}, then do nothing.
1046 # Else delete and re-create the tgz. 1042 # Else delete and re-create the tgz.
1047 # 1043 #
1048 case "$(${FIND} "${SYSPKG_DB_SUBDIR}" -type f \ 1044 case "$(${FIND} "${SYSPKG_DB_SUBDIR}" -type f \
1049 -newer "${binpkgfile}" -print)" \ 1045 -newer "${binpkgfile}" -print)" \
1050 in 1046 in
1051 "") ;; 1047 "") ;;
1052 *) delete_and_recreate ;; 1048 *) delete_and_recreate ;;
1053 esac 1049 esac
1054 else 1050 else
1055 bomb 1051 bomb
1056 fi 1052 fi
1057 else 1053 else
1058 create_syspkg_tgz 1054 create_syspkg_tgz
1059 fi 1055 fi
1060} 1056}
1061 1057
1062#################### 1058####################
1063# begin main program 1059# begin main program
1064 1060
1065parse_args ${1+"$@"} 1061parse_args ${1+"$@"}
1066make_PLIST 1062make_PLIST
1067choose_version_number 1063choose_version_number
1068SYSPKG_DB_SUBDIR="${SYSPKG_DB_TOPDIR}/${pkg}-${t}" 1064SYSPKG_DB_SUBDIR="${SYSPKG_DB_TOPDIR}/${pkg}-${t}"
1069do_register_syspkg 1065do_register_syspkg
1070if [ -n "${binpkgdir}" ]; then 1066if [ -n "${binpkgdir}" ]; then
1071 binpkgfile="${binpkgdir}/${pkg}-${t}.tgz" 1067 binpkgfile="${binpkgdir}/${pkg}-${t}.tgz"
1072 do_create_syspkg_tgz 1068 do_create_syspkg_tgz
1073fi 1069fi
1074 1070
1075exit 0 1071exit 0

cvs diff -r1.11 -r1.12 src/distrib/sets/regpkgset (switch to unified diff)

--- src/distrib/sets/regpkgset 2009/10/17 23:43:22 1.11
+++ src/distrib/sets/regpkgset 2009/12/01 15:49:21 1.12
@@ -1,199 +1,195 @@ @@ -1,199 +1,195 @@
1#! /bin/sh 1#! /bin/sh
2# 2#
3# $NetBSD: regpkgset,v 1.11 2009/10/17 23:43:22 agc Exp $ 3# $NetBSD: regpkgset,v 1.12 2009/12/01 15:49:21 apb Exp $
4# 4#
5# Copyright (c) 2003,2009 The NetBSD Foundation, Inc. 5# Copyright (c) 2003,2009 The NetBSD Foundation, Inc.
6# All rights reserved. 6# All rights reserved.
7# 7#
8# This code is derived from software contributed to The NetBSD Foundation 8# This code is derived from software contributed to The NetBSD Foundation
9# by Alistair Crooks (agc@NetBSD.org) 9# by Alistair Crooks (agc@NetBSD.org)
10# 10#
11# Redistribution and use in source and binary forms, with or without 11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions 12# modification, are permitted provided that the following conditions
13# are met: 13# are met:
14# 1. Redistributions of source code must retain the above copyright 14# 1. Redistributions of source code must retain the above copyright
15# notice, this list of conditions and the following disclaimer. 15# notice, this list of conditions and the following disclaimer.
16# 2. Redistributions in binary form must reproduce the above copyright 16# 2. Redistributions in binary form must reproduce the above copyright
17# notice, this list of conditions and the following disclaimer in the 17# notice, this list of conditions and the following disclaimer in the
18# documentation and/or other materials provided with the distribution. 18# documentation and/or other materials provided with the distribution.
19# 19#
20# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30# POSSIBILITY OF SUCH DAMAGE. 30# POSSIBILITY OF SUCH DAMAGE.
31# 31#
32 32
33# Usage: regpkgset [options] set 33# Usage: regpkgset [options] set
34# 34#
35# Options: 35# Options:
36# -q Quiet. 36# -q Quiet.
37# -v Verbose. 37# -v Verbose.
38# -f Force. 38# -f Force.
39# -m Ignore errors from missing files. 39# -m Ignore errors from missing files.
40# -u Update. 40# -u Update.
41# -c Cache some information in ${BUILD_INFO_CACHE}. 41# -c Cache some information in ${BUILD_INFO_CACHE}.
42# -d destdir Sets DESTDIR. 42# -d destdir Sets DESTDIR.
43# -t binpkgdir Create a binary package (in *.tgz format) in the 43# -t binpkgdir Create a binary package (in *.tgz format) in the
44# specified directory. Without this option, a binary 44# specified directory. Without this option, a binary
45# package is not created. 45# package is not created.
46# -M metalog Use the specified metalog file to override file 46# -M metalog Use the specified metalog file to override file
47# or directory attributes when creating a binary package. 47# or directory attributes when creating a binary package.
48# -N etcdir Use the specified directory for passwd and group files. 48# -N etcdir Use the specified directory for passwd and group files.
49 49
50prog="${0##*/}" 50prog="${0##*/}"
51toppid=$$ 51toppid=$$
52rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/" 52rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
53. "${rundir}/sets.subr" 53. "${rundir}/sets.subr"
54 54
55: ${TARGET_ENDIANNESS:="$(arch_to_endian "${MACHINE_ARCH}")"} 55: ${TARGET_ENDIANNESS:="$(arch_to_endian "${MACHINE_ARCH}")"}
56export TARGET_ENDIANNESS 56export TARGET_ENDIANNESS
57 57
58bomb() 58bomb()
59{ 59{
60 kill ${toppid} # in case we were invoked from a subshell 60 kill ${toppid} # in case we were invoked from a subshell
61 exit 1 61 exit 1
62} 62}
63 63
64# A literal newline 64# A literal newline
65nl=' 65nl='
66' 66'
67 67
68# 68#
69# cleanup() deletes temporary files. 69# cleanup() deletes temporary files.
70# 70#
71es=0 71es=0
72cleanup() 72cleanup()
73{ 73{
74 trap - 0 74 trap - 0
75 [ x"${BUILD_INFO_CACHE}" != x ] && rm -f "${BUILD_INFO_CACHE}" 75 [ x"${BUILD_INFO_CACHE}" != x ] && rm -f "${BUILD_INFO_CACHE}"
76 exit ${es} 76 exit ${es}
77} 77}
78trap 'es=128; cleanup' 1 2 3 13 15 # HUP INT QUIT PIPE TERM 78trap 'es=128; cleanup' 1 2 3 13 15 # HUP INT QUIT PIPE TERM
79trap 'es=$?; cleanup' 0 # EXIT 79trap 'es=$?; cleanup' 0 # EXIT
80 80
81# 81#
82# Parse command line args. 82# Parse command line args.
83# 83#
84verbose=false 84verbose=false
85quiet=false 85quiet=false
86force=false 86force=false
87allowmissing=false 87allowmissing=false
88update=false 88update=false
89cache=false 89cache=false
90pkgdir="" 90pkgdir=""
91metalog="" 91metalog=""
92etcdir="" 92etcdir=""
93all_options="" 93all_options=""
94while [ $# -gt 1 ]; do 94while [ $# -gt 1 ]; do
95 # XXX: ${all_options} doesn't correctly handle args with 95 # XXX: ${all_options} doesn't correctly handle args with
96 # embedded shell special characters. 96 # embedded shell special characters.
97 case "$1" in 97 case "$1" in
98 -q) quiet=true; verbose=false ;; 98 -q) quiet=true; verbose=false ;;
99 -v) verbose=true; quiet=false ;; 99 -v) verbose=true; quiet=false ;;
100 -f) force=true ;; 100 -f) force=true ;;
101 -m) allowmissing=true ;; 101 -m) allowmissing=true ;;
102 -u) update=true ;; 102 -u) update=true ;;
103 -c) cache=true ;; 103 -c) cache=true ;;
104 -d) DESTDIR="$2"; all_options="${all_options} $1"; shift ;; 104 -d) DESTDIR="$2"; all_options="${all_options} $1"; shift ;;
105 -d*) DESTDIR="${1#-?}" ;; 105 -d*) DESTDIR="${1#-?}" ;;
106 -t) pkgdir="$2"; all_options="${all_options} $1"; shift ;; 106 -t) pkgdir="$2"; all_options="${all_options} $1"; shift ;;
107 -t*) pkgdir="${1#-?}" ;; 107 -t*) pkgdir="${1#-?}" ;;
108 -M) metalog="$2"; all_options="${all_options} $1"; shift ;; 108 -M) metalog="$2"; all_options="${all_options} $1"; shift ;;
109 -M*) metalog="${1#-?}" ;; 109 -M*) metalog="${1#-?}" ;;
110 -N) etcdir="$2"; all_options="${all_options} $1"; shift ;; 110 -N) etcdir="$2"; all_options="${all_options} $1"; shift ;;
111 -N*) etcdir="${1#-?}" ;; 111 -N*) etcdir="${1#-?}" ;;
112 -*) echo "Usage: regpkgset [options] set ..."; bomb ;; 112 -*) echo "Usage: regpkgset [options] set ..."; bomb ;;
113 *) break ;; 113 *) break ;;
114 esac 114 esac
115 all_options="${all_options} $1" 115 all_options="${all_options} $1"
116 shift 116 shift
117done 117done
118export DESTDIR 118export DESTDIR
119 119
120if [ $# -lt 1 ]; then 120if [ $# -lt 1 ]; then
121 echo "Usage: regpkgset [options] set ..." 121 echo "Usage: regpkgset [options] set ..."
122 bomb 122 bomb
123fi 123fi
124 124
125case "$1" in 125case "$1" in
126all) list="base comp etc games man misc tests text" ;; 126all) list="base comp etc games man misc tests text" ;;
127*) list="$*" ;; 127*) list="$*" ;;
128esac 128esac
129 129
130if ${cache}; then 130if ${cache}; then
131 BUILD_INFO_CACHE="$(${MKTEMP} "/var/tmp/${prog}-BUILD_INFO.XXXXXX")" 131 BUILD_INFO_CACHE="$(${MKTEMP} "/var/tmp/${prog}-BUILD_INFO.XXXXXX")"
132 export BUILD_INFO_CACHE 132 export BUILD_INFO_CACHE
133 { 133 {
134 # These variables describe the build 134 # These variables describe the build
135 # environment, not the target. 135 # environment, not the target.
136 echo "OPSYS=$(${UNAME} -s)" 136 echo "OPSYS=$(${UNAME} -s)"
137 echo "OS_VERSION=$(${UNAME} -r)" 137 echo "OS_VERSION=$(${UNAME} -r)"
138 ${MAKE} -B -f- all <<EOF 138 ${MAKE} -B -f- all <<EOF
139.include <bsd.own.mk> 139.include <bsd.own.mk>
140all: 140all:
141 @echo OBJECT_FMT=${OBJECT_FMT} 141 @echo OBJECT_FMT=${OBJECT_FMT}
142 @echo MACHINE_ARCH=${MACHINE_ARCH} 142 @echo MACHINE_ARCH=${MACHINE_ARCH}
143 @echo MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH} 143 @echo MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH}
144EOF 144EOF
145 # XXX: what's the point of reporting _PKGTOOLS_VER 
146 # when we roll everything by hand without using 
147 # the pkg tools? 
148 echo "_PKGTOOLS_VER=$(${PKG_CREATE} -V)" 
149 } > "${BUILD_INFO_CACHE}" 145 } > "${BUILD_INFO_CACHE}"
150fi 146fi
151 147
152# 148#
153# For each pkgset mentioned in ${list}, get a list of all pkgs in the pkgset. 149# For each pkgset mentioned in ${list}, get a list of all pkgs in the pkgset.
154# 150#
155# Sort all the pkgs into dependency order (with prerequisite pkgs before 151# Sort all the pkgs into dependency order (with prerequisite pkgs before
156# pkgs that depend on them). 152# pkgs that depend on them).
157# 153#
158# Invoke ${rundir}/regpkg for each pkg, taking care to do it in dependency 154# Invoke ${rundir}/regpkg for each pkg, taking care to do it in dependency
159# order. If there were any pkgs for which we failed to find dependency 155# order. If there were any pkgs for which we failed to find dependency
160# information, handle them at the end. 156# information, handle them at the end.
161# 157#
162pkgs="$(for pkgset in ${list}; do 158pkgs="$(for pkgset in ${list}; do
163 ${HOST_SH} "${rundir}/listpkgs" "${pkgset}" || bomb 159 ${HOST_SH} "${rundir}/listpkgs" "${pkgset}" || bomb
164 done)" 160 done)"
165tsort_input="$(${AWK} '{print $2 " " $1}' <"${rundir}/deps" || bomb)" 161tsort_input="$(${AWK} '{print $2 " " $1}' <"${rundir}/deps" || bomb)"
166tsort_output="$(echo "${tsort_input}" | ${TSORT} || bomb)" 162tsort_output="$(echo "${tsort_input}" | ${TSORT} || bomb)"
167for pkg in ${tsort_output}; do 163for pkg in ${tsort_output}; do
168 case "${nl}${pkgs}${nl}" in 164 case "${nl}${pkgs}${nl}" in
169 *"${nl}${pkg}${nl}"*) 165 *"${nl}${pkg}${nl}"*)
170 # We want this pkg. 166 # We want this pkg.
171 pkgset="${pkg%%-*}" 167 pkgset="${pkg%%-*}"
172 ${verbose} && echo "${prog}: registering ${pkg}" 168 ${verbose} && echo "${prog}: registering ${pkg}"
173 ${HOST_SH} "${rundir}/regpkg" ${all_options} \ 169 ${HOST_SH} "${rundir}/regpkg" ${all_options} \
174 "${pkgset}" "${pkg}" || bomb 170 "${pkgset}" "${pkg}" || bomb
175 ;; 171 ;;
176 *) # pkg is mentioned in ${tsort_output} but not in ${pkgs}. 172 *) # pkg is mentioned in ${tsort_output} but not in ${pkgs}.
177 # We do not want this pkg. 173 # We do not want this pkg.
178 ;; 174 ;;
179 esac 175 esac
180done 176done
181for pkg in ${pkgs}; do 177for pkg in ${pkgs}; do
182 case "${nl}${tsort_output}${nl}" in 178 case "${nl}${tsort_output}${nl}" in
183 *"${nl}${pkg}${nl}"*) 179 *"${nl}${pkg}${nl}"*)
184 # pkg was in the tsort output, so it would have been 180 # pkg was in the tsort output, so it would have been
185 # handled above. 181 # handled above.
186 ;; 182 ;;
187 *) # This pkg was not in the tsort output. 183 *) # This pkg was not in the tsort output.
188 # This is probably an error, but process the 184 # This is probably an error, but process the
189 # pkg anyway. 185 # pkg anyway.
190 echo >&2 "${prog}: WARNING: ${pkg} is not mentioned in deps file" 186 echo >&2 "${prog}: WARNING: ${pkg} is not mentioned in deps file"
191 pkgset="${pkg%%-*}" 187 pkgset="${pkg%%-*}"
192 ${verbose} && echo "${prog}: registering ${pkg}" 188 ${verbose} && echo "${prog}: registering ${pkg}"
193 ${HOST_SH} "${rundir}/regpkg" ${all_options} \ 189 ${HOST_SH} "${rundir}/regpkg" ${all_options} \
194 "${pkgset}" "${pkg}" || bomb 190 "${pkgset}" "${pkg}" || bomb
195 ;; 191 ;;
196 esac 192 esac
197done 193done
198 194
199exit 0 195exit 0

cvs diff -r1.92 -r1.93 src/distrib/sets/sets.subr (switch to unified diff)

--- src/distrib/sets/sets.subr 2009/11/30 16:13:23 1.92
+++ src/distrib/sets/sets.subr 2009/12/01 15:49:21 1.93
@@ -1,571 +1,570 @@ @@ -1,571 +1,570 @@
1# $NetBSD: sets.subr,v 1.92 2009/11/30 16:13:23 uebayasi Exp $ 1# $NetBSD: sets.subr,v 1.93 2009/12/01 15:49:21 apb Exp $
2# 2#
3 3
4# 4#
5# The following variables contain defaults for sets.subr functions and callers: 5# The following variables contain defaults for sets.subr functions and callers:
6# setsdir path to src/distrib/sets 6# setsdir path to src/distrib/sets
7# nlists list of base sets 7# nlists list of base sets
8# xlists list of x11 sets 8# xlists list of x11 sets
9# extlists list of extsrc sets 9# extlists list of extsrc sets
10# obsolete controls if obsolete files are selected instead 10# obsolete controls if obsolete files are selected instead
11# module if != "no", enable MODULE sets 11# module if != "no", enable MODULE sets
12# shlib shared library format (a.out, elf, or "") 12# shlib shared library format (a.out, elf, or "")
13# stlib static library format (a.out, elf) 13# stlib static library format (a.out, elf)
14# 14#
15# The following <bsd.own.mk> variables are exported to the environment: 15# The following <bsd.own.mk> variables are exported to the environment:
16# MACHINE  16# MACHINE
17# MACHINE_ARCH 17# MACHINE_ARCH
18# MACHINE_CPU 18# MACHINE_CPU
19# HAVE_BINUTILS 19# HAVE_BINUTILS
20# HAVE_GCC 20# HAVE_GCC
21# HAVE_GDB 21# HAVE_GDB
22# TOOLCHAIN_MISSING 22# TOOLCHAIN_MISSING
23# OBJECT_FMT 23# OBJECT_FMT
24# as well as: 24# as well as:
25# 25#
26MKVARS="\ 26MKVARS="\
27 MKBFD \ 27 MKBFD \
28 MKBINUTILS \ 28 MKBINUTILS \
29 MKCATPAGES \ 29 MKCATPAGES \
30 MKCOMPAT \ 30 MKCOMPAT \
31 MKCRYPTO \ 31 MKCRYPTO \
32 MKCRYPTO_IDEA \ 32 MKCRYPTO_IDEA \
33 MKCRYPTO_MDC2 \ 33 MKCRYPTO_MDC2 \
34 MKCRYPTO_RC5 \ 34 MKCRYPTO_RC5 \
35 MKCVS \ 35 MKCVS \
36 MKDEBUG \ 36 MKDEBUG \
37 MKDEBUGLIB \ 37 MKDEBUGLIB \
38 MKDOC \ 38 MKDOC \
39 MKDYNAMICROOT \ 39 MKDYNAMICROOT \
40 MKEXTSRC \ 40 MKEXTSRC \
41 MKGCC \ 41 MKGCC \
42 MKGCCCMDS \ 42 MKGCCCMDS \
43 MKGDB \ 43 MKGDB \
44 MKHESIOD \ 44 MKHESIOD \
45 MKHTML \ 45 MKHTML \
46 MKINET6 \ 46 MKINET6 \
47 MKINFO \ 47 MKINFO \
48 MKIPFILTER \ 48 MKIPFILTER \
49 MKISCSI \ 49 MKISCSI \
50 MKKERBEROS \ 50 MKKERBEROS \
51 MKKMOD \ 51 MKKMOD \
52 MKLDAP \ 52 MKLDAP \
53 MKLINT \ 53 MKLINT \
54 MKLVM \ 54 MKLVM \
55 MKMAN \ 55 MKMAN \
56 MKMANPAGES \ 56 MKMANPAGES \
57 MKMANZ \ 57 MKMANZ \
58 MKMDNS \ 58 MKMDNS \
59 MKNLS \ 59 MKNLS \
60 MKNVI \ 60 MKNVI \
61 MKPAM \ 61 MKPAM \
62 MKPF \ 62 MKPF \
63 MKPIC \ 63 MKPIC \
64 MKPOSTFIX \ 64 MKPOSTFIX \
65 MKPROFILE \ 65 MKPROFILE \
66 MKSHARE \ 66 MKSHARE \
67 MKSKEY \ 67 MKSKEY \
68 MKX11 \ 68 MKX11 \
69 MKX11FONTS \ 69 MKX11FONTS \
70 MKXORG \ 70 MKXORG \
71 MKYP \ 71 MKYP \
72 MKZFS \ 72 MKZFS \
73 USE_INET6 \ 73 USE_INET6 \
74 USE_KERBEROS \ 74 USE_KERBEROS \
75 USE_LDAP \ 75 USE_LDAP \
76 USE_YP \ 76 USE_YP \
77 NETBSDSRCDIR \ 77 NETBSDSRCDIR \
78 MAKEVERBOSE \ 78 MAKEVERBOSE \
79" 79"
80# 80#
81# The following variables refer to tools that are used when building sets: 81# The following variables refer to tools that are used when building sets:
82# 82#
83: ${AWK:=awk} 83: ${AWK:=awk}
84: ${CKSUM:=cksum} 84: ${CKSUM:=cksum}
85: ${COMM:=comm} 85: ${COMM:=comm}
86: ${DATE:=date} 86: ${DATE:=date}
87: ${DB:=db} 87: ${DB:=db}
88: ${EGREP:=egrep} 88: ${EGREP:=egrep}
89: ${ENV_CMD:=env} # ${ENV} is special to sh(1), ksh(1), etc. 89: ${ENV_CMD:=env} # ${ENV} is special to sh(1), ksh(1), etc.
90: ${FGREP:=fgrep} 90: ${FGREP:=fgrep}
91: ${FIND:=find} 91: ${FIND:=find}
92: ${GREP:=grep} 92: ${GREP:=grep}
93: ${GZIP_CMD:=gzip} # ${GZIP} is special to gzip(1) 93: ${GZIP_CMD:=gzip} # ${GZIP} is special to gzip(1)
94: ${HOSTNAME:=hostname} 94: ${HOSTNAME:=hostname}
95: ${HOST_SH:=sh} 95: ${HOST_SH:=sh}
96: ${IDENT:=ident} 96: ${IDENT:=ident}
97: ${JOIN:=join} 97: ${JOIN:=join}
98: ${LS:=ls} 98: ${LS:=ls}
99: ${MAKE:=make} 99: ${MAKE:=make}
100: ${MKTEMP:=mktemp} 100: ${MKTEMP:=mktemp}
101: ${MTREE:=mtree} 101: ${MTREE:=mtree}
102: ${PASTE:=paste} 102: ${PASTE:=paste}
103: ${PAX:=pax} 103: ${PAX:=pax}
104: ${PKG_CREATE:=pkg_create} 
105: ${PRINTF:=printf} 104: ${PRINTF:=printf}
106: ${SED:=sed} 105: ${SED:=sed}
107: ${SORT:=sort} 106: ${SORT:=sort}
108: ${STAT:=stat} 107: ${STAT:=stat}
109: ${TSORT:=tsort} 108: ${TSORT:=tsort}
110: ${UNAME:=uname} 109: ${UNAME:=uname}
111: ${WC:=wc} 110: ${WC:=wc}
112 111
113# 112#
114# If printf is a shell builtin command, then we can 113# If printf is a shell builtin command, then we can
115# implement cheaper versions of basename and dirname 114# implement cheaper versions of basename and dirname
116# that do not involve any fork/exec overhead. 115# that do not involve any fork/exec overhead.
117# If printf is not builtin, approximate it using echo, 116# If printf is not builtin, approximate it using echo,
118# and hope there are no weird file names that cause 117# and hope there are no weird file names that cause
119# some versions of echo to do the wrong thing. 118# some versions of echo to do the wrong thing.
120# (Converting to this version of dirname speeded up the 119# (Converting to this version of dirname speeded up the
121# syspkgdeps script by an order of magnitude, from 68 120# syspkgdeps script by an order of magnitude, from 68
122# seconds to 6.3 seconds on one particular host.) 121# seconds to 6.3 seconds on one particular host.)
123# 122#
124# Note that naive approximations for dirname 123# Note that naive approximations for dirname
125# using ${foo%/*} do not do the right thing in cases 124# using ${foo%/*} do not do the right thing in cases
126# where the result should be "/" or ".". 125# where the result should be "/" or ".".
127# 126#
128case "$(type printf)" in 127case "$(type printf)" in
129*builtin*) 128*builtin*)
130 basename () 129 basename ()
131 { 130 {
132 local bn 131 local bn
133 bn="${1##*/}" 132 bn="${1##*/}"
134 bn="${bn%$2}" 133 bn="${bn%$2}"
135 printf "%s\n" "$bn" 134 printf "%s\n" "$bn"
136 } 135 }
137 dirname () 136 dirname ()
138 { 137 {
139 local dn 138 local dn
140 case "$1" in 139 case "$1" in
141 ?*/*) dn="${1%/*}" ;; 140 ?*/*) dn="${1%/*}" ;;
142 /*) dn=/ ;; 141 /*) dn=/ ;;
143 *) dn=. ;; 142 *) dn=. ;;
144 esac 143 esac
145 printf "%s\n" "$dn" 144 printf "%s\n" "$dn"
146 } 145 }
147 ;; 146 ;;
148*) 147*)
149 basename () 148 basename ()
150 { 149 {
151 local bn 150 local bn
152 bn="${1##*/}" 151 bn="${1##*/}"
153 bn="${bn%$2}" 152 bn="${bn%$2}"
154 echo "$bn" 153 echo "$bn"
155 } 154 }
156 dirname () 155 dirname ()
157 { 156 {
158 local dn 157 local dn
159 case "$1" in 158 case "$1" in
160 ?*/*) dn="${1%/*}" ;; 159 ?*/*) dn="${1%/*}" ;;
161 /*) dn=/ ;; 160 /*) dn=/ ;;
162 *) dn=. ;; 161 *) dn=. ;;
163 esac 162 esac
164 echo "$dn" 163 echo "$dn"
165 } 164 }
166 ;; 165 ;;
167esac 166esac
168 167
169oIFS=$IFS 168oIFS=$IFS
170IFS=" 169IFS="
171" 170"
172for x in $( 171for x in $(
173${MAKE} -B -f- all <<EOMAKE 172${MAKE} -B -f- all <<EOMAKE
174.include <bsd.own.mk> 173.include <bsd.own.mk>
175.if (\${MKMAN} == "no" || empty(MANINSTALL:Mmaninstall)) 174.if (\${MKMAN} == "no" || empty(MANINSTALL:Mmaninstall))
176MKMANPAGES=no 175MKMANPAGES=no
177.else 176.else
178MKMANPAGES=yes 177MKMANPAGES=yes
179.endif 178.endif
180.if \${MKX11} != "no" 179.if \${MKX11} != "no"
181. if \${X11FLAVOUR} == "Xorg" 180. if \${X11FLAVOUR} == "Xorg"
182MKXORG:=yes 181MKXORG:=yes
183MKX11:=no 182MKX11:=no
184. else 183. else
185MKXORG:=no 184MKXORG:=no
186. endif 185. endif
187.endif 186.endif
188all: 187all:
189.for i in MACHINE MACHINE_ARCH MACHINE_CPU \ 188.for i in MACHINE MACHINE_ARCH MACHINE_CPU \
190 HAVE_BINUTILS HAVE_GCC HAVE_GDB OBJECT_FMT TOOLCHAIN_MISSING \ 189 HAVE_BINUTILS HAVE_GCC HAVE_GDB OBJECT_FMT TOOLCHAIN_MISSING \
191 ${MKVARS} 190 ${MKVARS}
192 @echo "export \$i=\${\$i}" 191 @echo "export \$i=\${\$i}"
193.endfor 192.endfor
194 193
195EOMAKE 194EOMAKE
196); do 195); do
197# echo 1>&2 "DEBUG: read $x" 196# echo 1>&2 "DEBUG: read $x"
198 eval $x 197 eval $x
199done 198done
200IFS=$oIFS 199IFS=$oIFS
201 200
202setsdir=${0%/*} 201setsdir=${0%/*}
203obsolete=0 202obsolete=0
204module=yes 203module=yes
205if [ "${MKKMOD}" = "no" ]; then 204if [ "${MKKMOD}" = "no" ]; then
206 module=no # MODULEs are off. 205 module=no # MODULEs are off.
207elif [ "${MACHINE}" = "evbppc" ]; then 206elif [ "${MACHINE}" = "evbppc" ]; then
208 module=no # Turn off MODULEs for some ports. 207 module=no # Turn off MODULEs for some ports.
209fi 208fi
210# Determine lib type. Do this first so stlib also gets set. 209# Determine lib type. Do this first so stlib also gets set.
211if [ "${OBJECT_FMT}" = "ELF" ]; then 210if [ "${OBJECT_FMT}" = "ELF" ]; then
212 shlib=elf 211 shlib=elf
213else 212else
214 shlib=aout 213 shlib=aout
215fi 214fi
216stlib=$shlib 215stlib=$shlib
217# Now check for MKPIC or specials and turn off shlib if need be. 216# Now check for MKPIC or specials and turn off shlib if need be.
218if [ "${MKPIC}" = "no" ]; then 217if [ "${MKPIC}" = "no" ]; then
219 shlib=no 218 shlib=no
220fi 219fi
221if [ "${MACHINE_ARCH}" = "m68000" ]; then 220if [ "${MACHINE_ARCH}" = "m68000" ]; then
222 shlib=no # Turn off shlibs for some ports. 221 shlib=no # Turn off shlibs for some ports.
223fi 222fi
224if [ "$module" != "no" ]; then 223if [ "$module" != "no" ]; then
225 nlists="base comp etc games man misc modules tests text" 224 nlists="base comp etc games man misc modules tests text"
226else 225else
227 nlists="base comp etc games man misc tests text" 226 nlists="base comp etc games man misc tests text"
228fi 227fi
229xlists="xbase xcomp xetc xfont xserver" 228xlists="xbase xcomp xetc xfont xserver"
230extlists="extbase extcomp extetc" 229extlists="extbase extcomp extetc"
231 230
232OSRELEASE=`${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh` 231OSRELEASE=`${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh`
233MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules" 232MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
234SUBST="s#@MODULEDIR@#${MODULEDIR}#g" 233SUBST="s#@MODULEDIR@#${MODULEDIR}#g"
235SUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g" 234SUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
236SUBST="${SUBST};s#@MACHINE@#${MACHINE}#g" 235SUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
237 236
238# 237#
239# list_set_files setfile [...] 238# list_set_files setfile [...]
240#  239#
241# Produce a packing list for setfile(s). 240# Produce a packing list for setfile(s).
242# In each file, a record consists of a path and a System Package name, 241# In each file, a record consists of a path and a System Package name,
243# separated by whitespace. E.g., 242# separated by whitespace. E.g.,
244# 243#
245# # $NetBSD: sets.subr,v 1.92 2009/11/30 16:13:23 uebayasi Exp $ 244# # $NetBSD: sets.subr,v 1.93 2009/12/01 15:49:21 apb Exp $
246# . base-sys-root [keyword[,...]] 245# . base-sys-root [keyword[,...]]
247# ./altroot base-sys-root 246# ./altroot base-sys-root
248# ./bin base-sys-root 247# ./bin base-sys-root
249# ./bin/[ base-util-root 248# ./bin/[ base-util-root
250# ./bin/cat base-util-root 249# ./bin/cat base-util-root
251# [...] 250# [...]
252# 251#
253# A # in the first column marks a comment. 252# A # in the first column marks a comment.
254# 253#
255# If ${obsolete} != 0, only entries with an "obsolete" keyword will 254# If ${obsolete} != 0, only entries with an "obsolete" keyword will
256# be printed. All other keywords must be present. 255# be printed. All other keywords must be present.
257# 256#
258# The third field is an optional comma separated list of keywords to 257# The third field is an optional comma separated list of keywords to
259# control if a record is printed; every keyword listed must be enabled 258# control if a record is printed; every keyword listed must be enabled
260# for the record to be printed. The following keywords are available: 259# for the record to be printed. The following keywords are available:
261# dummy dummy entry (ignored) 260# dummy dummy entry (ignored)
262# obsolete file is obsolete, and only printed if  261# obsolete file is obsolete, and only printed if
263# ${obsolete} != 0 262# ${obsolete} != 0
264# 263#
265# bfd obsolete, use binutils. 264# bfd obsolete, use binutils.
266# binutils ${MKBINUTILS} != no 265# binutils ${MKBINUTILS} != no
267# catpages ${MKCATPAGES} != no 266# catpages ${MKCATPAGES} != no
268# compat ${MKCOMPAT} != no 267# compat ${MKCOMPAT} != no
269# crypto ${MKCRYPTO} != no 268# crypto ${MKCRYPTO} != no
270# crypto_idea ${MKCRYPTO_IDEA} != no 269# crypto_idea ${MKCRYPTO_IDEA} != no
271# crypto_mdc2 ${MKCRYPTO_MDC2} != no 270# crypto_mdc2 ${MKCRYPTO_MDC2} != no
272# crypto_rc5 ${MKCRYPTO_RC5} != no 271# crypto_rc5 ${MKCRYPTO_RC5} != no
273# cvs ${MKCVS} != no 272# cvs ${MKCVS} != no
274# debug ${MKDEBUG} != no 273# debug ${MKDEBUG} != no
275# debuglib ${MKDEBUGLIB} != no 274# debuglib ${MKDEBUGLIB} != no
276# doc ${MKDOC} != no 275# doc ${MKDOC} != no
277# dynamicroot ${MKDYNAMICROOT} != no 276# dynamicroot ${MKDYNAMICROOT} != no
278# extsrc ${MKEXTSRC} != no 277# extsrc ${MKEXTSRC} != no
279# gcc ${MKGCC} != no 278# gcc ${MKGCC} != no
280# gcccmds ${MKGCCCMDS} != no 279# gcccmds ${MKGCCCMDS} != no
281# gdb ${MKGDB} != no 280# gdb ${MKGDB} != no
282# hesiod ${MKHESIOD} != no 281# hesiod ${MKHESIOD} != no
283# html ${MKHTML} != no 282# html ${MKHTML} != no
284# inet6 ${MKINET6} != no 283# inet6 ${MKINET6} != no
285# info ${MKINFO} != no 284# info ${MKINFO} != no
286# ipfilter ${MKIPFILTER} != no 285# ipfilter ${MKIPFILTER} != no
287# iscsi ${MKISCSI} != no 286# iscsi ${MKISCSI} != no
288# kerberos ${MKKERBEROS} != no 287# kerberos ${MKKERBEROS} != no
289# kmod ${MKKMOD} != no 288# kmod ${MKKMOD} != no
290# ldap ${MKLDAP} != no 289# ldap ${MKLDAP} != no
291# lint ${MKLINT} != no 290# lint ${MKLINT} != no
292# lvm ${MKLVM} != no 291# lvm ${MKLVM} != no
293# man ${MKMAN} != no 292# man ${MKMAN} != no
294# manpages ${MKMANPAGES} != no 293# manpages ${MKMANPAGES} != no
295# manz ${MKMANZ} != no 294# manz ${MKMANZ} != no
296# mdns ${MKMDNS} != no 295# mdns ${MKMDNS} != no
297# nls ${MKNLS} != no 296# nls ${MKNLS} != no
298# nvi ${MKNVI} != no 297# nvi ${MKNVI} != no
299# pam ${MKPAM} != no 298# pam ${MKPAM} != no
300# pf ${MKPF} != no 299# pf ${MKPF} != no
301# pic ${MKPIC} != no 300# pic ${MKPIC} != no
302# postfix ${MKPOSTFIX} != no 301# postfix ${MKPOSTFIX} != no
303# profile ${MKPROFILE} != no 302# profile ${MKPROFILE} != no
304# share ${MKSHARE} != no 303# share ${MKSHARE} != no
305# skey ${MKSKEY} != no 304# skey ${MKSKEY} != no
306# x11 ${MKX11} != no && ${X11FLAVOUR} != "Xorg" 305# x11 ${MKX11} != no && ${X11FLAVOUR} != "Xorg"
307# xorg ${MKX11} != no && ${X11FLAVOUR} == "Xorg" 306# xorg ${MKX11} != no && ${X11FLAVOUR} == "Xorg"
308# yp ${MKYP} != no 307# yp ${MKYP} != no
309# zfs ${MKZFS} != no 308# zfs ${MKZFS} != no
310# 309#
311# binutils=<n> <n> = value of ${HAVE_BINUTILS} 310# binutils=<n> <n> = value of ${HAVE_BINUTILS}
312# gcc=<n> <n> = value of ${HAVE_GCC} 311# gcc=<n> <n> = value of ${HAVE_GCC}
313# gdb=<n> <n> = value of ${HAVE_GDB} 312# gdb=<n> <n> = value of ${HAVE_GDB}
314# 313#
315# use_inet6 ${USE_INET6} != no 314# use_inet6 ${USE_INET6} != no
316# use_kerberos ${USE_KERBEROS} != no 315# use_kerberos ${USE_KERBEROS} != no
317# use_yp ${USE_YP} != no 316# use_yp ${USE_YP} != no
318# 317#
319# .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no" 318# .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
320# automatically append ".gz" to the filename 319# automatically append ".gz" to the filename
321# 320#
322# .man if ${MKMANZ} != "no" && ${MKMAN} != "no" 321# .man if ${MKMANZ} != "no" && ${MKMAN} != "no"
323# automatically append ".gz" to the filename 322# automatically append ".gz" to the filename
324# 323#
325list_set_files() 324list_set_files()
326{ 325{
327 if [ ${MAKEVERBOSE:-2} -lt 3 ]; then 326 if [ ${MAKEVERBOSE:-2} -lt 3 ]; then
328 verbose=false 327 verbose=false
329 else 328 else
330 verbose=true 329 verbose=true
331 fi 330 fi
332 for setname; do 331 for setname; do
333 list=`list_set_lists $setname` 332 list=`list_set_lists $setname`
334 for l in $list; do 333 for l in $list; do
335 echo $l 334 echo $l
336 if $verbose; then 335 if $verbose; then
337 echo >&2 "DEBUG: list_set_files: $l" 336 echo >&2 "DEBUG: list_set_files: $l"
338 fi 337 fi
339 done 338 done
340 done | xargs cat | ${SED} ${SUBST} | \ 339 done | xargs cat | ${SED} ${SUBST} | \
341 ${AWK} -v obsolete=${obsolete} ' 340 ${AWK} -v obsolete=${obsolete} '
342 BEGIN { 341 BEGIN {
343 if (obsolete) 342 if (obsolete)
344 wanted["obsolete"] = 1 343 wanted["obsolete"] = 1
345  344
346 split("'"${MKVARS}"'", needvars) 345 split("'"${MKVARS}"'", needvars)
347 for (vi in needvars) { 346 for (vi in needvars) {
348 nv = needvars[vi] 347 nv = needvars[vi]
349 kw = tolower(nv) 348 kw = tolower(nv)
350 sub(/^mk/, "", kw) 349 sub(/^mk/, "", kw)
351 if (ENVIRON[nv] != "no") 350 if (ENVIRON[nv] != "no")
352 wanted[kw] = 1  351 wanted[kw] = 1
353 } 352 }
354 353
355 if ("'"${TOOLCHAIN_MISSING}"'" != "yes") { 354 if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
356 if ("binutils" in wanted) 355 if ("binutils" in wanted)
357 wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1 356 wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1
358 if ("gcc" in wanted) 357 if ("gcc" in wanted)
359 wanted["gcc=" "'"${HAVE_GCC}"'"] = 1 358 wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
360 if ("gdb" in wanted) 359 if ("gdb" in wanted)
361 wanted["gdb=" "'"${HAVE_GDB}"'"] = 1 360 wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
362 } 361 }
363 if (("man" in wanted) && ("catpages" in wanted)) 362 if (("man" in wanted) && ("catpages" in wanted))
364 wanted[".cat"] = 1 363 wanted[".cat"] = 1
365 if (("man" in wanted) && ("manpages" in wanted)) 364 if (("man" in wanted) && ("manpages" in wanted))
366 wanted[".man"] = 1 365 wanted[".man"] = 1
367 } 366 }
368 367
369 /^#/ { 368 /^#/ {
370 next; 369 next;
371 } 370 }
372 371
373 NF > 2 && $3 != "-" { 372 NF > 2 && $3 != "-" {
374 split($3, keywords, ",") 373 split($3, keywords, ",")
375 show = 1 374 show = 1
376 haveobs = 0 375 haveobs = 0
377 for (ki in keywords) { 376 for (ki in keywords) {
378 kw = keywords[ki] 377 kw = keywords[ki]
379 if (("manz" in wanted) && 378 if (("manz" in wanted) &&
380 (kw == ".cat" || kw == ".man")) 379 (kw == ".cat" || kw == ".man"))
381 $1 = $1 ".gz" 380 $1 = $1 ".gz"
382 negated = match(kw, "! *") 381 negated = match(kw, "! *")
383 if (negated > 0) { 382 if (negated > 0) {
384 kw = substr(kw, RSTART + RLENGTH) 383 kw = substr(kw, RSTART + RLENGTH)
385 if (kw in wanted) 384 if (kw in wanted)
386 show = 0 385 show = 0
387 } else { 386 } else {
388 if (! (kw in wanted)) 387 if (! (kw in wanted))
389 show = 0 388 show = 0
390 } 389 }
391 if (kw == "obsolete") 390 if (kw == "obsolete")
392 haveobs = 1 391 haveobs = 1
393 } 392 }
394 if (obsolete && ! haveobs) 393 if (obsolete && ! haveobs)
395 next 394 next
396 if (show) 395 if (show)
397 print 396 print
398 next 397 next
399 } 398 }
400 399
401 { 400 {
402 if (! obsolete) 401 if (! obsolete)
403 print 402 print
404 }' 403 }'
405 404
406} 405}
407 406
408# 407#
409# list_set_lists setname 408# list_set_lists setname
410#  409#
411# Print to stdout a list of files, one filename per line, which 410# Print to stdout a list of files, one filename per line, which
412# concatenate to create the packing list for setname. E.g., 411# concatenate to create the packing list for setname. E.g.,
413# 412#
414# .../lists/base/mi 413# .../lists/base/mi
415# .../lists/base/rescue.mi 414# .../lists/base/rescue.mi
416# .../lists/base/md.i386 415# .../lists/base/md.i386
417# [...] 416# [...]
418# 417#
419# For a given setname $set, the following files may be selected from 418# For a given setname $set, the following files may be selected from
420# .../list/$set: 419# .../list/$set:
421# mi 420# mi
422# mi.ext.* 421# mi.ext.*
423# ad.${MACHINE_ARCH} 422# ad.${MACHINE_ARCH}
424# (or) ad.${MACHINE_CPU} 423# (or) ad.${MACHINE_CPU}
425# ad.${MACHINE_CPU}.shl 424# ad.${MACHINE_CPU}.shl
426# md.${MACHINE}.${MACHINE_ARCH} 425# md.${MACHINE}.${MACHINE_ARCH}
427# (or) md.${MACHINE} 426# (or) md.${MACHINE}
428# stl.mi 427# stl.mi
429# stl.${stlib} 428# stl.${stlib}
430# shl.mi 429# shl.mi
431# shl.mi.ext.* 430# shl.mi.ext.*
432# shl.${shlib} 431# shl.${shlib}
433# shl.${shlib}.ext.* 432# shl.${shlib}.ext.*
434# module.mi if ${module} != no 433# module.mi if ${module} != no
435# module.${MACHINE} if ${module} != no 434# module.${MACHINE} if ${module} != no
436# module.ad.${MACHINE_ARCH} if ${module} != no 435# module.ad.${MACHINE_ARCH} if ${module} != no
437# (or) module.ad.${MACHINE_CPU} if ${module} != no 436# (or) module.ad.${MACHINE_CPU} if ${module} != no
438# rescue.shl 437# rescue.shl
439# rescue.${MACHINE} 438# rescue.${MACHINE}
440# rescue.ad.${MACHINE_ARCH} 439# rescue.ad.${MACHINE_ARCH}
441# (or) rescue.ad.${MACHINE_CPU} 440# (or) rescue.ad.${MACHINE_CPU}
442# rescue.ad.${MACHINE_CPU}.shl 441# rescue.ad.${MACHINE_CPU}.shl
443# 442#
444# Environment: 443# Environment:
445# shlib 444# shlib
446# stlib 445# stlib
447# 446#
448list_set_lists() 447list_set_lists()
449{ 448{
450 setname=$1 449 setname=$1
451 450
452 setdir=$setsdir/lists/$setname 451 setdir=$setsdir/lists/$setname
453 echo $setdir/mi 452 echo $setdir/mi
454 for _extsrc_pkg in ${EXTSRCS}; do 453 for _extsrc_pkg in ${EXTSRCS}; do
455 if [ -f $setdir/mi.ext.${_extsrc_pkg} ]; then 454 if [ -f $setdir/mi.ext.${_extsrc_pkg} ]; then
456 echo $setdir/mi.ext.${_extsrc_pkg} 455 echo $setdir/mi.ext.${_extsrc_pkg}
457 fi 456 fi
458 done 457 done
459 if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then 458 if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
460 # Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU}, 459 # Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU},
461 # since the arch-specific one will be more specific than 460 # since the arch-specific one will be more specific than
462 # the cpu-specific one. 461 # the cpu-specific one.
463 if [ -f $setdir/ad.${MACHINE_ARCH} ]; then 462 if [ -f $setdir/ad.${MACHINE_ARCH} ]; then
464 echo $setdir/ad.${MACHINE_ARCH} 463 echo $setdir/ad.${MACHINE_ARCH}
465 elif [ -f $setdir/ad.${MACHINE_CPU} ]; then 464 elif [ -f $setdir/ad.${MACHINE_CPU} ]; then
466 echo $setdir/ad.${MACHINE_CPU} 465 echo $setdir/ad.${MACHINE_CPU}
467 fi 466 fi
468 if [ "$shlib" != "no" -a \ 467 if [ "$shlib" != "no" -a \
469 -f $setdir/ad.${MACHINE_CPU}.shl ]; then 468 -f $setdir/ad.${MACHINE_CPU}.shl ]; then
470 echo $setdir/ad.${MACHINE_CPU}.shl 469 echo $setdir/ad.${MACHINE_CPU}.shl
471 fi 470 fi
472 fi 471 fi
473 if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then 472 if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then
474 echo $setdir/md.${MACHINE}.${MACHINE_ARCH} 473 echo $setdir/md.${MACHINE}.${MACHINE_ARCH}
475 elif [ -f $setdir/md.${MACHINE} ]; then 474 elif [ -f $setdir/md.${MACHINE} ]; then
476 echo $setdir/md.${MACHINE} 475 echo $setdir/md.${MACHINE}
477 fi 476 fi
478 if [ -f $setdir/stl.mi ]; then 477 if [ -f $setdir/stl.mi ]; then
479 echo $setdir/stl.mi 478 echo $setdir/stl.mi
480 fi 479 fi
481 if [ -f $setdir/stl.${stlib} ]; then 480 if [ -f $setdir/stl.${stlib} ]; then
482 echo $setdir/stl.${stlib} 481 echo $setdir/stl.${stlib}
483 fi 482 fi
484 if [ "$shlib" != "no" ]; then 483 if [ "$shlib" != "no" ]; then
485 if [ -f $setdir/shl.mi ]; then 484 if [ -f $setdir/shl.mi ]; then
486 echo $setdir/shl.mi 485 echo $setdir/shl.mi
487 fi 486 fi
488 for _extsrc_pkg in ${EXTSRCS}; do 487 for _extsrc_pkg in ${EXTSRCS}; do
489 if [ -f $setdir/shl.mi.ext.${_extsrc_pkg} ]; then 488 if [ -f $setdir/shl.mi.ext.${_extsrc_pkg} ]; then
490 echo $setdir/shl.mi.ext.${_extsrc_pkg} 489 echo $setdir/shl.mi.ext.${_extsrc_pkg}
491 fi 490 fi
492 done 491 done
493 if [ -f $setdir/shl.${shlib} ]; then 492 if [ -f $setdir/shl.${shlib} ]; then
494 echo $setdir/shl.${shlib} 493 echo $setdir/shl.${shlib}
495 fi 494 fi
496 for _extsrc_pkg in ${EXTSRCS}; do 495 for _extsrc_pkg in ${EXTSRCS}; do
497 if [ -f $setdir/shl.${shlib}.ext.${_extsrc_pkg} ]; then 496 if [ -f $setdir/shl.${shlib}.ext.${_extsrc_pkg} ]; then
498 echo $setdir/shl.${shlib}.ext.${_extsrc_pkg} 497 echo $setdir/shl.${shlib}.ext.${_extsrc_pkg}
499 fi 498 fi
500 done 499 done
501 fi 500 fi
502 if [ "$module" != "no" ]; then 501 if [ "$module" != "no" ]; then
503 if [ -f $setdir/module.mi ]; then 502 if [ -f $setdir/module.mi ]; then
504 echo $setdir/module.mi 503 echo $setdir/module.mi
505 fi 504 fi
506 if [ -f $setdir/module.${MACHINE} ]; then 505 if [ -f $setdir/module.${MACHINE} ]; then
507 echo $setdir/module.${MACHINE} 506 echo $setdir/module.${MACHINE}
508 fi 507 fi
509 if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then 508 if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
510 # Prefer a module.ad.${MACHINE_ARCH} over a 509 # Prefer a module.ad.${MACHINE_ARCH} over a
511 # module.ad.${MACHINE_CPU}, since the arch- 510 # module.ad.${MACHINE_CPU}, since the arch-
512 # specific one will be more specific than the 511 # specific one will be more specific than the
513 # cpu-specific one. 512 # cpu-specific one.
514 if [ -f $setdir/module.ad.${MACHINE_ARCH} ]; then 513 if [ -f $setdir/module.ad.${MACHINE_ARCH} ]; then
515 echo $setdir/module.ad.${MACHINE_ARCH} 514 echo $setdir/module.ad.${MACHINE_ARCH}
516 elif [ -f $setdir/module.ad.${MACHINE_CPU} ]; then 515 elif [ -f $setdir/module.ad.${MACHINE_CPU} ]; then
517 echo $setdir/module.ad.${MACHINE_CPU} 516 echo $setdir/module.ad.${MACHINE_CPU}
518 fi 517 fi
519 fi 518 fi
520 fi 519 fi
521 520
522 if [ -f $setdir/rescue.mi ]; then 521 if [ -f $setdir/rescue.mi ]; then
523 echo $setdir/rescue.mi 522 echo $setdir/rescue.mi
524 fi 523 fi
525 if [ -f $setdir/rescue.${MACHINE} ]; then 524 if [ -f $setdir/rescue.${MACHINE} ]; then
526 echo $setdir/rescue.${MACHINE} 525 echo $setdir/rescue.${MACHINE}
527 fi 526 fi
528 if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then 527 if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
529 # Prefer a rescue.ad.${MACHINE_ARCH} over a 528 # Prefer a rescue.ad.${MACHINE_ARCH} over a
530 # rescue.ad.${MACHINE_CPU}, since the arch- 529 # rescue.ad.${MACHINE_CPU}, since the arch-
531 # specific one will be more specific than the 530 # specific one will be more specific than the
532 # cpu-specific one. 531 # cpu-specific one.
533 if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then 532 if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then
534 echo $setdir/rescue.ad.${MACHINE_ARCH} 533 echo $setdir/rescue.ad.${MACHINE_ARCH}
535 elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then 534 elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then
536 echo $setdir/rescue.ad.${MACHINE_CPU} 535 echo $setdir/rescue.ad.${MACHINE_CPU}
537 fi 536 fi
538 if [ "$shlib" != "no" -a \ 537 if [ "$shlib" != "no" -a \
539 -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then 538 -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then
540 echo $setdir/rescue.ad.${MACHINE_CPU}.shl 539 echo $setdir/rescue.ad.${MACHINE_CPU}.shl
541 fi 540 fi
542 fi 541 fi
543} 542}
544 543
545# arch_to_cpu mach 544# arch_to_cpu mach
546# 545#
547# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 546# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
548# as determined by <bsd.own.mk>. 547# as determined by <bsd.own.mk>.
549# 548#
550arch_to_cpu() 549arch_to_cpu()
551{ 550{
552 MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE 551 MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
553.include <bsd.own.mk> 552.include <bsd.own.mk>
554all: 553all:
555 @echo \${MACHINE_CPU} 554 @echo \${MACHINE_CPU}
556EOMAKE 555EOMAKE
557} 556}
558 557
559# arch_to_endian mach 558# arch_to_endian mach
560# 559#
561# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach, 560# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
562# as determined by <bsd.endian.mk>. 561# as determined by <bsd.endian.mk>.
563# 562#
564arch_to_endian() 563arch_to_endian()
565{ 564{
566 MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE 565 MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
567.include <bsd.endian.mk> 566.include <bsd.endian.mk>
568all: 567all:
569 @echo \${TARGET_ENDIANNESS} 568 @echo \${TARGET_ENDIANNESS}
570EOMAKE 569EOMAKE
571} 570}