Thu Nov 15 22:08:30 2018 UTC ()
Update the root_group for Minix to match the changes to mk files.

Head up by <leot>


(sevan)
diff -r1.259 -r1.260 pkgsrc/bootstrap/bootstrap

cvs diff -r1.259 -r1.260 pkgsrc/bootstrap/bootstrap (switch to unified diff)

--- pkgsrc/bootstrap/bootstrap 2018/11/11 19:31:54 1.259
+++ pkgsrc/bootstrap/bootstrap 2018/11/15 22:08:30 1.260
@@ -1,1431 +1,1431 @@ @@ -1,1431 +1,1431 @@
1#! /bin/sh 1#! /bin/sh
2 2
3# $NetBSD: bootstrap,v 1.259 2018/11/11 19:31:54 rillig Exp $ 3# $NetBSD: bootstrap,v 1.260 2018/11/15 22:08:30 sevan 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 34
35BOOTSTRAP_VERSION=20060721 35BOOTSTRAP_VERSION=20060721
36 36
37# Don't let the bootstrap program get confused by a pre-existing mk.conf 37# Don't let the bootstrap program get confused by a pre-existing mk.conf
38# file. 38# file.
39MAKECONF=/dev/null 39MAKECONF=/dev/null
40export MAKECONF 40export MAKECONF
41 41
42# No vulnerability checks since there might be an incompatible checker installed 42# No vulnerability checks since there might be an incompatible checker installed
43NO_PKGTOOLS_REQD_CHECK=yes 43NO_PKGTOOLS_REQD_CHECK=yes
44export NO_PKGTOOLS_REQD_CHECK 44export NO_PKGTOOLS_REQD_CHECK
45 45
46unprivileged=no 46unprivileged=no
47 47
48preserve_path=no 48preserve_path=no
49 49
50# where the building takes place 50# where the building takes place
51bootstrapdir=`dirname "$0"` 51bootstrapdir=`dirname "$0"`
52bootstrapdir=`cd "${bootstrapdir}" && pwd` 52bootstrapdir=`cd "${bootstrapdir}" && pwd`
53pkgsrcdir=`dirname "${bootstrapdir}"` 53pkgsrcdir=`dirname "${bootstrapdir}"`
54wrkdir="`pwd`/work" 54wrkdir="`pwd`/work"
55 55
56usage="Usage: $0 "' 56usage="Usage: $0 "'
57 [ --abi [32|64] ] 57 [ --abi [32|64] ]
58 [ --binary-kit <tarball> ] 58 [ --binary-kit <tarball> ]
59 [ --binary-macpkg <pkg> ] 59 [ --binary-macpkg <pkg> ]
60 [ --compiler <compiler> ] 60 [ --compiler <compiler> ]
61 [ --cwrappers <auto|yes|no> ] 61 [ --cwrappers <auto|yes|no> ]
62 [ --full ] 62 [ --full ]
63 [ --gzip-binary-kit <tarball> ] 63 [ --gzip-binary-kit <tarball> ]
64 [ --help ] 64 [ --help ]
65 [ --make-jobs <num> ] 65 [ --make-jobs <num> ]
66 [ --mk-fragment <mk.conf> ] 66 [ --mk-fragment <mk.conf> ]
67 [ --pkgdbdir <pkgdbdir> ] 67 [ --pkgdbdir <pkgdbdir> ]
68 [ --pkginfodir <pkginfodir> ] 68 [ --pkginfodir <pkginfodir> ]
69 [ --pkgmandir <pkgmandir> ] 69 [ --pkgmandir <pkgmandir> ]
70 [ --prefer-pkgsrc <list|yes|no> ] 70 [ --prefer-pkgsrc <list|yes|no> ]
71 [ --prefix <prefix> ] 71 [ --prefix <prefix> ]
72 [ --preserve-path ] 72 [ --preserve-path ]
73 [ --quiet ] 73 [ --quiet ]
74 [ --sysconfdir <sysconfdir> ] 74 [ --sysconfdir <sysconfdir> ]
75 [ --unprivileged | --ignore-user-check ] 75 [ --unprivileged | --ignore-user-check ]
76 [ --varbase <varbase> ] 76 [ --varbase <varbase> ]
77 [ --workdir <workdir> ] 77 [ --workdir <workdir> ]
78' 78'
79 79
80# strip / for BSD/OS, strip - for HP-UX 80# strip / for BSD/OS, strip - for HP-UX
81opsys=`uname -s | tr -d /-` 81opsys=`uname -s | tr -d /-`
82 82
83mkbinarykit_macpkg() 83mkbinarykit_macpkg()
84{ 84{
85 local macdestdir 85 local macdestdir
86 macdestdir=${wrkdir}/macpkg-destdir 86 macdestdir=${wrkdir}/macpkg-destdir
87 rm -rf ${macdestdir} || die "cleanup destdir" 87 rm -rf ${macdestdir} || die "cleanup destdir"
88 88
89 mkdir -p ${macdestdir}${prefix} || die "mkdir destprefix" 89 mkdir -p ${macdestdir}${prefix} || die "mkdir destprefix"
90 rmdir ${macdestdir}${prefix} || die "rmdir destprefix" 90 rmdir ${macdestdir}${prefix} || die "rmdir destprefix"
91 cp -Rp ${prefix} ${macdestdir}${prefix} || die "copy prefix" 91 cp -Rp ${prefix} ${macdestdir}${prefix} || die "copy prefix"
92 92
93 if [ ! -d ${macdestdir}${pkgdbdir} ]; then 93 if [ ! -d ${macdestdir}${pkgdbdir} ]; then
94 mkdir -p ${macdestdir}${pkgdbdir} || die "mkdir destdbdir" 94 mkdir -p ${macdestdir}${pkgdbdir} || die "mkdir destdbdir"
95 rmdir ${macdestdir}${pkgdbdir} || die "rmdir destdbdir" 95 rmdir ${macdestdir}${pkgdbdir} || die "rmdir destdbdir"
96 cp -Rp ${pkgdbdir} ${macdestdir}${pkgdbdir} || die "copy dbdir" 96 cp -Rp ${pkgdbdir} ${macdestdir}${pkgdbdir} || die "copy dbdir"
97 fi 97 fi
98 98
99 ${sedprog} -e "s|%WRKDIR%|${wrkdir}|g" \ 99 ${sedprog} -e "s|%WRKDIR%|${wrkdir}|g" \
100 -e "s|%TARGETDIR%|${targetdir}|g" -e "s|%DATE%|${date}|g" \ 100 -e "s|%TARGETDIR%|${targetdir}|g" -e "s|%DATE%|${date}|g" \
101 < macpkg.pmproj.in > ${wrkdir}/macpkg.pmproj 101 < macpkg.pmproj.in > ${wrkdir}/macpkg.pmproj
102 ${packagemaker} -build -proj ${wrkdir}/macpkg.pmproj -p "${binary_macpkg}" 102 ${packagemaker} -build -proj ${wrkdir}/macpkg.pmproj -p "${binary_macpkg}"
103} 103}
104 104
105mkbinarykit_tar() 105mkbinarykit_tar()
106{ 106{
107 # in case tar was built by bootstrap 107 # in case tar was built by bootstrap
108 PATH="$prefix/bin:$PATH"; export PATH 108 PATH="$prefix/bin:$PATH"; export PATH
109 cd / && tar -hcf "${binary_kit}" .$prefix .$pkgdbdir .$etc_mk_conf 109 cd / && tar -hcf "${binary_kit}" .$prefix .$pkgdbdir .$etc_mk_conf
110} 110}
111 111
112mkbinarykit_tgz() 112mkbinarykit_tgz()
113{ 113{
114 # in case tar was built by bootstrap 114 # in case tar was built by bootstrap
115 PATH="$prefix/bin:$PATH"; export PATH 115 PATH="$prefix/bin:$PATH"; export PATH
116 cd / && tar -hcf - .$prefix .$pkgdbdir .$etc_mk_conf | gzip > "${binary_gzip_kit}" 116 cd / && tar -hcf - .$prefix .$pkgdbdir .$etc_mk_conf | gzip > "${binary_gzip_kit}"
117} 117}
118 118
119die() 119die()
120{ 120{
121 echo >&2 "$@" 121 echo >&2 "$@"
122 exit 1 122 exit 1
123} 123}
124 124
125echo_msg() 125echo_msg()
126{ 126{
127 echo "===> $@" 127 echo "===> $@"
128} 128}
129 129
130# see if we're using gcc. If so, set $compiler_is_gnu to '1'. 130# see if we're using gcc. If so, set $compiler_is_gnu to '1'.
131get_compiler() 131get_compiler()
132{ 132{
133 testcc="${CC}" 133 testcc="${CC}"
134 # normally, we'd just use 'cc', but certain configure tools look 134 # normally, we'd just use 'cc', but certain configure tools look
135 # for gcc specifically, so we have to see if that comes first 135 # for gcc specifically, so we have to see if that comes first
136 if [ -z "${testcc}" ]; then 136 if [ -z "${testcc}" ]; then
137 save_IFS="${IFS}" 137 save_IFS="${IFS}"
138 IFS=':' 138 IFS=':'
139 for dir in ${PATH}; do 139 for dir in ${PATH}; do
140 test -z "$dir" && dir=. 140 test -z "$dir" && dir=.
141 if [ -x "$dir/gcc" ]; then 141 if [ -x "$dir/gcc" ]; then
142 testcc="$dir/gcc" 142 testcc="$dir/gcc"
143 break 143 break
144 fi 144 fi
145 done 145 done
146 IFS="${save_IFS}" 146 IFS="${save_IFS}"
147 fi 147 fi
148 148
149 # Clang compiler pretends to be GCC, so we have to check that 149 # Clang compiler pretends to be GCC, so we have to check that
150 cat >${wrkdir}/$$.c <<EOF 150 cat >${wrkdir}/$$.c <<EOF
151#ifdef __clang__ 151#ifdef __clang__
152indeed 152indeed
153#endif 153#endif
154EOF 154EOF
155 compiler_is_clang=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed` 155 compiler_is_clang=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed`
156 rm -f ${wrkdir}/$$.c 156 rm -f ${wrkdir}/$$.c
157 157
158 cat >${wrkdir}/$$.c <<EOF 158 cat >${wrkdir}/$$.c <<EOF
159#ifdef __GNUC__ 159#ifdef __GNUC__
160#ifndef __clang__ 160#ifndef __clang__
161indeed 161indeed
162#endif 162#endif
163#endif 163#endif
164EOF 164EOF
165 compiler_is_gnu=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed` 165 compiler_is_gnu=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed`
166 rm -f ${wrkdir}/$$.c 166 rm -f ${wrkdir}/$$.c
167 167
168} 168}
169get_abi() 169get_abi()
170{ 170{
171 abi_opsys=$@ 171 abi_opsys=$@
172 172
173 if [ -n "$abi" ]; then 173 if [ -n "$abi" ]; then
174 case "$abi_opsys" in 174 case "$abi_opsys" in
175 IRIX) 175 IRIX)
176 die "ERROR: $abi_opsys has special ABI handling, --abi not supported (yet)." 176 die "ERROR: $abi_opsys has special ABI handling, --abi not supported (yet)."
177 ;; 177 ;;
178 esac 178 esac
179 fi 179 fi
180 180
181 case "$abi_opsys" in 181 case "$abi_opsys" in
182 IRIX) 182 IRIX)
183 if [ `uname -r` -ge 6 ]; then 183 if [ `uname -r` -ge 6 ]; then
184 abi=`sed -e 's/.*\(abi=\)\([on]*[36][24]\).*/\2/' /etc/compiler.defaults` 184 abi=`sed -e 's/.*\(abi=\)\([on]*[36][24]\).*/\2/' /etc/compiler.defaults`
185 isa=`sed -e 's/.*\(isa=mips\)\([1234]\).*/\2/' /etc/compiler.defaults` 185 isa=`sed -e 's/.*\(isa=mips\)\([1234]\).*/\2/' /etc/compiler.defaults`
186 case "$abi" in 186 case "$abi" in
187 o32) 187 o32)
188 imakeopts="-DBuildO32 -DSgiISAo32=$isa" 188 imakeopts="-DBuildO32 -DSgiISAo32=$isa"
189 abi="" 189 abi=""
190 ;; 190 ;;
191 n32) imakeopts="-DBuildN32 -DSgiISA32=$isa" 191 n32) imakeopts="-DBuildN32 -DSgiISA32=$isa"
192 abi="32" 192 abi="32"
193 ;; 193 ;;
194 64 | n64) 194 64 | n64)
195 imakeopts="-DBuild64bit -DSgiISA64=$isa" 195 imakeopts="-DBuild64bit -DSgiISA64=$isa"
196 abi="64" 196 abi="64"
197 ;; 197 ;;
198 esac 198 esac
199 else # IRIX before 6 199 else # IRIX before 6
200 abi=32 200 abi=32
201 fi 201 fi
202 ;; 202 ;;
203 esac 203 esac
204} 204}
205 205
206get_machine_arch_aix() 206get_machine_arch_aix()
207{ 207{
208 _cpuid=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` 208 _cpuid=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
209 if /usr/sbin/lsattr -El $_cpuid | grep ' POWER' >/dev/null 2>&1; then 209 if /usr/sbin/lsattr -El $_cpuid | grep ' POWER' >/dev/null 2>&1; then
210 echo rs6000 210 echo rs6000
211 else 211 else
212 echo powerpc 212 echo powerpc
213 fi 213 fi
214} 214}
215 215
216get_machine_arch_darwin() 216get_machine_arch_darwin()
217{ 217{
218 case `uname -p` in 218 case `uname -p` in
219 i386) 219 i386)
220 # Returns "i386" or "x86_64" depending on CPU 220 # Returns "i386" or "x86_64" depending on CPU
221 echo `uname -m` 221 echo `uname -m`
222 ;; 222 ;;
223 powerpc) 223 powerpc)
224 # sysctl mib exists on 64-bit hardware 224 # sysctl mib exists on 64-bit hardware
225 if [ -n "`sysctl -n hw.optional.64bitops 2>/dev/null`" ]; then 225 if [ -n "`sysctl -n hw.optional.64bitops 2>/dev/null`" ]; then
226 echo "powerpc64" 226 echo "powerpc64"
227 else 227 else
228 echo "powerpc" 228 echo "powerpc"
229 fi 229 fi
230 ;; 230 ;;
231 esac 231 esac
232} 232}
233 233
234check_prog() 234check_prog()
235{ 235{
236 _var="$1"; _name="$2" 236 _var="$1"; _name="$2"
237 237
238 eval _tmp=\"\$$_var\" 238 eval _tmp=\"\$$_var\"
239 if [ "x$_tmp" != "x" ]; then 239 if [ "x$_tmp" != "x" ]; then
240 # Variable is already set (by the user, for example) 240 # Variable is already set (by the user, for example)
241 return 0 241 return 0
242 fi 242 fi
243 243
244 for _d in `echo $PATH | tr ':' ' '`; do 244 for _d in `echo $PATH | tr ':' ' '`; do
245 if [ -f "$_d/$_name" ] && [ -x "$_d/$_name" ]; then 245 if [ -f "$_d/$_name" ] && [ -x "$_d/$_name" ]; then
246 # Program found 246 # Program found
247 eval $_var=\""$_d/$_name"\" 247 eval $_var=\""$_d/$_name"\"
248 return 1 248 return 1
249 fi 249 fi
250 done 250 done
251 251
252 die "$_name not found in path." 252 die "$_name not found in path."
253} 253}
254 254
255opsys_finish() 255opsys_finish()
256{ 256{
257 case "$opsys" in 257 case "$opsys" in
258 IRIX) 258 IRIX)
259 if [ -n "$imakeopts" ]; then 259 if [ -n "$imakeopts" ]; then
260 echo "IMAKEOPTS+= $imakeopts" >> ${TARGET_MKCONF} 260 echo "IMAKEOPTS+= $imakeopts" >> ${TARGET_MKCONF}
261 fi 261 fi
262 if [ `uname -r` -lt 6 ]; then 262 if [ `uname -r` -lt 6 ]; then
263 echo_msg "Installing fake ldd script" 263 echo_msg "Installing fake ldd script"
264 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/fakeldd $prefix/sbin" 264 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/fakeldd $prefix/sbin"
265 need_extras=yes 265 need_extras=yes
266 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF} 266 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF}
267 fi 267 fi
268 ;; 268 ;;
269 Haiku) 269 Haiku)
270 need_extras=yes 270 need_extras=yes
271 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF} 271 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF}
272 ;; 272 ;;
273 esac 273 esac
274} 274}
275 275
276is_root() 276is_root()
277{ 277{
278 if [ `uname -s` = "IRIX" ]; then 278 if [ `uname -s` = "IRIX" ]; then
279 if [ `uname -r` -lt 6 -a -z "$ID" ]; then 279 if [ `uname -r` -lt 6 -a -z "$ID" ]; then
280 # older version of IRIX have an id command with limited features 280 # older version of IRIX have an id command with limited features
281 if [ "`$idprog`" != "uid=0(root) gid=0(sys)" ]; then 281 if [ "`$idprog`" != "uid=0(root) gid=0(sys)" ]; then
282 return 1 282 return 1
283 fi 283 fi
284 return 0 284 return 0
285 fi 285 fi
286 fi 286 fi
287 if [ `$idprog -u` != 0 ]; then 287 if [ `$idprog -u` != 0 ]; then
288 return 1 288 return 1
289 fi 289 fi
290 return 0 290 return 0
291} 291}
292 292
293# run a command, abort if it fails 293# run a command, abort if it fails
294run_cmd() 294run_cmd()
295{ 295{
296 echo_msg "running: $@" 296 echo_msg "running: $@"
297 eval "$@" 297 eval "$@"
298 ret=$? 298 ret=$?
299 if [ $ret -ne 0 ]; then 299 if [ $ret -ne 0 ]; then
300 echo_msg "exited with status $ret" 300 echo_msg "exited with status $ret"
301 die "aborted." 301 die "aborted."
302 fi 302 fi
303} 303}
304 304
305# Some versions of mkdir (notably SunOS) bail out too easily, so use the 305# Some versions of mkdir (notably SunOS) bail out too easily, so use the
306# install-sh wrapper instead. 306# install-sh wrapper instead.
307mkdir_p() 307mkdir_p()
308{ 308{
309 for dir in $@; do 309 for dir in $@; do
310 run_cmd "$install_sh -d -o $user -g $group $dir" 310 run_cmd "$install_sh -d -o $user -g $group $dir"
311 done 311 done
312} 312}
313 313
314mkdir_p_early() 314mkdir_p_early()
315{ 315{
316 [ -d "$1" ] && return 0 316 [ -d "$1" ] && return 0
317 mkdir -p "$1" 2> /dev/null && return 0 317 mkdir -p "$1" 2> /dev/null && return 0
318 parent=`dirname "$1"` 318 parent=`dirname "$1"`
319 mkdir_p_early "$parent" 319 mkdir_p_early "$parent"
320 if [ ! -d "$1" ] && mkdir "$1"; then 320 if [ ! -d "$1" ] && mkdir "$1"; then
321 echo_msg "mkdir $1 exited with status $?" 321 echo_msg "mkdir $1 exited with status $?"
322 die "aborted." 322 die "aborted."
323 fi 323 fi
324 return 0 324 return 0
325} 325}
326 326
327copy_src() 327copy_src()
328{ 328{
329 _src="$1"; _dst="$2" 329 _src="$1"; _dst="$2"
330 if [ ! -d $wrkdir/$_dst ]; then 330 if [ ! -d $wrkdir/$_dst ]; then
331 mkdir_p $wrkdir/$_dst 331 mkdir_p $wrkdir/$_dst
332 fi 332 fi
333 $cpprog -r $_src/* $wrkdir/$_dst 333 $cpprog -r $_src/* $wrkdir/$_dst
334 if [ -f $wrkdir/$_dst/config.guess ]; then 334 if [ -f $wrkdir/$_dst/config.guess ]; then
335 $cpprog $pkgsrcdir/mk/gnu-config/config.guess $wrkdir/$_dst/ 335 $cpprog $pkgsrcdir/mk/gnu-config/config.guess $wrkdir/$_dst/
336 fi 336 fi
337 if [ -f $wrkdir/$_dst/config.sub ]; then 337 if [ -f $wrkdir/$_dst/config.sub ]; then
338 $cpprog $pkgsrcdir/mk/gnu-config/config.sub $wrkdir/$_dst/ 338 $cpprog $pkgsrcdir/mk/gnu-config/config.sub $wrkdir/$_dst/
339 fi 339 fi
340} 340}
341 341
342get_optarg() 342get_optarg()
343{ 343{
344 expr "x$1" : "x[^=]*=\\(.*\\)" 344 expr "x$1" : "x[^=]*=\\(.*\\)"
345} 345}
346 346
347checkarg_sane_absolute_path() { 347checkarg_sane_absolute_path() {
348 case "$1" in 348 case "$1" in
349 "") ;; # the default value will be used. 349 "") ;; # the default value will be used.
350 *[!-A-Za-z0-9_./]*) 350 *[!-A-Za-z0-9_./]*)
351 die "ERROR: Invalid characters in path $1 (from $2)." ;; 351 die "ERROR: Invalid characters in path $1 (from $2)." ;;
352 */) die "ERROR: The argument to $2 must not end in /." ;; 352 */) die "ERROR: The argument to $2 must not end in /." ;;
353 /*) ;; 353 /*) ;;
354 *) die "ERROR: The argument to $2 must be an absolute path." ;; 354 *) die "ERROR: The argument to $2 must be an absolute path." ;;
355 esac 355 esac
356} 356}
357 357
358checkarg_sane_relative_path() { 358checkarg_sane_relative_path() {
359 case "$1" in 359 case "$1" in
360 "") ;; # the default value will be used. 360 "") ;; # the default value will be used.
361 *[!-A-Za-z0-9_./]*) 361 *[!-A-Za-z0-9_./]*)
362 die "ERROR: Invalid characters in path $1 (from $2)." ;; 362 die "ERROR: Invalid characters in path $1 (from $2)." ;;
363 /*) die "ERROR: The argument to $2 must be a relative path." ;; 363 /*) die "ERROR: The argument to $2 must be a relative path." ;;
364 *) ;; 364 *) ;;
365 esac 365 esac
366} 366}
367 367
368bootstrap_sh=${SH-/bin/sh} 368bootstrap_sh=${SH-/bin/sh}
369bootstrap_sh_set=${SH+set} 369bootstrap_sh_set=${SH+set}
370 370
371case "$bootstrap_sh" in 371case "$bootstrap_sh" in
372/*) 372/*)
373 ;; 373 ;;
374*) 374*)
375 die "ERROR: The variable SH must contain an absolute path" 375 die "ERROR: The variable SH must contain an absolute path"
376 ;; 376 ;;
377esac 377esac
378 378
379# On some newer Ubuntu installations, /bin/sh is a symlink to /bin/dash, 379# On some newer Ubuntu installations, /bin/sh is a symlink to /bin/dash,
380# whose echo(1) is not BSD-compatible. 380# whose echo(1) is not BSD-compatible.
381# On all Debian GNU/kFreeBSD 7.0, /bin/sh is a symlink to /bin/dash, and 381# On all Debian GNU/kFreeBSD 7.0, /bin/sh is a symlink to /bin/dash, and
382# use /bin/bash. bootstrap forces /bin/bash is used. 382# use /bin/bash. bootstrap forces /bin/bash is used.
383dash_echo_test=`$bootstrap_sh -c 'echo "\\100"'` 383dash_echo_test=`$bootstrap_sh -c 'echo "\\100"'`
384if [ "$opsys" != "GNUkFreeBSD" ] && [ "$dash_echo_test" = "@" ]; then 384if [ "$opsys" != "GNUkFreeBSD" ] && [ "$dash_echo_test" = "@" ]; then
385 { echo "ERROR: Your shell's echo command is not BSD-compatible." 385 { echo "ERROR: Your shell's echo command is not BSD-compatible."
386 echo "ERROR: Please select another shell by setting the environment" 386 echo "ERROR: Please select another shell by setting the environment"
387 echo "ERROR: variable SH." 387 echo "ERROR: variable SH."
388 } 1>&2 388 } 1>&2
389 exit 1; 389 exit 1;
390fi 390fi
391 391
392if [ -n "$PKG_PATH" ]; then 392if [ -n "$PKG_PATH" ]; then
393 die "ERROR: Please unset PKG_PATH before running bootstrap." 393 die "ERROR: Please unset PKG_PATH before running bootstrap."
394fi 394fi
395 395
396build_start=`date` 396build_start=`date`
397echo_msg "bootstrap command: $0 $@" 397echo_msg "bootstrap command: $0 $@"
398echo_msg "bootstrap started: $build_start" 398echo_msg "bootstrap started: $build_start"
399 399
400# ensure system locations are empty; we will set them later when we know 400# ensure system locations are empty; we will set them later when we know
401# whether they will be system wide or user specific 401# whether they will be system wide or user specific
402prefix= 402prefix=
403pkgdbdir= 403pkgdbdir=
404pkginfodir= 404pkginfodir=
405pkgmandir= 405pkgmandir=
406sysconfdir= 406sysconfdir=
407varbase= 407varbase=
408 408
409compiler="" 409compiler=""
410cwrappers=auto 410cwrappers=auto
411full=no 411full=no
412make_jobs=1 412make_jobs=1
413mk_fragment= 413mk_fragment=
414quiet=no 414quiet=no
415 415
416while [ $# -gt 0 ]; do 416while [ $# -gt 0 ]; do
417 case $1 in 417 case $1 in
418 --workdir=*) wrkdir=`get_optarg "$1"` ;; 418 --workdir=*) wrkdir=`get_optarg "$1"` ;;
419 --workdir) wrkdir="$2"; shift ;; 419 --workdir) wrkdir="$2"; shift ;;
420 --prefix=*) prefix=`get_optarg "$1"` ;; 420 --prefix=*) prefix=`get_optarg "$1"` ;;
421 --prefix) prefix="$2"; shift ;; 421 --prefix) prefix="$2"; shift ;;
422 --pkgdbdir=*) pkgdbdir=`get_optarg "$1"` ;; 422 --pkgdbdir=*) pkgdbdir=`get_optarg "$1"` ;;
423 --pkgdbdir) pkgdbdir="$2"; shift ;; 423 --pkgdbdir) pkgdbdir="$2"; shift ;;
424 --pkginfodir=*) pkginfodir=`get_optarg "$1"` ;; 424 --pkginfodir=*) pkginfodir=`get_optarg "$1"` ;;
425 --pkginfodir) pkginfodir="$2"; shift ;; 425 --pkginfodir) pkginfodir="$2"; shift ;;
426 --pkgmandir=*) pkgmandir=`get_optarg "$1"` ;; 426 --pkgmandir=*) pkgmandir=`get_optarg "$1"` ;;
427 --pkgmandir) pkgmandir="$2"; shift ;; 427 --pkgmandir) pkgmandir="$2"; shift ;;
428 --sysconfdir=*) sysconfdir=`get_optarg "$1"` ;; 428 --sysconfdir=*) sysconfdir=`get_optarg "$1"` ;;
429 --sysconfdir) sysconfdir="$2"; shift ;; 429 --sysconfdir) sysconfdir="$2"; shift ;;
430 --varbase=*) varbase=`get_optarg "$1"` ;; 430 --varbase=*) varbase=`get_optarg "$1"` ;;
431 --varbase) varbase="$2"; shift ;; 431 --varbase) varbase="$2"; shift ;;
432 --compiler=*) compiler=`get_optarg "$1"` ;; 432 --compiler=*) compiler=`get_optarg "$1"` ;;
433 --compiler) compiler="$2"; shift ;; 433 --compiler) compiler="$2"; shift ;;
434 --abi=*) abi=`get_optarg "$1"` ;; 434 --abi=*) abi=`get_optarg "$1"` ;;
435 --abi) abi="$2"; shift ;; 435 --abi) abi="$2"; shift ;;
436 --cwrappers=*) cwrappers=`get_optarg "$1"` ;; 436 --cwrappers=*) cwrappers=`get_optarg "$1"` ;;
437 --cwrappers) cwrappers="$2"; shift ;; 437 --cwrappers) cwrappers="$2"; shift ;;
438 --unprivileged | --ignore-user-check) unprivileged=yes ;; 438 --unprivileged | --ignore-user-check) unprivileged=yes ;;
439 --prefer-pkgsrc=*) 439 --prefer-pkgsrc=*)
440 prefer_pkgsrc=`get_optarg "$1"` ;; 440 prefer_pkgsrc=`get_optarg "$1"` ;;
441 --prefer-pkgsrc) 441 --prefer-pkgsrc)
442 prefer_pkgsrc="$2"; shift ;; 442 prefer_pkgsrc="$2"; shift ;;
443 --preserve-path) preserve_path=yes ;; 443 --preserve-path) preserve_path=yes ;;
444 --mk-fragment=*) 444 --mk-fragment=*)
445 mk_fragment=`get_optarg "$1"` ;; 445 mk_fragment=`get_optarg "$1"` ;;
446 --mk-fragment) 446 --mk-fragment)
447 mk_fragment="$2"; shift ;; 447 mk_fragment="$2"; shift ;;
448 --binary-kit=*) 448 --binary-kit=*)
449 binary_kit=`get_optarg "$1"` ;; 449 binary_kit=`get_optarg "$1"` ;;
450 --binary-kit) 450 --binary-kit)
451 binary_kit="$2"; shift ;; 451 binary_kit="$2"; shift ;;
452 --gzip-binary-kit=*) 452 --gzip-binary-kit=*)
453 binary_gzip_kit=`get_optarg "$1"` ;; 453 binary_gzip_kit=`get_optarg "$1"` ;;
454 --gzip-binary-kit) 454 --gzip-binary-kit)
455 binary_gzip_kit="$2"; shift ;; 455 binary_gzip_kit="$2"; shift ;;
456 --binary-macpkg=*) 456 --binary-macpkg=*)
457 binary_macpkg=`get_optarg "$1"` ;; 457 binary_macpkg=`get_optarg "$1"` ;;
458 --binary-macpkg) 458 --binary-macpkg)
459 binary_macpkg="$2"; shift ;; 459 binary_macpkg="$2"; shift ;;
460 --make-jobs=*) make_jobs=`get_optarg "$1"` ;; 460 --make-jobs=*) make_jobs=`get_optarg "$1"` ;;
461 --make-jobs) make_jobs="$2"; shift ;; 461 --make-jobs) make_jobs="$2"; shift ;;
462 --full) full=yes ;; 462 --full) full=yes ;;
463 --quiet) quiet=yes ;; 463 --quiet) quiet=yes ;;
464 --help) echo "$usage"; exit ;; 464 --help) echo "$usage"; exit ;;
465 -h) echo "$usage"; exit ;; 465 -h) echo "$usage"; exit ;;
466 -*) echo "${0##*/}: unknown option \"$1\"" 1>&2 466 -*) echo "${0##*/}: unknown option \"$1\"" 1>&2
467 echo "$usage" 1>&2; exit 1 ;; 467 echo "$usage" 1>&2; exit 1 ;;
468 esac 468 esac
469 shift 469 shift
470done 470done
471 471
472checkarg_sane_absolute_path "$wrkdir" "--workdir" 472checkarg_sane_absolute_path "$wrkdir" "--workdir"
473checkarg_sane_absolute_path "$prefix" "--prefix" 473checkarg_sane_absolute_path "$prefix" "--prefix"
474checkarg_sane_absolute_path "$pkgdbdir" "--pkgdbdir" 474checkarg_sane_absolute_path "$pkgdbdir" "--pkgdbdir"
475checkarg_sane_absolute_path "$sysconfdir" "--sysconfdir" 475checkarg_sane_absolute_path "$sysconfdir" "--sysconfdir"
476checkarg_sane_absolute_path "$varbase" "--varbase" 476checkarg_sane_absolute_path "$varbase" "--varbase"
477checkarg_sane_relative_path "$pkginfodir" "--pkginfodir" 477checkarg_sane_relative_path "$pkginfodir" "--pkginfodir"
478checkarg_sane_relative_path "$pkgmandir" "--pkgmandir" 478checkarg_sane_relative_path "$pkgmandir" "--pkgmandir"
479 479
480# set defaults for system locations if not already set by the user 480# set defaults for system locations if not already set by the user
481wrkobjdir=${wrkdir}/pkgsrc 481wrkobjdir=${wrkdir}/pkgsrc
482if [ "$unprivileged" = "yes" ]; then 482if [ "$unprivileged" = "yes" ]; then
483 [ -z "$prefix" ] && prefix=${HOME}/pkg 483 [ -z "$prefix" ] && prefix=${HOME}/pkg
484elif [ -z "$prefix" -o "$prefix" = "/usr/pkg" ]; then 484elif [ -z "$prefix" -o "$prefix" = "/usr/pkg" ]; then
485 prefix=/usr/pkg 485 prefix=/usr/pkg
486 [ -z "$varbase" ] && varbase=/var 486 [ -z "$varbase" ] && varbase=/var
487fi 487fi
488 488
489[ -z "$varbase" ] && varbase=${prefix}/var 489[ -z "$varbase" ] && varbase=${prefix}/var
490[ -z "$pkgdbdir" ] && pkgdbdir=${prefix}/pkgdb 490[ -z "$pkgdbdir" ] && pkgdbdir=${prefix}/pkgdb
491 491
492if [ "$prefix" = "/usr" ]; then 492if [ "$prefix" = "/usr" ]; then
493 [ -z "$pkginfodir" ] && pkginfodir=share/info 493 [ -z "$pkginfodir" ] && pkginfodir=share/info
494 [ -z "$pkgmandir" ] && pkgmandir=share/man 494 [ -z "$pkgmandir" ] && pkgmandir=share/man
495else 495else
496 [ -z "$pkginfodir" ] && pkginfodir=info 496 [ -z "$pkginfodir" ] && pkginfodir=info
497 [ -z "$pkgmandir" ] && pkgmandir=man 497 [ -z "$pkgmandir" ] && pkgmandir=man
498fi 498fi
499infodir=${prefix}/${pkginfodir} 499infodir=${prefix}/${pkginfodir}
500mandir=${prefix}/${pkgmandir} 500mandir=${prefix}/${pkgmandir}
501[ -z "$sysconfdir" ] && sysconfdir=${prefix}/etc 501[ -z "$sysconfdir" ] && sysconfdir=${prefix}/etc
502 502
503if [ "x$preserve_path" != "xyes" ]; then 503if [ "x$preserve_path" != "xyes" ]; then
504 PATH="$PATH:/sbin:/usr/sbin" 504 PATH="$PATH:/sbin:/usr/sbin"
505fi 505fi
506 506
507overpath="" 507overpath=""
508root_user=root 508root_user=root
509bmakexargs= 509bmakexargs=
510need_extras=no 510need_extras=no
511use_bsdinstall= 511use_bsdinstall=
512case "$opsys" in 512case "$opsys" in
513AIX) 513AIX)
514 root_group=system 514 root_group=system
515 need_bsd_install=yes 515 need_bsd_install=yes
516 need_awk=yes 516 need_awk=yes
517 need_sed=yes 517 need_sed=yes
518 need_ksh=yes 518 need_ksh=yes
519 need_fixed_strip=yes 519 need_fixed_strip=yes
520 set_opsys=no 520 set_opsys=no
521 machine_arch=`get_machine_arch_aix` 521 machine_arch=`get_machine_arch_aix`
522 ;; 522 ;;
523Bitrig) 523Bitrig)
524 root_group=wheel 524 root_group=wheel
525 need_bsd_install=no 525 need_bsd_install=no
526 need_awk=no 526 need_awk=no
527 need_sed=no 527 need_sed=no
528 set_opsys=no 528 set_opsys=no
529 machine_arch=`arch -s` 529 machine_arch=`arch -s`
530 check_compiler=yes 530 check_compiler=yes
531 ;; 531 ;;
532CYGWIN_*) 532CYGWIN_*)
533 is_root () { 533 is_root () {
534 if id -nG | grep -q 'Administrators'; then 534 if id -nG | grep -q 'Administrators'; then
535 return 0 535 return 0
536 fi 536 fi
537 return 1 537 return 1
538 } 538 }
539 root_user=Administrators 539 root_user=Administrators
540 root_group=Administrators 540 root_group=Administrators
541 need_bsd_install=no 541 need_bsd_install=no
542 opsys=`uname -o` 542 opsys=`uname -o`
543 need_awk=no 543 need_awk=no
544 need_sed=no 544 need_sed=no
545 need_xargs=no 545 need_xargs=no
546 machine_arch=`uname -m` 546 machine_arch=`uname -m`
547 # only used for unprivileged builds. 547 # only used for unprivileged builds.
548 whoamiprog='id -u' 548 whoamiprog='id -u'
549 groupsprog='id -g' 549 groupsprog='id -g'
550 ;; 550 ;;
551 551
552Darwin) 552Darwin)
553 root_group=wheel 553 root_group=wheel
554 need_bsd_install=no 554 need_bsd_install=no
555 need_awk=no 555 need_awk=no
556 need_sed=no 556 need_sed=no
557 set_opsys=no 557 set_opsys=no
558 machine_arch=`get_machine_arch_darwin` 558 machine_arch=`get_machine_arch_darwin`
559 CC=${CC:-"cc -isystem /usr/include"}; export CC 559 CC=${CC:-"cc -isystem /usr/include"}; export CC
560 check_compiler=yes 560 check_compiler=yes
561 osrev=`uname -r` 561 osrev=`uname -r`
562 macosx_version=`echo $osrev | awk -F . '{ print "10."$1-4; }'` 562 macosx_version=`echo $osrev | awk -F . '{ print "10."$1-4; }'`
563 case "$macosx_version" in 563 case "$macosx_version" in
564 10.[7-9]) 564 10.[7-9])
565 packagemaker=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker 565 packagemaker=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
566 ;; 566 ;;
567 10.[0-4]) 567 10.[0-4])
568 packagemaker=/Developer/Tools/packagemaker 568 packagemaker=/Developer/Tools/packagemaker
569 ;; 569 ;;
570 *) 570 *)
571 packagemaker=/Developer/usr/bin/packagemaker 571 packagemaker=/Developer/usr/bin/packagemaker
572 ;; 572 ;;
573 esac 573 esac
574 case "$macosx_version" in 574 case "$macosx_version" in
575 10.[8-9]|10.1[0123]) 575 10.[8-9]|10.1[0123])
576 need_awk=yes 576 need_awk=yes
577 need_sed=yes 577 need_sed=yes
578 ;; 578 ;;
579 esac 579 esac
580 unset osrev macosx_version 580 unset osrev macosx_version
581 ;; 581 ;;
582DragonFly) 582DragonFly)
583 root_group=wheel 583 root_group=wheel
584 need_bsd_install=no 584 need_bsd_install=no
585 need_awk=no 585 need_awk=no
586 need_sed=no 586 need_sed=no
587 set_opsys=no 587 set_opsys=no
588 check_prog tarprog tar 588 check_prog tarprog tar
589 machine_arch=`uname -p` 589 machine_arch=`uname -p`
590 ;; 590 ;;
591FreeBSD) 591FreeBSD)
592 root_group=wheel 592 root_group=wheel
593 need_bsd_install=no 593 need_bsd_install=no
594 need_awk=no 594 need_awk=no
595 need_sed=no 595 need_sed=no
596 set_opsys=no 596 set_opsys=no
597 machine_arch=`uname -p` 597 machine_arch=`uname -p`
598 check_compiler=yes 598 check_compiler=yes
599 ;; 599 ;;
600FreeMiNT) 600FreeMiNT)
601 root_group=root 601 root_group=root
602 need_bsd_install=no 602 need_bsd_install=no
603 need_awk=no 603 need_awk=no
604 need_sed=no 604 need_sed=no
605 set_opsys=no 605 set_opsys=no
606 machine_arch=m68k 606 machine_arch=m68k
607 ;; 607 ;;
608GNUkFreeBSD) 608GNUkFreeBSD)
609 root_group=root 609 root_group=root
610 need_bsd_install=no 610 need_bsd_install=no
611 need_awk=yes 611 need_awk=yes
612 need_sed=no 612 need_sed=no
613 set_opsys=no 613 set_opsys=no
614 machine_arch=`uname -m` 614 machine_arch=`uname -m`
615 ;; 615 ;;
616Haiku) 616Haiku)
617 root_user=`id -un` 617 root_user=`id -un`
618 root_group=root 618 root_group=root
619 need_bsd_install=no 619 need_bsd_install=no
620 need_awk=no 620 need_awk=no
621 need_sed=no 621 need_sed=no
622 set_opsys=no 622 set_opsys=no
623 case `uname -m` in 623 case `uname -m` in
624 BeMac) 624 BeMac)
625 machine_arch=powerpc 625 machine_arch=powerpc
626 ;; 626 ;;
627 BePC) 627 BePC)
628 machine_arch=i386 628 machine_arch=i386
629 ;; 629 ;;
630 *) 630 *)
631 machine_arch=`uname -p` 631 machine_arch=`uname -p`
632 ;; 632 ;;
633 esac 633 esac
634 ;; 634 ;;
635HPUX) 635HPUX)
636 root_group=sys 636 root_group=sys
637 need_bsd_install=yes 637 need_bsd_install=yes
638 need_awk=yes 638 need_awk=yes
639 need_sed=yes 639 need_sed=yes
640 set_opsys=no 640 set_opsys=no
641 machine_arch=`uname -m | sed 's/^9000.*$/hppa/'` 641 machine_arch=`uname -m | sed 's/^9000.*$/hppa/'`
642 ;; 642 ;;
643Interix) 643Interix)
644 is_root () { 644 is_root () {
645 if id -G | grep -q 131616; then 645 if id -G | grep -q 131616; then
646 return 0 646 return 0
647 fi 647 fi
648 return 1 648 return 1
649 } 649 }
650 mkdir_p () { 650 mkdir_p () {
651 mkdir -p "$@" # allows umask to take effect 651 mkdir -p "$@" # allows umask to take effect
652 } 652 }
653 default_install_mode=0775 653 default_install_mode=0775
654 root_user=`id -un` 654 root_user=`id -un`
655 root_group=+Administrators 655 root_group=+Administrators
656 case `uname -r` in 656 case `uname -r` in
657 3.* | 5.*) 657 3.* | 5.*)
658 need_bsd_install=yes 658 need_bsd_install=yes
659 need_awk=yes 659 need_awk=yes
660 need_sed=yes 660 need_sed=yes
661 set_opsys=no 661 set_opsys=no
662 need_xargs=yes 662 need_xargs=yes
663 ;; 663 ;;
664 *) 664 *)
665 need_bsd_install=no 665 need_bsd_install=no
666 need_awk=no 666 need_awk=no
667 need_sed=no 667 need_sed=no
668 set_opsys=no 668 set_opsys=no
669 need_xargs=no 669 need_xargs=no
670 ;; 670 ;;
671 esac 671 esac
672 # only used for unprivileged builds 672 # only used for unprivileged builds
673 groupsprog="id -gn" 673 groupsprog="id -gn"
674 # for bootstrap only; pkgsrc uses CPPFLAGS 674 # for bootstrap only; pkgsrc uses CPPFLAGS
675 CC="gcc -D_ALL_SOURCE"; export CC 675 CC="gcc -D_ALL_SOURCE"; export CC
676 ac_cv_header_poll_h=no; export ac_cv_header_poll_h 676 ac_cv_header_poll_h=no; export ac_cv_header_poll_h
677 ac_cv_func_poll=no; export ac_cv_func_poll 677 ac_cv_func_poll=no; export ac_cv_func_poll
678 ;; 678 ;;
679IRIX*) 679IRIX*)
680 if [ -d "/usr/freeware/bin" ]; then 680 if [ -d "/usr/freeware/bin" ]; then
681 overpath="/usr/freeware/bin:$overpath" 681 overpath="/usr/freeware/bin:$overpath"
682 fi 682 fi
683 if [ -d "/usr/bsd" ]; then 683 if [ -d "/usr/bsd" ]; then
684 overpath="/usr/bsd:$overpath" 684 overpath="/usr/bsd:$overpath"
685 fi 685 fi
686 if [ -d "/usr/bsd/bin" ]; then 686 if [ -d "/usr/bsd/bin" ]; then
687 overpath="/usr/bsd/bin:$overpath" 687 overpath="/usr/bsd/bin:$overpath"
688 fi 688 fi
689 root_group=sys 689 root_group=sys
690 need_bsd_install=yes 690 need_bsd_install=yes
691 get_abi "IRIX" 691 get_abi "IRIX"
692 opsys=IRIX 692 opsys=IRIX
693 need_awk=yes 693 need_awk=yes
694 need_sed=yes 694 need_sed=yes
695 set_opsys=yes 695 set_opsys=yes
696 machine_arch=mipseb 696 machine_arch=mipseb
697 check_compiler=yes 697 check_compiler=yes
698 if [ `uname -r` -lt 6 ]; then 698 if [ `uname -r` -lt 6 ]; then
699# IRIX 5's mkdir bails out with an error when trying to create with the -p 699# IRIX 5's mkdir bails out with an error when trying to create with the -p
700# option an already existing directory 700# option an already existing directory
701 need_mkdir=yes 701 need_mkdir=yes
702 fi 702 fi
703 ;; 703 ;;
704Linux) 704Linux)
705 if [ -f /etc/ssdlinux_version ]; then 705 if [ -f /etc/ssdlinux_version ]; then
706 root_group=wheel 706 root_group=wheel
707 else 707 else
708 root_group=root 708 root_group=root
709 fi 709 fi
710 need_bsd_install=no 710 need_bsd_install=no
711 # Debian/Ubuntu's awk is mawk, and mawk does not understand 711 # Debian/Ubuntu's awk is mawk, and mawk does not understand
712 # some regexp used in pkgsrc/mk. 712 # some regexp used in pkgsrc/mk.
713 if [ -f /etc/debian_version ]; then 713 if [ -f /etc/debian_version ]; then
714 need_awk=yes 714 need_awk=yes
715 elif grep -sq '^CHROMEOS_RELEASE_NAME' /etc/lsb-release; then 715 elif grep -sq '^CHROMEOS_RELEASE_NAME' /etc/lsb-release; then
716 need_awk=yes 716 need_awk=yes
717 need_sed=yes 717 need_sed=yes
718 else 718 else
719 need_awk=no 719 need_awk=no
720 need_sed=no 720 need_sed=no
721 fi 721 fi
722 # Arch does not provide pax anymore 722 # Arch does not provide pax anymore
723 if [ -f /etc/arch-release ]; then 723 if [ -f /etc/arch-release ]; then
724 need_pax=yes 724 need_pax=yes
725 fi 725 fi
726 set_opsys=no 726 set_opsys=no
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 ;;
734Minix) 734Minix)
735 root_group=operator 735 root_group=wheel
736 need_bsd_install=no 736 need_bsd_install=no
737 need_awk=no 737 need_awk=no
738 need_sed=no 738 need_sed=no
739 set_opsys=no 739 set_opsys=no
740 machine_arch=`uname -p` 740 machine_arch=`uname -p`
741 check_compiler=yes 741 check_compiler=yes
742 ;;  742 ;;
743MirBSD) 743MirBSD)
744 root_group=wheel 744 root_group=wheel
745 need_pax=yes 745 need_pax=yes
746 need_mtree=no 746 need_mtree=no
747 need_bsd_install=no 747 need_bsd_install=no
748 need_awk=no 748 need_awk=no
749 need_sed=no 749 need_sed=no
750 set_opsys=no 750 set_opsys=no
751 check_prog mtreeprog mtree 751 check_prog mtreeprog mtree
752 machine_arch=`arch -s` 752 machine_arch=`arch -s`
753 # there is no /usr/bin/cc, so use mgcc if unset 753 # there is no /usr/bin/cc, so use mgcc if unset
754 test -n "$CC" || { CC=mgcc; export CC; } 754 test -n "$CC" || { CC=mgcc; export CC; }
755 # get some variables from the native make if unset 755 # get some variables from the native make if unset
756 for var in CFLAGS CPPFLAGS LDFLAGS; do 756 for var in CFLAGS CPPFLAGS LDFLAGS; do
757 # check if variable is already set 757 # check if variable is already set
758 eval _tmp=\"\$$var\" 758 eval _tmp=\"\$$var\"
759 [ "x$_tmp" != x ] && continue 759 [ "x$_tmp" != x ] && continue
760 # ask the native make (EXPERIMENTAL = don't add -Werror) 760 # ask the native make (EXPERIMENTAL = don't add -Werror)
761 # the -I${.CURDIR} dance is to prevent junk in CPPFLAGS 761 # the -I${.CURDIR} dance is to prevent junk in CPPFLAGS
762 _tmp=`printf '%s\nall:\n\t@%s %%s %s=${%s:M*:Q:Q}\n%s\n%s\n' \ 762 _tmp=`printf '%s\nall:\n\t@%s %%s %s=${%s:M*:Q:Q}\n%s\n%s\n' \
763 $var'+=-I${.CURDIR}' printf $var $var':S/-I${.CURDIR}//' \ 763 $var'+=-I${.CURDIR}' printf $var $var':S/-I${.CURDIR}//' \
764 EXPERIMENTAL=yes '.include <bsd.prog.mk>' | \ 764 EXPERIMENTAL=yes '.include <bsd.prog.mk>' | \
765 (unset MAKECONF; /usr/bin/make -f - all 2>/dev/null) | \ 765 (unset MAKECONF; /usr/bin/make -f - all 2>/dev/null) | \
766 sed 's/^x//'` 766 sed 's/^x//'`
767 eval $_tmp 767 eval $_tmp
768 eval export $var 768 eval export $var
769 done 769 done
770 ;; 770 ;;
771NetBSD) 771NetBSD)
772 root_group=wheel 772 root_group=wheel
773 need_bsd_install=no 773 need_bsd_install=no
774 need_awk=no 774 need_awk=no
775 need_sed=no 775 need_sed=no
776 set_opsys=no 776 set_opsys=no
777 machine_arch=`uname -p` 777 machine_arch=`uname -p`
778 ;; 778 ;;
779OpenBSD) 779OpenBSD)
780 root_group=wheel 780 root_group=wheel
781 need_bsd_install=no 781 need_bsd_install=no
782 need_awk=no 782 need_awk=no
783 need_sed=no 783 need_sed=no
784 set_opsys=no 784 set_opsys=no
785 machine_arch=`arch -s` 785 machine_arch=`arch -s`
786 CC=${CC:-cc}; export CC 786 CC=${CC:-cc}; export CC
787 check_compiler=yes 787 check_compiler=yes
788 ;; 788 ;;
789OSF1) 789OSF1)
790 root_group=system 790 root_group=system
791 need_bsd_install=yes 791 need_bsd_install=yes
792 need_awk=yes 792 need_awk=yes
793 need_sed=yes 793 need_sed=yes
794 need_ksh=yes 794 need_ksh=yes
795 set_opsys=no 795 set_opsys=no
796 machine_arch=`uname -p` 796 machine_arch=`uname -p`
797 ;; 797 ;;
798QNX) 798QNX)
799 root_group=root 799 root_group=root
800 need_bsd_install=yes 800 need_bsd_install=yes
801 need_awk=yes 801 need_awk=yes
802 need_sed=yes 802 need_sed=yes
803 set_opsys=no 803 set_opsys=no
804 groupsprog="id -gn" 804 groupsprog="id -gn"
805 whoamiprog="id -un" 805 whoamiprog="id -un"
806 machine_arch=`uname -p | sed -e 's/x86/i386/'` 806 machine_arch=`uname -p | sed -e 's/x86/i386/'`
807 ;; 807 ;;
808SCO_SV) 808SCO_SV)
809 root_group=root 809 root_group=root
810 need_awk=yes 810 need_awk=yes
811 need_bsd_install=yes 811 need_bsd_install=yes
812 need_sed=yes 812 need_sed=yes
813 set_opsys=no 813 set_opsys=no
814 whoamiprog='id -u' 814 whoamiprog='id -u'
815 groupsprog='id -g' 815 groupsprog='id -g'
816 # /bin/sh under OpenServer 5.0.7/3.2 breaks bmake tests. 816 # /bin/sh under OpenServer 5.0.7/3.2 breaks bmake tests.
817 #bmakexargs="$bmakexargs --with-defshell=/bin/ksh" 817 #bmakexargs="$bmakexargs --with-defshell=/bin/ksh"
818 ;; 818 ;;
819SunOS) 819SunOS)
820 root_group=root 820 root_group=root
821 need_bsd_install=yes 821 need_bsd_install=yes
822 use_bsdinstall=yes 822 use_bsdinstall=yes
823 if [ -x "/usr/gnu/bin/awk" ]; then 823 if [ -x "/usr/gnu/bin/awk" ]; then
824 need_awk=no 824 need_awk=no
825 else 825 else
826 need_awk=yes 826 need_awk=yes
827 fi 827 fi
828 if [ -x "/usr/gnu/bin/sed" ]; then 828 if [ -x "/usr/gnu/bin/sed" ]; then
829 need_sed=no 829 need_sed=no
830 else 830 else
831 need_sed=yes 831 need_sed=yes
832 fi 832 fi
833 if [ -x "/usr/bin/bash" ]; then 833 if [ -x "/usr/bin/bash" ]; then
834 bootstrap_sh=${SH:-/usr/bin/bash} 834 bootstrap_sh=${SH:-/usr/bin/bash}
835 bootstrap_sh_set=set 835 bootstrap_sh_set=set
836 else 836 else
837 need_ksh=yes 837 need_ksh=yes
838 fi 838 fi
839 set_opsys=no 839 set_opsys=no
840 idprog="/usr/xpg4/bin/id" 840 idprog="/usr/xpg4/bin/id"
841 groupsprog="${idprog} -gn" 841 groupsprog="${idprog} -gn"
842 whoamiprog="${idprog} -un" 842 whoamiprog="${idprog} -un"
843 machine_arch=`uname -p | sed -e 's/i86pc/i386/'` 843 machine_arch=`uname -p | sed -e 's/i86pc/i386/'`
844 check_compiler=yes 844 check_compiler=yes
845 check_ssp=yes 845 check_ssp=yes
846 ;; 846 ;;
847UnixWare) 847UnixWare)
848 root_group=sys 848 root_group=sys
849 need_bsd_install=no 849 need_bsd_install=no
850 BSTRAP_ENV="INSTALL=/usr/ucb/install $BSTRAP_ENV" 850 BSTRAP_ENV="INSTALL=/usr/ucb/install $BSTRAP_ENV"
851 need_mkdir=yes 851 need_mkdir=yes
852 need_awk=yes 852 need_awk=yes
853 need_sed=yes 853 need_sed=yes
854 whoamiprog=/usr/ucb/whoami 854 whoamiprog=/usr/ucb/whoami
855 set_opsys=no 855 set_opsys=no
856 CC="gcc -DUNIXWARE"; export CC 856 CC="gcc -DUNIXWARE"; export CC
857 ;; 857 ;;
858*) 858*)
859 echo "This platform ($opsys) is untried - good luck, and thanks for using pkgsrc" 859 echo "This platform ($opsys) is untried - good luck, and thanks for using pkgsrc"
860 root_group=wheel 860 root_group=wheel
861 need_bsd_install=yes 861 need_bsd_install=yes
862 need_awk=yes 862 need_awk=yes
863 need_sed=yes 863 need_sed=yes
864 set_opsys=no 864 set_opsys=no
865 ;; 865 ;;
866esac 866esac
867 867
868# Fixup MACHINE_ARCH to use canonical pkgsrc variants, and support multiarch 868# Fixup MACHINE_ARCH to use canonical pkgsrc variants, and support multiarch
869# systems via --abi, setting a default $abi based on MACHINE_ARCH if not set. 869# systems via --abi, setting a default $abi based on MACHINE_ARCH if not set.
870# 870#
871case "$machine_arch/$abi" in 871case "$machine_arch/$abi" in
872# "amd64" translates to "x86_64", defaults to 64-bit 872# "amd64" translates to "x86_64", defaults to 64-bit
873amd64/32) abi=32 machine_arch=i386 ;; 873amd64/32) abi=32 machine_arch=i386 ;;
874amd64/*) abi=64 machine_arch=x86_64 ;; 874amd64/*) abi=64 machine_arch=x86_64 ;;
875# XXX: hppa untested 875# XXX: hppa untested
876hppa/64) abi=64 machine_arch=hppa64 ;; 876hppa/64) abi=64 machine_arch=hppa64 ;;
877hppa/*) abi=32 machine_arch=hppa ;; 877hppa/*) abi=32 machine_arch=hppa ;;
878hppa64/32) abi=32 machine_arch=hppa ;; 878hppa64/32) abi=32 machine_arch=hppa ;;
879hppa64/*) abi=64 machine_arch=hppa64 ;; 879hppa64/*) abi=64 machine_arch=hppa64 ;;
880# "i386" can support 64-bit, e.g. SunOS, defaults to 32-bit. 880# "i386" can support 64-bit, e.g. SunOS, defaults to 32-bit.
881i386/64) abi=64 machine_arch=x86_64 ;; 881i386/64) abi=64 machine_arch=x86_64 ;;
882i386/*) abi=32 machine_arch=i386 ;; 882i386/*) abi=32 machine_arch=i386 ;;
883# XXX: powerpc untested 883# XXX: powerpc untested
884powerpc/64) abi=64 machine_arch=powerpc64 ;; 884powerpc/64) abi=64 machine_arch=powerpc64 ;;
885powerpc/*) abi=32 machine_arch=powerpc ;; 885powerpc/*) abi=32 machine_arch=powerpc ;;
886powerpc64/32) abi=32 machine_arch=powerpc ;; 886powerpc64/32) abi=32 machine_arch=powerpc ;;
887powerpc64/*) abi=64 machine_arch=powerpc64 ;; 887powerpc64/*) abi=64 machine_arch=powerpc64 ;;
888powerpc64le/*) abi=64 machine_arch=powerpc64le;; 888powerpc64le/*) abi=64 machine_arch=powerpc64le;;
889# "sparc" can support 64-bit, e.g. SunOS, defaults to 32-bit. 889# "sparc" can support 64-bit, e.g. SunOS, defaults to 32-bit.
890sparc/64) abi=64 machine_arch=sparc64 ;; 890sparc/64) abi=64 machine_arch=sparc64 ;;
891sparc/*) abi=32 machine_arch=sparc ;; 891sparc/*) abi=32 machine_arch=sparc ;;
892# x86_64 supports 32-bit/64-bit, defaults to 64-bit. 892# x86_64 supports 32-bit/64-bit, defaults to 64-bit.
893x86_64/32) abi=32 machine_arch=i386 ;; 893x86_64/32) abi=32 machine_arch=i386 ;;
894x86_64/*) abi=64 machine_arch=x86_64 ;; 894x86_64/*) abi=64 machine_arch=x86_64 ;;
895esac 895esac
896 896
897# If "--full" is specified, then install all of the platform-independent 897# If "--full" is specified, then install all of the platform-independent
898# bootstrap software. 898# bootstrap software.
899# 899#
900case "$full" in 900case "$full" in
901yes) 901yes)
902 need_bsd_install=yes 902 need_bsd_install=yes
903 need_awk=yes 903 need_awk=yes
904 need_sed=yes 904 need_sed=yes
905 need_ksh=yes 905 need_ksh=yes
906 ;; 906 ;;
907esac 907esac
908 908
909case "$quiet" in 909case "$quiet" in
910yes) 910yes)
911 configure_quiet_flags="--quiet" 911 configure_quiet_flags="--quiet"
912 make_quiet_flags="-s" 912 make_quiet_flags="-s"
913 ;; 913 ;;
914no) 914no)
915 configure_quiet_flags="" 915 configure_quiet_flags=""
916 make_quiet_flags="" 916 make_quiet_flags=""
917esac 917esac
918 918
919test ${make_jobs} -gt 0 2>/dev/null 919test ${make_jobs} -gt 0 2>/dev/null
920if [ $? -ne 0 ]; then 920if [ $? -ne 0 ]; then
921 die "ERROR: --make-jobs must be a positive integer argument" 921 die "ERROR: --make-jobs must be a positive integer argument"
922fi 922fi
923 923
924# export MACHINE_ARCH and OPSYS for bmake and pkg_install. 924# export MACHINE_ARCH and OPSYS for bmake and pkg_install.
925MACHINE_ARCH=${machine_arch}; export MACHINE_ARCH 925MACHINE_ARCH=${machine_arch}; export MACHINE_ARCH
926OPSYS=${opsys}; export OPSYS 926OPSYS=${opsys}; export OPSYS
927 927
928if [ "x$preserve_path" != "xyes" ]; then 928if [ "x$preserve_path" != "xyes" ]; then
929 PATH="$overpath:$PATH" 929 PATH="$overpath:$PATH"
930fi 930fi
931 931
932check_prog awkprog awk 932check_prog awkprog awk
933check_prog chmodprog chmod 933check_prog chmodprog chmod
934if [ -n "$CP" ]; then 934if [ -n "$CP" ]; then
935 cpprog="$CP" 935 cpprog="$CP"
936else 936else
937 check_prog cpprog cp 937 check_prog cpprog cp
938fi 938fi
939if [ -n "$ID" ]; then 939if [ -n "$ID" ]; then
940 idprog="$ID" 940 idprog="$ID"
941else 941else
942 check_prog idprog id 942 check_prog idprog id
943fi 943fi
944check_prog groupsprog groups 944check_prog groupsprog groups
945check_prog lnprog ln 945check_prog lnprog ln
946check_prog lsprog ls 946check_prog lsprog ls
947check_prog rmdirprog rmdir 947check_prog rmdirprog rmdir
948check_prog sedprog sed 948check_prog sedprog sed
949check_prog shprog sh 949check_prog shprog sh
950check_prog whoamiprog whoami 950check_prog whoamiprog whoami
951 951
952if [ -d "${wrkdir}" ] || [ -f "${wrkdir}" ]; then 952if [ -d "${wrkdir}" ] || [ -f "${wrkdir}" ]; then
953 die "\"${wrkdir}\" already exists, please remove it or use --workdir" 953 die "\"${wrkdir}\" already exists, please remove it or use --workdir"
954fi 954fi
955 955
956if [ -f "${prefix}/share/mk/sys.mk" ]; then 956if [ -f "${prefix}/share/mk/sys.mk" ]; then
957 die "\"${prefix}\" already in use, remove it or use a different --prefix" 957 die "\"${prefix}\" already in use, remove it or use a different --prefix"
958fi 958fi
959 959
960if [ -d "${pkgdbdir}/bootstrap-mk-files-"* ]; then 960if [ -d "${pkgdbdir}/bootstrap-mk-files-"* ]; then
961 die "\"${pkgdbdir}\" already in use, remove it or use a different --pkgdbdir" 961 die "\"${pkgdbdir}\" already in use, remove it or use a different --pkgdbdir"
962fi 962fi
963 963
964mkdir_p_early ${wrkdir} 964mkdir_p_early ${wrkdir}
965if touch ${wrkdir}/.writeable; then 965if touch ${wrkdir}/.writeable; then
966 : 966 :
967else 967else
968 die "\"${wrkdir}\" is not writeable. Try $0 -h" 968 die "\"${wrkdir}\" is not writeable. Try $0 -h"
969fi 969fi
970echo "Working directory is: ${wrkdir}" 970echo "Working directory is: ${wrkdir}"
971 971
972if [ "$compiler" = "" ] && [ x"$check_compiler" = x"yes" ]; then 972if [ "$compiler" = "" ] && [ x"$check_compiler" = x"yes" ]; then
973 get_compiler 973 get_compiler
974 # Clang pretends to be GCC, so we have to check it first. 974 # Clang pretends to be GCC, so we have to check it first.
975 if [ $compiler_is_clang -gt 0 ]; then 975 if [ $compiler_is_clang -gt 0 ]; then
976 compiler="clang" 976 compiler="clang"
977 elif [ $compiler_is_gnu -gt 0 ]; then 977 elif [ $compiler_is_gnu -gt 0 ]; then
978 compiler="gcc" 978 compiler="gcc"
979 else 979 else
980 case "$opsys" in 980 case "$opsys" in
981 IRIX) 981 IRIX)
982 if [ `uname -r` -ge 6 ]; then 982 if [ `uname -r` -ge 6 ]; then
983 compiler="mipspro" 983 compiler="mipspro"
984 else 984 else
985 compiler="ido" 985 compiler="ido"
986 fi 986 fi
987 test -n "$CC" || CC=cc 987 test -n "$CC" || CC=cc
988 ;; 988 ;;
989 SunOS) compiler="sunpro" 989 SunOS) compiler="sunpro"
990 test -n "$CC" || CC=cc 990 test -n "$CC" || CC=cc
991 ;; 991 ;;
992 esac 992 esac
993 fi 993 fi
994fi 994fi
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}
1108echo "VARBASE= $varbase" >> ${TARGET_MKCONF} 1108echo "VARBASE= $varbase" >> ${TARGET_MKCONF}
1109if [ "${sysconfdir}" != "${prefix}/etc" ]; then 1109if [ "${sysconfdir}" != "${prefix}/etc" ]; then
1110 echo "PKG_SYSCONFBASE= $sysconfdir" >> ${TARGET_MKCONF} 1110 echo "PKG_SYSCONFBASE= $sysconfdir" >> ${TARGET_MKCONF}
1111fi 1111fi
1112echo "PKG_TOOLS_BIN= $prefix/sbin" >> ${TARGET_MKCONF} 1112echo "PKG_TOOLS_BIN= $prefix/sbin" >> ${TARGET_MKCONF}
1113echo "PKGINFODIR= $pkginfodir" >> ${TARGET_MKCONF} 1113echo "PKGINFODIR= $pkginfodir" >> ${TARGET_MKCONF}
1114echo "PKGMANDIR= $pkgmandir" >> ${TARGET_MKCONF} 1114echo "PKGMANDIR= $pkgmandir" >> ${TARGET_MKCONF}
1115echo "" >> ${TARGET_MKCONF} 1115echo "" >> ${TARGET_MKCONF}
1116 1116
1117if [ -n "$prefer_pkgsrc" ]; then 1117if [ -n "$prefer_pkgsrc" ]; then
1118 echo "PREFER_PKGSRC= $prefer_pkgsrc" >> ${TARGET_MKCONF} 1118 echo "PREFER_PKGSRC= $prefer_pkgsrc" >> ${TARGET_MKCONF}
1119 echo "" >> ${TARGET_MKCONF} 1119 echo "" >> ${TARGET_MKCONF}
1120fi 1120fi
1121 1121
1122BOOTSTRAP_MKCONF=${wrkdir}/mk.conf 1122BOOTSTRAP_MKCONF=${wrkdir}/mk.conf
1123cp ${TARGET_MKCONF} ${BOOTSTRAP_MKCONF} 1123cp ${TARGET_MKCONF} ${BOOTSTRAP_MKCONF}
1124 1124
1125case "$cwrappers" in 1125case "$cwrappers" in
1126yes|no) 1126yes|no)
1127 echo "USE_CWRAPPERS= $cwrappers" >> ${TARGET_MKCONF} 1127 echo "USE_CWRAPPERS= $cwrappers" >> ${TARGET_MKCONF}
1128 echo "USE_CWRAPPERS= $cwrappers" >> ${BOOTSTRAP_MKCONF} 1128 echo "USE_CWRAPPERS= $cwrappers" >> ${BOOTSTRAP_MKCONF}
1129 echo "" >> ${TARGET_MKCONF} 1129 echo "" >> ${TARGET_MKCONF}
1130 ;; 1130 ;;
1131esac 1131esac
1132 1132
1133# On all Debian GNU/kFreeBSD 7, /bin/sh is a symlink to /bin/dash, and 1133# On all Debian GNU/kFreeBSD 7, /bin/sh is a symlink to /bin/dash, and
1134# use /bin/bash. 1134# use /bin/bash.
1135if [ "$opsys" = "GNUkFreeBSD" -a "$bootstrap_sh_set" != "set" ]; then 1135if [ "$opsys" = "GNUkFreeBSD" -a "$bootstrap_sh_set" != "set" ]; then
1136 echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${TARGET_MKCONF} 1136 echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${TARGET_MKCONF}
1137 echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${BOOTSTRAP_MKCONF} 1137 echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${BOOTSTRAP_MKCONF}
1138 echo $opsys 1138 echo $opsys
1139fi 1139fi
1140 1140
1141# sbin is used by pkg_install, share/mk by bootstrap-mk-files 1141# sbin is used by pkg_install, share/mk by bootstrap-mk-files
1142mkdir_p $wrkdir/sbin $wrkdir/share/mk 1142mkdir_p $wrkdir/sbin $wrkdir/share/mk
1143mkdir_p_early ${wrkdir} 1143mkdir_p_early ${wrkdir}
1144 1144
1145if [ "$need_bsd_install" = "yes" ]; then 1145if [ "$need_bsd_install" = "yes" ]; then
1146 BSTRAP_ENV="INSTALL='$prefix/bin/install-sh -c' $BSTRAP_ENV" 1146 BSTRAP_ENV="INSTALL='$prefix/bin/install-sh -c' $BSTRAP_ENV"
1147 if [ "$use_bsdinstall" = "yes" ]; then 1147 if [ "$use_bsdinstall" = "yes" ]; then
1148 echo "TOOLS_PLATFORM.install?= $prefix/bin/bsdinstall" >> ${TARGET_MKCONF} 1148 echo "TOOLS_PLATFORM.install?= $prefix/bin/bsdinstall" >> ${TARGET_MKCONF}
1149 else 1149 else
1150 echo "TOOLS_PLATFORM.install?= $prefix/bin/install-sh" >> ${TARGET_MKCONF} 1150 echo "TOOLS_PLATFORM.install?= $prefix/bin/install-sh" >> ${TARGET_MKCONF}
1151 fi 1151 fi
1152 echo "TOOLS_PLATFORM.install?= $wrkdir/bin/install-sh" >> ${BOOTSTRAP_MKCONF} 1152 echo "TOOLS_PLATFORM.install?= $wrkdir/bin/install-sh" >> ${BOOTSTRAP_MKCONF}
1153fi 1153fi
1154 1154
1155if [ "$need_fixed_strip" = "yes" ] ; then 1155if [ "$need_fixed_strip" = "yes" ] ; then
1156 echo_msg "Installing fixed strip script" 1156 echo_msg "Installing fixed strip script"
1157 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/strip-sh $wrkdir/bin/strip" 1157 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/strip-sh $wrkdir/bin/strip"
1158 echo "TOOLS_PLATFORM.strip?= $prefix/bin/strip" >> ${TARGET_MKCONF} 1158 echo "TOOLS_PLATFORM.strip?= $prefix/bin/strip" >> ${TARGET_MKCONF}
1159 echo "TOOLS_PLATFORM.strip?= $wrkdir/bin/strip" >> ${BOOTSTRAP_MKCONF} 1159 echo "TOOLS_PLATFORM.strip?= $wrkdir/bin/strip" >> ${BOOTSTRAP_MKCONF}
1160 need_extras=yes 1160 need_extras=yes
1161fi 1161fi
1162 1162
1163if [ "$need_mkdir" = "yes" -a -z "$MKDIR" ]; then 1163if [ "$need_mkdir" = "yes" -a -z "$MKDIR" ]; then
1164 echo_msg "Installing fixed mkdir script \"mkdir-sh\"" 1164 echo_msg "Installing fixed mkdir script \"mkdir-sh\""
1165 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/mkdir-sh $wrkdir/bin/mkdir-sh" 1165 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/mkdir-sh $wrkdir/bin/mkdir-sh"
1166 echo "TOOLS_PLATFORM.mkdir?= $prefix/bin/mkdir-sh -p" >> ${TARGET_MKCONF} 1166 echo "TOOLS_PLATFORM.mkdir?= $prefix/bin/mkdir-sh -p" >> ${TARGET_MKCONF}
1167 echo "TOOLS_PLATFORM.mkdir?= $wrkdir/bin/mkdir-sh -p" >> ${BOOTSTRAP_MKCONF} 1167 echo "TOOLS_PLATFORM.mkdir?= $wrkdir/bin/mkdir-sh -p" >> ${BOOTSTRAP_MKCONF}
1168 need_extras=yes 1168 need_extras=yes
1169fi 1169fi
1170 1170
1171if [ "$need_xargs" = "yes" ]; then 1171if [ "$need_xargs" = "yes" ]; then
1172 echo_msg "Installing fixed xargs script" 1172 echo_msg "Installing fixed xargs script"
1173 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/xargs-sh $wrkdir/bin/xargs" 1173 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/xargs-sh $wrkdir/bin/xargs"
1174 echo "TOOLS_PLATFORM.xargs?= $prefix/bin/xargs" >> ${TARGET_MKCONF} 1174 echo "TOOLS_PLATFORM.xargs?= $prefix/bin/xargs" >> ${TARGET_MKCONF}
1175 echo "TOOLS_PLATFORM.xargs?= $wrkdir/bin/xargs" >> ${BOOTSTRAP_MKCONF} 1175 echo "TOOLS_PLATFORM.xargs?= $wrkdir/bin/xargs" >> ${BOOTSTRAP_MKCONF}
1176 need_extras=yes 1176 need_extras=yes
1177fi 1177fi
1178 1178
1179echo_msg "Bootstrapping mk-files" 1179echo_msg "Bootstrapping mk-files"
1180run_cmd "(cd ${pkgsrcdir}/pkgtools/bootstrap-mk-files/files && env CP=${cpprog} \ 1180run_cmd "(cd ${pkgsrcdir}/pkgtools/bootstrap-mk-files/files && env CP=${cpprog} \
1181 OPSYS=${opsys} MK_DST=${wrkdir}/share/mk ROOT_GROUP=${root_group} \ 1181 OPSYS=${opsys} MK_DST=${wrkdir}/share/mk ROOT_GROUP=${root_group} \
1182ROOT_USER=${root_user} SED=${sedprog} SYSCONFDIR=${sysconfdir} \ 1182ROOT_USER=${root_user} SED=${sedprog} SYSCONFDIR=${sysconfdir} \
1183$shprog ./bootstrap.sh)" 1183$shprog ./bootstrap.sh)"
1184 1184
1185bootstrap_bmake() { 1185bootstrap_bmake() {
1186 echo_msg "Bootstrapping bmake" 1186 echo_msg "Bootstrapping bmake"
1187 copy_src $pkgsrcdir/devel/bmake/files bmake 1187 copy_src $pkgsrcdir/devel/bmake/files bmake
1188 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)" 1188 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)"
1189 run_cmd "(cd $wrkdir/bmake && $shprog make-bootstrap.sh)" 1189 run_cmd "(cd $wrkdir/bmake && $shprog make-bootstrap.sh)"
1190 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/bmake/bmake $wrkdir/bin/bmake" 1190 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/bmake/bmake $wrkdir/bin/bmake"
1191} 1191}
1192bootstrap_bmake 1192bootstrap_bmake
1193 1193
1194bmake="$wrkdir/bin/bmake" 1194bmake="$wrkdir/bin/bmake"
1195 1195
1196# build libnbcompat 1196# build libnbcompat
1197echo_msg "Building libnbcompat" 1197echo_msg "Building libnbcompat"
1198copy_src $pkgsrcdir/pkgtools/libnbcompat/files libnbcompat 1198copy_src $pkgsrcdir/pkgtools/libnbcompat/files libnbcompat
1199run_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)" 1199run_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)"
1200 1200
1201# bootstrap ksh if necessary 1201# bootstrap ksh if necessary
1202case "$need_ksh" in 1202case "$need_ksh" in
1203yes) echo_msg "Bootstrapping ksh" 1203yes) echo_msg "Bootstrapping ksh"
1204 copy_src $pkgsrcdir/shells/pdksh/files ksh 1204 copy_src $pkgsrcdir/shells/pdksh/files ksh
1205 test -n "$CC" || CC=gcc # default to gcc if no compiler is specified 1205 test -n "$CC" || CC=gcc # default to gcc if no compiler is specified
1206 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)" 1206 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)"
1207 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/ksh/ksh $wrkdir/bin/pdksh" 1207 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/ksh/ksh $wrkdir/bin/pdksh"
1208 echo "TOOLS_PLATFORM.sh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF} 1208 echo "TOOLS_PLATFORM.sh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF}
1209 echo "TOOLS_PLATFORM.sh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF} 1209 echo "TOOLS_PLATFORM.sh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF}
1210 echo "TOOLS_PLATFORM.ksh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF} 1210 echo "TOOLS_PLATFORM.ksh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF}
1211 echo "TOOLS_PLATFORM.ksh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF} 1211 echo "TOOLS_PLATFORM.ksh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF}
1212# Now rebootstrap bmake for ksh 1212# Now rebootstrap bmake for ksh
1213 echo_msg "Rebootstrapping bmake for ksh" 1213 echo_msg "Rebootstrapping bmake for ksh"
1214 bmakexargs="$bmakexargs --with-defshell=$wrkdir/bin/pdksh" 1214 bmakexargs="$bmakexargs --with-defshell=$wrkdir/bin/pdksh"
1215 bootstrap_bmake 1215 bootstrap_bmake
1216 ;; 1216 ;;
1217esac 1217esac
1218 1218
1219# bootstrap awk if necessary 1219# bootstrap awk if necessary
1220case "$need_awk" in 1220case "$need_awk" in
1221yes) echo_msg "Bootstrapping awk" 1221yes) echo_msg "Bootstrapping awk"
1222 copy_src $pkgsrcdir/lang/nawk/files awk 1222 copy_src $pkgsrcdir/lang/nawk/files awk
1223 test -n "$CC" || CC=gcc # default to gcc if no compiler is specified 1223 test -n "$CC" || CC=gcc # default to gcc if no compiler is specified
1224 run_cmd "(cd $wrkdir/awk && $bmake $make_quiet_flags -j$make_jobs -f Makefile CC=\"${CC}\" CFLAGS=\"${CFLAGS}\")" 1224 run_cmd "(cd $wrkdir/awk && $bmake $make_quiet_flags -j$make_jobs -f Makefile CC=\"${CC}\" CFLAGS=\"${CFLAGS}\")"
1225 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/awk/a.out $wrkdir/bin/nawk" 1225 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/awk/a.out $wrkdir/bin/nawk"
1226 echo "TOOLS_PLATFORM.awk?= $prefix/bin/nawk" >> ${TARGET_MKCONF} 1226 echo "TOOLS_PLATFORM.awk?= $prefix/bin/nawk" >> ${TARGET_MKCONF}
1227 echo "TOOLS_PLATFORM.awk?= $wrkdir/bin/nawk" >> ${BOOTSTRAP_MKCONF} 1227 echo "TOOLS_PLATFORM.awk?= $wrkdir/bin/nawk" >> ${BOOTSTRAP_MKCONF}
1228 ;; 1228 ;;
1229esac 1229esac
1230 1230
1231# bootstrap sed if necessary 1231# bootstrap sed if necessary
1232case "$need_sed" in 1232case "$need_sed" in
1233yes) echo_msg "Bootstrapping sed" 1233yes) echo_msg "Bootstrapping sed"
1234 copy_src $pkgsrcdir/textproc/nbsed/files sed 1234 copy_src $pkgsrcdir/textproc/nbsed/files sed
1235 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)" 1235 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)"
1236 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/sed/sed $wrkdir/bin/sed" 1236 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/sed/sed $wrkdir/bin/sed"
1237 echo "TOOLS_PLATFORM.sed?= $prefix/bin/nbsed" >> ${TARGET_MKCONF} 1237 echo "TOOLS_PLATFORM.sed?= $prefix/bin/nbsed" >> ${TARGET_MKCONF}
1238 echo "TOOLS_PLATFORM.sed?= $wrkdir/bin/sed" >> ${BOOTSTRAP_MKCONF} 1238 echo "TOOLS_PLATFORM.sed?= $wrkdir/bin/sed" >> ${BOOTSTRAP_MKCONF}
1239 ;; 1239 ;;
1240esac 1240esac
1241 1241
1242# bootstrap pkg_install 1242# bootstrap pkg_install
1243echo_msg "Bootstrapping pkgtools" 1243echo_msg "Bootstrapping pkgtools"
1244copy_src $pkgsrcdir/archivers/libarchive/files libarchive 1244copy_src $pkgsrcdir/archivers/libarchive/files libarchive
1245run_cmd "(cd $wrkdir/libarchive; env $BSTRAP_ENV \ 1245run_cmd "(cd $wrkdir/libarchive; env $BSTRAP_ENV \
1246$shprog ./configure $configure_quiet_flags --enable-static --disable-shared \ 1246$shprog ./configure $configure_quiet_flags --enable-static --disable-shared \
1247--disable-bsdtar --disable-bsdcpio --disable-posix-regex-lib --disable-xattr \ 1247--disable-bsdtar --disable-bsdcpio --disable-posix-regex-lib --disable-xattr \
1248--disable-maintainer-mode --disable-acl --without-zlib --without-bz2lib \ 1248--disable-maintainer-mode --disable-acl --without-zlib --without-bz2lib \
1249--without-lzmadec --without-iconv --without-lzma --without-lzo2 --without-lz4 \ 1249--without-lzmadec --without-iconv --without-lzma --without-lzo2 --without-lz4 \
1250--without-nettle --without-openssl --without-xml2 --without-expat \ 1250--without-nettle --without-openssl --without-xml2 --without-expat \
1251MAKE=$bmake && $bmake $make_quiet_flags -j$make_jobs)" 1251MAKE=$bmake && $bmake $make_quiet_flags -j$make_jobs)"
1252copy_src $pkgsrcdir/pkgtools/pkg_install/files pkg_install 1252copy_src $pkgsrcdir/pkgtools/pkg_install/files pkg_install
1253run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV \ 1253run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV \
1254CPPFLAGS='$CPPFLAGS -I${wrkdir}/libnbcompat -I${wrkdir}/libarchive/libarchive' \ 1254CPPFLAGS='$CPPFLAGS -I${wrkdir}/libnbcompat -I${wrkdir}/libarchive/libarchive' \
1255LDFLAGS='$LDFLAGS -L${wrkdir}/libnbcompat' \ 1255LDFLAGS='$LDFLAGS -L${wrkdir}/libnbcompat' \
1256LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C \ 1256LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C \
1257--enable-bootstrap --prefix=$prefix --sysconfdir=$sysconfdir \ 1257--enable-bootstrap --prefix=$prefix --sysconfdir=$sysconfdir \
1258--with-pkgdbdir=$pkgdbdir --infodir=$infodir \ 1258--with-pkgdbdir=$pkgdbdir --infodir=$infodir \
1259--mandir=$mandir $pkg_install_args && \ 1259--mandir=$mandir $pkg_install_args && \
1260STATIC_LIBARCHIVE=$wrkdir/libarchive/.libs/libarchive.a \ 1260STATIC_LIBARCHIVE=$wrkdir/libarchive/.libs/libarchive.a \
1261PKGSRC_MACHINE_ARCH="$machine_arch" $bmake $make_quiet_flags -j$make_jobs)" 1261PKGSRC_MACHINE_ARCH="$machine_arch" $bmake $make_quiet_flags -j$make_jobs)"
1262run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/add/pkg_add $wrkdir/sbin/pkg_add" 1262run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/add/pkg_add $wrkdir/sbin/pkg_add"
1263run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/admin/pkg_admin $wrkdir/sbin/pkg_admin" 1263run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/admin/pkg_admin $wrkdir/sbin/pkg_admin"
1264run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/create/pkg_create $wrkdir/sbin/pkg_create" 1264run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/create/pkg_create $wrkdir/sbin/pkg_create"
1265run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/info/pkg_info $wrkdir/sbin/pkg_info" 1265run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/info/pkg_info $wrkdir/sbin/pkg_info"
1266echo "PKG_ADD_CMD?= $wrkdir/sbin/pkg_add" >> ${BOOTSTRAP_MKCONF} 1266echo "PKG_ADD_CMD?= $wrkdir/sbin/pkg_add" >> ${BOOTSTRAP_MKCONF}
1267echo "PKG_ADMIN_CMD?= $wrkdir/sbin/pkg_admin" >> ${BOOTSTRAP_MKCONF} 1267echo "PKG_ADMIN_CMD?= $wrkdir/sbin/pkg_admin" >> ${BOOTSTRAP_MKCONF}
1268echo "PKG_CREATE_CMD?= $wrkdir/sbin/pkg_create" >> ${BOOTSTRAP_MKCONF} 1268echo "PKG_CREATE_CMD?= $wrkdir/sbin/pkg_create" >> ${BOOTSTRAP_MKCONF}
1269echo "PKG_INFO_CMD?= $wrkdir/sbin/pkg_info" >> ${BOOTSTRAP_MKCONF} 1269echo "PKG_INFO_CMD?= $wrkdir/sbin/pkg_info" >> ${BOOTSTRAP_MKCONF}
1270 1270
1271MAKECONF=$wrkdir/mk.conf 1271MAKECONF=$wrkdir/mk.conf
1272export MAKECONF 1272export MAKECONF
1273 1273
1274if [ "$bootstrap_sh_set" = "set" ]; then 1274if [ "$bootstrap_sh_set" = "set" ]; then
1275 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${TARGET_MKCONF} 1275 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${TARGET_MKCONF}
1276 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${BOOTSTRAP_MKCONF} 1276 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${BOOTSTRAP_MKCONF}
1277fi 1277fi
1278 1278
1279# preserve compiler and tool environment variables settings 1279# preserve compiler and tool environment variables settings
1280if test -n "$CP"; then 1280if test -n "$CP"; then
1281 echo "TOOLS_PLATFORM.cp?= $CP" >> ${TARGET_MKCONF} 1281 echo "TOOLS_PLATFORM.cp?= $CP" >> ${TARGET_MKCONF}
1282 echo "TOOLS_PLATFORM.cp?= $CP" >> ${BOOTSTRAP_MKCONF} 1282 echo "TOOLS_PLATFORM.cp?= $CP" >> ${BOOTSTRAP_MKCONF}
1283fi 1283fi
1284if test -n "$GREP"; then 1284if test -n "$GREP"; then
1285 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${TARGET_MKCONF} 1285 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${TARGET_MKCONF}
1286 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${BOOTSTRAP_MKCONF} 1286 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${BOOTSTRAP_MKCONF}
1287fi 1287fi
1288if test -n "$ID"; then 1288if test -n "$ID"; then
1289 echo "TOOLS_PLATFORM.id?= $ID" >> ${TARGET_MKCONF} 1289 echo "TOOLS_PLATFORM.id?= $ID" >> ${TARGET_MKCONF}
1290 echo "TOOLS_PLATFORM.id?= $ID" >> ${BOOTSTRAP_MKCONF} 1290 echo "TOOLS_PLATFORM.id?= $ID" >> ${BOOTSTRAP_MKCONF}
1291fi 1291fi
1292if test -n "$MKDIR"; then 1292if test -n "$MKDIR"; then
1293 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${TARGET_MKCONF} 1293 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${TARGET_MKCONF}
1294 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${BOOTSTRAP_MKCONF} 1294 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${BOOTSTRAP_MKCONF}
1295fi 1295fi
1296if test -n "$TEST"; then 1296if test -n "$TEST"; then
1297 echo "TOOLS_PLATFORM.test?= $TEST" >> ${TARGET_MKCONF} 1297 echo "TOOLS_PLATFORM.test?= $TEST" >> ${TARGET_MKCONF}
1298 echo "TOOLS_PLATFORM.test?= $TEST" >> ${BOOTSTRAP_MKCONF} 1298 echo "TOOLS_PLATFORM.test?= $TEST" >> ${BOOTSTRAP_MKCONF}
1299fi 1299fi
1300if test -n "$TOUCH"; then 1300if test -n "$TOUCH"; then
1301 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${TARGET_MKCONF} 1301 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${TARGET_MKCONF}
1302 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${BOOTSTRAP_MKCONF} 1302 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${BOOTSTRAP_MKCONF}
1303fi 1303fi
1304if test -n "$XARGS"; then 1304if test -n "$XARGS"; then
1305 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${TARGET_MKCONF} 1305 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${TARGET_MKCONF}
1306 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${BOOTSTRAP_MKCONF} 1306 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${BOOTSTRAP_MKCONF}
1307fi 1307fi
1308if test -n "$CFLAGS"; then 1308if test -n "$CFLAGS"; then
1309 echo "CFLAGS+= $CFLAGS" >> ${TARGET_MKCONF} 1309 echo "CFLAGS+= $CFLAGS" >> ${TARGET_MKCONF}
1310 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${TARGET_MKCONF} 1310 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${TARGET_MKCONF}
1311 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${BOOTSTRAP_MKCONF} 1311 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${BOOTSTRAP_MKCONF}
1312fi 1312fi
1313if test -n "$CPPFLAGS"; then 1313if test -n "$CPPFLAGS"; then
1314 echo "CPPFLAGS+= $CPPFLAGS" >> ${TARGET_MKCONF} 1314 echo "CPPFLAGS+= $CPPFLAGS" >> ${TARGET_MKCONF}
1315fi 1315fi
1316if test -n "$LDFLAGS"; then 1316if test -n "$LDFLAGS"; then
1317 echo "LDFLAGS+= $LDFLAGS" >> ${TARGET_MKCONF} 1317 echo "LDFLAGS+= $LDFLAGS" >> ${TARGET_MKCONF}
1318fi 1318fi
1319if test -n "$LIBS"; then 1319if test -n "$LIBS"; then
1320 echo "LIBS+= $LIBS" >> ${TARGET_MKCONF} 1320 echo "LIBS+= $LIBS" >> ${TARGET_MKCONF}
1321fi 1321fi
1322 1322
1323# opsys specific fiddling 1323# opsys specific fiddling
1324opsys_finish 1324opsys_finish
1325 1325
1326echo "WRKOBJDIR= ${wrkdir}/wrk" >> ${BOOTSTRAP_MKCONF} 1326echo "WRKOBJDIR= ${wrkdir}/wrk" >> ${BOOTSTRAP_MKCONF}
1327 1327
1328echo "" >> ${TARGET_MKCONF} 1328echo "" >> ${TARGET_MKCONF}
1329echo "" >> ${BOOTSTRAP_MKCONF} 1329echo "" >> ${BOOTSTRAP_MKCONF}
1330if test -n "${mk_fragment}"; then 1330if test -n "${mk_fragment}"; then
1331 cat "${mk_fragment}" >> ${TARGET_MKCONF} 1331 cat "${mk_fragment}" >> ${TARGET_MKCONF}
1332 echo "" >> ${TARGET_MKCONF} 1332 echo "" >> ${TARGET_MKCONF}
1333fi 1333fi
1334echo ".endif # end pkgsrc settings" >> ${TARGET_MKCONF} 1334echo ".endif # end pkgsrc settings" >> ${TARGET_MKCONF}
1335echo ".endif # end pkgsrc settings" >> ${BOOTSTRAP_MKCONF} 1335echo ".endif # end pkgsrc settings" >> ${BOOTSTRAP_MKCONF}
1336 1336
1337# build and register packages 1337# build and register packages
1338# usage: build_package <packagedirectory> 1338# usage: build_package <packagedirectory>
1339build_package() { 1339build_package() {
1340 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)" 1340 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)"
1341} 1341}
1342build_package_nopreserve() { 1342build_package_nopreserve() {
1343 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)" 1343 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)"
1344} 1344}
1345 1345
1346# 1346#
1347# cwrappers is special, we don't want to set it as a BOOTSTRAP_PKG but must 1347# cwrappers is special, we don't want to set it as a BOOTSTRAP_PKG but must
1348# build it (if required) without -DPKG_PRESERVE set so that it can be deleted. 1348# build it (if required) without -DPKG_PRESERVE set so that it can be deleted.
1349# 1349#
1350use_cwrappers=`(cd $pkgsrcdir/devel/bmake && $bmake show-var VARNAME=_USE_CWRAPPERS)` 1350use_cwrappers=`(cd $pkgsrcdir/devel/bmake && $bmake show-var VARNAME=_USE_CWRAPPERS)`
1351case "$use_cwrappers" in 1351case "$use_cwrappers" in
1352yes) 1352yes)
1353 build_package_nopreserve "pkgtools/cwrappers" 1353 build_package_nopreserve "pkgtools/cwrappers"
1354 ;; 1354 ;;
1355esac 1355esac
1356 1356
1357# 1357#
1358# Please make sure that the following packages and 1358# Please make sure that the following packages and
1359# only the following packages set BOOTSTRAP_PKG=yes. 1359# only the following packages set BOOTSTRAP_PKG=yes.
1360# 1360#
1361echo_msg "Installing packages" 1361echo_msg "Installing packages"
1362build_package "pkgtools/bootstrap-mk-files" 1362build_package "pkgtools/bootstrap-mk-files"
1363case "$need_bsd_install" in 1363case "$need_bsd_install" in
1364yes) 1364yes)
1365 if [ "$use_bsdinstall" = "yes" ]; then 1365 if [ "$use_bsdinstall" = "yes" ]; then
1366 build_package "sysutils/bsdinstall" 1366 build_package "sysutils/bsdinstall"
1367 else 1367 else
1368 build_package "sysutils/install-sh" 1368 build_package "sysutils/install-sh"
1369 fi 1369 fi
1370 ;; 1370 ;;
1371esac 1371esac
1372case "$need_ksh" in 1372case "$need_ksh" in
1373yes) build_package "shells/pdksh";; 1373yes) build_package "shells/pdksh";;
1374esac 1374esac
1375build_package "devel/bmake" 1375build_package "devel/bmake"
1376case "$need_awk" in 1376case "$need_awk" in
1377yes) build_package "lang/nawk";; 1377yes) build_package "lang/nawk";;
1378esac 1378esac
1379case "$need_sed" in 1379case "$need_sed" in
1380yes) build_package "textproc/nbsed";; 1380yes) build_package "textproc/nbsed";;
1381esac 1381esac
1382case "$need_extras" in 1382case "$need_extras" in
1383yes) build_package "pkgtools/bootstrap-extras";; 1383yes) build_package "pkgtools/bootstrap-extras";;
1384esac 1384esac
1385case "$need_pax" in 1385case "$need_pax" in
1386yes) build_package "archivers/pax" 1386yes) build_package "archivers/pax"
1387esac 1387esac
1388build_package "pkgtools/pkg_install" 1388build_package "pkgtools/pkg_install"
1389 1389
1390etc_mk_conf="$sysconfdir/mk.conf" 1390etc_mk_conf="$sysconfdir/mk.conf"
1391 1391
1392# Install the example mk.conf so that it is used, but only if it doesn't 1392# Install the example mk.conf so that it is used, but only if it doesn't
1393# exist yet. This can happen with non-default sysconfdir settings. 1393# exist yet. This can happen with non-default sysconfdir settings.
1394mkdir_p "$sysconfdir" 1394mkdir_p "$sysconfdir"
1395if [ ! -f "$etc_mk_conf" ]; then 1395if [ ! -f "$etc_mk_conf" ]; then
1396 cp "$TARGET_MKCONF" "$etc_mk_conf" 1396 cp "$TARGET_MKCONF" "$etc_mk_conf"
1397 TARGET_MKCONF="$etc_mk_conf" 1397 TARGET_MKCONF="$etc_mk_conf"
1398fi 1398fi
1399 1399
1400hline="===========================================================================" 1400hline="==========================================================================="
1401echo "" 1401echo ""
1402echo "$hline" 1402echo "$hline"
1403echo "" 1403echo ""
1404echo "Please remember to add $prefix/bin to your PATH environment variable" 1404echo "Please remember to add $prefix/bin to your PATH environment variable"
1405echo "and $mandir to your MANPATH environment variable, if necessary." 1405echo "and $mandir to your MANPATH environment variable, if necessary."
1406echo "" 1406echo ""
1407echo "An example mk.conf file with the settings you provided to \"bootstrap\"" 1407echo "An example mk.conf file with the settings you provided to \"bootstrap\""
1408echo "has been created for you. It can be found in:" 1408echo "has been created for you. It can be found in:"
1409echo "" 1409echo ""
1410echo " ${TARGET_MKCONF}" 1410echo " ${TARGET_MKCONF}"
1411echo "" 1411echo ""
1412if [ "$TARGET_MKCONF" != "$etc_mk_conf" ]; then 1412if [ "$TARGET_MKCONF" != "$etc_mk_conf" ]; then
1413 echo "Please copy it to $etc_mk_conf to use it." 1413 echo "Please copy it to $etc_mk_conf to use it."
1414 echo "" 1414 echo ""
1415fi 1415fi
1416echo "You can find extensive documentation of the NetBSD Packages Collection" 1416echo "You can find extensive documentation of the NetBSD Packages Collection"
1417echo "in $pkgsrcdir/doc/pkgsrc.txt." 1417echo "in $pkgsrcdir/doc/pkgsrc.txt."
1418echo "" 1418echo ""
1419echo "Thank you for using pkgsrc!" 1419echo "Thank you for using pkgsrc!"
1420echo "" 1420echo ""
1421echo "$hline" 1421echo "$hline"
1422echo "" 1422echo ""
1423 1423
1424[ -n "${binary_kit}" ] && mkbinarykit_tar 1424[ -n "${binary_kit}" ] && mkbinarykit_tar
1425[ -n "${binary_gzip_kit}" ] && mkbinarykit_tgz 1425[ -n "${binary_gzip_kit}" ] && mkbinarykit_tgz
1426[ -n "${binary_macpkg}" ] && mkbinarykit_macpkg 1426[ -n "${binary_macpkg}" ] && mkbinarykit_macpkg
1427 1427
1428echo_msg "bootstrap started: $build_start" 1428echo_msg "bootstrap started: $build_start"
1429echo_msg "bootstrap ended: `date`" 1429echo_msg "bootstrap ended: `date`"
1430 1430
1431exit 0 1431exit 0