Mon Dec 27 14:16:30 2021 UTC ()
extra_libarchive_depends() apparently hasn't given multiple values for
Libs.private before, but it does on Gentoo ("-lmd -lb2"), so failing to
double-quote the output breaks bootstrap there. Adding the quotes causes
no regressions bootstrapping macOS Monterey or Ubuntu 21.10. Problem
report and solution from p.spek@tyil.nl.


(schmonz)
diff -r1.304 -r1.305 pkgsrc/bootstrap/bootstrap

cvs diff -r1.304 -r1.305 pkgsrc/bootstrap/bootstrap (switch to unified diff)

--- pkgsrc/bootstrap/bootstrap 2021/11/29 18:32:51 1.304
+++ pkgsrc/bootstrap/bootstrap 2021/12/27 14:16:30 1.305
@@ -1,1488 +1,1488 @@ @@ -1,1488 +1,1488 @@
1#! /bin/sh 1#! /bin/sh
2 2
3# $NetBSD: bootstrap,v 1.304 2021/11/29 18:32:51 jperkin Exp $ 3# $NetBSD: bootstrap,v 1.305 2021/12/27 14:16:30 schmonz Exp $
4# 4#
5# Copyright (c) 2001-2011 Alistair Crooks <agc@NetBSD.org> 5# Copyright (c) 2001-2011 Alistair Crooks <agc@NetBSD.org>
6# All rights reserved. 6# All rights reserved.
7# 7#
8# Redistribution and use in source and binary forms, with or without 8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions 9# modification, are permitted provided that the following conditions
10# are met: 10# are met:
11# 1. Redistributions of source code must retain the above copyright 11# 1. Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer. 12# notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright 13# 2. Redistributions in binary form must reproduce the above copyright
14# notice, this list of conditions and the following disclaimer in the 14# notice, this list of conditions and the following disclaimer in the
15# documentation and/or other materials provided with the distribution. 15# documentation and/or other materials provided with the distribution.
16# 16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27# 27#
28#set -x 28#set -x
29 29
30# the following environment variables are honored: 30# the following environment variables are honored:
31# compiler/linker flags: CFLAGS, CPPFLAGS, LDFLAGS, LIBS 31# compiler/linker flags: CFLAGS, CPPFLAGS, LDFLAGS, LIBS
32# tools: CP, GREP, ID, MKDIR, SH, TEST, TOUCH, XARGS 32# tools: CP, GREP, ID, MKDIR, SH, TEST, TOUCH, XARGS
33 33
34# The bootstrap program must be able to run with very limited shells. 34# The bootstrap program must be able to run with very limited shells.
35# It must not use any of the following features: 35# It must not use any of the following features:
36# 36#
37# * the ${var%pattern} or ${var#pattern} expansions 37# * the ${var%pattern} or ${var#pattern} expansions
38# * the $(command) subshell 38# * the $(command) subshell
39 39
40# Don't let the bootstrap program get confused by a pre-existing mk.conf 40# Don't let the bootstrap program get confused by a pre-existing mk.conf
41# file. 41# file.
42MAKECONF=/dev/null 42MAKECONF=/dev/null
43export MAKECONF 43export MAKECONF
44 44
45# No vulnerability checks since there might be an incompatible checker installed 45# No vulnerability checks since there might be an incompatible checker installed
46NO_PKGTOOLS_REQD_CHECK=yes 46NO_PKGTOOLS_REQD_CHECK=yes
47export NO_PKGTOOLS_REQD_CHECK 47export NO_PKGTOOLS_REQD_CHECK
48 48
49unprivileged=no 49unprivileged=no
50 50
51preserve_path=no 51preserve_path=no
52 52
53# where the building takes place 53# where the building takes place
54bootstrapdir=`dirname "$0"` 54bootstrapdir=`dirname "$0"`
55bootstrapdir=`cd "${bootstrapdir}" && pwd` 55bootstrapdir=`cd "${bootstrapdir}" && pwd`
56pkgsrcdir=`dirname "${bootstrapdir}"` 56pkgsrcdir=`dirname "${bootstrapdir}"`
57wrkdir="`pwd`/work" 57wrkdir="`pwd`/work"
58 58
59usage="Usage: $0 "' 59usage="Usage: $0 "'
60 [ --abi [32|64] ] 60 [ --abi [32|64] ]
61 [ --binary-kit <tarball> ] 61 [ --binary-kit <tarball> ]
62 [ --compiler <compiler> ] 62 [ --compiler <compiler> ]
63 [ --cwrappers <auto|yes|no> ] 63 [ --cwrappers <auto|yes|no> ]
64 [ --full ] 64 [ --full ]
65 [ --gzip-binary-kit <tarball> ] 65 [ --gzip-binary-kit <tarball> ]
66 [ --help ] 66 [ --help ]
67 [ --machine-arch <arch> ] 67 [ --machine-arch <arch> ]
68 [ --make-jobs <num> ] 68 [ --make-jobs <num> ]
69 [ --mk-fragment <mk.conf> ] 69 [ --mk-fragment <mk.conf> ]
70 [ --pkgdbdir <pkgdbdir> ] 70 [ --pkgdbdir <pkgdbdir> ]
71 [ --pkginfodir <pkginfodir> ] 71 [ --pkginfodir <pkginfodir> ]
72 [ --pkgmandir <pkgmandir> ] 72 [ --pkgmandir <pkgmandir> ]
73 [ --prefer-pkgsrc <list|yes|no> ] 73 [ --prefer-pkgsrc <list|yes|no> ]
74 [ --prefer-native <list|yes|no> ] 74 [ --prefer-native <list|yes|no> ]
75 [ --prefix <prefix> ] 75 [ --prefix <prefix> ]
76 [ --preserve-path ] 76 [ --preserve-path ]
77 [ --quiet ] 77 [ --quiet ]
78 [ --sysconfbase <sysconfbase> ] 78 [ --sysconfbase <sysconfbase> ]
79 [ --sysconfdir <sysconfdir> ] 79 [ --sysconfdir <sysconfdir> ]
80 [ --unprivileged | --ignore-user-check ] 80 [ --unprivileged | --ignore-user-check ]
81 [ --varbase <varbase> ] 81 [ --varbase <varbase> ]
82 [ --workdir <workdir> ] 82 [ --workdir <workdir> ]
83' 83'
84 84
85# strip / for BSD/OS, strip - for HP-UX 85# strip / for BSD/OS, strip - for HP-UX
86opsys=`uname -s | tr -d /-` 86opsys=`uname -s | tr -d /-`
87 87
88mkbinarykit_tar() 88mkbinarykit_tar()
89{ 89{
90 # in case tar was built by bootstrap 90 # in case tar was built by bootstrap
91 PATH="$prefix/bin:$PATH"; export PATH 91 PATH="$prefix/bin:$PATH"; export PATH
92 cd / && tar -hcf "${binary_kit}" .$prefix .$pkgdbdir .$etc_mk_conf 92 cd / && tar -hcf "${binary_kit}" .$prefix .$pkgdbdir .$etc_mk_conf
93} 93}
94 94
95mkbinarykit_tgz() 95mkbinarykit_tgz()
96{ 96{
97 # in case tar was built by bootstrap 97 # in case tar was built by bootstrap
98 PATH="$prefix/bin:$PATH"; export PATH 98 PATH="$prefix/bin:$PATH"; export PATH
99 cd / && tar -hcf - .$prefix .$pkgdbdir .$etc_mk_conf | gzip > "${binary_gzip_kit}" 99 cd / && tar -hcf - .$prefix .$pkgdbdir .$etc_mk_conf | gzip > "${binary_gzip_kit}"
100} 100}
101 101
102die() 102die()
103{ 103{
104 echo >&2 "$*" 104 echo >&2 "$*"
105 exit 1 105 exit 1
106} 106}
107 107
108echo_msg() 108echo_msg()
109{ 109{
110 echo "===> $*" 110 echo "===> $*"
111} 111}
112 112
113# see if we're using gcc. If so, set $compiler_is_gnu to '1'. 113# see if we're using gcc. If so, set $compiler_is_gnu to '1'.
114get_compiler() 114get_compiler()
115{ 115{
116 testcc="${CC}" 116 testcc="${CC}"
117 # normally, we'd just use 'cc', but certain configure tools look 117 # normally, we'd just use 'cc', but certain configure tools look
118 # for gcc specifically, so we have to see if that comes first 118 # for gcc specifically, so we have to see if that comes first
119 if [ -z "${testcc}" ]; then 119 if [ -z "${testcc}" ]; then
120 save_IFS="${IFS}" 120 save_IFS="${IFS}"
121 IFS=':' 121 IFS=':'
122 for dir in ${PATH}; do 122 for dir in ${PATH}; do
123 test -z "$dir" && dir=. 123 test -z "$dir" && dir=.
124 if [ -x "$dir/gcc" ]; then 124 if [ -x "$dir/gcc" ]; then
125 testcc="$dir/gcc" 125 testcc="$dir/gcc"
126 break 126 break
127 fi 127 fi
128 done 128 done
129 IFS="${save_IFS}" 129 IFS="${save_IFS}"
130 fi 130 fi
131 131
132 # Clang compiler pretends to be GCC, so we have to check that 132 # Clang compiler pretends to be GCC, so we have to check that
133 cat >${wrkdir}/$$.c <<EOF 133 cat >${wrkdir}/$$.c <<EOF
134#ifdef __clang__ 134#ifdef __clang__
135indeed 135indeed
136#endif 136#endif
137EOF 137EOF
138 compiler_is_clang=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed` 138 compiler_is_clang=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed`
139 rm -f ${wrkdir}/$$.c 139 rm -f ${wrkdir}/$$.c
140 140
141 cat >${wrkdir}/$$.c <<EOF 141 cat >${wrkdir}/$$.c <<EOF
142#ifdef __GNUC__ 142#ifdef __GNUC__
143#ifndef __clang__ 143#ifndef __clang__
144indeed 144indeed
145#endif 145#endif
146#endif 146#endif
147EOF 147EOF
148 compiler_is_gnu=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed` 148 compiler_is_gnu=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed`
149 rm -f ${wrkdir}/$$.c 149 rm -f ${wrkdir}/$$.c
150 150
151} 151}
152get_abi() 152get_abi()
153{ 153{
154 abi_opsys=$@ 154 abi_opsys=$@
155 155
156 if [ -n "$abi" ]; then 156 if [ -n "$abi" ]; then
157 case "$abi_opsys" in 157 case "$abi_opsys" in
158 IRIX) 158 IRIX)
159 die "ERROR: $abi_opsys has special ABI handling, --abi not supported (yet)." 159 die "ERROR: $abi_opsys has special ABI handling, --abi not supported (yet)."
160 ;; 160 ;;
161 esac 161 esac
162 fi 162 fi
163 163
164 case "$abi_opsys" in 164 case "$abi_opsys" in
165 IRIX) 165 IRIX)
166 if [ `uname -r` -ge 6 ]; then 166 if [ `uname -r` -ge 6 ]; then
167 abi=`sed -e 's/.*\(abi=\)\([on]*[36][24]\).*/\2/' /etc/compiler.defaults` 167 abi=`sed -e 's/.*\(abi=\)\([on]*[36][24]\).*/\2/' /etc/compiler.defaults`
168 isa=`sed -e 's/.*\(isa=mips\)\([1234]\).*/\2/' /etc/compiler.defaults` 168 isa=`sed -e 's/.*\(isa=mips\)\([1234]\).*/\2/' /etc/compiler.defaults`
169 case "$abi" in 169 case "$abi" in
170 o32) 170 o32)
171 imakeopts="-DBuildO32 -DSgiISAo32=$isa" 171 imakeopts="-DBuildO32 -DSgiISAo32=$isa"
172 abi="" 172 abi=""
173 ;; 173 ;;
174 n32) imakeopts="-DBuildN32 -DSgiISA32=$isa" 174 n32) imakeopts="-DBuildN32 -DSgiISA32=$isa"
175 abi="32" 175 abi="32"
176 ;; 176 ;;
177 64 | n64) 177 64 | n64)
178 imakeopts="-DBuild64bit -DSgiISA64=$isa" 178 imakeopts="-DBuild64bit -DSgiISA64=$isa"
179 abi="64" 179 abi="64"
180 ;; 180 ;;
181 esac 181 esac
182 else # IRIX before 6 182 else # IRIX before 6
183 abi=32 183 abi=32
184 fi 184 fi
185 ;; 185 ;;
186 esac 186 esac
187} 187}
188 188
189get_machine_arch_aix() 189get_machine_arch_aix()
190{ 190{
191 _cpuid=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` 191 _cpuid=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
192 if /usr/sbin/lsattr -El $_cpuid | grep ' POWER' >/dev/null 2>&1; then 192 if /usr/sbin/lsattr -El $_cpuid | grep ' POWER' >/dev/null 2>&1; then
193 echo rs6000 193 echo rs6000
194 else 194 else
195 echo powerpc 195 echo powerpc
196 fi 196 fi
197} 197}
198 198
199get_machine_arch_darwin() 199get_machine_arch_darwin()
200{ 200{
201 case `uname -p` in 201 case `uname -p` in
202 arm) 202 arm)
203 echo "aarch64" 203 echo "aarch64"
204 ;; 204 ;;
205 i386) 205 i386)
206 # Returns "i386" or "x86_64" depending on CPU 206 # Returns "i386" or "x86_64" depending on CPU
207 echo `uname -m` 207 echo `uname -m`
208 ;; 208 ;;
209 powerpc) 209 powerpc)
210 echo "powerpc" 210 echo "powerpc"
211 ;; 211 ;;
212 esac 212 esac
213} 213}
214 214
215check_prog() 215check_prog()
216{ 216{
217 _var="$1"; _name="$2" 217 _var="$1"; _name="$2"
218 218
219 eval _tmp=\"\$$_var\" 219 eval _tmp=\"\$$_var\"
220 if [ "x$_tmp" != "x" ]; then 220 if [ "x$_tmp" != "x" ]; then
221 # Variable is already set (by the user, for example) 221 # Variable is already set (by the user, for example)
222 return 0 222 return 0
223 fi 223 fi
224 224
225 for _d in `echo $PATH | tr ':' ' '`; do 225 for _d in `echo $PATH | tr ':' ' '`; do
226 if [ -f "$_d/$_name" ] && [ -x "$_d/$_name" ]; then 226 if [ -f "$_d/$_name" ] && [ -x "$_d/$_name" ]; then
227 # Program found 227 # Program found
228 eval $_var=\""$_d/$_name"\" 228 eval $_var=\""$_d/$_name"\"
229 return 1 229 return 1
230 fi 230 fi
231 done 231 done
232 232
233 die "$_name not found in path." 233 die "$_name not found in path."
234} 234}
235 235
236opsys_finish() 236opsys_finish()
237{ 237{
238 case "$opsys" in 238 case "$opsys" in
239 IRIX) 239 IRIX)
240 if [ -n "$imakeopts" ]; then 240 if [ -n "$imakeopts" ]; then
241 echo "IMAKEOPTS+= $imakeopts" >> ${TARGET_MKCONF} 241 echo "IMAKEOPTS+= $imakeopts" >> ${TARGET_MKCONF}
242 fi 242 fi
243 if [ `uname -r` -lt 6 ]; then 243 if [ `uname -r` -lt 6 ]; then
244 echo_msg "Installing fake ldd script" 244 echo_msg "Installing fake ldd script"
245 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/fakeldd $prefix/sbin" 245 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/fakeldd $prefix/sbin"
246 need_extras=yes 246 need_extras=yes
247 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF} 247 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF}
248 fi 248 fi
249 ;; 249 ;;
250 Haiku) 250 Haiku)
251 need_extras=yes 251 need_extras=yes
252 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF} 252 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF}
253 ;; 253 ;;
254 esac 254 esac
255} 255}
256 256
257is_root() 257is_root()
258{ 258{
259 if [ `uname -s` = "IRIX" ]; then 259 if [ `uname -s` = "IRIX" ]; then
260 if [ `uname -r` -lt 6 -a -z "$ID" ]; then 260 if [ `uname -r` -lt 6 -a -z "$ID" ]; then
261 # older version of IRIX have an id command with limited features 261 # older version of IRIX have an id command with limited features
262 if [ "`$idprog`" != "uid=0(root) gid=0(sys)" ]; then 262 if [ "`$idprog`" != "uid=0(root) gid=0(sys)" ]; then
263 return 1 263 return 1
264 fi 264 fi
265 return 0 265 return 0
266 fi 266 fi
267 fi 267 fi
268 if [ `$idprog -u` != 0 ]; then 268 if [ `$idprog -u` != 0 ]; then
269 return 1 269 return 1
270 fi 270 fi
271 return 0 271 return 0
272} 272}
273 273
274# run a command, abort if it fails 274# run a command, abort if it fails
275run_cmd() 275run_cmd()
276{ 276{
277 echo_msg "running: $*" 277 echo_msg "running: $*"
278 eval "$@" 278 eval "$@"
279 ret=$? 279 ret=$?
280 if [ $ret -ne 0 ]; then 280 if [ $ret -ne 0 ]; then
281 echo_msg "exited with status $ret" 281 echo_msg "exited with status $ret"
282 die "aborted." 282 die "aborted."
283 fi 283 fi
284} 284}
285 285
286# Some versions of mkdir (notably SunOS) bail out too easily, so use the 286# Some versions of mkdir (notably SunOS) bail out too easily, so use the
287# install-sh wrapper instead. 287# install-sh wrapper instead.
288mkdir_p() 288mkdir_p()
289{ 289{
290 for dir in "$@"; do 290 for dir in "$@"; do
291 run_cmd "$install_sh -d -o $user -g $group $dir" 291 run_cmd "$install_sh -d -o $user -g $group $dir"
292 done 292 done
293} 293}
294 294
295mkdir_p_early() 295mkdir_p_early()
296{ 296{
297 [ -d "$1" ] && return 0 297 [ -d "$1" ] && return 0
298 mkdir -p "$1" 2> /dev/null && return 0 298 mkdir -p "$1" 2> /dev/null && return 0
299 parent=`dirname "$1"` 299 parent=`dirname "$1"`
300 mkdir_p_early "$parent" 300 mkdir_p_early "$parent"
301 if [ ! -d "$1" ] && mkdir "$1"; then 301 if [ ! -d "$1" ] && mkdir "$1"; then
302 echo_msg "mkdir $1 exited with status $?" 302 echo_msg "mkdir $1 exited with status $?"
303 die "aborted." 303 die "aborted."
304 fi 304 fi
305 return 0 305 return 0
306} 306}
307 307
308copy_src() 308copy_src()
309{ 309{
310 _src="$1"; _dst="$2" 310 _src="$1"; _dst="$2"
311 if [ ! -d $wrkdir/$_dst ]; then 311 if [ ! -d $wrkdir/$_dst ]; then
312 mkdir_p $wrkdir/$_dst 312 mkdir_p $wrkdir/$_dst
313 fi 313 fi
314 $cpprog -r $_src/* $wrkdir/$_dst 314 $cpprog -r $_src/* $wrkdir/$_dst
315 if [ -f $wrkdir/$_dst/config.guess ]; then 315 if [ -f $wrkdir/$_dst/config.guess ]; then
316 $cpprog $pkgsrcdir/mk/gnu-config/config.guess $wrkdir/$_dst/ 316 $cpprog $pkgsrcdir/mk/gnu-config/config.guess $wrkdir/$_dst/
317 fi 317 fi
318 if [ -f $wrkdir/$_dst/config.sub ]; then 318 if [ -f $wrkdir/$_dst/config.sub ]; then
319 $cpprog $pkgsrcdir/mk/gnu-config/config.sub $wrkdir/$_dst/ 319 $cpprog $pkgsrcdir/mk/gnu-config/config.sub $wrkdir/$_dst/
320 fi 320 fi
321} 321}
322 322
323get_optarg() 323get_optarg()
324{ 324{
325 expr "x$1" : "x[^=]*=\\(.*\\)" 325 expr "x$1" : "x[^=]*=\\(.*\\)"
326} 326}
327 327
328# The --prefer-pkgsrc and --prefer native options require an argument,  328# The --prefer-pkgsrc and --prefer native options require an argument,
329# but our manual getopt parser is unable to detect the difference  329# but our manual getopt parser is unable to detect the difference
330# between a valid argument and the next getopt option (or no option  330# between a valid argument and the next getopt option (or no option
331# at all if it's the last). Ensure that the argument does not begin  331# at all if it's the last). Ensure that the argument does not begin
332# with "-" or is empty in case the user forgets to provide one. 332# with "-" or is empty in case the user forgets to provide one.
333checkarg_missing() 333checkarg_missing()
334{ 334{
335 case $1 in 335 case $1 in
336 -*|"") 336 -*|"")
337 die "ERROR: $2 takes yes, no or a list" 337 die "ERROR: $2 takes yes, no or a list"
338 ;; 338 ;;
339 esac 339 esac
340} 340}
341 341
342checkarg_sane_absolute_path() 342checkarg_sane_absolute_path()
343{ 343{
344 case "$1" in 344 case "$1" in
345 "") ;; # the default value will be used. 345 "") ;; # the default value will be used.
346 *[!-A-Za-z0-9_./]*) 346 *[!-A-Za-z0-9_./]*)
347 die "ERROR: Invalid characters in path $1 (from $2)." ;; 347 die "ERROR: Invalid characters in path $1 (from $2)." ;;
348 */) die "ERROR: The argument to $2 must not end in /." ;; 348 */) die "ERROR: The argument to $2 must not end in /." ;;
349 *//* | */. | */./* | */.. | */../*) 349 *//* | */. | */./* | */.. | */../*)
350 die "ERROR: The path $1 (from $2) must be canonical." ;; 350 die "ERROR: The path $1 (from $2) must be canonical." ;;
351 /*) checkarg_no_symlink_path "$1" "$2" ;; 351 /*) checkarg_no_symlink_path "$1" "$2" ;;
352 *) die "ERROR: The argument to $2 must be an absolute path." ;; 352 *) die "ERROR: The argument to $2 must be an absolute path." ;;
353 esac 353 esac
354} 354}
355 355
356checkarg_no_symlink_path() 356checkarg_no_symlink_path()
357{ 357{
358 _dir=$1 358 _dir=$1
359 while [ ! -d "$_dir" ]; do 359 while [ ! -d "$_dir" ]; do
360 _dir=`dirname "$_dir"` 360 _dir=`dirname "$_dir"`
361 [ "$_dir" ] || _dir="/" 361 [ "$_dir" ] || _dir="/"
362 done 362 done
363 363
364 _realdir=`cd "$_dir" && exec pwd` 364 _realdir=`cd "$_dir" && exec pwd`
365 [ "$_realdir" = "$_dir" ] && return 365 [ "$_realdir" = "$_dir" ] && return
366 366
367 die "ERROR: The path $1 (from $2) must not contain symlinks. 367 die "ERROR: The path $1 (from $2) must not contain symlinks.
368 368
369 Given path : $1 369 Given path : $1
370 Resolved path: $_realdir${1##${_dir}} 370 Resolved path: $_realdir${1##${_dir}}
371 371
372 Several packages assume that the given path of $2 stays the same 372 Several packages assume that the given path of $2 stays the same
373 when symlinks are resolved. When that assumption fails, they will: 373 when symlinks are resolved. When that assumption fails, they will:
374 374
375 * not find some include files or libraries during the build phase 375 * not find some include files or libraries during the build phase
376 since the files from dependencies are not installed in 376 since the files from dependencies are not installed in
377 \${WRKDIR}/.buildlink. 377 \${WRKDIR}/.buildlink.
378 378
379 * install their files into the wrong path inside \${WRKDIR}/.destdir, 379 * install their files into the wrong path inside \${WRKDIR}/.destdir,
380 which will fail the PLIST check during the install phase." 380 which will fail the PLIST check during the install phase."
381} 381}
382 382
383checkarg_sane_relative_path() { 383checkarg_sane_relative_path() {
384 case "$1" in 384 case "$1" in
385 "") ;; # the default value will be used. 385 "") ;; # the default value will be used.
386 *[!-A-Za-z0-9_./]*) 386 *[!-A-Za-z0-9_./]*)
387 die "ERROR: Invalid characters in path $1 (from $2)." ;; 387 die "ERROR: Invalid characters in path $1 (from $2)." ;;
388 /*) die "ERROR: The argument to $2 must be a relative path." ;; 388 /*) die "ERROR: The argument to $2 must be a relative path." ;;
389 *) ;; 389 *) ;;
390 esac 390 esac
391} 391}
392 392
393bootstrap_sh=${SH-/bin/sh} 393bootstrap_sh=${SH-/bin/sh}
394bootstrap_sh_set=${SH+set} 394bootstrap_sh_set=${SH+set}
395 395
396case "$bootstrap_sh" in 396case "$bootstrap_sh" in
397/*) 397/*)
398 ;; 398 ;;
399*) 399*)
400 die "ERROR: The variable SH must contain an absolute path" 400 die "ERROR: The variable SH must contain an absolute path"
401 ;; 401 ;;
402esac 402esac
403 403
404if [ -n "$PKG_PATH" ]; then 404if [ -n "$PKG_PATH" ]; then
405 die "ERROR: Please unset PKG_PATH before running bootstrap." 405 die "ERROR: Please unset PKG_PATH before running bootstrap."
406fi 406fi
407 407
408build_start=`date` 408build_start=`date`
409echo_msg "bootstrap command: $0 $*" 409echo_msg "bootstrap command: $0 $*"
410echo_msg "bootstrap started: $build_start" 410echo_msg "bootstrap started: $build_start"
411 411
412# ensure system locations are empty; we will set them later when we know 412# ensure system locations are empty; we will set them later when we know
413# whether they will be system wide or user specific 413# whether they will be system wide or user specific
414prefix= 414prefix=
415pkgdbdir= 415pkgdbdir=
416pkginfodir= 416pkginfodir=
417pkgmandir= 417pkgmandir=
418sysconfbase= 418sysconfbase=
419sysconfdir= 419sysconfdir=
420varbase= 420varbase=
421 421
422compiler="" 422compiler=""
423cwrappers=auto 423cwrappers=auto
424full=no 424full=no
425march= 425march=
426make_jobs=1 426make_jobs=1
427mk_fragment= 427mk_fragment=
428quiet=no 428quiet=no
429 429
430# Set these variables so that we can test whether they have been 430# Set these variables so that we can test whether they have been
431# correctly enabled by the user and not left empty 431# correctly enabled by the user and not left empty
432prefer_native=unset 432prefer_native=unset
433prefer_pkgsrc=unset 433prefer_pkgsrc=unset
434 434
435while [ $# -gt 0 ]; do 435while [ $# -gt 0 ]; do
436 case $1 in 436 case $1 in
437 --workdir=*) wrkdir=`get_optarg "$1"` ;; 437 --workdir=*) wrkdir=`get_optarg "$1"` ;;
438 --workdir) wrkdir="$2"; shift ;; 438 --workdir) wrkdir="$2"; shift ;;
439 --prefix=*) prefix=`get_optarg "$1"` ;; 439 --prefix=*) prefix=`get_optarg "$1"` ;;
440 --prefix) prefix="$2"; shift ;; 440 --prefix) prefix="$2"; shift ;;
441 --pkgdbdir=*) pkgdbdir=`get_optarg "$1"` ;; 441 --pkgdbdir=*) pkgdbdir=`get_optarg "$1"` ;;
442 --pkgdbdir) pkgdbdir="$2"; shift ;; 442 --pkgdbdir) pkgdbdir="$2"; shift ;;
443 --pkginfodir=*) pkginfodir=`get_optarg "$1"` ;; 443 --pkginfodir=*) pkginfodir=`get_optarg "$1"` ;;
444 --pkginfodir) pkginfodir="$2"; shift ;; 444 --pkginfodir) pkginfodir="$2"; shift ;;
445 --pkgmandir=*) pkgmandir=`get_optarg "$1"` ;; 445 --pkgmandir=*) pkgmandir=`get_optarg "$1"` ;;
446 --pkgmandir) pkgmandir="$2"; shift ;; 446 --pkgmandir) pkgmandir="$2"; shift ;;
447 --sysconfbase=*)sysconfbase=`get_optarg "$1"` ;; 447 --sysconfbase=*)sysconfbase=`get_optarg "$1"` ;;
448 --sysconfbase) sysconfbase="$2"; shift ;; 448 --sysconfbase) sysconfbase="$2"; shift ;;
449 --sysconfdir=*) sysconfdir=`get_optarg "$1"` ;; 449 --sysconfdir=*) sysconfdir=`get_optarg "$1"` ;;
450 --sysconfdir) sysconfdir="$2"; shift ;; 450 --sysconfdir) sysconfdir="$2"; shift ;;
451 --varbase=*) varbase=`get_optarg "$1"` ;; 451 --varbase=*) varbase=`get_optarg "$1"` ;;
452 --varbase) varbase="$2"; shift ;; 452 --varbase) varbase="$2"; shift ;;
453 --compiler=*) compiler=`get_optarg "$1"` ;; 453 --compiler=*) compiler=`get_optarg "$1"` ;;
454 --compiler) compiler="$2"; shift ;; 454 --compiler) compiler="$2"; shift ;;
455 --abi=*) abi=`get_optarg "$1"` ;; 455 --abi=*) abi=`get_optarg "$1"` ;;
456 --abi) abi="$2"; shift ;; 456 --abi) abi="$2"; shift ;;
457 --cwrappers=*) cwrappers=`get_optarg "$1"` ;; 457 --cwrappers=*) cwrappers=`get_optarg "$1"` ;;
458 --cwrappers) cwrappers="$2"; shift ;; 458 --cwrappers) cwrappers="$2"; shift ;;
459 --unprivileged | --ignore-user-check) unprivileged=yes ;; 459 --unprivileged | --ignore-user-check) unprivileged=yes ;;
460 --prefer-pkgsrc=*) 460 --prefer-pkgsrc=*)
461 prefer_pkgsrc=`get_optarg "$1"` ;; 461 prefer_pkgsrc=`get_optarg "$1"` ;;
462 --prefer-pkgsrc) 462 --prefer-pkgsrc)
463 prefer_pkgsrc="$2"; shift ;; 463 prefer_pkgsrc="$2"; shift ;;
464 --prefer-native=*) 464 --prefer-native=*)
465 prefer_native=`get_optarg "$1"` ;; 465 prefer_native=`get_optarg "$1"` ;;
466 --prefer-native) 466 --prefer-native)
467 prefer_native="$2"; shift ;; 467 prefer_native="$2"; shift ;;
468 --preserve-path) preserve_path=yes ;; 468 --preserve-path) preserve_path=yes ;;
469 --mk-fragment=*) 469 --mk-fragment=*)
470 mk_fragment=`get_optarg "$1"` ;; 470 mk_fragment=`get_optarg "$1"` ;;
471 --mk-fragment) 471 --mk-fragment)
472 mk_fragment="$2"; shift ;; 472 mk_fragment="$2"; shift ;;
473 --binary-kit=*) 473 --binary-kit=*)
474 binary_kit=`get_optarg "$1"` ;; 474 binary_kit=`get_optarg "$1"` ;;
475 --binary-kit) 475 --binary-kit)
476 binary_kit="$2"; shift ;; 476 binary_kit="$2"; shift ;;
477 --gzip-binary-kit=*) 477 --gzip-binary-kit=*)
478 binary_gzip_kit=`get_optarg "$1"` ;; 478 binary_gzip_kit=`get_optarg "$1"` ;;
479 --gzip-binary-kit) 479 --gzip-binary-kit)
480 binary_gzip_kit="$2"; shift ;; 480 binary_gzip_kit="$2"; shift ;;
481 --machine-arch=*) 481 --machine-arch=*)
482 march=`get_optarg "$1"` ;; 482 march=`get_optarg "$1"` ;;
483 --machine-arch) march="$2"; shift ;; 483 --machine-arch) march="$2"; shift ;;
484 --make-jobs=*) make_jobs=`get_optarg "$1"` ;; 484 --make-jobs=*) make_jobs=`get_optarg "$1"` ;;
485 --make-jobs) make_jobs="$2"; shift ;; 485 --make-jobs) make_jobs="$2"; shift ;;
486 --full) full=yes ;; 486 --full) full=yes ;;
487 --quiet) quiet=yes ;; 487 --quiet) quiet=yes ;;
488 --help) echo "$usage"; exit ;; 488 --help) echo "$usage"; exit ;;
489 -h) echo "$usage"; exit ;; 489 -h) echo "$usage"; exit ;;
490 -*) echo "${0##*/}: unknown option \"$1\"" 1>&2 490 -*) echo "${0##*/}: unknown option \"$1\"" 1>&2
491 echo "$usage" 1>&2; exit 1 ;; 491 echo "$usage" 1>&2; exit 1 ;;
492 esac 492 esac
493 shift 493 shift
494done 494done
495 495
496checkarg_sane_absolute_path "$pkgdbdir" "--pkgdbdir" 496checkarg_sane_absolute_path "$pkgdbdir" "--pkgdbdir"
497checkarg_sane_absolute_path "$sysconfbase" "--sysconfbase" 497checkarg_sane_absolute_path "$sysconfbase" "--sysconfbase"
498checkarg_sane_absolute_path "$sysconfdir" "--sysconfdir" 498checkarg_sane_absolute_path "$sysconfdir" "--sysconfdir"
499checkarg_sane_absolute_path "$varbase" "--varbase" 499checkarg_sane_absolute_path "$varbase" "--varbase"
500checkarg_sane_relative_path "$pkginfodir" "--pkginfodir" 500checkarg_sane_relative_path "$pkginfodir" "--pkginfodir"
501checkarg_sane_relative_path "$pkgmandir" "--pkgmandir" 501checkarg_sane_relative_path "$pkgmandir" "--pkgmandir"
502checkarg_sane_absolute_path "$wrkdir" "--workdir" 502checkarg_sane_absolute_path "$wrkdir" "--workdir"
503checkarg_missing "$prefer_pkgsrc" "--prefer-pkgsrc"  503checkarg_missing "$prefer_pkgsrc" "--prefer-pkgsrc"
504checkarg_missing "$prefer_native" "--prefer-native"  504checkarg_missing "$prefer_native" "--prefer-native"
505 505
506 506
507# set defaults for system locations if not already set by the user 507# set defaults for system locations if not already set by the user
508wrkobjdir=${wrkdir}/pkgsrc 508wrkobjdir=${wrkdir}/pkgsrc
509if [ "$unprivileged" = "yes" ]; then 509if [ "$unprivileged" = "yes" ]; then
510 [ -z "$prefix" ] && prefix=${HOME}/pkg 510 [ -z "$prefix" ] && prefix=${HOME}/pkg
511elif [ -z "$prefix" -o "$prefix" = "/usr/pkg" ]; then 511elif [ -z "$prefix" -o "$prefix" = "/usr/pkg" ]; then
512 prefix=/usr/pkg 512 prefix=/usr/pkg
513 [ -z "$sysconfbase" ] && sysconfbase=/etc 513 [ -z "$sysconfbase" ] && sysconfbase=/etc
514 [ -z "$varbase" ] && varbase=/var 514 [ -z "$varbase" ] && varbase=/var
515fi 515fi
516checkarg_sane_absolute_path "$prefix" "--prefix" 516checkarg_sane_absolute_path "$prefix" "--prefix"
517 517
518[ -z "$varbase" ] && varbase=${prefix}/var 518[ -z "$varbase" ] && varbase=${prefix}/var
519[ -z "$pkgdbdir" ] && pkgdbdir=${prefix}/pkgdb 519[ -z "$pkgdbdir" ] && pkgdbdir=${prefix}/pkgdb
520 520
521if [ "$prefix" = "/usr" ]; then 521if [ "$prefix" = "/usr" ]; then
522 [ -z "$pkginfodir" ] && pkginfodir=share/info 522 [ -z "$pkginfodir" ] && pkginfodir=share/info
523 [ -z "$pkgmandir" ] && pkgmandir=share/man 523 [ -z "$pkgmandir" ] && pkgmandir=share/man
524 [ -z "$sysconfbase" ] && sysconfbase=/etc 524 [ -z "$sysconfbase" ] && sysconfbase=/etc
525else 525else
526 [ -z "$pkginfodir" ] && pkginfodir=info 526 [ -z "$pkginfodir" ] && pkginfodir=info
527 [ -z "$pkgmandir" ] && pkgmandir=man 527 [ -z "$pkgmandir" ] && pkgmandir=man
528 [ -z "$sysconfbase" ] && sysconfbase=${prefix}/etc 528 [ -z "$sysconfbase" ] && sysconfbase=${prefix}/etc
529fi 529fi
530infodir=${prefix}/${pkginfodir} 530infodir=${prefix}/${pkginfodir}
531mandir=${prefix}/${pkgmandir} 531mandir=${prefix}/${pkgmandir}
532[ -z "$sysconfdir" ] && sysconfdir=${prefix}/etc 532[ -z "$sysconfdir" ] && sysconfdir=${prefix}/etc
533 533
534if [ "x$preserve_path" != "xyes" ]; then 534if [ "x$preserve_path" != "xyes" ]; then
535 PATH="$PATH:/sbin:/usr/sbin" 535 PATH="$PATH:/sbin:/usr/sbin"
536fi 536fi
537 537
538if [ "$prefer_native" = "unset" ]; then 538if [ "$prefer_native" = "unset" ]; then
539 prefer_native= 539 prefer_native=
540fi 540fi
541if [ "$prefer_pkgsrc" = "unset" ]; then 541if [ "$prefer_pkgsrc" = "unset" ]; then
542 prefer_pkgsrc= 542 prefer_pkgsrc=
543fi 543fi
544 544
545 545
546overpath="" 546overpath=""
547root_user=root 547root_user=root
548bmakexargs= 548bmakexargs=
549need_awk=no 549need_awk=no
550need_bsd_install=no 550need_bsd_install=no
551need_extras=no 551need_extras=no
552need_sed=no 552need_sed=no
553need_xargs=no 553need_xargs=no
554set_opsys=no 554set_opsys=no
555use_bsdinstall= 555use_bsdinstall=
556case "$opsys" in 556case "$opsys" in
557AIX) 557AIX)
558 root_group=system 558 root_group=system
559 need_bsd_install=yes 559 need_bsd_install=yes
560 need_awk=yes 560 need_awk=yes
561 need_sed=yes 561 need_sed=yes
562 need_ksh=yes 562 need_ksh=yes
563 need_fixed_strip=yes 563 need_fixed_strip=yes
564 machine_arch=`get_machine_arch_aix` 564 machine_arch=`get_machine_arch_aix`
565 ;; 565 ;;
566Bitrig) 566Bitrig)
567 root_group=wheel 567 root_group=wheel
568 machine_arch=`arch -s` 568 machine_arch=`arch -s`
569 check_compiler=yes 569 check_compiler=yes
570 ;; 570 ;;
571CYGWIN_*) 571CYGWIN_*)
572 is_root () { 572 is_root () {
573 if id -nG | grep -q 'Administrators'; then 573 if id -nG | grep -q 'Administrators'; then
574 return 0 574 return 0
575 fi 575 fi
576 return 1 576 return 1
577 } 577 }
578 root_user=Administrators 578 root_user=Administrators
579 root_group=Administrators 579 root_group=Administrators
580 opsys=`uname -o` 580 opsys=`uname -o`
581 need_sed=yes 581 need_sed=yes
582 machine_arch=`uname -m` 582 machine_arch=`uname -m`
583 # only used for unprivileged builds. 583 # only used for unprivileged builds.
584 whoamiprog='id -u' 584 whoamiprog='id -u'
585 groupsprog='id -g' 585 groupsprog='id -g'
586 ;; 586 ;;
587Darwin) 587Darwin)
588 root_group=wheel 588 root_group=wheel
589 machine_arch=`get_machine_arch_darwin` 589 machine_arch=`get_machine_arch_darwin`
590 CC=${CC:-"cc -isystem /usr/include"}; export CC 590 CC=${CC:-"cc -isystem /usr/include"}; export CC
591 check_compiler=yes 591 check_compiler=yes
592 592
593 # Combine major.minor product version for simpler numerical tests. 593 # Combine major.minor product version for simpler numerical tests.
594 macos_version=`sw_vers -productVersion | \ 594 macos_version=`sw_vers -productVersion | \
595 awk -F. '{ printf("%02d%02d", $1, $2) }'` 595 awk -F. '{ printf("%02d%02d", $1, $2) }'`
596 596
597 # Newer native sed does not support multibyte correctly. 597 # Newer native sed does not support multibyte correctly.
598 if [ $macos_version -ge 1008 ]; then 598 if [ $macos_version -ge 1008 ]; then
599 need_awk=yes 599 need_awk=yes
600 need_sed=yes 600 need_sed=yes
601 fi 601 fi
602 602
603 # Avoid system shells on macOS versions that enable System Integrity 603 # Avoid system shells on macOS versions that enable System Integrity
604 # Protection (SIP) as it affects packages that rely on variables such 604 # Protection (SIP) as it affects packages that rely on variables such
605 # as LD_LIBRARY_PATH. SIP unsets any variables that may affect 605 # as LD_LIBRARY_PATH. SIP unsets any variables that may affect
606 # security when using system binaries, i.e. /bin/*sh, but using a 606 # security when using system binaries, i.e. /bin/*sh, but using a
607 # non-system shell is unaffected, at least for now. 607 # non-system shell is unaffected, at least for now.
608 if [ $macos_version -ge 1011 ]; then 608 if [ $macos_version -ge 1011 ]; then
609 need_mksh=yes 609 need_mksh=yes
610 fi 610 fi
611 611
612 unset macos_version 612 unset macos_version
613 ;; 613 ;;
614DragonFly) 614DragonFly)
615 root_group=wheel 615 root_group=wheel
616 check_prog tarprog tar 616 check_prog tarprog tar
617 machine_arch=`uname -p` 617 machine_arch=`uname -p`
618 ;; 618 ;;
619FreeBSD) 619FreeBSD)
620 root_group=wheel 620 root_group=wheel
621 machine_arch=`uname -p` 621 machine_arch=`uname -p`
622 check_compiler=yes 622 check_compiler=yes
623 ;; 623 ;;
624FreeMiNT) 624FreeMiNT)
625 root_group=root 625 root_group=root
626 machine_arch=m68k 626 machine_arch=m68k
627 ;; 627 ;;
628GNUkFreeBSD) 628GNUkFreeBSD)
629 root_group=root 629 root_group=root
630 need_awk=yes 630 need_awk=yes
631 machine_arch=`uname -m` 631 machine_arch=`uname -m`
632 ;; 632 ;;
633Haiku) 633Haiku)
634 root_user=`id -un` 634 root_user=`id -un`
635 root_group=root 635 root_group=root
636 case `uname -m` in 636 case `uname -m` in
637 BeMac) 637 BeMac)
638 machine_arch=powerpc 638 machine_arch=powerpc
639 ;; 639 ;;
640 BePC) 640 BePC)
641 machine_arch=i386 641 machine_arch=i386
642 ;; 642 ;;
643 *) 643 *)
644 machine_arch=`uname -p` 644 machine_arch=`uname -p`
645 ;; 645 ;;
646 esac 646 esac
647 ;; 647 ;;
648HPUX) 648HPUX)
649 root_group=sys 649 root_group=sys
650 need_bsd_install=yes 650 need_bsd_install=yes
651 need_awk=yes 651 need_awk=yes
652 need_sed=yes 652 need_sed=yes
653 machine_arch=`uname -m | sed 's/^9000.*$/hppa/'` 653 machine_arch=`uname -m | sed 's/^9000.*$/hppa/'`
654 ;; 654 ;;
655Interix) 655Interix)
656 is_root () { 656 is_root () {
657 if id -G | grep -q 131616; then 657 if id -G | grep -q 131616; then
658 return 0 658 return 0
659 fi 659 fi
660 return 1 660 return 1
661 } 661 }
662 mkdir_p () { 662 mkdir_p () {
663 mkdir -p "$@" # allows umask to take effect 663 mkdir -p "$@" # allows umask to take effect
664 } 664 }
665 default_install_mode=0775 665 default_install_mode=0775
666 root_user=`id -un` 666 root_user=`id -un`
667 root_group=+Administrators 667 root_group=+Administrators
668 case `uname -r` in 668 case `uname -r` in
669 3.* | 5.*) 669 3.* | 5.*)
670 need_bsd_install=yes 670 need_bsd_install=yes
671 need_awk=yes 671 need_awk=yes
672 need_sed=yes 672 need_sed=yes
673 need_xargs=yes 673 need_xargs=yes
674 ;; 674 ;;
675 esac 675 esac
676 # only used for unprivileged builds 676 # only used for unprivileged builds
677 groupsprog="id -gn" 677 groupsprog="id -gn"
678 # for bootstrap only; pkgsrc uses CPPFLAGS 678 # for bootstrap only; pkgsrc uses CPPFLAGS
679 CC="gcc -D_ALL_SOURCE"; export CC 679 CC="gcc -D_ALL_SOURCE"; export CC
680 ac_cv_header_poll_h=no; export ac_cv_header_poll_h 680 ac_cv_header_poll_h=no; export ac_cv_header_poll_h
681 ac_cv_func_poll=no; export ac_cv_func_poll 681 ac_cv_func_poll=no; export ac_cv_func_poll
682 ;; 682 ;;
683IRIX*) 683IRIX*)
684 if [ -d "/usr/freeware/bin" ]; then 684 if [ -d "/usr/freeware/bin" ]; then
685 overpath="/usr/freeware/bin:$overpath" 685 overpath="/usr/freeware/bin:$overpath"
686 fi 686 fi
687 if [ -d "/usr/bsd" ]; then 687 if [ -d "/usr/bsd" ]; then
688 overpath="/usr/bsd:$overpath" 688 overpath="/usr/bsd:$overpath"
689 fi 689 fi
690 if [ -d "/usr/bsd/bin" ]; then 690 if [ -d "/usr/bsd/bin" ]; then
691 overpath="/usr/bsd/bin:$overpath" 691 overpath="/usr/bsd/bin:$overpath"
692 fi 692 fi
693 root_group=sys 693 root_group=sys
694 need_bsd_install=yes 694 need_bsd_install=yes
695 get_abi "IRIX" 695 get_abi "IRIX"
696 opsys=IRIX 696 opsys=IRIX
697 need_awk=yes 697 need_awk=yes
698 need_sed=yes 698 need_sed=yes
699 set_opsys=yes 699 set_opsys=yes
700 machine_arch=mipseb 700 machine_arch=mipseb
701 check_compiler=yes 701 check_compiler=yes
702 if [ `uname -r` -lt 6 ]; then 702 if [ `uname -r` -lt 6 ]; then
703# IRIX 5's mkdir bails out with an error when trying to create with the -p 703# IRIX 5's mkdir bails out with an error when trying to create with the -p
704# option an already existing directory 704# option an already existing directory
705 need_mkdir=yes 705 need_mkdir=yes
706 fi 706 fi
707 ;; 707 ;;
708Linux) 708Linux)
709 if [ -f /etc/ssdlinux_version ]; then 709 if [ -f /etc/ssdlinux_version ]; then
710 root_group=wheel 710 root_group=wheel
711 else 711 else
712 root_group=root 712 root_group=root
713 fi 713 fi
714 # Debian/Ubuntu's awk is mawk, and mawk does not understand 714 # Debian/Ubuntu's awk is mawk, and mawk does not understand
715 # some regexp used in pkgsrc/mk. 715 # some regexp used in pkgsrc/mk.
716 if [ -f /etc/debian_version ]; then 716 if [ -f /etc/debian_version ]; then
717 need_awk=yes 717 need_awk=yes
718 # Arch uses gawk 5 that breaks some regexps. It doesn't provide pax 718 # Arch uses gawk 5 that breaks some regexps. It doesn't provide pax
719 # anymore. 719 # anymore.
720 elif [ -f /etc/arch-release ]; then 720 elif [ -f /etc/arch-release ]; then
721 need_awk=yes 721 need_awk=yes
722 need_pax=yes 722 need_pax=yes
723 elif grep -sq '^CHROMEOS_RELEASE_NAME' /etc/lsb-release; then 723 elif grep -sq '^CHROMEOS_RELEASE_NAME' /etc/lsb-release; then
724 need_awk=yes 724 need_awk=yes
725 need_sed=yes 725 need_sed=yes
726 fi 726 fi
727 machine_arch=`uname -m` 727 machine_arch=`uname -m`
728 # Override machine_arch where required. 728 # Override machine_arch where required.
729 case "$machine_arch" in 729 case "$machine_arch" in
730 i?86) machine_arch=i386 ;; 730 i?86) machine_arch=i386 ;;
731 ppc64le) machine_arch=powerpc64le ;; 731 ppc64le) machine_arch=powerpc64le ;;
732 esac 732 esac
733 ;; 733 ;;
734MidnightBSD) 734MidnightBSD)
735 root_group=wheel 735 root_group=wheel
736 machine_arch=`uname -p` 736 machine_arch=`uname -p`
737 check_compiler=yes 737 check_compiler=yes
738 ;; 738 ;;
739Minix) 739Minix)
740 root_group=wheel 740 root_group=wheel
741 machine_arch=`uname -p` 741 machine_arch=`uname -p`
742 check_compiler=yes 742 check_compiler=yes
743 ;;  743 ;;
744MirBSD) 744MirBSD)
745 root_group=wheel 745 root_group=wheel
746 need_pax=yes 746 need_pax=yes
747 machine_arch=`arch -s` 747 machine_arch=`arch -s`
748 # there is no /usr/bin/cc, so use mgcc if unset 748 # there is no /usr/bin/cc, so use mgcc if unset
749 test -n "$CC" || { CC=mgcc; export CC; } 749 test -n "$CC" || { CC=mgcc; export CC; }
750 # get some variables from the native make if unset 750 # get some variables from the native make if unset
751 for var in CFLAGS CPPFLAGS LDFLAGS; do 751 for var in CFLAGS CPPFLAGS LDFLAGS; do
752 # check if variable is already set 752 # check if variable is already set
753 eval _tmp=\"\$$var\" 753 eval _tmp=\"\$$var\"
754 [ "x$_tmp" != x ] && continue 754 [ "x$_tmp" != x ] && continue
755 # ask the native make (EXPERIMENTAL = don't add -Werror) 755 # ask the native make (EXPERIMENTAL = don't add -Werror)
756 # the -I${.CURDIR} dance is to prevent junk in CPPFLAGS 756 # the -I${.CURDIR} dance is to prevent junk in CPPFLAGS
757 _tmp=`printf '%s\nall:\n\t@%s %%s %s=${%s:M*:Q:Q}\n%s\n%s\n' \ 757 _tmp=`printf '%s\nall:\n\t@%s %%s %s=${%s:M*:Q:Q}\n%s\n%s\n' \
758 $var'+=-I${.CURDIR}' printf $var $var':S/-I${.CURDIR}//' \ 758 $var'+=-I${.CURDIR}' printf $var $var':S/-I${.CURDIR}//' \
759 EXPERIMENTAL=yes '.include <bsd.prog.mk>' | \ 759 EXPERIMENTAL=yes '.include <bsd.prog.mk>' | \
760 (unset MAKECONF; /usr/bin/make -f - all 2>/dev/null) | \ 760 (unset MAKECONF; /usr/bin/make -f - all 2>/dev/null) | \
761 sed 's/^x//'` 761 sed 's/^x//'`
762 eval $_tmp 762 eval $_tmp
763 eval export $var 763 eval export $var
764 done 764 done
765 ;; 765 ;;
766NetBSD) 766NetBSD)
767 root_group=wheel 767 root_group=wheel
768 machine_arch=`uname -p` 768 machine_arch=`uname -p`
769 ;; 769 ;;
770OpenBSD) 770OpenBSD)
771 root_group=wheel 771 root_group=wheel
772 machine_arch=`arch -s` 772 machine_arch=`arch -s`
773 CC=${CC:-cc}; export CC 773 CC=${CC:-cc}; export CC
774 check_compiler=yes 774 check_compiler=yes
775 ;; 775 ;;
776OSF1) 776OSF1)
777 root_group=system 777 root_group=system
778 need_bsd_install=yes 778 need_bsd_install=yes
779 need_awk=yes 779 need_awk=yes
780 need_sed=yes 780 need_sed=yes
781 need_mksh=yes 781 need_mksh=yes
782 machine_arch=`uname -p` 782 machine_arch=`uname -p`
783 ;; 783 ;;
784QNX) 784QNX)
785 root_group=root 785 root_group=root
786 need_bsd_install=yes 786 need_bsd_install=yes
787 need_awk=yes 787 need_awk=yes
788 need_sed=yes 788 need_sed=yes
789 groupsprog="id -gn" 789 groupsprog="id -gn"
790 whoamiprog="id -un" 790 whoamiprog="id -un"
791 machine_arch=`uname -p | sed -e 's/x86/i386/'` 791 machine_arch=`uname -p | sed -e 's/x86/i386/'`
792 # libarchive checks for "rm -f" with no arguments being accepted. This 792 # libarchive checks for "rm -f" with no arguments being accepted. This
793 # does not work on QNX. Interestingly, libarchive doesn't seem to 793 # does not work on QNX. Interestingly, libarchive doesn't seem to
794 # actually need it during the build. 794 # actually need it during the build.
795 export ACCEPT_INFERIOR_RM_PROGRAM=yes 795 export ACCEPT_INFERIOR_RM_PROGRAM=yes
796 ;; 796 ;;
797SCO_SV) 797SCO_SV)
798 root_group=root 798 root_group=root
799 need_awk=yes 799 need_awk=yes
800 need_bsd_install=yes 800 need_bsd_install=yes
801 need_sed=yes 801 need_sed=yes
802 whoamiprog='id -u' 802 whoamiprog='id -u'
803 groupsprog='id -g' 803 groupsprog='id -g'
804 # /bin/sh under OpenServer 5.0.7/3.2 breaks bmake tests. 804 # /bin/sh under OpenServer 5.0.7/3.2 breaks bmake tests.
805 #bmakexargs="$bmakexargs --with-defshell=/bin/ksh" 805 #bmakexargs="$bmakexargs --with-defshell=/bin/ksh"
806 ;; 806 ;;
807SunOS) 807SunOS)
808 root_group=root 808 root_group=root
809 need_bsd_install=yes 809 need_bsd_install=yes
810 use_bsdinstall=yes 810 use_bsdinstall=yes
811 if [ ! -x "/usr/gnu/bin/awk" ]; then 811 if [ ! -x "/usr/gnu/bin/awk" ]; then
812 need_awk=yes 812 need_awk=yes
813 fi 813 fi
814 if [ ! -x "/usr/gnu/bin/sed" ]; then 814 if [ ! -x "/usr/gnu/bin/sed" ]; then
815 need_sed=yes 815 need_sed=yes
816 fi 816 fi
817 if [ -x "/usr/bin/bash" ]; then 817 if [ -x "/usr/bin/bash" ]; then
818 bootstrap_sh=${SH:-/usr/bin/bash} 818 bootstrap_sh=${SH:-/usr/bin/bash}
819 bootstrap_sh_set=set 819 bootstrap_sh_set=set
820 else 820 else
821 need_mksh=yes 821 need_mksh=yes
822 fi 822 fi
823 idprog="/usr/xpg4/bin/id" 823 idprog="/usr/xpg4/bin/id"
824 groupsprog="${idprog} -gn" 824 groupsprog="${idprog} -gn"
825 whoamiprog="${idprog} -un" 825 whoamiprog="${idprog} -un"
826 machine_arch=`isainfo -k` 826 machine_arch=`isainfo -k`
827 check_compiler=yes 827 check_compiler=yes
828 check_ssp=yes 828 check_ssp=yes
829 ;; 829 ;;
830UnixWare) 830UnixWare)
831 root_group=sys 831 root_group=sys
832 BSTRAP_ENV="INSTALL=/usr/ucb/install $BSTRAP_ENV" 832 BSTRAP_ENV="INSTALL=/usr/ucb/install $BSTRAP_ENV"
833 need_mkdir=yes 833 need_mkdir=yes
834 need_awk=yes 834 need_awk=yes
835 need_sed=yes 835 need_sed=yes
836 whoamiprog=/usr/ucb/whoami 836 whoamiprog=/usr/ucb/whoami
837 machine_arch=`uname -m` 837 machine_arch=`uname -m`
838 CC="gcc -DUNIXWARE"; export CC 838 CC="gcc -DUNIXWARE"; export CC
839 ;; 839 ;;
840*) 840*)
841 echo "This platform ($opsys) is untried - good luck, and thanks for using pkgsrc" 841 echo "This platform ($opsys) is untried - good luck, and thanks for using pkgsrc"
842 root_group=wheel 842 root_group=wheel
843 need_bsd_install=yes 843 need_bsd_install=yes
844 need_awk=yes 844 need_awk=yes
845 need_sed=yes 845 need_sed=yes
846 ;; 846 ;;
847esac 847esac
848 848
849# Override if the user explicitly requests it. 849# Override if the user explicitly requests it.
850if [ -n "${march}" ]; then 850if [ -n "${march}" ]; then
851 machine_arch="${march}" 851 machine_arch="${march}"
852fi 852fi
853 853
854# Fixup MACHINE_ARCH to use canonical pkgsrc variants, and support multiarch 854# Fixup MACHINE_ARCH to use canonical pkgsrc variants, and support multiarch
855# systems via --abi, setting a default $abi based on MACHINE_ARCH if not set. 855# systems via --abi, setting a default $abi based on MACHINE_ARCH if not set.
856# 856#
857case "$machine_arch/$abi" in 857case "$machine_arch/$abi" in
858# "amd64" translates to "x86_64", defaults to 64-bit 858# "amd64" translates to "x86_64", defaults to 64-bit
859amd64/32) abi=32 machine_arch=i386 ;; 859amd64/32) abi=32 machine_arch=i386 ;;
860amd64/*) abi=64 machine_arch=x86_64 ;; 860amd64/*) abi=64 machine_arch=x86_64 ;;
861# XXX: hppa untested 861# XXX: hppa untested
862hppa/64) abi=64 machine_arch=hppa64 ;; 862hppa/64) abi=64 machine_arch=hppa64 ;;
863hppa/*) abi=32 machine_arch=hppa ;; 863hppa/*) abi=32 machine_arch=hppa ;;
864hppa64/32) abi=32 machine_arch=hppa ;; 864hppa64/32) abi=32 machine_arch=hppa ;;
865hppa64/*) abi=64 machine_arch=hppa64 ;; 865hppa64/*) abi=64 machine_arch=hppa64 ;;
866# "i386" can support 64-bit, e.g. SunOS, defaults to 32-bit. 866# "i386" can support 64-bit, e.g. SunOS, defaults to 32-bit.
867i386/64) abi=64 machine_arch=x86_64 ;; 867i386/64) abi=64 machine_arch=x86_64 ;;
868i386/*) abi=32 machine_arch=i386 ;; 868i386/*) abi=32 machine_arch=i386 ;;
869# XXX: powerpc untested 869# XXX: powerpc untested
870powerpc/64) abi=64 machine_arch=powerpc64 ;; 870powerpc/64) abi=64 machine_arch=powerpc64 ;;
871powerpc/*) abi=32 machine_arch=powerpc ;; 871powerpc/*) abi=32 machine_arch=powerpc ;;
872powerpc64/32) abi=32 machine_arch=powerpc ;; 872powerpc64/32) abi=32 machine_arch=powerpc ;;
873powerpc64/*) abi=64 machine_arch=powerpc64 ;; 873powerpc64/*) abi=64 machine_arch=powerpc64 ;;
874powerpc64le/*) abi=64 machine_arch=powerpc64le;; 874powerpc64le/*) abi=64 machine_arch=powerpc64le;;
875# sparc/sparcv9 support 32-bit/64-bit, default to native. 875# sparc/sparcv9 support 32-bit/64-bit, default to native.
876sparcv9/32) abi=32 machine_arch=sparc ;; 876sparcv9/32) abi=32 machine_arch=sparc ;;
877sparcv9/*) abi=64 machine_arch=sparc64 ;; 877sparcv9/*) abi=64 machine_arch=sparc64 ;;
878sparc/64) abi=64 machine_arch=sparc64 ;; 878sparc/64) abi=64 machine_arch=sparc64 ;;
879sparc/*) abi=32 machine_arch=sparc ;; 879sparc/*) abi=32 machine_arch=sparc ;;
880# x86_64 supports 32-bit/64-bit, defaults to 64-bit. 880# x86_64 supports 32-bit/64-bit, defaults to 64-bit.
881x86_64/32) abi=32 machine_arch=i386 ;; 881x86_64/32) abi=32 machine_arch=i386 ;;
882x86_64/*) abi=64 machine_arch=x86_64 ;; 882x86_64/*) abi=64 machine_arch=x86_64 ;;
883esac 883esac
884 884
885# If "--full" is specified, then install all of the platform-independent 885# If "--full" is specified, then install all of the platform-independent
886# bootstrap software. 886# bootstrap software.
887# 887#
888case "$full" in 888case "$full" in
889yes) 889yes)
890 need_bsd_install=yes 890 need_bsd_install=yes
891 need_awk=yes 891 need_awk=yes
892 need_sed=yes 892 need_sed=yes
893 need_mksh=yes 893 need_mksh=yes
894 ;; 894 ;;
895esac 895esac
896 896
897# mksh and ksh are mutually exclusive, prefer mksh while we transition to it. 897# mksh and ksh are mutually exclusive, prefer mksh while we transition to it.
898case "$need_mksh" in 898case "$need_mksh" in
899yes) need_ksh=no ;; 899yes) need_ksh=no ;;
900esac 900esac
901 901
902case "$quiet" in 902case "$quiet" in
903yes) 903yes)
904 configure_quiet_flags="--quiet" 904 configure_quiet_flags="--quiet"
905 make_quiet_flags="-s" 905 make_quiet_flags="-s"
906 ;; 906 ;;
907no) 907no)
908 configure_quiet_flags="" 908 configure_quiet_flags=""
909 make_quiet_flags="" 909 make_quiet_flags=""
910esac 910esac
911 911
912test ${make_jobs} -gt 0 2>/dev/null 912test ${make_jobs} -gt 0 2>/dev/null
913if [ $? -ne 0 ]; then 913if [ $? -ne 0 ]; then
914 die "ERROR: --make-jobs must be a positive integer argument" 914 die "ERROR: --make-jobs must be a positive integer argument"
915fi 915fi
916 916
917# export MACHINE_ARCH and OPSYS for bmake and pkg_install. 917# export MACHINE_ARCH and OPSYS for bmake and pkg_install.
918MACHINE_ARCH=${machine_arch}; export MACHINE_ARCH 918MACHINE_ARCH=${machine_arch}; export MACHINE_ARCH
919OPSYS=${opsys}; export OPSYS 919OPSYS=${opsys}; export OPSYS
920 920
921if [ "x$preserve_path" != "xyes" ]; then 921if [ "x$preserve_path" != "xyes" ]; then
922 PATH="$overpath:$PATH" 922 PATH="$overpath:$PATH"
923fi 923fi
924 924
925check_prog awkprog awk 925check_prog awkprog awk
926check_prog chmodprog chmod 926check_prog chmodprog chmod
927if [ -n "$CP" ]; then 927if [ -n "$CP" ]; then
928 cpprog="$CP" 928 cpprog="$CP"
929else 929else
930 check_prog cpprog cp 930 check_prog cpprog cp
931fi 931fi
932if [ -n "$ID" ]; then 932if [ -n "$ID" ]; then
933 idprog="$ID" 933 idprog="$ID"
934else 934else
935 check_prog idprog id 935 check_prog idprog id
936fi 936fi
937check_prog groupsprog groups 937check_prog groupsprog groups
938check_prog lnprog ln 938check_prog lnprog ln
939check_prog lsprog ls 939check_prog lsprog ls
940check_prog rmdirprog rmdir 940check_prog rmdirprog rmdir
941check_prog sedprog sed 941check_prog sedprog sed
942check_prog shprog sh 942check_prog shprog sh
943check_prog whoamiprog whoami 943check_prog whoamiprog whoami
944 944
945if [ -d "${wrkdir}" ] || [ -f "${wrkdir}" ]; then 945if [ -d "${wrkdir}" ] || [ -f "${wrkdir}" ]; then
946 die "\"${wrkdir}\" already exists, please remove it or use --workdir" 946 die "\"${wrkdir}\" already exists, please remove it or use --workdir"
947fi 947fi
948 948
949if [ -f "${prefix}/share/mk/sys.mk" ]; then 949if [ -f "${prefix}/share/mk/sys.mk" ]; then
950 die "\"${prefix}\" already in use, remove it or use a different --prefix" 950 die "\"${prefix}\" already in use, remove it or use a different --prefix"
951fi 951fi
952 952
953if [ -d "${pkgdbdir}/bootstrap-mk-files-"* ]; then 953if [ -d "${pkgdbdir}/bootstrap-mk-files-"* ]; then
954 die "\"${pkgdbdir}\" already in use, remove it or use a different --pkgdbdir" 954 die "\"${pkgdbdir}\" already in use, remove it or use a different --pkgdbdir"
955fi 955fi
956 956
957mkdir_p_early ${wrkdir} 957mkdir_p_early ${wrkdir}
958if touch ${wrkdir}/.writeable; then 958if touch ${wrkdir}/.writeable; then
959 : 959 :
960else 960else
961 die "\"${wrkdir}\" is not writeable. Try $0 -h" 961 die "\"${wrkdir}\" is not writeable. Try $0 -h"
962fi 962fi
963echo "Working directory is: ${wrkdir}" 963echo "Working directory is: ${wrkdir}"
964 964
965if [ "$compiler" = "" ] && [ x"$check_compiler" = x"yes" ]; then 965if [ "$compiler" = "" ] && [ x"$check_compiler" = x"yes" ]; then
966 get_compiler 966 get_compiler
967 # Clang pretends to be GCC, so we have to check it first. 967 # Clang pretends to be GCC, so we have to check it first.
968 if [ $compiler_is_clang -gt 0 ]; then 968 if [ $compiler_is_clang -gt 0 ]; then
969 compiler="clang" 969 compiler="clang"
970 elif [ $compiler_is_gnu -gt 0 ]; then 970 elif [ $compiler_is_gnu -gt 0 ]; then
971 compiler="gcc" 971 compiler="gcc"
972 else 972 else
973 case "$opsys" in 973 case "$opsys" in
974 IRIX) 974 IRIX)
975 if [ `uname -r` -ge 6 ]; then 975 if [ `uname -r` -ge 6 ]; then
976 compiler="mipspro" 976 compiler="mipspro"
977 else 977 else
978 compiler="ido" 978 compiler="ido"
979 fi 979 fi
980 ;; 980 ;;
981 SunOS) compiler="sunpro" 981 SunOS) compiler="sunpro"
982 ;; 982 ;;
983 esac 983 esac
984 fi 984 fi
985fi 985fi
986 986
987case "$compiler" in 987case "$compiler" in
988clang|gcc) 988clang|gcc)
989 test -n "$CC" || CC=$compiler 989 test -n "$CC" || CC=$compiler
990 ;; 990 ;;
991*) 991*)
992 test -n "$CC" || CC=cc 992 test -n "$CC" || CC=cc
993 ;; 993 ;;
994esac 994esac
995 995
996has_ssp_support() { 996has_ssp_support() {
997 mkdir_p_early ${wrkdir}/tmp 997 mkdir_p_early ${wrkdir}/tmp
998 echo 'int main(void){return 0;}' > ${wrkdir}/tmp/ssp.c 998 echo 'int main(void){return 0;}' > ${wrkdir}/tmp/ssp.c
999 ${CC:-cc} -fstack-protector-strong -o ${wrkdir}/tmp/ssp ${wrkdir}/tmp/ssp.c >/dev/null 2>&1 999 ${CC:-cc} -fstack-protector-strong -o ${wrkdir}/tmp/ssp ${wrkdir}/tmp/ssp.c >/dev/null 2>&1
1000 1000
1001 if [ $? -eq 0 ]; then 1001 if [ $? -eq 0 ]; then
1002 echo yes 1002 echo yes
1003 else 1003 else
1004 echo no 1004 echo no
1005 fi 1005 fi
1006} 1006}
1007 1007
1008if [ "$has_ssp" = "" ] && [ x"$check_ssp" = x"yes" ]; then 1008if [ "$has_ssp" = "" ] && [ x"$check_ssp" = x"yes" ]; then
1009 has_ssp=`has_ssp_support` 1009 has_ssp=`has_ssp_support`
1010fi 1010fi
1011 1011
1012mkdir_p_early ${wrkdir}/bin 1012mkdir_p_early ${wrkdir}/bin
1013 1013
1014# build install-sh 1014# build install-sh
1015run_cmd "$sedprog -e 's|@DEFAULT_INSTALL_MODE@|'${default_install_mode-0755}'|' $pkgsrcdir/sysutils/install-sh/files/install-sh.in > $wrkdir/bin/install-sh" 1015run_cmd "$sedprog -e 's|@DEFAULT_INSTALL_MODE@|'${default_install_mode-0755}'|' $pkgsrcdir/sysutils/install-sh/files/install-sh.in > $wrkdir/bin/install-sh"
1016run_cmd "$chmodprog +x $wrkdir/bin/install-sh" 1016run_cmd "$chmodprog +x $wrkdir/bin/install-sh"
1017install_sh="$shprog $wrkdir/bin/install-sh" 1017install_sh="$shprog $wrkdir/bin/install-sh"
1018 1018
1019if [ $unprivileged = "yes" ]; then 1019if [ $unprivileged = "yes" ]; then
1020 user=`$whoamiprog` 1020 user=`$whoamiprog`
1021 group=`$groupsprog | $awkprog '{print $1}'` 1021 group=`$groupsprog | $awkprog '{print $1}'`
1022 echo_msg "building as unprivileged user $user/$group" 1022 echo_msg "building as unprivileged user $user/$group"
1023 1023
1024 # force bmake install target to use $user and $group 1024 # force bmake install target to use $user and $group
1025 echo "BINOWN=$user 1025 echo "BINOWN=$user
1026BINGRP=$group 1026BINGRP=$group
1027LIBOWN=$user 1027LIBOWN=$user
1028LIBGRP=$group 1028LIBGRP=$group
1029MANOWN=$user 1029MANOWN=$user
1030MANGRP=$group" > ${wrkdir}/Makefile.inc 1030MANGRP=$group" > ${wrkdir}/Makefile.inc
1031elif is_root; then 1031elif is_root; then
1032 user=$root_user 1032 user=$root_user
1033 group=$root_group 1033 group=$root_group
1034else 1034else
1035 die "You must be either root to install bootstrap-pkgsrc or use the --unprivileged option." 1035 die "You must be either root to install bootstrap-pkgsrc or use the --unprivileged option."
1036fi 1036fi
1037 1037
1038# export the proper environment 1038# export the proper environment
1039PATH=$prefix/bin:$prefix/sbin:${PATH}; export PATH 1039PATH=$prefix/bin:$prefix/sbin:${PATH}; export PATH
1040if [ -d /usr/ccs/bin -a -x /usr/ccs/bin/make ]; then 1040if [ -d /usr/ccs/bin -a -x /usr/ccs/bin/make ]; then
1041 PATH=${PATH}:/usr/ccs/bin; export PATH 1041 PATH=${PATH}:/usr/ccs/bin; export PATH
1042fi 1042fi
1043PKG_DBDIR=$pkgdbdir; export PKG_DBDIR 1043PKG_DBDIR=$pkgdbdir; export PKG_DBDIR
1044LOCALBASE=$prefix; export LOCALBASE 1044LOCALBASE=$prefix; export LOCALBASE
1045VARBASE=$varbase; export VARBASE 1045VARBASE=$varbase; export VARBASE
1046if [ x"$has_ssp" = x"no" ] && [ x"$check_ssp" = x"yes" ]; then 1046if [ x"$has_ssp" = x"no" ] && [ x"$check_ssp" = x"yes" ]; then
1047_OPSYS_SUPPORTS_SSP=no; export _OPSYS_SUPPORTS_SSP 1047_OPSYS_SUPPORTS_SSP=no; export _OPSYS_SUPPORTS_SSP
1048fi 1048fi
1049 1049
1050# set up an example mk.conf file 1050# set up an example mk.conf file
1051TARGET_MKCONF=${wrkdir}/mk.conf.example 1051TARGET_MKCONF=${wrkdir}/mk.conf.example
1052echo_msg "Creating default mk.conf in ${wrkdir}" 1052echo_msg "Creating default mk.conf in ${wrkdir}"
1053echo "# Example ${sysconfdir}/mk.conf file produced by bootstrap-pkgsrc" > ${TARGET_MKCONF} 1053echo "# Example ${sysconfdir}/mk.conf file produced by bootstrap-pkgsrc" > ${TARGET_MKCONF}
1054echo "# `date`" >> ${TARGET_MKCONF} 1054echo "# `date`" >> ${TARGET_MKCONF}
1055echo "" >> ${TARGET_MKCONF} 1055echo "" >> ${TARGET_MKCONF}
1056echo ".ifdef BSD_PKG_MK # begin pkgsrc settings" >> ${TARGET_MKCONF} 1056echo ".ifdef BSD_PKG_MK # begin pkgsrc settings" >> ${TARGET_MKCONF}
1057echo "" >> ${TARGET_MKCONF} 1057echo "" >> ${TARGET_MKCONF}
1058 1058
1059# IRIX64 needs to be set to IRIX, for example 1059# IRIX64 needs to be set to IRIX, for example
1060if [ "$set_opsys" = "yes" ]; then 1060if [ "$set_opsys" = "yes" ]; then
1061 echo "OPSYS= $opsys" >> ${TARGET_MKCONF} 1061 echo "OPSYS= $opsys" >> ${TARGET_MKCONF}
1062fi 1062fi
1063 1063
1064if [ -n "$abi" ]; then 1064if [ -n "$abi" ]; then
1065 echo "ABI= $abi" >> ${TARGET_MKCONF} 1065 echo "ABI= $abi" >> ${TARGET_MKCONF}
1066fi 1066fi
1067if [ "$compiler" != "" ]; then 1067if [ "$compiler" != "" ]; then
1068 echo "PKGSRC_COMPILER= $compiler" >> ${TARGET_MKCONF} 1068 echo "PKGSRC_COMPILER= $compiler" >> ${TARGET_MKCONF}
1069fi 1069fi
1070case "$compiler" in 1070case "$compiler" in
1071sunpro) 1071sunpro)
1072 echo "CC= cc" >> ${TARGET_MKCONF} 1072 echo "CC= cc" >> ${TARGET_MKCONF}
1073 echo "CXX= CC" >> ${TARGET_MKCONF} 1073 echo "CXX= CC" >> ${TARGET_MKCONF}
1074 echo "CPP= \${CC} -E" >> ${TARGET_MKCONF} 1074 echo "CPP= \${CC} -E" >> ${TARGET_MKCONF}
1075 ;; 1075 ;;
1076clang) 1076clang)
1077 echo "CC= clang" >> ${TARGET_MKCONF} 1077 echo "CC= clang" >> ${TARGET_MKCONF}
1078 echo "CXX= clang++" >> ${TARGET_MKCONF} 1078 echo "CXX= clang++" >> ${TARGET_MKCONF}
1079 echo "CPP= \${CC} -E" >> ${TARGET_MKCONF} 1079 echo "CPP= \${CC} -E" >> ${TARGET_MKCONF}
1080 if [ -z "$CLANGBASE" -a -f "/usr/bin/clang" ]; then 1080 if [ -z "$CLANGBASE" -a -f "/usr/bin/clang" ]; then
1081 CLANGBASE="/usr" 1081 CLANGBASE="/usr"
1082 fi 1082 fi
1083 if [ -n "$CLANGBASE" -o -f "/bin/clang" ]; then 1083 if [ -n "$CLANGBASE" -o -f "/bin/clang" ]; then
1084 echo "CLANGBASE= $CLANGBASE" >> ${TARGET_MKCONF} 1084 echo "CLANGBASE= $CLANGBASE" >> ${TARGET_MKCONF}
1085 fi 1085 fi
1086 ;; 1086 ;;
1087esac 1087esac
1088if [ -n "$GCCBASE" ]; then 1088if [ -n "$GCCBASE" ]; then
1089 echo "GCCBASE= $GCCBASE" >> ${TARGET_MKCONF} 1089 echo "GCCBASE= $GCCBASE" >> ${TARGET_MKCONF}
1090fi 1090fi
1091if [ -n "$SUNWSPROBASE" ]; then 1091if [ -n "$SUNWSPROBASE" ]; then
1092 echo "SUNWSPROBASE= $SUNWSPROBASE" >> ${TARGET_MKCONF} 1092 echo "SUNWSPROBASE= $SUNWSPROBASE" >> ${TARGET_MKCONF}
1093fi 1093fi
1094echo "" >> ${TARGET_MKCONF} 1094echo "" >> ${TARGET_MKCONF}
1095 1095
1096if [ x"$has_ssp" = x"no" ] && [ x"$check_ssp" = x"yes" ]; then 1096if [ x"$has_ssp" = x"no" ] && [ x"$check_ssp" = x"yes" ]; then
1097 echo "_OPSYS_SUPPORTS_SSP= no" >> ${TARGET_MKCONF} 1097 echo "_OPSYS_SUPPORTS_SSP= no" >> ${TARGET_MKCONF}
1098fi 1098fi
1099 1099
1100# enable unprivileged builds if not root 1100# enable unprivileged builds if not root
1101if [ "$unprivileged" = "yes" ]; then 1101if [ "$unprivileged" = "yes" ]; then
1102 echo "UNPRIVILEGED= yes" >> ${TARGET_MKCONF} 1102 echo "UNPRIVILEGED= yes" >> ${TARGET_MKCONF}
1103fi 1103fi
1104 1104
1105# save environment in example mk.conf 1105# save environment in example mk.conf
1106echo "PKG_DBDIR= $pkgdbdir" >> ${TARGET_MKCONF} 1106echo "PKG_DBDIR= $pkgdbdir" >> ${TARGET_MKCONF}
1107echo "LOCALBASE= $prefix" >> ${TARGET_MKCONF} 1107echo "LOCALBASE= $prefix" >> ${TARGET_MKCONF}
1108if [ "${sysconfbase}" != "/etc" ]; then 1108if [ "${sysconfbase}" != "/etc" ]; then
1109echo "SYSCONFBASE= $sysconfbase" >> ${TARGET_MKCONF} 1109echo "SYSCONFBASE= $sysconfbase" >> ${TARGET_MKCONF}
1110fi 1110fi
1111echo "VARBASE= $varbase" >> ${TARGET_MKCONF} 1111echo "VARBASE= $varbase" >> ${TARGET_MKCONF}
1112if [ "${sysconfdir}" != "${prefix}/etc" ]; then 1112if [ "${sysconfdir}" != "${prefix}/etc" ]; then
1113 echo "PKG_SYSCONFBASE= $sysconfdir" >> ${TARGET_MKCONF} 1113 echo "PKG_SYSCONFBASE= $sysconfdir" >> ${TARGET_MKCONF}
1114fi 1114fi
1115echo "PKG_TOOLS_BIN= $prefix/sbin" >> ${TARGET_MKCONF} 1115echo "PKG_TOOLS_BIN= $prefix/sbin" >> ${TARGET_MKCONF}
1116echo "PKGINFODIR= $pkginfodir" >> ${TARGET_MKCONF} 1116echo "PKGINFODIR= $pkginfodir" >> ${TARGET_MKCONF}
1117echo "PKGMANDIR= $pkgmandir" >> ${TARGET_MKCONF} 1117echo "PKGMANDIR= $pkgmandir" >> ${TARGET_MKCONF}
1118echo "" >> ${TARGET_MKCONF} 1118echo "" >> ${TARGET_MKCONF}
1119 1119
1120case $opsys in 1120case $opsys in
1121Linux) 1121Linux)
1122 # Default to PREFER_PKGSRC=yes unless user specifies --prefer-native=yes 1122 # Default to PREFER_PKGSRC=yes unless user specifies --prefer-native=yes
1123 # Linux systems likely have software from other packages managers 1123 # Linux systems likely have software from other packages managers
1124 # like yum or apt that can leak into pkgsrc and cause issues as they 1124 # like yum or apt that can leak into pkgsrc and cause issues as they
1125 # age, undergo ABI changes, or get added/removed behind our backs. 1125 # age, undergo ABI changes, or get added/removed behind our backs.
1126 # Let pkgsrc maintain all dependencies to avoid these problems. 1126 # Let pkgsrc maintain all dependencies to avoid these problems.
1127 # The exception here is Elbrus 2000, for which a lot of patches have 1127 # The exception here is Elbrus 2000, for which a lot of patches have
1128 # not been upstreamed, so that it is better to use native. 1128 # not been upstreamed, so that it is better to use native.
1129 if [ -z "$prefer_pkgsrc" ] && [ "$prefer_native" != "yes" ] && \ 1129 if [ -z "$prefer_pkgsrc" ] && [ "$prefer_native" != "yes" ] && \
1130 [ "$machine_arch" != "e2k" ]; then 1130 [ "$machine_arch" != "e2k" ]; then
1131 prefer_pkgsrc="yes" 1131 prefer_pkgsrc="yes"
1132 fi 1132 fi
1133 ;; 1133 ;;
1134esac 1134esac
1135 1135
1136if [ -n "$prefer_pkgsrc" ]; then 1136if [ -n "$prefer_pkgsrc" ]; then
1137 echo "# WARNING: Changing PREFER_* after bootstrap will require rebuilding all" >> ${TARGET_MKCONF} 1137 echo "# WARNING: Changing PREFER_* after bootstrap will require rebuilding all" >> ${TARGET_MKCONF}
1138 echo "# packages with a dependency that switched between native/pkgsrc." >> ${TARGET_MKCONF} 1138 echo "# packages with a dependency that switched between native/pkgsrc." >> ${TARGET_MKCONF}
1139 echo "PREFER_PKGSRC= $prefer_pkgsrc" >> ${TARGET_MKCONF} 1139 echo "PREFER_PKGSRC= $prefer_pkgsrc" >> ${TARGET_MKCONF}
1140 echo "" >> ${TARGET_MKCONF} 1140 echo "" >> ${TARGET_MKCONF}
1141fi 1141fi
1142if [ -n "$prefer_native" ]; then 1142if [ -n "$prefer_native" ]; then
1143 echo "PREFER_NATIVE= $prefer_native" >> ${TARGET_MKCONF} 1143 echo "PREFER_NATIVE= $prefer_native" >> ${TARGET_MKCONF}
1144 echo "" >> ${TARGET_MKCONF} 1144 echo "" >> ${TARGET_MKCONF}
1145fi 1145fi
1146 1146
1147BOOTSTRAP_MKCONF=${wrkdir}/mk.conf 1147BOOTSTRAP_MKCONF=${wrkdir}/mk.conf
1148cp ${TARGET_MKCONF} ${BOOTSTRAP_MKCONF} 1148cp ${TARGET_MKCONF} ${BOOTSTRAP_MKCONF}
1149 1149
1150case "$cwrappers" in 1150case "$cwrappers" in
1151yes|no) 1151yes|no)
1152 echo "USE_CWRAPPERS= $cwrappers" >> ${TARGET_MKCONF} 1152 echo "USE_CWRAPPERS= $cwrappers" >> ${TARGET_MKCONF}
1153 echo "USE_CWRAPPERS= $cwrappers" >> ${BOOTSTRAP_MKCONF} 1153 echo "USE_CWRAPPERS= $cwrappers" >> ${BOOTSTRAP_MKCONF}
1154 echo "" >> ${TARGET_MKCONF} 1154 echo "" >> ${TARGET_MKCONF}
1155 ;; 1155 ;;
1156esac 1156esac
1157 1157
1158# On all Debian GNU/kFreeBSD 7, /bin/sh is a symlink to /bin/dash, and 1158# On all Debian GNU/kFreeBSD 7, /bin/sh is a symlink to /bin/dash, and
1159# use /bin/bash. 1159# use /bin/bash.
1160# Only needed by legacy wrappers. 1160# Only needed by legacy wrappers.
1161if [ "$opsys" = "GNUkFreeBSD" -a "$bootstrap_sh_set" != "set" ]; then 1161if [ "$opsys" = "GNUkFreeBSD" -a "$bootstrap_sh_set" != "set" ]; then
1162 echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${TARGET_MKCONF} 1162 echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${TARGET_MKCONF}
1163 echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${BOOTSTRAP_MKCONF} 1163 echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${BOOTSTRAP_MKCONF}
1164 echo $opsys 1164 echo $opsys
1165fi 1165fi
1166 1166
1167# sbin is used by pkg_install, share/mk by bootstrap-mk-files 1167# sbin is used by pkg_install, share/mk by bootstrap-mk-files
1168mkdir_p $wrkdir/sbin $wrkdir/share/mk 1168mkdir_p $wrkdir/sbin $wrkdir/share/mk
1169mkdir_p_early ${wrkdir} 1169mkdir_p_early ${wrkdir}
1170 1170
1171if [ "$need_bsd_install" = "yes" ]; then 1171if [ "$need_bsd_install" = "yes" ]; then
1172 BSTRAP_ENV="INSTALL='$prefix/bin/install-sh -c' $BSTRAP_ENV" 1172 BSTRAP_ENV="INSTALL='$prefix/bin/install-sh -c' $BSTRAP_ENV"
1173 if [ "$use_bsdinstall" = "yes" ]; then 1173 if [ "$use_bsdinstall" = "yes" ]; then
1174 echo "TOOLS_PLATFORM.install?= $prefix/bin/bsdinstall" >> ${TARGET_MKCONF} 1174 echo "TOOLS_PLATFORM.install?= $prefix/bin/bsdinstall" >> ${TARGET_MKCONF}
1175 else 1175 else
1176 echo "TOOLS_PLATFORM.install?= $prefix/bin/install-sh" >> ${TARGET_MKCONF} 1176 echo "TOOLS_PLATFORM.install?= $prefix/bin/install-sh" >> ${TARGET_MKCONF}
1177 fi 1177 fi
1178 echo "TOOLS_PLATFORM.install?= $wrkdir/bin/install-sh" >> ${BOOTSTRAP_MKCONF} 1178 echo "TOOLS_PLATFORM.install?= $wrkdir/bin/install-sh" >> ${BOOTSTRAP_MKCONF}
1179fi 1179fi
1180 1180
1181if [ "$need_fixed_strip" = "yes" ] ; then 1181if [ "$need_fixed_strip" = "yes" ] ; then
1182 echo_msg "Installing fixed strip script" 1182 echo_msg "Installing fixed strip script"
1183 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/strip-sh $wrkdir/bin/strip" 1183 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/strip-sh $wrkdir/bin/strip"
1184 echo "TOOLS_PLATFORM.strip?= $prefix/bin/strip" >> ${TARGET_MKCONF} 1184 echo "TOOLS_PLATFORM.strip?= $prefix/bin/strip" >> ${TARGET_MKCONF}
1185 echo "TOOLS_PLATFORM.strip?= $wrkdir/bin/strip" >> ${BOOTSTRAP_MKCONF} 1185 echo "TOOLS_PLATFORM.strip?= $wrkdir/bin/strip" >> ${BOOTSTRAP_MKCONF}
1186 need_extras=yes 1186 need_extras=yes
1187fi 1187fi
1188 1188
1189if [ "$need_mkdir" = "yes" -a -z "$MKDIR" ]; then 1189if [ "$need_mkdir" = "yes" -a -z "$MKDIR" ]; then
1190 echo_msg "Installing fixed mkdir script \"mkdir-sh\"" 1190 echo_msg "Installing fixed mkdir script \"mkdir-sh\""
1191 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/mkdir-sh $wrkdir/bin/mkdir-sh" 1191 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/mkdir-sh $wrkdir/bin/mkdir-sh"
1192 echo "TOOLS_PLATFORM.mkdir?= $prefix/bin/mkdir-sh -p" >> ${TARGET_MKCONF} 1192 echo "TOOLS_PLATFORM.mkdir?= $prefix/bin/mkdir-sh -p" >> ${TARGET_MKCONF}
1193 echo "TOOLS_PLATFORM.mkdir?= $wrkdir/bin/mkdir-sh -p" >> ${BOOTSTRAP_MKCONF} 1193 echo "TOOLS_PLATFORM.mkdir?= $wrkdir/bin/mkdir-sh -p" >> ${BOOTSTRAP_MKCONF}
1194 need_extras=yes 1194 need_extras=yes
1195fi 1195fi
1196 1196
1197if [ "$need_xargs" = "yes" ]; then 1197if [ "$need_xargs" = "yes" ]; then
1198 echo_msg "Installing fixed xargs script" 1198 echo_msg "Installing fixed xargs script"
1199 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/xargs-sh $wrkdir/bin/xargs" 1199 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/xargs-sh $wrkdir/bin/xargs"
1200 echo "TOOLS_PLATFORM.xargs?= $prefix/bin/xargs" >> ${TARGET_MKCONF} 1200 echo "TOOLS_PLATFORM.xargs?= $prefix/bin/xargs" >> ${TARGET_MKCONF}
1201 echo "TOOLS_PLATFORM.xargs?= $wrkdir/bin/xargs" >> ${BOOTSTRAP_MKCONF} 1201 echo "TOOLS_PLATFORM.xargs?= $wrkdir/bin/xargs" >> ${BOOTSTRAP_MKCONF}
1202 need_extras=yes 1202 need_extras=yes
1203fi 1203fi
1204 1204
1205echo_msg "Bootstrapping mk-files" 1205echo_msg "Bootstrapping mk-files"
1206run_cmd "(cd ${pkgsrcdir}/pkgtools/bootstrap-mk-files/files && env CP=${cpprog} \ 1206run_cmd "(cd ${pkgsrcdir}/pkgtools/bootstrap-mk-files/files && env CP=${cpprog} \
1207 OPSYS=${opsys} MK_DST=${wrkdir}/share/mk ROOT_GROUP=${root_group} \ 1207 OPSYS=${opsys} MK_DST=${wrkdir}/share/mk ROOT_GROUP=${root_group} \
1208ROOT_USER=${root_user} SED=${sedprog} SYSCONFDIR=${sysconfdir} \ 1208ROOT_USER=${root_user} SED=${sedprog} SYSCONFDIR=${sysconfdir} \
1209$shprog ./bootstrap.sh)" 1209$shprog ./bootstrap.sh)"
1210 1210
1211if [ -n "${bootstrap_sh_set}" ]; then 1211if [ -n "${bootstrap_sh_set}" ]; then
1212 bmakexargs="${bmakexargs} --with-defshell=${bootstrap_sh}" 1212 bmakexargs="${bmakexargs} --with-defshell=${bootstrap_sh}"
1213fi 1213fi
1214 1214
1215bootstrap_bmake() { 1215bootstrap_bmake() {
1216 echo_msg "Bootstrapping bmake" 1216 echo_msg "Bootstrapping bmake"
1217 copy_src $pkgsrcdir/devel/bmake/files bmake 1217 copy_src $pkgsrcdir/devel/bmake/files bmake
1218 run_cmd "(cd $wrkdir/bmake && $shprog configure $configure_quiet_flags --prefix=$wrkdir --with-default-sys-path=$wrkdir/share/mk --with-machine-arch=${machine_arch} $bmakexargs)" 1218 run_cmd "(cd $wrkdir/bmake && $shprog configure $configure_quiet_flags --prefix=$wrkdir --with-default-sys-path=$wrkdir/share/mk --with-machine-arch=${machine_arch} $bmakexargs)"
1219 run_cmd "(cd $wrkdir/bmake && $shprog make-bootstrap.sh)" 1219 run_cmd "(cd $wrkdir/bmake && $shprog make-bootstrap.sh)"
1220 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/bmake/bmake $wrkdir/bin/bmake" 1220 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/bmake/bmake $wrkdir/bin/bmake"
1221} 1221}
1222bootstrap_bmake 1222bootstrap_bmake
1223 1223
1224bmake="$wrkdir/bin/bmake" 1224bmake="$wrkdir/bin/bmake"
1225 1225
1226# build libnbcompat 1226# build libnbcompat
1227echo_msg "Building libnbcompat" 1227echo_msg "Building libnbcompat"
1228copy_src $pkgsrcdir/pkgtools/libnbcompat/files libnbcompat 1228copy_src $pkgsrcdir/pkgtools/libnbcompat/files libnbcompat
1229run_cmd "(cd $wrkdir/libnbcompat; $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir --enable-bsd-getopt --enable-db && $bmake $make_quiet_flags -j$make_jobs)" 1229run_cmd "(cd $wrkdir/libnbcompat; $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir --enable-bsd-getopt --enable-db && $bmake $make_quiet_flags -j$make_jobs)"
1230 1230
1231# bootstrap mksh if necessary 1231# bootstrap mksh if necessary
1232case "$need_mksh" in 1232case "$need_mksh" in
1233yes) echo_msg "Bootstrapping mksh" 1233yes) echo_msg "Bootstrapping mksh"
1234 copy_src $pkgsrcdir/shells/mksh/files mksh 1234 copy_src $pkgsrcdir/shells/mksh/files mksh
1235 run_cmd "(cd $wrkdir/mksh && env $BSTRAP_ENV CC=\"${CC}\" $shprog Build.sh -r)" 1235 run_cmd "(cd $wrkdir/mksh && env $BSTRAP_ENV CC=\"${CC}\" $shprog Build.sh -r)"
1236 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/mksh/mksh $wrkdir/bin/mksh" 1236 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/mksh/mksh $wrkdir/bin/mksh"
1237 echo "TOOLS_PLATFORM.sh?= $prefix/bin/mksh" >> ${TARGET_MKCONF} 1237 echo "TOOLS_PLATFORM.sh?= $prefix/bin/mksh" >> ${TARGET_MKCONF}
1238 echo "TOOLS_PLATFORM.sh?= $wrkdir/bin/mksh" >> ${BOOTSTRAP_MKCONF} 1238 echo "TOOLS_PLATFORM.sh?= $wrkdir/bin/mksh" >> ${BOOTSTRAP_MKCONF}
1239 echo_msg "Rebootstrapping bmake for mksh" 1239 echo_msg "Rebootstrapping bmake for mksh"
1240 bmakexargs="$bmakexargs --with-defshell=$wrkdir/bin/mksh" 1240 bmakexargs="$bmakexargs --with-defshell=$wrkdir/bin/mksh"
1241 bootstrap_bmake 1241 bootstrap_bmake
1242 ;; 1242 ;;
1243esac 1243esac
1244 1244
1245# bootstrap ksh if necessary 1245# bootstrap ksh if necessary
1246case "$need_ksh" in 1246case "$need_ksh" in
1247yes) echo_msg "Bootstrapping ksh" 1247yes) echo_msg "Bootstrapping ksh"
1248 copy_src $pkgsrcdir/shells/pdksh/files ksh 1248 copy_src $pkgsrcdir/shells/pdksh/files ksh
1249 run_cmd "(cd $wrkdir/ksh && env $BSTRAP_ENV $shprog ./configure $configure_quiet_flags --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir && $bmake $make_quiet_flags -j$make_jobs)" 1249 run_cmd "(cd $wrkdir/ksh && env $BSTRAP_ENV $shprog ./configure $configure_quiet_flags --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir && $bmake $make_quiet_flags -j$make_jobs)"
1250 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/ksh/ksh $wrkdir/bin/pdksh" 1250 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/ksh/ksh $wrkdir/bin/pdksh"
1251 echo "TOOLS_PLATFORM.sh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF} 1251 echo "TOOLS_PLATFORM.sh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF}
1252 echo "TOOLS_PLATFORM.sh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF} 1252 echo "TOOLS_PLATFORM.sh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF}
1253 echo "TOOLS_PLATFORM.ksh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF} 1253 echo "TOOLS_PLATFORM.ksh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF}
1254 echo "TOOLS_PLATFORM.ksh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF} 1254 echo "TOOLS_PLATFORM.ksh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF}
1255# Now rebootstrap bmake for ksh 1255# Now rebootstrap bmake for ksh
1256 echo_msg "Rebootstrapping bmake for ksh" 1256 echo_msg "Rebootstrapping bmake for ksh"
1257 bmakexargs="$bmakexargs --with-defshell=$wrkdir/bin/pdksh" 1257 bmakexargs="$bmakexargs --with-defshell=$wrkdir/bin/pdksh"
1258 bootstrap_bmake 1258 bootstrap_bmake
1259 ;; 1259 ;;
1260esac 1260esac
1261 1261
1262# bootstrap awk if necessary 1262# bootstrap awk if necessary
1263case "$need_awk" in 1263case "$need_awk" in
1264yes) echo_msg "Bootstrapping awk" 1264yes) echo_msg "Bootstrapping awk"
1265 copy_src $pkgsrcdir/lang/nawk/files awk 1265 copy_src $pkgsrcdir/lang/nawk/files awk
1266 run_cmd "(cd $wrkdir/awk && $bmake $make_quiet_flags -j$make_jobs -f Makefile CC=\"${CC}\" CFLAGS=\"${CFLAGS}\")" 1266 run_cmd "(cd $wrkdir/awk && $bmake $make_quiet_flags -j$make_jobs -f Makefile CC=\"${CC}\" CFLAGS=\"${CFLAGS}\")"
1267 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/awk/a.out $wrkdir/bin/nawk" 1267 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/awk/a.out $wrkdir/bin/nawk"
1268 echo "TOOLS_PLATFORM.awk?= $prefix/bin/nawk" >> ${TARGET_MKCONF} 1268 echo "TOOLS_PLATFORM.awk?= $prefix/bin/nawk" >> ${TARGET_MKCONF}
1269 echo "TOOLS_PLATFORM.awk?= $wrkdir/bin/nawk" >> ${BOOTSTRAP_MKCONF} 1269 echo "TOOLS_PLATFORM.awk?= $wrkdir/bin/nawk" >> ${BOOTSTRAP_MKCONF}
1270 ;; 1270 ;;
1271esac 1271esac
1272 1272
1273# bootstrap sed if necessary 1273# bootstrap sed if necessary
1274case "$need_sed" in 1274case "$need_sed" in
1275yes) echo_msg "Bootstrapping sed" 1275yes) echo_msg "Bootstrapping sed"
1276 copy_src $pkgsrcdir/textproc/nbsed/files sed 1276 copy_src $pkgsrcdir/textproc/nbsed/files sed
1277 run_cmd "(cd $wrkdir/sed; env $BSTRAP_ENV CPPFLAGS='$CPPFLAGS -I../libnbcompat' LDFLAGS='$LDFLAGS -L../libnbcompat' LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir --program-transform-name='s,sed,nbsed,' && $bmake $make_quiet_flags -j$make_jobs)" 1277 run_cmd "(cd $wrkdir/sed; env $BSTRAP_ENV CPPFLAGS='$CPPFLAGS -I../libnbcompat' LDFLAGS='$LDFLAGS -L../libnbcompat' LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir --program-transform-name='s,sed,nbsed,' && $bmake $make_quiet_flags -j$make_jobs)"
1278 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/sed/sed $wrkdir/bin/sed" 1278 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/sed/sed $wrkdir/bin/sed"
1279 echo "TOOLS_PLATFORM.sed?= $prefix/bin/nbsed" >> ${TARGET_MKCONF} 1279 echo "TOOLS_PLATFORM.sed?= $prefix/bin/nbsed" >> ${TARGET_MKCONF}
1280 echo "TOOLS_PLATFORM.sed?= $wrkdir/bin/sed" >> ${BOOTSTRAP_MKCONF} 1280 echo "TOOLS_PLATFORM.sed?= $wrkdir/bin/sed" >> ${BOOTSTRAP_MKCONF}
1281 ;; 1281 ;;
1282esac 1282esac
1283 1283
1284# bootstrap pkg_install 1284# bootstrap pkg_install
1285extra_libarchive_depends() { 1285extra_libarchive_depends() {
1286 $sedprog -n -e 's/Libs.private: //p' $wrkdir/libarchive/build/pkgconfig/libarchive.pc 1286 $sedprog -n -e 's/Libs.private: //p' $wrkdir/libarchive/build/pkgconfig/libarchive.pc
1287} 1287}
1288 1288
1289echo_msg "Bootstrapping pkgtools" 1289echo_msg "Bootstrapping pkgtools"
1290copy_src $pkgsrcdir/archivers/libarchive/files libarchive 1290copy_src $pkgsrcdir/archivers/libarchive/files libarchive
1291run_cmd "(cd $wrkdir/libarchive; env $BSTRAP_ENV \ 1291run_cmd "(cd $wrkdir/libarchive; env $BSTRAP_ENV \
1292$shprog ./configure $configure_quiet_flags --enable-static --disable-shared \ 1292$shprog ./configure $configure_quiet_flags --enable-static --disable-shared \
1293--disable-bsdtar --disable-bsdcpio --disable-posix-regex-lib --disable-xattr \ 1293--disable-bsdtar --disable-bsdcpio --disable-posix-regex-lib --disable-xattr \
1294--disable-maintainer-mode --disable-acl --without-zlib --without-bz2lib \ 1294--disable-maintainer-mode --disable-acl --without-zlib --without-bz2lib \
1295--without-iconv --without-lzma --without-lzo2 --without-lz4 \ 1295--without-iconv --without-lzma --without-lzo2 --without-lz4 \
1296--without-nettle --without-openssl --without-xml2 --without-expat --without-zstd \ 1296--without-nettle --without-openssl --without-xml2 --without-expat --without-zstd \
1297MAKE=$bmake && $bmake $make_quiet_flags -j$make_jobs)" 1297MAKE=$bmake && $bmake $make_quiet_flags -j$make_jobs)"
1298copy_src $pkgsrcdir/pkgtools/pkg_install/files pkg_install 1298copy_src $pkgsrcdir/pkgtools/pkg_install/files pkg_install
1299run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV \ 1299run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV \
1300CPPFLAGS='$CPPFLAGS -I${wrkdir}/libnbcompat -I${wrkdir}/libarchive/libarchive' \ 1300CPPFLAGS='$CPPFLAGS -I${wrkdir}/libnbcompat -I${wrkdir}/libarchive/libarchive' \
1301LDFLAGS='$LDFLAGS -L${wrkdir}/libnbcompat' \ 1301LDFLAGS='$LDFLAGS -L${wrkdir}/libnbcompat' \
1302LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C \ 1302LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C \
1303--enable-bootstrap --prefix=$prefix --sysconfdir=$sysconfdir \ 1303--enable-bootstrap --prefix=$prefix --sysconfdir=$sysconfdir \
1304--with-pkgdbdir=$pkgdbdir --infodir=$infodir \ 1304--with-pkgdbdir=$pkgdbdir --infodir=$infodir \
1305--mandir=$mandir $pkg_install_args && \ 1305--mandir=$mandir $pkg_install_args && \
1306STATIC_LIBARCHIVE=$wrkdir/libarchive/.libs/libarchive.a \ 1306STATIC_LIBARCHIVE=$wrkdir/libarchive/.libs/libarchive.a \
1307STATIC_LIBARCHIVE_LDADD=`extra_libarchive_depends` \ 1307STATIC_LIBARCHIVE_LDADD="`extra_libarchive_depends`" \
1308PKGSRC_MACHINE_ARCH="$machine_arch" $bmake $make_quiet_flags -j$make_jobs)" 1308PKGSRC_MACHINE_ARCH="$machine_arch" $bmake $make_quiet_flags -j$make_jobs)"
1309run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/add/pkg_add $wrkdir/sbin/pkg_add" 1309run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/add/pkg_add $wrkdir/sbin/pkg_add"
1310run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/admin/pkg_admin $wrkdir/sbin/pkg_admin" 1310run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/admin/pkg_admin $wrkdir/sbin/pkg_admin"
1311run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/create/pkg_create $wrkdir/sbin/pkg_create" 1311run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/create/pkg_create $wrkdir/sbin/pkg_create"
1312run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/info/pkg_info $wrkdir/sbin/pkg_info" 1312run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/info/pkg_info $wrkdir/sbin/pkg_info"
1313echo "PKG_ADD_CMD?= $wrkdir/sbin/pkg_add" >> ${BOOTSTRAP_MKCONF} 1313echo "PKG_ADD_CMD?= $wrkdir/sbin/pkg_add" >> ${BOOTSTRAP_MKCONF}
1314echo "PKG_ADMIN_CMD?= $wrkdir/sbin/pkg_admin" >> ${BOOTSTRAP_MKCONF} 1314echo "PKG_ADMIN_CMD?= $wrkdir/sbin/pkg_admin" >> ${BOOTSTRAP_MKCONF}
1315echo "PKG_CREATE_CMD?= $wrkdir/sbin/pkg_create" >> ${BOOTSTRAP_MKCONF} 1315echo "PKG_CREATE_CMD?= $wrkdir/sbin/pkg_create" >> ${BOOTSTRAP_MKCONF}
1316echo "PKG_INFO_CMD?= $wrkdir/sbin/pkg_info" >> ${BOOTSTRAP_MKCONF} 1316echo "PKG_INFO_CMD?= $wrkdir/sbin/pkg_info" >> ${BOOTSTRAP_MKCONF}
1317 1317
1318MAKECONF=$wrkdir/mk.conf 1318MAKECONF=$wrkdir/mk.conf
1319export MAKECONF 1319export MAKECONF
1320 1320
1321if [ "$bootstrap_sh_set" = "set" ]; then 1321if [ "$bootstrap_sh_set" = "set" ]; then
1322 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${TARGET_MKCONF} 1322 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${TARGET_MKCONF}
1323 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${BOOTSTRAP_MKCONF} 1323 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${BOOTSTRAP_MKCONF}
1324fi 1324fi
1325 1325
1326# preserve compiler and tool environment variables settings 1326# preserve compiler and tool environment variables settings
1327if test -n "$CP"; then 1327if test -n "$CP"; then
1328 echo "TOOLS_PLATFORM.cp?= $CP" >> ${TARGET_MKCONF} 1328 echo "TOOLS_PLATFORM.cp?= $CP" >> ${TARGET_MKCONF}
1329 echo "TOOLS_PLATFORM.cp?= $CP" >> ${BOOTSTRAP_MKCONF} 1329 echo "TOOLS_PLATFORM.cp?= $CP" >> ${BOOTSTRAP_MKCONF}
1330fi 1330fi
1331if test -n "$GREP"; then 1331if test -n "$GREP"; then
1332 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${TARGET_MKCONF} 1332 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${TARGET_MKCONF}
1333 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${BOOTSTRAP_MKCONF} 1333 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${BOOTSTRAP_MKCONF}
1334fi 1334fi
1335if test -n "$EGREP"; then 1335if test -n "$EGREP"; then
1336 echo "TOOLS_PLATFORM.egrep?= $EGREP" >> ${TARGET_MKCONF} 1336 echo "TOOLS_PLATFORM.egrep?= $EGREP" >> ${TARGET_MKCONF}
1337 echo "TOOLS_PLATFORM.egrep?= $EGREP" >> ${BOOTSTRAP_MKCONF} 1337 echo "TOOLS_PLATFORM.egrep?= $EGREP" >> ${BOOTSTRAP_MKCONF}
1338fi 1338fi
1339if test -n "$FGREP"; then 1339if test -n "$FGREP"; then
1340 echo "TOOLS_PLATFORM.fgrep?= $FGREP" >> ${TARGET_MKCONF} 1340 echo "TOOLS_PLATFORM.fgrep?= $FGREP" >> ${TARGET_MKCONF}
1341 echo "TOOLS_PLATFORM.fgrep?= $FGREP" >> ${BOOTSTRAP_MKCONF} 1341 echo "TOOLS_PLATFORM.fgrep?= $FGREP" >> ${BOOTSTRAP_MKCONF}
1342fi 1342fi
1343if test -n "$ID"; then 1343if test -n "$ID"; then
1344 echo "TOOLS_PLATFORM.id?= $ID" >> ${TARGET_MKCONF} 1344 echo "TOOLS_PLATFORM.id?= $ID" >> ${TARGET_MKCONF}
1345 echo "TOOLS_PLATFORM.id?= $ID" >> ${BOOTSTRAP_MKCONF} 1345 echo "TOOLS_PLATFORM.id?= $ID" >> ${BOOTSTRAP_MKCONF}
1346fi 1346fi
1347if test -n "$MKDIR"; then 1347if test -n "$MKDIR"; then
1348 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${TARGET_MKCONF} 1348 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${TARGET_MKCONF}
1349 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${BOOTSTRAP_MKCONF} 1349 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${BOOTSTRAP_MKCONF}
1350fi 1350fi
1351if test -n "$TEST"; then 1351if test -n "$TEST"; then
1352 echo "TOOLS_PLATFORM.test?= $TEST" >> ${TARGET_MKCONF} 1352 echo "TOOLS_PLATFORM.test?= $TEST" >> ${TARGET_MKCONF}
1353 echo "TOOLS_PLATFORM.test?= $TEST" >> ${BOOTSTRAP_MKCONF} 1353 echo "TOOLS_PLATFORM.test?= $TEST" >> ${BOOTSTRAP_MKCONF}
1354fi 1354fi
1355if test -n "$TOUCH"; then 1355if test -n "$TOUCH"; then
1356 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${TARGET_MKCONF} 1356 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${TARGET_MKCONF}
1357 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${BOOTSTRAP_MKCONF} 1357 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${BOOTSTRAP_MKCONF}
1358fi 1358fi
1359if test -n "$XARGS"; then 1359if test -n "$XARGS"; then
1360 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${TARGET_MKCONF} 1360 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${TARGET_MKCONF}
1361 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${BOOTSTRAP_MKCONF} 1361 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${BOOTSTRAP_MKCONF}
1362fi 1362fi
1363if test -n "$CFLAGS"; then 1363if test -n "$CFLAGS"; then
1364 echo "CFLAGS+= $CFLAGS" >> ${TARGET_MKCONF} 1364 echo "CFLAGS+= $CFLAGS" >> ${TARGET_MKCONF}
1365 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${TARGET_MKCONF} 1365 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${TARGET_MKCONF}
1366 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${BOOTSTRAP_MKCONF} 1366 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${BOOTSTRAP_MKCONF}
1367fi 1367fi
1368if test -n "$CPPFLAGS"; then 1368if test -n "$CPPFLAGS"; then
1369 echo "CPPFLAGS+= $CPPFLAGS" >> ${TARGET_MKCONF} 1369 echo "CPPFLAGS+= $CPPFLAGS" >> ${TARGET_MKCONF}
1370fi 1370fi
1371if test -n "$LDFLAGS"; then 1371if test -n "$LDFLAGS"; then
1372 echo "LDFLAGS+= $LDFLAGS" >> ${TARGET_MKCONF} 1372 echo "LDFLAGS+= $LDFLAGS" >> ${TARGET_MKCONF}
1373fi 1373fi
1374if test -n "$LIBS"; then 1374if test -n "$LIBS"; then
1375 echo "LIBS+= $LIBS" >> ${TARGET_MKCONF} 1375 echo "LIBS+= $LIBS" >> ${TARGET_MKCONF}
1376fi 1376fi
1377 1377
1378# opsys specific fiddling 1378# opsys specific fiddling
1379opsys_finish 1379opsys_finish
1380 1380
1381echo "WRKOBJDIR= ${wrkdir}/wrk" >> ${BOOTSTRAP_MKCONF} 1381echo "WRKOBJDIR= ${wrkdir}/wrk" >> ${BOOTSTRAP_MKCONF}
1382 1382
1383echo "" >> ${TARGET_MKCONF} 1383echo "" >> ${TARGET_MKCONF}
1384echo "" >> ${BOOTSTRAP_MKCONF} 1384echo "" >> ${BOOTSTRAP_MKCONF}
1385if test -n "${mk_fragment}"; then 1385if test -n "${mk_fragment}"; then
1386 cat "${mk_fragment}" >> ${TARGET_MKCONF} 1386 cat "${mk_fragment}" >> ${TARGET_MKCONF}
1387 echo "" >> ${TARGET_MKCONF} 1387 echo "" >> ${TARGET_MKCONF}
1388fi 1388fi
1389echo ".endif # end pkgsrc settings" >> ${TARGET_MKCONF} 1389echo ".endif # end pkgsrc settings" >> ${TARGET_MKCONF}
1390echo ".endif # end pkgsrc settings" >> ${BOOTSTRAP_MKCONF} 1390echo ".endif # end pkgsrc settings" >> ${BOOTSTRAP_MKCONF}
1391 1391
1392# build and register packages 1392# build and register packages
1393# usage: build_package <packagedirectory> 1393# usage: build_package <packagedirectory>
1394build_package() { 1394build_package() {
1395 run_cmd "(cd $pkgsrcdir/$1 && $bmake $make_quiet_flags MAKE_JOBS=${make_jobs} PKG_COMPRESSION=none -DPKG_PRESERVE PKGSRC_KEEP_BIN_PKGS=no MAKECONF=${BOOTSTRAP_MKCONF} install)" 1395 run_cmd "(cd $pkgsrcdir/$1 && $bmake $make_quiet_flags MAKE_JOBS=${make_jobs} PKG_COMPRESSION=none -DPKG_PRESERVE PKGSRC_KEEP_BIN_PKGS=no MAKECONF=${BOOTSTRAP_MKCONF} install)"
1396} 1396}
1397build_package_nopreserve() { 1397build_package_nopreserve() {
1398 run_cmd "(cd $pkgsrcdir/$1 && $bmake $make_quiet_flags MAKE_JOBS=${make_jobs} PKG_COMPRESSION=none PKGSRC_KEEP_BIN_PKGS=no MAKECONF=${BOOTSTRAP_MKCONF} install)" 1398 run_cmd "(cd $pkgsrcdir/$1 && $bmake $make_quiet_flags MAKE_JOBS=${make_jobs} PKG_COMPRESSION=none PKGSRC_KEEP_BIN_PKGS=no MAKECONF=${BOOTSTRAP_MKCONF} install)"
1399} 1399}
1400 1400
1401# 1401#
1402# cwrappers is special, we don't want to set it as a BOOTSTRAP_PKG but must 1402# cwrappers is special, we don't want to set it as a BOOTSTRAP_PKG but must
1403# build it (if required) without -DPKG_PRESERVE set so that it can be deleted. 1403# build it (if required) without -DPKG_PRESERVE set so that it can be deleted.
1404# 1404#
1405use_cwrappers=`(cd $pkgsrcdir/devel/bmake && $bmake show-var VARNAME=_USE_CWRAPPERS)` 1405use_cwrappers=`(cd $pkgsrcdir/devel/bmake && $bmake show-var VARNAME=_USE_CWRAPPERS)`
1406case "$use_cwrappers" in 1406case "$use_cwrappers" in
1407yes) 1407yes)
1408 build_package_nopreserve "pkgtools/cwrappers" 1408 build_package_nopreserve "pkgtools/cwrappers"
1409 ;; 1409 ;;
1410esac 1410esac
1411 1411
1412# 1412#
1413# Please make sure that the following packages and 1413# Please make sure that the following packages and
1414# only the following packages set BOOTSTRAP_PKG=yes. 1414# only the following packages set BOOTSTRAP_PKG=yes.
1415# 1415#
1416echo_msg "Installing packages" 1416echo_msg "Installing packages"
1417build_package "pkgtools/bootstrap-mk-files" 1417build_package "pkgtools/bootstrap-mk-files"
1418case "$need_bsd_install" in 1418case "$need_bsd_install" in
1419yes) 1419yes)
1420 if [ "$use_bsdinstall" = "yes" ]; then 1420 if [ "$use_bsdinstall" = "yes" ]; then
1421 build_package "sysutils/bsdinstall" 1421 build_package "sysutils/bsdinstall"
1422 else 1422 else
1423 build_package "sysutils/install-sh" 1423 build_package "sysutils/install-sh"
1424 fi 1424 fi
1425 ;; 1425 ;;
1426esac 1426esac
1427case "$need_mksh" in 1427case "$need_mksh" in
1428yes) build_package "shells/mksh";; 1428yes) build_package "shells/mksh";;
1429esac 1429esac
1430case "$need_ksh" in 1430case "$need_ksh" in
1431yes) build_package "shells/pdksh";; 1431yes) build_package "shells/pdksh";;
1432esac 1432esac
1433build_package "devel/bmake" 1433build_package "devel/bmake"
1434case "$need_awk" in 1434case "$need_awk" in
1435yes) build_package "lang/nawk";; 1435yes) build_package "lang/nawk";;
1436esac 1436esac
1437case "$need_sed" in 1437case "$need_sed" in
1438yes) build_package "textproc/nbsed";; 1438yes) build_package "textproc/nbsed";;
1439esac 1439esac
1440case "$need_extras" in 1440case "$need_extras" in
1441yes) build_package "pkgtools/bootstrap-extras";; 1441yes) build_package "pkgtools/bootstrap-extras";;
1442esac 1442esac
1443case "$need_pax" in 1443case "$need_pax" in
1444yes) build_package "archivers/pax" 1444yes) build_package "archivers/pax"
1445esac 1445esac
1446build_package "pkgtools/pkg_install" 1446build_package "pkgtools/pkg_install"
1447 1447
1448etc_mk_conf="$sysconfdir/mk.conf" 1448etc_mk_conf="$sysconfdir/mk.conf"
1449 1449
1450# Install the example mk.conf so that it is used, but only if it doesn't 1450# Install the example mk.conf so that it is used, but only if it doesn't
1451# exist yet. This can happen with non-default sysconfdir settings. 1451# exist yet. This can happen with non-default sysconfdir settings.
1452mkdir_p "$sysconfdir" 1452mkdir_p "$sysconfdir"
1453if [ ! -f "$etc_mk_conf" ]; then 1453if [ ! -f "$etc_mk_conf" ]; then
1454 cp "$TARGET_MKCONF" "$etc_mk_conf" 1454 cp "$TARGET_MKCONF" "$etc_mk_conf"
1455 TARGET_MKCONF="$etc_mk_conf" 1455 TARGET_MKCONF="$etc_mk_conf"
1456fi 1456fi
1457 1457
1458[ -n "${binary_kit}" ] && mkbinarykit_tar 1458[ -n "${binary_kit}" ] && mkbinarykit_tar
1459[ -n "${binary_gzip_kit}" ] && mkbinarykit_tgz 1459[ -n "${binary_gzip_kit}" ] && mkbinarykit_tgz
1460 1460
1461hline="===========================================================================" 1461hline="==========================================================================="
1462echo "" 1462echo ""
1463echo "$hline" 1463echo "$hline"
1464echo "" 1464echo ""
1465echo "Please remember to add $prefix/bin to your PATH environment variable" 1465echo "Please remember to add $prefix/bin to your PATH environment variable"
1466echo "and $mandir to your MANPATH environment variable, if necessary." 1466echo "and $mandir to your MANPATH environment variable, if necessary."
1467echo "" 1467echo ""
1468echo "An example mk.conf file with the settings you provided to \"bootstrap\"" 1468echo "An example mk.conf file with the settings you provided to \"bootstrap\""
1469echo "has been created for you. It can be found in:" 1469echo "has been created for you. It can be found in:"
1470echo "" 1470echo ""
1471echo " ${TARGET_MKCONF}" 1471echo " ${TARGET_MKCONF}"
1472echo "" 1472echo ""
1473if [ "$TARGET_MKCONF" != "$etc_mk_conf" ]; then 1473if [ "$TARGET_MKCONF" != "$etc_mk_conf" ]; then
1474 echo "Please copy it to $etc_mk_conf to use it." 1474 echo "Please copy it to $etc_mk_conf to use it."
1475 echo "" 1475 echo ""
1476fi 1476fi
1477echo "You can find extensive documentation of the NetBSD Packages Collection" 1477echo "You can find extensive documentation of the NetBSD Packages Collection"
1478echo "in $pkgsrcdir/doc/pkgsrc.txt." 1478echo "in $pkgsrcdir/doc/pkgsrc.txt."
1479echo "" 1479echo ""
1480echo "Thank you for using pkgsrc!" 1480echo "Thank you for using pkgsrc!"
1481echo "" 1481echo ""
1482echo "$hline" 1482echo "$hline"
1483echo "" 1483echo ""
1484 1484
1485echo_msg "bootstrap started: $build_start" 1485echo_msg "bootstrap started: $build_start"
1486echo_msg "bootstrap ended: `date`" 1486echo_msg "bootstrap ended: `date`"
1487 1487
1488exit 0 1488exit 0