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