Annotation of pkgsrc/bootstrap/bootstrap, Revision 1.151
1.1 grant 1: #! /bin/sh
2:
1.151 ! obache 3: # $NetBSD: bootstrap,v 1.150 2009/08/01 20:19:37 dholland Exp $
1.1 grant 4: #
5: #
6: # Copyright (c) 2001-2002 Alistair G. Crooks. All rights reserved.
7: #
8: # Redistribution and use in source and binary forms, with or without
9: # modification, are permitted provided that the following conditions
10: # are met:
11: # 1. Redistributions of source code must retain the above copyright
12: # notice, this list of conditions and the following disclaimer.
13: # 2. Redistributions in binary form must reproduce the above copyright
14: # notice, this list of conditions and the following disclaimer in the
15: # documentation and/or other materials provided with the distribution.
16: # 3. All advertising materials mentioning features or use of this software
17: # must display the following acknowledgement:
18: # This product includes software developed by Alistair G. Crooks
19: # for the NetBSD project.
20: # 4. The name of the author may not be used to endorse or promote
21: # products derived from this software without specific prior written
22: # permission.
23: #
24: # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
25: # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26: # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27: # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
28: # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29: # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
30: # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31: # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32: # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33: # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34: # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35: #
36: #set -x
37:
1.81 schwarz 38: # the following environment variables are honored:
39: # compiler/linker flags: CFLAGS, CPPFLAGS, LDFLAGS
1.107 rillig 40: # tools: CP, GREP, ID, MKDIR, SH, TEST, TOUCH, XARGS
1.81 schwarz 41:
42:
1.74 jlam 43: BOOTSTRAP_VERSION=20060721
1.1 grant 44:
1.91 rillig 45: # Don't let the bootstrap program get confused by a pre-existing mk.conf
46: # file.
47: MAKECONF=/dev/null
48: export MAKECONF
49:
1.1 grant 50: ignorecasecheck=no
1.116 rillig 51: unprivileged=no
1.1 grant 52:
1.33 jschauma 53: preserve_path=no
54:
1.9 grant 55: # where the building takes place
1.78 rillig 56: bootstrapdir=`dirname "$0"`
57: bootstrapdir=`cd "${bootstrapdir}" && pwd`
58: pkgsrcdir=`dirname "${bootstrapdir}"`
59: wrkdir="`pwd`/work"
1.9 grant 60:
1.1 grant 61: usage="Usage: $0 "'
1.33 jschauma 62: [ --workdir <workdir> ]
63: [ --prefix <prefix> ]
64: [ --pkgdbdir <pkgdbdir> ]
1.55 jlam 65: [ --pkgmandir <pkgmandir> ]
1.33 jschauma 66: [ --sysconfdir <sysconfdir> ]
1.39 jmmv 67: [ --varbase <varbase> ]
1.49 joerg 68: [ --fetch-cmd <ftp command> ]
1.1 grant 69: [ --ignore-case-check ]
1.86 rillig 70: [ --unprivileged | --ignore-user-check ]
1.33 jschauma 71: [ --preserve-path ]
1.79 rillig 72: [ --compiler <compiler> ]
1.129 sketch 73: [ --abi [32|64] ]
1.102 joerg 74: [ --mk-fragment <mk.conf> ]
1.118 joerg 75: [ --binary-kit <tarball> ]
76: [ --gzip-binary-kit <tarball> ]
77: [ --binary-macpkg <pkg> ]
1.76 jlam 78: [ --full ]
1.86 rillig 79: [ --quiet ]
1.1 grant 80: [ --help ]'
81:
82: # this replicates some of the logic in bsd.prefs.mk. until
83: # bootstrap-pkgsrc is merged into pkgsrc, we need to determine the
84: # right value for OPSYS and MACHINE_ARCH.
85:
1.95 tnn 86: # strip / for BSD/OS, strip - for HP-UX
87: opsys=`uname -s | tr -d /-`
1.1 grant 88:
1.118 joerg 89: mkbinarykit_macpkg()
90: {
91: local macdestdir
92: macdestdir=${wrkdir}/macpkg-destdir
93: rm -rf ${macdestdir} || die "cleanup destdir"
94:
95: mkdir -p ${macdestdir}${prefix} || die "mkdir destprefix"
96: rmdir ${macdestdir}${prefix} || die "rmdir destprefix"
97: cp -Rp ${prefix} ${macdestdir}${prefix} || die "copy prefix"
98:
99: if [ ! -d ${macdestdir}${pkgdbdir} ]; then
100: mkdir -p ${macdestdir}${pkgdbdir} || die "mkdir destdbdir"
101: rmdir ${macdestdir}${pkgdbdir} || die "rmdir destdbdir"
102: cp -Rp ${pkgdbdir} ${macdestdir}${pkgdbdir} || die "copy dbdir"
103: fi
104:
105: ${sedprog} -e "s|%WRKDIR%|${wrkdir}|g" \
106: -e "s|%TARGETDIR%|${targetdir}|g" -e "s|%DATE%|${date}|g" \
107: < macpkg.pmproj.in > ${wrkdir}/macpkg.pmproj
108: ${packagemaker} -build -proj ${wrkdir}/macpkg.pmproj -p "${binary_macpkg}"
109: }
110:
111: mkbinarykit_tar()
112: {
113: # in case tar was built by bootstrap
114: PATH="$prefix/bin:$PATH"; export PATH
115: cd / && tar -hcf "${binary_kit}" .$prefix .$pkgdbdir .$etc_mk_conf
116: }
117:
118: mkbinarykit_tgz()
119: {
120: # in case tar was built by bootstrap
121: PATH="$prefix/bin:$PATH"; export PATH
122: cd / && tar -hzcf "${binary_gzip_kit}" .$prefix .$pkgdbdir .$etc_mk_conf
123: }
124:
1.1 grant 125: die()
126: {
127: echo >&2 "$@"
128: exit 1
129: }
130:
131: echo_msg()
132: {
133: echo "===> $@"
134: }
135:
1.33 jschauma 136: # see if we're using gcc. If so, set $compiler_is_gnu to '1'.
137: get_compiler()
138: {
139: testcc="${CC}"
140: # normally, we'd just use 'cc', but certain configure tools look
141: # for gcc specifically, so we have to see if that comes first
142: if [ -z "${testcc}" ]; then
143: save_IFS="${IFS}"
144: IFS=':'
145: for dir in ${PATH}; do
146: test -z "$dir" && dir=.
147: if [ -x "$dir/gcc" ]; then
148: testcc="$dir/gcc"
149: break
150: fi
151: done
152: IFS="${save_IFS}"
153: fi
154:
155: cat >${wrkdir}/$$.c <<EOF
156: #ifdef __GNUC__
157: indeed
158: #endif
159: EOF
160: compiler_is_gnu=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed`
161: rm -f ${wrkdir}/$$.c
162:
163: }
1.1 grant 164: get_abi()
165: {
166: abi_opsys=$@
1.131 sketch 167:
168: if [ -n "$abi" ]; then
169: die "ERROR: $abi_opsys has special ABI handling, --abi not supported (yet)."
170: fi
171:
1.1 grant 172: case "$abi_opsys" in
173: IRIX)
1.48 schwarz 174: if [ `uname -r` -ge 6 ]; then
1.1 grant 175: abi=`sed -e 's/.*\(abi=\)\([on]*[36][24]\).*/\2/' /etc/compiler.defaults`
176: isa=`sed -e 's/.*\(isa=mips\)\([1234]\).*/\2/' /etc/compiler.defaults`
177: case "$abi" in
178: o32)
179: imakeopts="-DBuildO32 -DSgiISAo32=$isa"
180: abi=""
181: ;;
182: n32) imakeopts="-DBuildN32 -DSgiISA32=$isa"
183: abi="32"
184: ;;
185: 64 | n64)
186: imakeopts="-DBuild64bit -DSgiISA64=$isa"
187: abi="64"
188: ;;
189: esac
1.48 schwarz 190: else # IRIX before 6
191: abi=32
192: fi
1.1 grant 193: ;;
194: esac
195: }
196:
1.31 grant 197: get_machine_arch_aix()
198: {
199: _cpuid=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
200: if /usr/sbin/lsattr -El $_cpuid | grep ' POWER' >/dev/null 2>&1; then
201: echo rs6000
202: else
203: echo powerpc
204: fi
205: }
206:
1.1 grant 207: check_prog()
208: {
209: _var="$1"; _name="$2"
210:
211: eval _tmp=\"\$$_var\"
212: if [ "x$_tmp" != "x" ]; then
213: # Variable is already set (by the user, for example)
214: return 0
215: fi
216:
217: for _d in `echo $PATH | tr ':' ' '`; do
1.117 rillig 218: if [ -f "$_d/$_name" ] && [ -x "$_d/$_name" ]; then
1.1 grant 219: # Program found
220: eval $_var=\""$_d/$_name"\"
221: return 1
222: fi
223: done
224:
225: die "$_name not found in path."
226: }
227:
228: opsys_finish()
229: {
230: case "$opsys" in
231: IRIX)
1.48 schwarz 232: if [ ! -z "$imakeopts" ]; then
1.101 joerg 233: echo "IMAKEOPTS+= $imakeopts" >> ${TARGET_MKCONF}
1.1 grant 234: fi
1.48 schwarz 235: if [ `uname -r` -lt 6 ]; then
236: echo_msg "Installing fake ldd script"
1.78 rillig 237: run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/fakeldd $prefix/sbin"
1.67 jlam 238: need_extras=yes
1.101 joerg 239: echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF}
1.1 grant 240: fi
241: ;;
242: esac
243: }
244:
245: is_root()
246: {
1.48 schwarz 247: if [ `uname -s` = "IRIX" ]; then
1.81 schwarz 248: if [ `uname -r` -lt 6 -a -z "$ID" ]; then
1.48 schwarz 249: # older version of IRIX have an id command with limited features
250: if [ "`$idprog`" != "uid=0(root) gid=0(sys)" ]; then
251: return 0
252: fi
253: return 1
254: fi
255: fi
1.1 grant 256: if [ `$idprog -u` != 0 ]; then
257: return 0
258: fi
259: return 1
260: }
261:
262: # run a command, abort if it fails
263: run_cmd()
264: {
265: echo_msg "running: $@"
266: eval "$@"
267: ret=$?
268: if [ $ret -ne 0 ]; then
269: echo_msg "exited with status $ret"
270: die "aborted."
271: fi
272: }
273:
1.4 sketch 274: # Some versions of mkdir (notably SunOS) bail out too easily, so use the
275: # install-sh wrapper instead.
276: mkdir_p()
277: {
1.7 tv 278: for dir in $@; do
1.67 jlam 279: run_cmd "$install_sh -d -o $user -g $group $dir"
1.7 tv 280: done
1.4 sketch 281: }
282:
1.101 joerg 283: mkdir_p_early()
284: {
1.146 rillig 285: [ -d "$1" ] && return 0
286: mkdir -p "$1" 2> /dev/null && return 0
287: parent=`dirname "$1"`
288: mkdir_p_early "$parent"
289: if [ ! -d "$1" ] && mkdir "$1"; then
290: echo_msg "mkdir $1 exited with status $?"
291: die "aborted."
292: fi
293: return 0
1.101 joerg 294: }
295:
1.2 grant 296: copy_src()
297: {
298: _src="$1"; _dst="$2"
299: if [ ! -d $wrkdir/$_dst ]; then
1.4 sketch 300: mkdir_p $wrkdir/$_dst
1.2 grant 301: fi
1.48 schwarz 302: $cpprog -r $_src/* $wrkdir/$_dst
1.2 grant 303: }
304:
1.38 rillig 305: get_optarg()
306: {
307: expr "x$1" : "x[^=]*=\\(.*\\)"
308: }
309:
1.115 rillig 310: checkarg_sane_absolute_path() {
311: case "$1" in
312: "") ;; # the default value will be used.
313: *[!-A-Za-z0-9_./]*)
314: die "ERROR: Invalid characters in path $1 (from $2)." ;;
315: /*) ;;
316: *) die "ERROR: The argument to $2 must be an absolute path." ;;
317: esac
318: }
319:
320: checkarg_sane_relative_path() {
321: case "$1" in
322: "") ;; # the default value will be used.
323: *[!-A-Za-z0-9_./]*)
324: die "ERROR: Invalid characters in path $1 (from $2)." ;;
325: /*) die "ERROR: The argument to $2 must be a relative path." ;;
326: *) ;;
327: esac
328: }
329:
1.107 rillig 330: bootstrap_sh=${SH-/bin/sh}
331: bootstrap_sh_set=${SH+set}
332:
333: # On some newer Ubuntu installations, /bin/sh is a symlink to /bin/dash,
334: # whose echo(1) is not BSD-compatible.
335: dash_echo_test=`$bootstrap_sh -c 'echo "\\100"'`
336: if [ "$dash_echo_test" = "@" ]; then
337: { echo "ERROR: Your shell's echo command is not BSD-compatible."
338: echo "ERROR: Please select another shell by setting the environment"
339: echo "ERROR: variable SH."
340: } 1>&2
341: exit 1;
342: fi
343:
1.147 joerg 344: if [ -n "$PKG_PATH" ]; then
345: echo "ERROR: Please unset PKG_PATH before running bootstrap." 1>&2
346: exit 1;
347: fi
348:
1.1 grant 349: build_start=`date`
350: echo_msg "bootstrap command: $0 $@"
351: echo_msg "bootstrap started: $build_start"
352:
1.39 jmmv 353: # ensure system locations are empty; we will set them later when we know
354: # whether they will be system wide or user specific
355: prefix=
356: pkgdbdir=
1.55 jlam 357: pkgmandir=
1.39 jmmv 358: sysconfdir=
359: varbase=
1.79 rillig 360:
361: full=no
362: compiler=""
1.85 rillig 363: quiet=no
1.102 joerg 364: mk_fragment=
1.39 jmmv 365:
1.33 jschauma 366: while [ $# -gt 0 ]; do
367: case $1 in
1.38 rillig 368: --workdir=*) wrkdir=`get_optarg "$1"` ;;
1.33 jschauma 369: --workdir) wrkdir="$2"; shift ;;
1.41 reed 370: --prefix=*) prefix=`get_optarg "$1"` ;;
371: --prefix) prefix="$2"; shift ;;
1.38 rillig 372: --pkgdbdir=*) pkgdbdir=`get_optarg "$1"` ;;
1.33 jschauma 373: --pkgdbdir) pkgdbdir="$2"; shift ;;
1.55 jlam 374: --pkgmandir=*) pkgmandir=`get_optarg "$1"` ;;
375: --pkgmandir) pkgmandir="$2"; shift ;;
1.38 rillig 376: --sysconfdir=*) sysconfdir=`get_optarg "$1"` ;;
1.33 jschauma 377: --sysconfdir) sysconfdir="$2"; shift ;;
1.40 jmmv 378: --varbase=*) varbase=`get_optarg "$1"` ;;
1.39 jmmv 379: --varbase) varbase="$2"; shift ;;
1.49 joerg 380: --fetch-cmd=*) fetch_cmd=`get_optarg "$1"` ;;
1.114 rillig 381: --fetch-cmd) fetch_cmd="$2"; shift ;;
1.79 rillig 382: --compiler=*) compiler=`get_optarg "$1"` ;;
383: --compiler) compiler="$2"; shift ;;
1.129 sketch 384: --abi=*) abi=`get_optarg "$1"` ;;
385: --abi) abi="$2"; shift ;;
1.33 jschauma 386: --ignore-case-check) ignorecasecheck=yes ;;
1.116 rillig 387: --unprivileged | --ignore-user-check) unprivileged=yes ;;
1.33 jschauma 388: --preserve-path) preserve_path=yes ;;
1.102 joerg 389: --mk-fragment=*)
390: mk_fragment=`get_optarg "$1"` ;;
391: --mk-fragment)
392: mk_fragment="$2"; shift ;;
1.118 joerg 393:
394: --binary-kit=*)
395: binary_kit=`get_optarg "$1"` ;;
396: --binary-kit)
397: binary_kit="$2"; shift ;;
398: --gzip-binary-kit=*)
399: binary_gzip_kit=`get_optarg "$1"` ;;
400: --gzip-binary-kit)
401: binary_gzip_kit="$2"; shift ;;
1.122 minskim 402: --binary-macpkg=*)
403: binary_macpkg=`get_optarg "$1"` ;;
1.118 joerg 404: --binary-macpkg)
1.122 minskim 405: binary_macpkg="$2"; shift ;;
1.76 jlam 406: --full) full=yes ;;
1.85 rillig 407: --quiet) quiet=yes ;;
1.33 jschauma 408: --help) echo "$usage"; exit ;;
409: -h) echo "$usage"; exit ;;
410: --*) echo "$usage"; exit 1 ;;
411: esac
412: shift
413: done
414:
1.115 rillig 415: checkarg_sane_absolute_path "$wrkdir" "--workdir"
416: checkarg_sane_absolute_path "$prefix" "--prefix"
417: checkarg_sane_absolute_path "$pkgdbdir" "--pkgdbdir"
418: checkarg_sane_absolute_path "$sysconfdir" "--sysconfdir"
419: checkarg_sane_absolute_path "$varbase" "--varbase"
420: checkarg_sane_relative_path "$pkgmandir" "--pkgmandir"
421:
1.39 jmmv 422: # set defaults for system locations if not already set by the user
1.67 jlam 423: wrkobjdir=${wrkdir}/pkgsrc
1.116 rillig 424: if [ "$unprivileged" = "yes" ]; then
1.39 jmmv 425: [ -z "$prefix" ] && prefix=${HOME}/pkg
1.119 joerg 426: elif [ -z "$prefix" -o "$prefix" = "/usr/pkg" ]; then
427: prefix=/usr/pkg
1.39 jmmv 428: [ -z "$varbase" ] && varbase=/var
429: fi
1.119 joerg 430:
431: [ -z "$varbase" ] && varbase=${prefix}/var
432: [ -z "$pkgdbdir" ] && pkgdbdir=${varbase}/db/pkg
433:
1.55 jlam 434: if [ "$prefix" = "/usr" ]; then
435: [ -z "$pkgmandir" ] && pkgmandir=share/man
436: else
437: [ -z "$pkgmandir" ] && pkgmandir=man
438: fi
439: mandir=${prefix}/${pkgmandir}
440: [ -z "$sysconfdir" ] && sysconfdir=${prefix}/etc
1.39 jmmv 441:
1.33 jschauma 442: if [ "x$preserve_path" != "xyes" ]; then
443: PATH="$PATH:/sbin:/usr/sbin"
1.16 danw 444: fi
445:
1.1 grant 446: overpath=""
1.3 tv 447: root_user=root
1.48 schwarz 448: bmakexenv=
449: bmakexargs=
1.67 jlam 450: need_extras=no
1.1 grant 451: case "$opsys" in
452: Darwin)
453: root_group=wheel
454: need_bsd_install=no
1.62 jlam 455: need_awk=no
456: need_sed=no
1.1 grant 457: set_opsys=no
1.133 dbj 458: [ -z "$fetch_cmd" ] && fetch_cmd="/usr/bin/ftp"
1.1 grant 459: machine_arch=`uname -p`
1.120 tron 460: CC="gcc -isystem /usr/include"; export CC
1.123 minskim 461: osrev=`uname -r`
462: macosx_version=`echo $osrev | awk -F . '{ print "10."$1-4; }'`
463: case "$macosx_version" in
464: 10.[0-4])
465: packagemaker=/Developer/Tools/packagemaker
466: ;;
467: *)
468: packagemaker=/Developer/usr/bin/packagemaker
469: ;;
470: esac
471: unset osrev macosx_version
1.1 grant 472: ;;
1.23 wiz 473: DragonFly)
474: root_group=wheel
475: need_bsd_install=no
1.57 jlam 476: need_awk=no
1.23 wiz 477: need_sed=no
478: set_opsys=no
1.26 agc 479: check_prog tarprog tar
1.23 wiz 480: machine_arch=`uname -p`
1.49 joerg 481: case `uname -r` in
1.50 joerg 482: 1.1[0-9]*)
483: [ -z "$fetch_cmd" ] && fetch_cmd="/usr/bin/ftp"
484: ;;
485: 1.0* | 1.1 | 1.2.* | 1.3.*)
1.49 joerg 486: ;;
487: *)
488: [ -z "$fetch_cmd" ] && fetch_cmd="/usr/bin/ftp"
489: ;;
490: esac
1.23 wiz 491: ;;
1.1 grant 492: FreeBSD)
493: root_group=wheel
494: need_bsd_install=no
1.57 jlam 495: need_awk=no
1.1 grant 496: need_sed=no
497: set_opsys=no
498: machine_arch=`uname -p`
499: ;;
1.95 tnn 500: HPUX)
501: root_group=sys
1.1 grant 502: need_bsd_install=yes
1.57 jlam 503: need_awk=yes
1.1 grant 504: need_sed=yes
505: set_opsys=no
1.96 tnn 506: machine_arch=`uname -m | sed 's/^9000.*$/hppa/'`
1.1 grant 507: ;;
508: IRIX*)
509: if [ -d "/usr/freeware/bin" ]; then
510: overpath="/usr/freeware/bin:$overpath"
511: fi
1.150 dholland 512: if [ -d "/usr/bsd" ]; then
513: overpath="/usr/bsd:$overpath"
514: fi
1.1 grant 515: if [ -d "/usr/bsd/bin" ]; then
516: overpath="/usr/bsd/bin:$overpath"
517: fi
518: root_group=sys
519: need_bsd_install=yes
520: get_abi "IRIX"
521: opsys=IRIX
1.57 jlam 522: need_awk=yes
1.1 grant 523: need_sed=yes
524: set_opsys=yes
1.27 jschauma 525: machine_arch=mipseb
1.47 jschauma 526: bmakexargs="MACHINE_ARCH=$machine_arch"
527: bmakexenv="MAKE=pmake"
1.33 jschauma 528: check_compiler=yes
1.48 schwarz 529: if [ `uname -r` -lt 6 ]; then
1.80 schwarz 530: # IRIX 5's mkdir bails out with an error when trying to create with the -p
531: # option an already existing directory
532: need_mkdir=yes
1.48 schwarz 533: fi
1.1 grant 534: ;;
535: Linux)
536: if [ -f /etc/debian_version ]; then
537: DEBIAN=yes
538: fi
539: root_group=root
540: need_bsd_install=no
1.57 jlam 541: need_awk=no
1.1 grant 542: need_sed=no
543: set_opsys=no
544: machine_arch=`uname -m | sed -e 's/i.86/i386/'`
545: ;;
546: NetBSD)
547: root_group=wheel
548: need_bsd_install=no
1.57 jlam 549: need_awk=no
1.1 grant 550: need_sed=no
551: set_opsys=no
552: machine_arch=`uname -p`
553: ;;
554: OpenBSD)
555: root_group=wheel
556: need_bsd_install=no
1.57 jlam 557: need_awk=no
1.1 grant 558: need_sed=no
559: set_opsys=no
1.8 grant 560: machine_arch=`uname -m`
1.1 grant 561: ;;
562: SunOS)
563: if [ -d "/usr/xpg4/bin" ]; then
564: overpath="/usr/xpg4/bin:$overpath"
565: fi
566: root_group=root
1.137 sketch 567: need_bsd_install=yes
1.57 jlam 568: need_awk=yes
1.1 grant 569: need_sed=yes
1.126 tnn 570: need_ksh=yes
1.1 grant 571: set_opsys=no
1.135 joerg 572: groupsprog="/usr/xpg4/bin/id -gn"
573: whoamiprog="/usr/xpg4/bin/id -un"
1.1 grant 574: machine_arch=`uname -p | sed -e 's/i86pc/i386/'`
1.79 rillig 575: check_compiler=yes
1.1 grant 576: ;;
577: AIX)
578: root_group=system
579: need_bsd_install=yes
1.57 jlam 580: need_awk=yes
1.1 grant 581: need_sed=yes
582: need_fixed_strip=yes
583: set_opsys=no
1.31 grant 584: machine_arch=`get_machine_arch_aix`
1.1 grant 585: ;;
586: Interix)
1.3 tv 587: is_root () {
1.17 tv 588: if id -G | grep -q 131616; then
1.3 tv 589: return 1
590: fi
591: return 0
592: }
1.14 tv 593: mkdir_p () {
594: mkdir -p "$@" # allows umask to take effect
595: }
1.15 tv 596: default_install_mode=0775
1.17 tv 597: root_user=`id -u`
598: root_group=131616
1.151 ! obache 599: case `uname -r` in
! 600: 3.* | 5.*)
! 601: need_bsd_install=yes
! 602: need_awk=yes
! 603: need_sed=yes
! 604: set_opsys=no
! 605: need_xargs=yes
! 606: ;;
! 607: *)
! 608: need_bsd_install=no
! 609: need_awk=no
! 610: need_sed=no
! 611: set_opsys=no
! 612: need_xargs=no
! 613: ;;
! 614: esac
1.10 tv 615: # only used for unprivileged builds
616: groupsprog="id -gn"
617: # for bootstrap only; pkgsrc uses CPPFLAGS
1.1 grant 618: CC="gcc -D_ALL_SOURCE"; export CC
1.17 tv 619: ac_cv_header_poll_h=no; export ac_cv_header_poll_h
620: ac_cv_func_poll=no; export ac_cv_func_poll
1.1 grant 621: ;;
1.12 heinz 622: UnixWare)
623: root_group=sys
624: need_bsd_install=no
625: BSTRAP_ENV="INSTALL=/usr/ucb/install $BSTRAP_ENV"
626: need_mkdir=yes
1.57 jlam 627: need_awk=yes
1.12 heinz 628: need_sed=yes
629: whoamiprog=/usr/ucb/whoami
630: set_opsys=no
631: CC="gcc -DUNIXWARE"; export CC
632: ;;
1.24 grant 633: OSF1)
634: root_group=system
635: need_bsd_install=yes
1.57 jlam 636: need_awk=yes
1.24 grant 637: need_sed=yes
1.125 tnn 638: need_ksh=yes
1.24 grant 639: set_opsys=no
640: ;;
1.110 joerg 641: QNX)
642: root_group=root
643: need_bsd_install=yes
644: set_opsys=no
645: groupsprog="id -gn"
646: whoamiprog="id -un"
647: fetch_cmd="/usr/bin/ftp"
648: machine_arch=`uname -p | sed -e 's/x86/i386/'`
649: ;;
1.1 grant 650: *)
651: echo "This platform ($opsys) is untried - good luck, and thanks for using pkgsrc"
652: root_group=wheel
653: need_bsd_install=yes
1.57 jlam 654: need_awk=yes
1.1 grant 655: need_sed=yes
656: set_opsys=no
657: ;;
658: esac
659:
1.76 jlam 660: # If "--full" is specified, then install all of the platform-independent
661: # bootstrap software.
662: #
663: case "$full" in
664: yes)
665: need_bsd_install=yes
666: need_awk=yes
667: need_sed=yes
1.125 tnn 668: need_ksh=yes
1.76 jlam 669: ;;
670: esac
671:
1.85 rillig 672: case "$quiet" in
673: yes)
674: configure_quiet_flags="--quiet"
675: make_quiet_flags="-s"
676: ;;
677: no)
678: configure_quiet_flags=""
679: make_quiet_flags=""
680: esac
681:
1.1 grant 682: # export OPSYS and MACHINE_ARCH for pkg_install. we only set
683: # MACHINE_ARCH on platforms where we override bmake's value.
684: OPSYS=${opsys}
685: export OPSYS
686: if [ "${machine_arch}" != "" ]; then
687: MACHINE_ARCH=${machine_arch}
688: export MACHINE_ARCH
689: fi
690:
1.33 jschauma 691: if [ "x$preserve_path" != "xyes" ]; then
1.1 grant 692: PATH="$overpath:$PATH"
693: fi
694:
695: check_prog awkprog awk
1.15 tv 696: check_prog chmodprog chmod
1.81 schwarz 697: if [ -n "$CP" ]; then
698: cpprog="$CP"
699: else
700: check_prog cpprog cp
701: fi
702: if [ -n "$ID" ]; then
703: idprog="$ID"
704: else
705: check_prog idprog id
706: fi
1.1 grant 707: check_prog groupsprog groups
1.48 schwarz 708: check_prog lnprog ln
1.1 grant 709: check_prog lsprog ls
710: check_prog rmdirprog rmdir
711: check_prog sedprog sed
712: check_prog shprog sh
713: check_prog whoamiprog whoami
714:
1.144 minskim 715: if [ -d "${wrkdir}" ] || [ -f "${wrkdir}" ]; then
1.143 joerg 716: echo "\"${wrkdir}\" already exists, please remove it or use --workdir.";
717: exit 1
718: fi
719:
1.101 joerg 720: mkdir_p_early ${wrkdir}
1.9 grant 721: if touch ${wrkdir}/.writeable; then
722: :
723: else
724: echo "\"${wrkdir}\" is not writeable. Try $0 -h.";
725: exit 1
726: fi
727: echo "Working directory is: ${wrkdir}"
728:
1.79 rillig 729: if [ "$compiler" = "" ] && [ x"$check_compiler" = x"yes" ]; then
1.33 jschauma 730: get_compiler
731: if [ $compiler_is_gnu -gt 0 ]; then
732: compiler="gcc"
733: else
734: case "$opsys" in
735: IRIX)
1.48 schwarz 736: if [ `uname -r` -ge 6 ]; then
737: compiler="mipspro"
738: else
739: compiler="ido"
740: fi
1.80 schwarz 741: test -n "$CC" || CC=cc
1.33 jschauma 742: ;;
1.79 rillig 743: SunOS) compiler="sunpro"
1.80 schwarz 744: test -n "$CC" || CC=cc
1.79 rillig 745: ;;
1.33 jschauma 746: esac
747: fi
748: fi
749:
1.101 joerg 750: mkdir_p_early ${wrkdir}/bin
751:
1.67 jlam 752: # build install-sh
1.101 joerg 753: run_cmd "$sedprog -e 's|@DEFAULT_INSTALL_MODE@|'${default_install_mode-0755}'|' $pkgsrcdir/sysutils/install-sh/files/install-sh.in > $wrkdir/bin/install-sh"
754: run_cmd "$chmodprog +x $wrkdir/bin/install-sh"
755: install_sh="$shprog $wrkdir/bin/install-sh"
1.15 tv 756:
1.1 grant 757: is_root
758: if [ $? = 1 ]; then
1.3 tv 759: user=$root_user
1.1 grant 760: group=$root_group
761: else
1.116 rillig 762: if [ $unprivileged = "no" ]; then
1.113 rillig 763: die "You must be either root to install bootstrap-pkgsrc or use the --unprivileged option."
1.1 grant 764: fi
765:
766: user=`$whoamiprog`
767: group=`$groupsprog | $awkprog '{print $1}'`
768: echo_msg "building as unprivileged user $user/$group"
769:
770: # force bmake install target to use $user and $group
771: echo "BINOWN=$user
772: BINGRP=$group
773: LIBOWN=$user
774: LIBGRP=$group
775: MANOWN=$user
1.9 grant 776: MANGRP=$group" > ${wrkdir}/Makefile.inc
1.1 grant 777: fi
778:
1.98 schmonz 779: # make sure we're using a case-sensitive file system
1.1 grant 780: if [ $ignorecasecheck = "no" ]; then
781: case "$opsys" in
1.124 agc 782: Interix)
1.1 grant 783: echo_msg "Testing file system case sensitivity"
1.98 schmonz 784: for fs in "$prefix"; do
1.1 grant 785: testdir="pkgsrc-REQUIRES-case-SENSITIVE-filesystem"
786: testdir_mangled="PKGSRC-requires-CASE-sensitive-FILESYSTEM"
1.4 sketch 787: mkdir_p "$fs/$testdir" || die "can't verify filesystem ($fs) case-sensitivity"
1.1 grant 788: if [ -d "$fs/$testdir_mangled" ]; then
789: $rmdirprog "$fs/$testdir"
1.6 tv 790: die "\"$fs\" needs to be on a case-sensitive filesystem (see README.$opsys)"
1.1 grant 791: fi
792: $rmdirprog "$fs/$testdir"
793: done
794: ;;
795: esac
796: fi
797:
798: # export the proper environment
799: PATH=$prefix/bin:$prefix/sbin:${PATH}; export PATH
800: if [ -d /usr/ccs/bin -a -x /usr/ccs/bin/make ]; then
1.28 grant 801: PATH=${PATH}:/usr/ccs/bin; export PATH
1.1 grant 802: fi
803: PKG_DBDIR=$pkgdbdir; export PKG_DBDIR
804: LOCALBASE=$prefix; export LOCALBASE
1.39 jmmv 805: VARBASE=$varbase; export VARBASE
1.1 grant 806:
807: # set up an example mk.conf file
1.101 joerg 808: TARGET_MKCONF=${wrkdir}/mk.conf.example
809: echo_msg "Creating default mk.conf. in ${wrkdir}"
810: echo "# Example ${sysconfdir}/mk.conf file produced by bootstrap-pkgsrc" > ${TARGET_MKCONF}
811: echo "# `date`" >> ${TARGET_MKCONF}
812: echo "" >> ${TARGET_MKCONF}
813: echo ".ifdef BSD_PKG_MK # begin pkgsrc settings" >> ${TARGET_MKCONF}
814: echo "" >> ${TARGET_MKCONF}
1.1 grant 815:
816: # IRIX64 needs to be set to IRIX, for example
817: if [ "$set_opsys" = "yes" ]; then
1.101 joerg 818: echo "OPSYS= $opsys" >> ${TARGET_MKCONF}
1.1 grant 819: fi
820:
821: if [ ! -z "$abi" ]; then
1.101 joerg 822: echo "ABI= $abi" >> ${TARGET_MKCONF}
1.1 grant 823: fi
1.79 rillig 824: if [ "$compiler" != "" ]; then
1.101 joerg 825: echo "PKGSRC_COMPILER= $compiler" >> ${TARGET_MKCONF}
1.33 jschauma 826: fi
1.138 sketch 827: case "$compiler" in
828: sunpro)
829: echo "CC= cc" >> ${TARGET_MKCONF}
830: echo "CXX= CC" >> ${TARGET_MKCONF}
831: echo "CPP= \${CC} -E" >> ${TARGET_MKCONF}
832: ;;
833: esac
1.130 sketch 834: if [ -n "$SUNWSPROBASE" ]; then
835: echo "SUNWSPROBASE= $SUNWSPROBASE" >> ${TARGET_MKCONF}
836: fi
837: echo "" >> ${TARGET_MKCONF}
1.1 grant 838:
1.39 jmmv 839: # enable unprivileged builds if not root
1.116 rillig 840: if [ "$unprivileged" = "yes" ]; then
1.101 joerg 841: echo "UNPRIVILEGED= yes" >> ${TARGET_MKCONF}
1.39 jmmv 842: fi
843:
1.1 grant 844: # save environment in example mk.conf
1.101 joerg 845: echo "PKG_DBDIR= $pkgdbdir" >> ${TARGET_MKCONF}
846: echo "LOCALBASE= $prefix" >> ${TARGET_MKCONF}
847: echo "VARBASE= $varbase" >> ${TARGET_MKCONF}
1.11 jmmv 848: if [ "${sysconfdir}" != "${prefix}/etc" ]; then
1.101 joerg 849: echo "PKG_SYSCONFBASE= $sysconfdir" >> ${TARGET_MKCONF}
1.11 jmmv 850: fi
1.101 joerg 851: echo "PKG_TOOLS_BIN= $prefix/sbin" >> ${TARGET_MKCONF}
852: echo "PKGMANDIR= $pkgmandir" >> ${TARGET_MKCONF}
853: echo "" >> ${TARGET_MKCONF}
854:
855: BOOTSTRAP_MKCONF=${wrkdir}/mk.conf
1.108 schwarz 856: cp ${TARGET_MKCONF} ${BOOTSTRAP_MKCONF}
1.101 joerg 857:
858: # sbin is used by pkg_install, share/mk by bootstrap-mk-files
859: mkdir_p $wrkdir/sbin $wrkdir/share/mk
860: mkdir_p_early ${wrkdir}
861:
1.1 grant 862: if [ "$need_bsd_install" = "yes" ]; then
863: BSTRAP_ENV="INSTALL='$prefix/bin/install-sh -c' $BSTRAP_ENV"
1.101 joerg 864: echo "TOOLS_PLATFORM.install?= $prefix/bin/install-sh" >> ${TARGET_MKCONF}
865: echo "TOOLS_PLATFORM.install?= $wrkdir/bin/install-sh" >> ${BOOTSTRAP_MKCONF}
1.1 grant 866: fi
867:
868: if [ "$need_fixed_strip" = "yes" ] ; then
869: echo_msg "Installing fixed strip script"
1.101 joerg 870: run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/strip-sh $wrkdir/bin/strip"
871: echo "TOOLS_PLATFORM.strip?= $prefix/bin/strip" >> ${TARGET_MKCONF}
872: echo "TOOLS_PLATFORM.strip?= $wrkdir/bin/strip" >> ${BOOTSTRAP_MKCONF}
1.67 jlam 873: need_extras=yes
1.1 grant 874: fi
875:
1.81 schwarz 876: if [ "$need_mkdir" = "yes" -a -z "$MKDIR" ]; then
1.13 heinz 877: echo_msg "Installing fixed mkdir script \"mkdir-sh\""
1.101 joerg 878: run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/mkdir-sh $wrkdir/bin/mkdir-sh"
879: echo "TOOLS_PLATFORM.mkdir?= $prefix/bin/mkdir-sh -p" >> ${TARGET_MKCONF}
880: echo "TOOLS_PLATFORM.mkdir?= $wrkdir/bin/mkdir-sh -p" >> ${BOOTSTRAP_MKCONF}
1.67 jlam 881: need_extras=yes
1.12 heinz 882: fi
883:
1.99 tnn 884: if [ "$need_xargs" = "yes" ]; then
885: echo_msg "Installing fixed xargs script"
1.105 tnn 886: run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/xargs-sh $wrkdir/bin/xargs"
1.101 joerg 887: echo "TOOLS_PLATFORM.xargs?= $prefix/bin/xargs" >> ${TARGET_MKCONF}
888: echo "TOOLS_PLATFORM.xargs?= $wrkdir/bin/xargs" >> ${BOOTSTRAP_MKCONF}
1.99 tnn 889: need_extras=yes
890: fi
891:
1.101 joerg 892: echo_msg "Bootstrapping mk-files"
893: run_cmd "(cd ${pkgsrcdir}/pkgtools/bootstrap-mk-files/files && env CP=${cpprog} \
894: OPSYS=${opsys} MK_DST=${wrkdir}/share/mk ROOT_GROUP=${root_group} \
895: ROOT_USER=${root_user} SED=${sedprog} SYSCONFDIR=${sysconfdir} \
896: $shprog ./bootstrap.sh)"
897:
1.125 tnn 898: bootstrap_bmake() {
899: echo_msg "Bootstrapping bmake"
900: copy_src $pkgsrcdir/devel/bmake/files bmake
1.136 joerg 901: run_cmd "(cd $wrkdir/bmake && env $bmakexenv $shprog ./boot-strap $configure_quiet_flags -q -o $opsys --prefix=$wrkdir --sysconfdir=$wrkdir --mksrc none --with-default-sys-path="$wrkdir/share/mk" $bmakexargs)"
1.125 tnn 902: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/bmake/$opsys/bmake $wrkdir/bin/bmake"
903: }
904: bootstrap_bmake
1.1 grant 905:
1.101 joerg 906: bmake="$wrkdir/bin/bmake $make_quiet_flags"
1.53 jlam 907:
1.136 joerg 908: # build libnbcompat
909: echo_msg "Building libnbcompat"
910: copy_src $pkgsrcdir/pkgtools/libnbcompat/files libnbcompat
1.140 joerg 911: run_cmd "(cd $wrkdir/libnbcompat; $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --mandir=$mandir --sysconfdir=$sysconfdir --enable-bsd-getopt --enable-db && $bmake $make_quiet_flags)"
1.136 joerg 912:
1.125 tnn 913: # bootstrap ksh if necessary
914: case "$need_ksh" in
915: yes) echo_msg "Bootstrapping ksh"
916: copy_src $pkgsrcdir/shells/pdksh/files ksh
917: test -n "$CC" || CC=gcc # default to gcc if no compiler is specified
918: run_cmd "(cd $wrkdir/ksh && env $BSTRAP_ENV $shprog ./configure $configure_quiet_flags --prefix=$prefix --mandir=$mandir --sysconfdir=$sysconfdir && $bmake)"
919: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/ksh/ksh $wrkdir/bin/pdksh"
920: echo "TOOLS_PLATFORM.sh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF}
921: echo "TOOLS_PLATFORM.sh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF}
1.128 sketch 922: echo "TOOLS_PLATFORM.ksh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF}
923: echo "TOOLS_PLATFORM.ksh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF}
1.125 tnn 924: # Now rebootstrap bmake for ksh
925: echo_msg "Rebootstrapping bmake for ksh"
926: bmakexargs="$bmakexargs --with-defshell=$wrkdir/bin/pdksh"
927: bootstrap_bmake
928: ;;
929: esac
930:
1.57 jlam 931: # bootstrap awk if necessary
932: case "$need_awk" in
1.101 joerg 933: yes) echo_msg "Bootstrapping awk"
1.78 rillig 934: copy_src $pkgsrcdir/lang/nawk/files awk
1.71 jlam 935: test -n "$CC" || CC=gcc # default to gcc if no compiler is specified
1.80 schwarz 936: run_cmd "(cd $wrkdir/awk && $bmake -f Makefile CC=\"${CC}\" CFLAGS=\"${CFLAGS}\")"
1.101 joerg 937: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/awk/a.out $wrkdir/bin/nawk"
938: echo "TOOLS_PLATFORM.awk?= $prefix/bin/nawk" >> ${TARGET_MKCONF}
939: echo "TOOLS_PLATFORM.awk?= $wrkdir/bin/nawk" >> ${BOOTSTRAP_MKCONF}
1.57 jlam 940: ;;
941: esac
942:
943: # bootstrap sed if necessary
944: case "$need_sed" in
1.101 joerg 945: yes) echo_msg "Bootstrapping sed"
1.78 rillig 946: copy_src $pkgsrcdir/textproc/nbsed/files sed
1.101 joerg 947: run_cmd "(cd $wrkdir/sed; env $BSTRAP_ENV CPPFLAGS='$CPPFLAGS -I../libnbcompat' LDFLAGS='$LDFLAGS -L../libnbcompat' LIBS='-lnbcompat' $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --mandir=$mandir --sysconfdir=$sysconfdir --program-transform-name='s,sed,nbsed,' && $bmake)"
948: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/sed/sed $wrkdir/bin/sed"
949: echo "TOOLS_PLATFORM.sed?= $prefix/bin/nbsed" >> ${TARGET_MKCONF}
950: echo "TOOLS_PLATFORM.sed?= $wrkdir/bin/sed" >> ${BOOTSTRAP_MKCONF}
1.57 jlam 951: ;;
952: esac
953:
1.1 grant 954: # bootstrap pkg_install
1.101 joerg 955: echo_msg "Bootstrapping pkgtools"
1.78 rillig 956: copy_src $pkgsrcdir/pkgtools/pkg_install/files pkg_install
1.101 joerg 957: run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV \
958: CPPFLAGS='$CPPFLAGS -I../libnbcompat -I../../libnbcompat' \
959: LDFLAGS='$LDFLAGS -L../libnbcompat -L../../libnbcompat' \
960: LIBS='-lnbcompat' $shprog ./configure $configure_quiet_flags -C \
1.104 joerg 961: --enable-bootstrap --prefix=$prefix --sysconfdir=$sysconfdir \
962: --with-pkgdbdir=$pkgdbdir --mandir=$mandir $pkg_install_args && $bmake)"
1.101 joerg 963: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/admin/pkg_admin $wrkdir/sbin/pkg_admin"
964: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/create/pkg_create $wrkdir/sbin/pkg_create"
965: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/info/pkg_info $wrkdir/sbin/pkg_info"
966: echo "PKG_ADMIN_CMD?= $wrkdir/sbin/pkg_admin" >> ${BOOTSTRAP_MKCONF}
967: echo "PKG_CREATE_CMD?= $wrkdir/sbin/pkg_create" >> ${BOOTSTRAP_MKCONF}
968: echo "PKG_INFO_CMD?= $wrkdir/sbin/pkg_info" >> ${BOOTSTRAP_MKCONF}
969:
1.103 joerg 970: if [ -n "${fetch_cmd}" ]; then
971: echo "FETCH_CMD= $fetch_cmd" >> ${TARGET_MKCONF}
972: fi
1.101 joerg 973:
974: MAKECONF=$wrkdir/mk.conf
975: export MAKECONF
1.1 grant 976:
1.107 rillig 977: if [ "$bootstrap_sh_set" = "set" ]; then
978: echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${TARGET_MKCONF}
979: echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${BOOTSTRAP_MKCONF}
1.90 rillig 980: fi
981:
1.81 schwarz 982: # preserve compiler and tool environment variables settings
1.101 joerg 983: if test -n "$CP"; then
984: echo "TOOLS_PLATFORM.cp?= $CP" >> ${TARGET_MKCONF}
985: echo "TOOLS_PLATFORM.cp?= $CP" >> ${BOOTSTRAP_MKCONF}
986: fi
987: if test -n "$GREP"; then
988: echo "TOOLS_PLATFORM.grep?= $GREP" >> ${TARGET_MKCONF}
989: echo "TOOLS_PLATFORM.grep?= $GREP" >> ${BOOTSTRAP_MKCONF}
990: fi
991: if test -n "$ID"; then
992: echo "TOOLS_PLATFORM.id?= $ID" >> ${TARGET_MKCONF}
993: echo "TOOLS_PLATFORM.id?= $ID" >> ${BOOTSTRAP_MKCONF}
994: fi
995: if test -n "$MKDIR"; then
996: echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${TARGET_MKCONF}
997: echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${BOOTSTRAP_MKCONF}
998: fi
999: if test -n "$TEST"; then
1000: echo "TOOLS_PLATFORM.test?= $TEST" >> ${TARGET_MKCONF}
1001: echo "TOOLS_PLATFORM.test?= $TEST" >> ${BOOTSTRAP_MKCONF}
1002: fi
1003: if test -n "$TOUCH"; then
1004: echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${TARGET_MKCONF}
1005: echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${BOOTSTRAP_MKCONF}
1006: fi
1007: if test -n "$XARGS"; then
1008: echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${TARGET_MKCONF}
1009: echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${BOOTSTRAP_MKCONF}
1010: fi
1011: if test -n "$CFLAGS"; then
1012: echo "CFLAGS+= $CFLAGS" >> ${TARGET_MKCONF}
1013: echo "DBG= # prevent DBG from adding default optimizer flags" >> ${TARGET_MKCONF}
1014: echo "DBG= # prevent DBG from adding default optimizer flags" >> ${BOOTSTRAP_MKCONF}
1015: fi
1016: if test -n "$CPPFLAGS"; then
1017: echo "CPPFLAGS+= $CPPFLAGS" >> ${TARGET_MKCONF}
1018: fi
1019: if test -n "$LDFLAGS"; then
1020: echo "LDFLAGS+= $LDFLAGS" >> ${TARGET_MKCONF}
1021: fi
1.81 schwarz 1022:
1.1 grant 1023: # opsys specific fiddling
1024: opsys_finish
1025:
1.101 joerg 1026: echo "WRKOBJDIR= ${wrkdir}/wrk" >> ${BOOTSTRAP_MKCONF}
1027:
1028: echo "" >> ${TARGET_MKCONF}
1029: echo "" >> ${BOOTSTRAP_MKCONF}
1.102 joerg 1030: if test -n "${mk_fragment}"; then
1031: cat "${mk_fragment}" >> ${TARGET_MKCONF}
1032: echo "" >> ${TARGET_MKCONF}
1033: fi
1.101 joerg 1034: echo ".endif # end pkgsrc settings" >> ${TARGET_MKCONF}
1035: echo ".endif # end pkgsrc settings" >> ${BOOTSTRAP_MKCONF}
1.1 grant 1036:
1.61 jlam 1037: # register packages
1.85 rillig 1038: # usage: register_package <packagedirectory> [additional arguments]
1.101 joerg 1039: build_package() {
1040: run_cmd "(cd $pkgsrcdir/$1 && $bmake -DPKG_PRESERVE MAKECONF=${BOOTSTRAP_MKCONF} install)"
1.85 rillig 1041: }
1042:
1.132 joerg 1043: #
1044: # Please make sure that the following packages and
1045: # only the following packages set BOOTSTRAP_PKG=yes.
1046: #
1.101 joerg 1047: echo_msg "Installing packages"
1048: build_package "pkgtools/bootstrap-mk-files"
1.127 tnn 1049: case "$need_bsd_install" in
1050: yes) build_package "sysutils/install-sh";;
1051: esac
1.125 tnn 1052: case "$need_ksh" in
1053: yes) build_package "shells/pdksh";;
1054: esac
1.101 joerg 1055: build_package "devel/bmake"
1.61 jlam 1056: case "$need_awk" in
1.101 joerg 1057: yes) build_package "lang/nawk";;
1.61 jlam 1058: esac
1059: case "$need_sed" in
1.141 joerg 1060: yes) build_package "textproc/nbsed";;
1.67 jlam 1061: esac
1062: case "$need_extras" in
1.101 joerg 1063: yes) build_package "pkgtools/bootstrap-extras";;
1.61 jlam 1064: esac
1.101 joerg 1065: build_package "pkgtools/pkg_install"
1.61 jlam 1066:
1.89 rillig 1067: etc_mk_conf="$sysconfdir/mk.conf"
1068:
1069: # Install the example mk.conf so that it is used, but only if it doesn't
1.101 joerg 1070: # exist yet. This can happen with non-default sysconfdir settings.
1.89 rillig 1071: mkdir_p "$sysconfdir"
1072: if [ ! -f "$etc_mk_conf" ]; then
1.101 joerg 1073: cp "$TARGET_MKCONF" "$etc_mk_conf"
1074: TARGET_MKCONF="$etc_mk_conf"
1.89 rillig 1075: fi
1076:
1.85 rillig 1077: hline="==========================================================================="
1078: echo ""
1079: echo "$hline"
1.1 grant 1080: echo ""
1.9 grant 1081: echo "Please remember to add $prefix/bin to your PATH environment variable"
1.77 jlam 1082: echo "and $mandir to your MANPATH environment variable, if necessary."
1.9 grant 1083: echo ""
1.85 rillig 1084: echo "An example mk.conf file with the settings you provided to \"bootstrap\""
1085: echo "has been created for you. It can be found in:"
1086: echo ""
1.101 joerg 1087: echo " ${TARGET_MKCONF}"
1.85 rillig 1088: echo ""
1.101 joerg 1089: if [ "$TARGET_MKCONF" != "$etc_mk_conf" ]; then
1.89 rillig 1090: echo "Please copy it to $etc_mk_conf to use it."
1091: echo ""
1092: fi
1.1 grant 1093: echo "You can find extensive documentation of the NetBSD Packages Collection"
1.92 wiz 1094: echo "in $pkgsrcdir/doc/pkgsrc.txt."
1.1 grant 1095: echo ""
1096: echo "Hopefully everything is now complete."
1097: echo "Thank you"
1.85 rillig 1098: echo ""
1099: echo "$hline"
1100: echo ""
1.1 grant 1101:
1.118 joerg 1102: [ ! -z "${binary_kit}" ] && mkbinarykit_tar
1103: [ ! -z "${binary_gzip_kit}" ] && mkbinarykit_tgz
1104: [ ! -z "${binary_macpkg}" ] && mkbinarykit_macpkg
1105:
1.1 grant 1106: echo_msg "bootstrap started: $build_start"
1107: echo_msg "bootstrap ended: `date`"
1108:
1109: exit 0
CVSweb <webmaster@jp.NetBSD.org>