Annotation of pkgsrc/bootstrap/bootstrap, Revision 1.158
1.1 grant 1: #! /bin/sh
2:
1.158 ! joerg 3: # $NetBSD: bootstrap,v 1.157 2010/03/19 14:11:11 seanb 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:
1.154 obache 39: # compiler/linker flags: CFLAGS, CPPFLAGS, LDFLAGS, LIBS
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: ;;
1.156 obache 242: Haiku)
243: need_extras=yes
244: echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF}
245: ;;
1.1 grant 246: esac
247: }
248:
249: is_root()
250: {
1.48 schwarz 251: if [ `uname -s` = "IRIX" ]; then
1.81 schwarz 252: if [ `uname -r` -lt 6 -a -z "$ID" ]; then
1.48 schwarz 253: # older version of IRIX have an id command with limited features
254: if [ "`$idprog`" != "uid=0(root) gid=0(sys)" ]; then
255: return 0
256: fi
257: return 1
258: fi
259: fi
1.1 grant 260: if [ `$idprog -u` != 0 ]; then
261: return 0
262: fi
263: return 1
264: }
265:
266: # run a command, abort if it fails
267: run_cmd()
268: {
269: echo_msg "running: $@"
270: eval "$@"
271: ret=$?
272: if [ $ret -ne 0 ]; then
273: echo_msg "exited with status $ret"
274: die "aborted."
275: fi
276: }
277:
1.4 sketch 278: # Some versions of mkdir (notably SunOS) bail out too easily, so use the
279: # install-sh wrapper instead.
280: mkdir_p()
281: {
1.7 tv 282: for dir in $@; do
1.67 jlam 283: run_cmd "$install_sh -d -o $user -g $group $dir"
1.7 tv 284: done
1.4 sketch 285: }
286:
1.101 joerg 287: mkdir_p_early()
288: {
1.146 rillig 289: [ -d "$1" ] && return 0
290: mkdir -p "$1" 2> /dev/null && return 0
291: parent=`dirname "$1"`
292: mkdir_p_early "$parent"
293: if [ ! -d "$1" ] && mkdir "$1"; then
294: echo_msg "mkdir $1 exited with status $?"
295: die "aborted."
296: fi
297: return 0
1.101 joerg 298: }
299:
1.2 grant 300: copy_src()
301: {
302: _src="$1"; _dst="$2"
303: if [ ! -d $wrkdir/$_dst ]; then
1.4 sketch 304: mkdir_p $wrkdir/$_dst
1.2 grant 305: fi
1.48 schwarz 306: $cpprog -r $_src/* $wrkdir/$_dst
1.2 grant 307: }
308:
1.38 rillig 309: get_optarg()
310: {
311: expr "x$1" : "x[^=]*=\\(.*\\)"
312: }
313:
1.115 rillig 314: checkarg_sane_absolute_path() {
315: case "$1" in
316: "") ;; # the default value will be used.
317: *[!-A-Za-z0-9_./]*)
318: die "ERROR: Invalid characters in path $1 (from $2)." ;;
1.158 ! joerg 319: */) die "ERROR: The argument to $2 must not end in /." ;;
1.115 rillig 320: /*) ;;
321: *) die "ERROR: The argument to $2 must be an absolute path." ;;
322: esac
323: }
324:
325: checkarg_sane_relative_path() {
326: case "$1" in
327: "") ;; # the default value will be used.
328: *[!-A-Za-z0-9_./]*)
329: die "ERROR: Invalid characters in path $1 (from $2)." ;;
330: /*) die "ERROR: The argument to $2 must be a relative path." ;;
331: *) ;;
332: esac
333: }
334:
1.107 rillig 335: bootstrap_sh=${SH-/bin/sh}
336: bootstrap_sh_set=${SH+set}
337:
338: # On some newer Ubuntu installations, /bin/sh is a symlink to /bin/dash,
339: # whose echo(1) is not BSD-compatible.
340: dash_echo_test=`$bootstrap_sh -c 'echo "\\100"'`
341: if [ "$dash_echo_test" = "@" ]; then
342: { echo "ERROR: Your shell's echo command is not BSD-compatible."
343: echo "ERROR: Please select another shell by setting the environment"
344: echo "ERROR: variable SH."
345: } 1>&2
346: exit 1;
347: fi
348:
1.147 joerg 349: if [ -n "$PKG_PATH" ]; then
350: echo "ERROR: Please unset PKG_PATH before running bootstrap." 1>&2
351: exit 1;
352: fi
353:
1.1 grant 354: build_start=`date`
355: echo_msg "bootstrap command: $0 $@"
356: echo_msg "bootstrap started: $build_start"
357:
1.39 jmmv 358: # ensure system locations are empty; we will set them later when we know
359: # whether they will be system wide or user specific
360: prefix=
361: pkgdbdir=
1.55 jlam 362: pkgmandir=
1.39 jmmv 363: sysconfdir=
364: varbase=
1.79 rillig 365:
366: full=no
367: compiler=""
1.85 rillig 368: quiet=no
1.102 joerg 369: mk_fragment=
1.39 jmmv 370:
1.33 jschauma 371: while [ $# -gt 0 ]; do
372: case $1 in
1.38 rillig 373: --workdir=*) wrkdir=`get_optarg "$1"` ;;
1.33 jschauma 374: --workdir) wrkdir="$2"; shift ;;
1.41 reed 375: --prefix=*) prefix=`get_optarg "$1"` ;;
376: --prefix) prefix="$2"; shift ;;
1.38 rillig 377: --pkgdbdir=*) pkgdbdir=`get_optarg "$1"` ;;
1.33 jschauma 378: --pkgdbdir) pkgdbdir="$2"; shift ;;
1.55 jlam 379: --pkgmandir=*) pkgmandir=`get_optarg "$1"` ;;
380: --pkgmandir) pkgmandir="$2"; shift ;;
1.38 rillig 381: --sysconfdir=*) sysconfdir=`get_optarg "$1"` ;;
1.33 jschauma 382: --sysconfdir) sysconfdir="$2"; shift ;;
1.40 jmmv 383: --varbase=*) varbase=`get_optarg "$1"` ;;
1.39 jmmv 384: --varbase) varbase="$2"; shift ;;
1.49 joerg 385: --fetch-cmd=*) fetch_cmd=`get_optarg "$1"` ;;
1.114 rillig 386: --fetch-cmd) fetch_cmd="$2"; shift ;;
1.79 rillig 387: --compiler=*) compiler=`get_optarg "$1"` ;;
388: --compiler) compiler="$2"; shift ;;
1.129 sketch 389: --abi=*) abi=`get_optarg "$1"` ;;
390: --abi) abi="$2"; shift ;;
1.33 jschauma 391: --ignore-case-check) ignorecasecheck=yes ;;
1.116 rillig 392: --unprivileged | --ignore-user-check) unprivileged=yes ;;
1.33 jschauma 393: --preserve-path) preserve_path=yes ;;
1.102 joerg 394: --mk-fragment=*)
395: mk_fragment=`get_optarg "$1"` ;;
396: --mk-fragment)
397: mk_fragment="$2"; shift ;;
1.118 joerg 398:
399: --binary-kit=*)
400: binary_kit=`get_optarg "$1"` ;;
401: --binary-kit)
402: binary_kit="$2"; shift ;;
403: --gzip-binary-kit=*)
404: binary_gzip_kit=`get_optarg "$1"` ;;
405: --gzip-binary-kit)
406: binary_gzip_kit="$2"; shift ;;
1.122 minskim 407: --binary-macpkg=*)
408: binary_macpkg=`get_optarg "$1"` ;;
1.118 joerg 409: --binary-macpkg)
1.122 minskim 410: binary_macpkg="$2"; shift ;;
1.76 jlam 411: --full) full=yes ;;
1.85 rillig 412: --quiet) quiet=yes ;;
1.33 jschauma 413: --help) echo "$usage"; exit ;;
414: -h) echo "$usage"; exit ;;
415: --*) echo "$usage"; exit 1 ;;
416: esac
417: shift
418: done
419:
1.115 rillig 420: checkarg_sane_absolute_path "$wrkdir" "--workdir"
421: checkarg_sane_absolute_path "$prefix" "--prefix"
422: checkarg_sane_absolute_path "$pkgdbdir" "--pkgdbdir"
423: checkarg_sane_absolute_path "$sysconfdir" "--sysconfdir"
424: checkarg_sane_absolute_path "$varbase" "--varbase"
425: checkarg_sane_relative_path "$pkgmandir" "--pkgmandir"
426:
1.39 jmmv 427: # set defaults for system locations if not already set by the user
1.67 jlam 428: wrkobjdir=${wrkdir}/pkgsrc
1.116 rillig 429: if [ "$unprivileged" = "yes" ]; then
1.39 jmmv 430: [ -z "$prefix" ] && prefix=${HOME}/pkg
1.119 joerg 431: elif [ -z "$prefix" -o "$prefix" = "/usr/pkg" ]; then
432: prefix=/usr/pkg
1.39 jmmv 433: [ -z "$varbase" ] && varbase=/var
434: fi
1.119 joerg 435:
436: [ -z "$varbase" ] && varbase=${prefix}/var
437: [ -z "$pkgdbdir" ] && pkgdbdir=${varbase}/db/pkg
438:
1.55 jlam 439: if [ "$prefix" = "/usr" ]; then
440: [ -z "$pkgmandir" ] && pkgmandir=share/man
441: else
442: [ -z "$pkgmandir" ] && pkgmandir=man
443: fi
444: mandir=${prefix}/${pkgmandir}
445: [ -z "$sysconfdir" ] && sysconfdir=${prefix}/etc
1.39 jmmv 446:
1.33 jschauma 447: if [ "x$preserve_path" != "xyes" ]; then
448: PATH="$PATH:/sbin:/usr/sbin"
1.16 danw 449: fi
450:
1.1 grant 451: overpath=""
1.3 tv 452: root_user=root
1.48 schwarz 453: bmakexenv=
454: bmakexargs=
1.67 jlam 455: need_extras=no
1.1 grant 456: case "$opsys" in
1.153 obache 457: AIX)
458: root_group=system
459: need_bsd_install=yes
460: need_awk=yes
461: need_sed=yes
462: need_fixed_strip=yes
463: set_opsys=no
464: machine_arch=`get_machine_arch_aix`
465: ;;
1.1 grant 466: Darwin)
467: root_group=wheel
468: need_bsd_install=no
1.62 jlam 469: need_awk=no
470: need_sed=no
1.1 grant 471: set_opsys=no
1.133 dbj 472: [ -z "$fetch_cmd" ] && fetch_cmd="/usr/bin/ftp"
1.1 grant 473: machine_arch=`uname -p`
1.120 tron 474: CC="gcc -isystem /usr/include"; export CC
1.123 minskim 475: osrev=`uname -r`
476: macosx_version=`echo $osrev | awk -F . '{ print "10."$1-4; }'`
477: case "$macosx_version" in
478: 10.[0-4])
479: packagemaker=/Developer/Tools/packagemaker
480: ;;
481: *)
482: packagemaker=/Developer/usr/bin/packagemaker
483: ;;
484: esac
485: unset osrev macosx_version
1.1 grant 486: ;;
1.23 wiz 487: DragonFly)
488: root_group=wheel
489: need_bsd_install=no
1.57 jlam 490: need_awk=no
1.23 wiz 491: need_sed=no
492: set_opsys=no
1.26 agc 493: check_prog tarprog tar
1.23 wiz 494: machine_arch=`uname -p`
1.49 joerg 495: case `uname -r` in
1.50 joerg 496: 1.1[0-9]*)
497: [ -z "$fetch_cmd" ] && fetch_cmd="/usr/bin/ftp"
498: ;;
499: 1.0* | 1.1 | 1.2.* | 1.3.*)
1.49 joerg 500: ;;
501: *)
502: [ -z "$fetch_cmd" ] && fetch_cmd="/usr/bin/ftp"
503: ;;
504: esac
1.23 wiz 505: ;;
1.1 grant 506: FreeBSD)
507: root_group=wheel
508: need_bsd_install=no
1.57 jlam 509: need_awk=no
1.1 grant 510: need_sed=no
511: set_opsys=no
512: machine_arch=`uname -p`
513: ;;
1.156 obache 514: Haiku)
515: root_user=user
516: root_group=root
517: need_bsd_install=no
518: need_awk=no
519: need_sed=no
520: set_opsys=no
521: case `uname -m` in
522: BeMac)
523: machine_arch=powerpc
524: ;;
525: BePC)
526: machine_arch=i386
527: ;;
528: *)
529: machine_arch=`uname -p`
530: ;;
531: esac
532: ;;
1.95 tnn 533: HPUX)
534: root_group=sys
1.1 grant 535: need_bsd_install=yes
1.57 jlam 536: need_awk=yes
1.1 grant 537: need_sed=yes
538: set_opsys=no
1.96 tnn 539: machine_arch=`uname -m | sed 's/^9000.*$/hppa/'`
1.1 grant 540: ;;
1.153 obache 541: Interix)
542: is_root () {
543: if id -G | grep -q 131616; then
544: return 1
545: fi
546: return 0
547: }
548: mkdir_p () {
549: mkdir -p "$@" # allows umask to take effect
550: }
551: default_install_mode=0775
552: root_user=`id -u`
553: root_group=131616
554: case `uname -r` in
555: 3.* | 5.*)
556: need_bsd_install=yes
557: need_awk=yes
558: need_sed=yes
559: set_opsys=no
560: need_xargs=yes
561: ;;
562: *)
563: need_bsd_install=no
564: need_awk=no
565: need_sed=no
566: set_opsys=no
567: need_xargs=no
568: ;;
569: esac
570: # only used for unprivileged builds
571: groupsprog="id -gn"
572: # for bootstrap only; pkgsrc uses CPPFLAGS
573: CC="gcc -D_ALL_SOURCE"; export CC
574: ac_cv_header_poll_h=no; export ac_cv_header_poll_h
575: ac_cv_func_poll=no; export ac_cv_func_poll
576: ;;
1.1 grant 577: IRIX*)
578: if [ -d "/usr/freeware/bin" ]; then
579: overpath="/usr/freeware/bin:$overpath"
580: fi
1.150 dholland 581: if [ -d "/usr/bsd" ]; then
582: overpath="/usr/bsd:$overpath"
583: fi
1.1 grant 584: if [ -d "/usr/bsd/bin" ]; then
585: overpath="/usr/bsd/bin:$overpath"
586: fi
587: root_group=sys
588: need_bsd_install=yes
589: get_abi "IRIX"
590: opsys=IRIX
1.57 jlam 591: need_awk=yes
1.1 grant 592: need_sed=yes
593: set_opsys=yes
1.27 jschauma 594: machine_arch=mipseb
1.47 jschauma 595: bmakexargs="MACHINE_ARCH=$machine_arch"
596: bmakexenv="MAKE=pmake"
1.33 jschauma 597: check_compiler=yes
1.48 schwarz 598: if [ `uname -r` -lt 6 ]; then
1.80 schwarz 599: # IRIX 5's mkdir bails out with an error when trying to create with the -p
600: # option an already existing directory
601: need_mkdir=yes
1.48 schwarz 602: fi
1.1 grant 603: ;;
604: Linux)
1.152 obache 605: if [ -f /etc/ssdlinux_version ]; then
606: root_group=wheel
607: else
608: root_group=root
1.1 grant 609: fi
610: need_bsd_install=no
1.57 jlam 611: need_awk=no
1.1 grant 612: need_sed=no
613: set_opsys=no
614: machine_arch=`uname -m | sed -e 's/i.86/i386/'`
615: ;;
616: NetBSD)
617: root_group=wheel
618: need_bsd_install=no
1.57 jlam 619: need_awk=no
1.1 grant 620: need_sed=no
621: set_opsys=no
622: machine_arch=`uname -p`
623: ;;
624: OpenBSD)
625: root_group=wheel
626: need_bsd_install=no
1.57 jlam 627: need_awk=no
1.1 grant 628: need_sed=no
629: set_opsys=no
1.8 grant 630: machine_arch=`uname -m`
1.1 grant 631: ;;
1.153 obache 632: OSF1)
633: root_group=system
634: need_bsd_install=yes
635: need_awk=yes
636: need_sed=yes
637: need_ksh=yes
638: set_opsys=no
639: ;;
640: QNX)
641: root_group=root
642: need_bsd_install=yes
1.157 seanb 643: need_awk=yes
644: need_sed=yes
1.153 obache 645: set_opsys=no
646: groupsprog="id -gn"
647: whoamiprog="id -un"
648: fetch_cmd="/usr/bin/ftp"
649: machine_arch=`uname -p | sed -e 's/x86/i386/'`
650: ;;
1.1 grant 651: SunOS)
652: if [ -d "/usr/xpg4/bin" ]; then
653: overpath="/usr/xpg4/bin:$overpath"
654: fi
655: root_group=root
1.137 sketch 656: need_bsd_install=yes
1.57 jlam 657: need_awk=yes
1.1 grant 658: need_sed=yes
1.126 tnn 659: need_ksh=yes
1.1 grant 660: set_opsys=no
1.135 joerg 661: groupsprog="/usr/xpg4/bin/id -gn"
662: whoamiprog="/usr/xpg4/bin/id -un"
1.1 grant 663: machine_arch=`uname -p | sed -e 's/i86pc/i386/'`
1.79 rillig 664: check_compiler=yes
1.1 grant 665: ;;
1.12 heinz 666: UnixWare)
667: root_group=sys
668: need_bsd_install=no
669: BSTRAP_ENV="INSTALL=/usr/ucb/install $BSTRAP_ENV"
670: need_mkdir=yes
1.57 jlam 671: need_awk=yes
1.12 heinz 672: need_sed=yes
673: whoamiprog=/usr/ucb/whoami
674: set_opsys=no
675: CC="gcc -DUNIXWARE"; export CC
676: ;;
1.1 grant 677: *)
678: echo "This platform ($opsys) is untried - good luck, and thanks for using pkgsrc"
679: root_group=wheel
680: need_bsd_install=yes
1.57 jlam 681: need_awk=yes
1.1 grant 682: need_sed=yes
683: set_opsys=no
684: ;;
685: esac
686:
1.76 jlam 687: # If "--full" is specified, then install all of the platform-independent
688: # bootstrap software.
689: #
690: case "$full" in
691: yes)
692: need_bsd_install=yes
693: need_awk=yes
694: need_sed=yes
1.125 tnn 695: need_ksh=yes
1.76 jlam 696: ;;
697: esac
698:
1.85 rillig 699: case "$quiet" in
700: yes)
701: configure_quiet_flags="--quiet"
702: make_quiet_flags="-s"
703: ;;
704: no)
705: configure_quiet_flags=""
706: make_quiet_flags=""
707: esac
708:
1.1 grant 709: # export OPSYS and MACHINE_ARCH for pkg_install. we only set
710: # MACHINE_ARCH on platforms where we override bmake's value.
711: OPSYS=${opsys}
712: export OPSYS
713: if [ "${machine_arch}" != "" ]; then
714: MACHINE_ARCH=${machine_arch}
715: export MACHINE_ARCH
716: fi
717:
1.33 jschauma 718: if [ "x$preserve_path" != "xyes" ]; then
1.1 grant 719: PATH="$overpath:$PATH"
720: fi
721:
722: check_prog awkprog awk
1.15 tv 723: check_prog chmodprog chmod
1.81 schwarz 724: if [ -n "$CP" ]; then
725: cpprog="$CP"
726: else
727: check_prog cpprog cp
728: fi
729: if [ -n "$ID" ]; then
730: idprog="$ID"
731: else
732: check_prog idprog id
733: fi
1.1 grant 734: check_prog groupsprog groups
1.48 schwarz 735: check_prog lnprog ln
1.1 grant 736: check_prog lsprog ls
737: check_prog rmdirprog rmdir
738: check_prog sedprog sed
739: check_prog shprog sh
740: check_prog whoamiprog whoami
741:
1.144 minskim 742: if [ -d "${wrkdir}" ] || [ -f "${wrkdir}" ]; then
1.143 joerg 743: echo "\"${wrkdir}\" already exists, please remove it or use --workdir.";
744: exit 1
745: fi
746:
1.101 joerg 747: mkdir_p_early ${wrkdir}
1.9 grant 748: if touch ${wrkdir}/.writeable; then
749: :
750: else
751: echo "\"${wrkdir}\" is not writeable. Try $0 -h.";
752: exit 1
753: fi
754: echo "Working directory is: ${wrkdir}"
755:
1.79 rillig 756: if [ "$compiler" = "" ] && [ x"$check_compiler" = x"yes" ]; then
1.33 jschauma 757: get_compiler
758: if [ $compiler_is_gnu -gt 0 ]; then
759: compiler="gcc"
760: else
761: case "$opsys" in
762: IRIX)
1.48 schwarz 763: if [ `uname -r` -ge 6 ]; then
764: compiler="mipspro"
765: else
766: compiler="ido"
767: fi
1.80 schwarz 768: test -n "$CC" || CC=cc
1.33 jschauma 769: ;;
1.79 rillig 770: SunOS) compiler="sunpro"
1.80 schwarz 771: test -n "$CC" || CC=cc
1.79 rillig 772: ;;
1.33 jschauma 773: esac
774: fi
775: fi
776:
1.101 joerg 777: mkdir_p_early ${wrkdir}/bin
778:
1.67 jlam 779: # build install-sh
1.101 joerg 780: run_cmd "$sedprog -e 's|@DEFAULT_INSTALL_MODE@|'${default_install_mode-0755}'|' $pkgsrcdir/sysutils/install-sh/files/install-sh.in > $wrkdir/bin/install-sh"
781: run_cmd "$chmodprog +x $wrkdir/bin/install-sh"
782: install_sh="$shprog $wrkdir/bin/install-sh"
1.15 tv 783:
1.1 grant 784: is_root
785: if [ $? = 1 ]; then
1.3 tv 786: user=$root_user
1.1 grant 787: group=$root_group
788: else
1.116 rillig 789: if [ $unprivileged = "no" ]; then
1.113 rillig 790: die "You must be either root to install bootstrap-pkgsrc or use the --unprivileged option."
1.1 grant 791: fi
792:
793: user=`$whoamiprog`
794: group=`$groupsprog | $awkprog '{print $1}'`
795: echo_msg "building as unprivileged user $user/$group"
796:
797: # force bmake install target to use $user and $group
798: echo "BINOWN=$user
799: BINGRP=$group
800: LIBOWN=$user
801: LIBGRP=$group
802: MANOWN=$user
1.9 grant 803: MANGRP=$group" > ${wrkdir}/Makefile.inc
1.1 grant 804: fi
805:
1.98 schmonz 806: # make sure we're using a case-sensitive file system
1.1 grant 807: if [ $ignorecasecheck = "no" ]; then
808: case "$opsys" in
1.124 agc 809: Interix)
1.1 grant 810: echo_msg "Testing file system case sensitivity"
1.98 schmonz 811: for fs in "$prefix"; do
1.1 grant 812: testdir="pkgsrc-REQUIRES-case-SENSITIVE-filesystem"
813: testdir_mangled="PKGSRC-requires-CASE-sensitive-FILESYSTEM"
1.4 sketch 814: mkdir_p "$fs/$testdir" || die "can't verify filesystem ($fs) case-sensitivity"
1.1 grant 815: if [ -d "$fs/$testdir_mangled" ]; then
816: $rmdirprog "$fs/$testdir"
1.6 tv 817: die "\"$fs\" needs to be on a case-sensitive filesystem (see README.$opsys)"
1.1 grant 818: fi
819: $rmdirprog "$fs/$testdir"
820: done
821: ;;
822: esac
823: fi
824:
825: # export the proper environment
826: PATH=$prefix/bin:$prefix/sbin:${PATH}; export PATH
827: if [ -d /usr/ccs/bin -a -x /usr/ccs/bin/make ]; then
1.28 grant 828: PATH=${PATH}:/usr/ccs/bin; export PATH
1.1 grant 829: fi
830: PKG_DBDIR=$pkgdbdir; export PKG_DBDIR
831: LOCALBASE=$prefix; export LOCALBASE
1.39 jmmv 832: VARBASE=$varbase; export VARBASE
1.1 grant 833:
834: # set up an example mk.conf file
1.101 joerg 835: TARGET_MKCONF=${wrkdir}/mk.conf.example
1.155 obache 836: echo_msg "Creating default mk.conf in ${wrkdir}"
1.101 joerg 837: echo "# Example ${sysconfdir}/mk.conf file produced by bootstrap-pkgsrc" > ${TARGET_MKCONF}
838: echo "# `date`" >> ${TARGET_MKCONF}
839: echo "" >> ${TARGET_MKCONF}
840: echo ".ifdef BSD_PKG_MK # begin pkgsrc settings" >> ${TARGET_MKCONF}
841: echo "" >> ${TARGET_MKCONF}
1.1 grant 842:
843: # IRIX64 needs to be set to IRIX, for example
844: if [ "$set_opsys" = "yes" ]; then
1.101 joerg 845: echo "OPSYS= $opsys" >> ${TARGET_MKCONF}
1.1 grant 846: fi
847:
848: if [ ! -z "$abi" ]; then
1.101 joerg 849: echo "ABI= $abi" >> ${TARGET_MKCONF}
1.1 grant 850: fi
1.79 rillig 851: if [ "$compiler" != "" ]; then
1.101 joerg 852: echo "PKGSRC_COMPILER= $compiler" >> ${TARGET_MKCONF}
1.33 jschauma 853: fi
1.138 sketch 854: case "$compiler" in
855: sunpro)
856: echo "CC= cc" >> ${TARGET_MKCONF}
857: echo "CXX= CC" >> ${TARGET_MKCONF}
858: echo "CPP= \${CC} -E" >> ${TARGET_MKCONF}
859: ;;
860: esac
1.130 sketch 861: if [ -n "$SUNWSPROBASE" ]; then
862: echo "SUNWSPROBASE= $SUNWSPROBASE" >> ${TARGET_MKCONF}
863: fi
864: echo "" >> ${TARGET_MKCONF}
1.1 grant 865:
1.39 jmmv 866: # enable unprivileged builds if not root
1.116 rillig 867: if [ "$unprivileged" = "yes" ]; then
1.101 joerg 868: echo "UNPRIVILEGED= yes" >> ${TARGET_MKCONF}
1.39 jmmv 869: fi
870:
1.1 grant 871: # save environment in example mk.conf
1.101 joerg 872: echo "PKG_DBDIR= $pkgdbdir" >> ${TARGET_MKCONF}
873: echo "LOCALBASE= $prefix" >> ${TARGET_MKCONF}
874: echo "VARBASE= $varbase" >> ${TARGET_MKCONF}
1.11 jmmv 875: if [ "${sysconfdir}" != "${prefix}/etc" ]; then
1.101 joerg 876: echo "PKG_SYSCONFBASE= $sysconfdir" >> ${TARGET_MKCONF}
1.11 jmmv 877: fi
1.101 joerg 878: echo "PKG_TOOLS_BIN= $prefix/sbin" >> ${TARGET_MKCONF}
879: echo "PKGMANDIR= $pkgmandir" >> ${TARGET_MKCONF}
880: echo "" >> ${TARGET_MKCONF}
881:
882: BOOTSTRAP_MKCONF=${wrkdir}/mk.conf
1.108 schwarz 883: cp ${TARGET_MKCONF} ${BOOTSTRAP_MKCONF}
1.101 joerg 884:
885: # sbin is used by pkg_install, share/mk by bootstrap-mk-files
886: mkdir_p $wrkdir/sbin $wrkdir/share/mk
887: mkdir_p_early ${wrkdir}
888:
1.1 grant 889: if [ "$need_bsd_install" = "yes" ]; then
890: BSTRAP_ENV="INSTALL='$prefix/bin/install-sh -c' $BSTRAP_ENV"
1.101 joerg 891: echo "TOOLS_PLATFORM.install?= $prefix/bin/install-sh" >> ${TARGET_MKCONF}
892: echo "TOOLS_PLATFORM.install?= $wrkdir/bin/install-sh" >> ${BOOTSTRAP_MKCONF}
1.1 grant 893: fi
894:
895: if [ "$need_fixed_strip" = "yes" ] ; then
896: echo_msg "Installing fixed strip script"
1.101 joerg 897: run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/strip-sh $wrkdir/bin/strip"
898: echo "TOOLS_PLATFORM.strip?= $prefix/bin/strip" >> ${TARGET_MKCONF}
899: echo "TOOLS_PLATFORM.strip?= $wrkdir/bin/strip" >> ${BOOTSTRAP_MKCONF}
1.67 jlam 900: need_extras=yes
1.1 grant 901: fi
902:
1.81 schwarz 903: if [ "$need_mkdir" = "yes" -a -z "$MKDIR" ]; then
1.13 heinz 904: echo_msg "Installing fixed mkdir script \"mkdir-sh\""
1.101 joerg 905: run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/mkdir-sh $wrkdir/bin/mkdir-sh"
906: echo "TOOLS_PLATFORM.mkdir?= $prefix/bin/mkdir-sh -p" >> ${TARGET_MKCONF}
907: echo "TOOLS_PLATFORM.mkdir?= $wrkdir/bin/mkdir-sh -p" >> ${BOOTSTRAP_MKCONF}
1.67 jlam 908: need_extras=yes
1.12 heinz 909: fi
910:
1.99 tnn 911: if [ "$need_xargs" = "yes" ]; then
912: echo_msg "Installing fixed xargs script"
1.105 tnn 913: run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/xargs-sh $wrkdir/bin/xargs"
1.101 joerg 914: echo "TOOLS_PLATFORM.xargs?= $prefix/bin/xargs" >> ${TARGET_MKCONF}
915: echo "TOOLS_PLATFORM.xargs?= $wrkdir/bin/xargs" >> ${BOOTSTRAP_MKCONF}
1.99 tnn 916: need_extras=yes
917: fi
918:
1.101 joerg 919: echo_msg "Bootstrapping mk-files"
920: run_cmd "(cd ${pkgsrcdir}/pkgtools/bootstrap-mk-files/files && env CP=${cpprog} \
921: OPSYS=${opsys} MK_DST=${wrkdir}/share/mk ROOT_GROUP=${root_group} \
922: ROOT_USER=${root_user} SED=${sedprog} SYSCONFDIR=${sysconfdir} \
923: $shprog ./bootstrap.sh)"
924:
1.125 tnn 925: bootstrap_bmake() {
926: echo_msg "Bootstrapping bmake"
927: copy_src $pkgsrcdir/devel/bmake/files bmake
1.136 joerg 928: 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 929: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/bmake/$opsys/bmake $wrkdir/bin/bmake"
930: }
931: bootstrap_bmake
1.1 grant 932:
1.101 joerg 933: bmake="$wrkdir/bin/bmake $make_quiet_flags"
1.53 jlam 934:
1.136 joerg 935: # build libnbcompat
936: echo_msg "Building libnbcompat"
937: copy_src $pkgsrcdir/pkgtools/libnbcompat/files libnbcompat
1.140 joerg 938: 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 939:
1.125 tnn 940: # bootstrap ksh if necessary
941: case "$need_ksh" in
942: yes) echo_msg "Bootstrapping ksh"
943: copy_src $pkgsrcdir/shells/pdksh/files ksh
944: test -n "$CC" || CC=gcc # default to gcc if no compiler is specified
945: run_cmd "(cd $wrkdir/ksh && env $BSTRAP_ENV $shprog ./configure $configure_quiet_flags --prefix=$prefix --mandir=$mandir --sysconfdir=$sysconfdir && $bmake)"
946: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/ksh/ksh $wrkdir/bin/pdksh"
947: echo "TOOLS_PLATFORM.sh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF}
948: echo "TOOLS_PLATFORM.sh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF}
1.128 sketch 949: echo "TOOLS_PLATFORM.ksh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF}
950: echo "TOOLS_PLATFORM.ksh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF}
1.125 tnn 951: # Now rebootstrap bmake for ksh
952: echo_msg "Rebootstrapping bmake for ksh"
953: bmakexargs="$bmakexargs --with-defshell=$wrkdir/bin/pdksh"
954: bootstrap_bmake
955: ;;
956: esac
957:
1.57 jlam 958: # bootstrap awk if necessary
959: case "$need_awk" in
1.101 joerg 960: yes) echo_msg "Bootstrapping awk"
1.78 rillig 961: copy_src $pkgsrcdir/lang/nawk/files awk
1.71 jlam 962: test -n "$CC" || CC=gcc # default to gcc if no compiler is specified
1.80 schwarz 963: run_cmd "(cd $wrkdir/awk && $bmake -f Makefile CC=\"${CC}\" CFLAGS=\"${CFLAGS}\")"
1.101 joerg 964: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/awk/a.out $wrkdir/bin/nawk"
965: echo "TOOLS_PLATFORM.awk?= $prefix/bin/nawk" >> ${TARGET_MKCONF}
966: echo "TOOLS_PLATFORM.awk?= $wrkdir/bin/nawk" >> ${BOOTSTRAP_MKCONF}
1.57 jlam 967: ;;
968: esac
969:
970: # bootstrap sed if necessary
971: case "$need_sed" in
1.101 joerg 972: yes) echo_msg "Bootstrapping sed"
1.78 rillig 973: copy_src $pkgsrcdir/textproc/nbsed/files sed
1.154 obache 974: 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 975: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/sed/sed $wrkdir/bin/sed"
976: echo "TOOLS_PLATFORM.sed?= $prefix/bin/nbsed" >> ${TARGET_MKCONF}
977: echo "TOOLS_PLATFORM.sed?= $wrkdir/bin/sed" >> ${BOOTSTRAP_MKCONF}
1.57 jlam 978: ;;
979: esac
980:
1.1 grant 981: # bootstrap pkg_install
1.101 joerg 982: echo_msg "Bootstrapping pkgtools"
1.78 rillig 983: copy_src $pkgsrcdir/pkgtools/pkg_install/files pkg_install
1.101 joerg 984: run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV \
985: CPPFLAGS='$CPPFLAGS -I../libnbcompat -I../../libnbcompat' \
986: LDFLAGS='$LDFLAGS -L../libnbcompat -L../../libnbcompat' \
1.154 obache 987: LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C \
1.104 joerg 988: --enable-bootstrap --prefix=$prefix --sysconfdir=$sysconfdir \
989: --with-pkgdbdir=$pkgdbdir --mandir=$mandir $pkg_install_args && $bmake)"
1.101 joerg 990: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/admin/pkg_admin $wrkdir/sbin/pkg_admin"
991: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/create/pkg_create $wrkdir/sbin/pkg_create"
992: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/info/pkg_info $wrkdir/sbin/pkg_info"
993: echo "PKG_ADMIN_CMD?= $wrkdir/sbin/pkg_admin" >> ${BOOTSTRAP_MKCONF}
994: echo "PKG_CREATE_CMD?= $wrkdir/sbin/pkg_create" >> ${BOOTSTRAP_MKCONF}
995: echo "PKG_INFO_CMD?= $wrkdir/sbin/pkg_info" >> ${BOOTSTRAP_MKCONF}
996:
1.103 joerg 997: if [ -n "${fetch_cmd}" ]; then
998: echo "FETCH_CMD= $fetch_cmd" >> ${TARGET_MKCONF}
999: fi
1.101 joerg 1000:
1001: MAKECONF=$wrkdir/mk.conf
1002: export MAKECONF
1.1 grant 1003:
1.107 rillig 1004: if [ "$bootstrap_sh_set" = "set" ]; then
1005: echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${TARGET_MKCONF}
1006: echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${BOOTSTRAP_MKCONF}
1.90 rillig 1007: fi
1008:
1.81 schwarz 1009: # preserve compiler and tool environment variables settings
1.101 joerg 1010: if test -n "$CP"; then
1011: echo "TOOLS_PLATFORM.cp?= $CP" >> ${TARGET_MKCONF}
1012: echo "TOOLS_PLATFORM.cp?= $CP" >> ${BOOTSTRAP_MKCONF}
1013: fi
1014: if test -n "$GREP"; then
1015: echo "TOOLS_PLATFORM.grep?= $GREP" >> ${TARGET_MKCONF}
1016: echo "TOOLS_PLATFORM.grep?= $GREP" >> ${BOOTSTRAP_MKCONF}
1017: fi
1018: if test -n "$ID"; then
1019: echo "TOOLS_PLATFORM.id?= $ID" >> ${TARGET_MKCONF}
1020: echo "TOOLS_PLATFORM.id?= $ID" >> ${BOOTSTRAP_MKCONF}
1021: fi
1022: if test -n "$MKDIR"; then
1023: echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${TARGET_MKCONF}
1024: echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${BOOTSTRAP_MKCONF}
1025: fi
1026: if test -n "$TEST"; then
1027: echo "TOOLS_PLATFORM.test?= $TEST" >> ${TARGET_MKCONF}
1028: echo "TOOLS_PLATFORM.test?= $TEST" >> ${BOOTSTRAP_MKCONF}
1029: fi
1030: if test -n "$TOUCH"; then
1031: echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${TARGET_MKCONF}
1032: echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${BOOTSTRAP_MKCONF}
1033: fi
1034: if test -n "$XARGS"; then
1035: echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${TARGET_MKCONF}
1036: echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${BOOTSTRAP_MKCONF}
1037: fi
1038: if test -n "$CFLAGS"; then
1039: echo "CFLAGS+= $CFLAGS" >> ${TARGET_MKCONF}
1040: echo "DBG= # prevent DBG from adding default optimizer flags" >> ${TARGET_MKCONF}
1041: echo "DBG= # prevent DBG from adding default optimizer flags" >> ${BOOTSTRAP_MKCONF}
1042: fi
1043: if test -n "$CPPFLAGS"; then
1044: echo "CPPFLAGS+= $CPPFLAGS" >> ${TARGET_MKCONF}
1045: fi
1046: if test -n "$LDFLAGS"; then
1047: echo "LDFLAGS+= $LDFLAGS" >> ${TARGET_MKCONF}
1048: fi
1.154 obache 1049: if test -n "$LIBS"; then
1050: echo "LIBS+= $LIBS" >> ${TARGET_MKCONF}
1051: fi
1.81 schwarz 1052:
1.1 grant 1053: # opsys specific fiddling
1054: opsys_finish
1055:
1.101 joerg 1056: echo "WRKOBJDIR= ${wrkdir}/wrk" >> ${BOOTSTRAP_MKCONF}
1057:
1058: echo "" >> ${TARGET_MKCONF}
1059: echo "" >> ${BOOTSTRAP_MKCONF}
1.102 joerg 1060: if test -n "${mk_fragment}"; then
1061: cat "${mk_fragment}" >> ${TARGET_MKCONF}
1062: echo "" >> ${TARGET_MKCONF}
1063: fi
1.101 joerg 1064: echo ".endif # end pkgsrc settings" >> ${TARGET_MKCONF}
1065: echo ".endif # end pkgsrc settings" >> ${BOOTSTRAP_MKCONF}
1.1 grant 1066:
1.61 jlam 1067: # register packages
1.85 rillig 1068: # usage: register_package <packagedirectory> [additional arguments]
1.101 joerg 1069: build_package() {
1070: run_cmd "(cd $pkgsrcdir/$1 && $bmake -DPKG_PRESERVE MAKECONF=${BOOTSTRAP_MKCONF} install)"
1.85 rillig 1071: }
1072:
1.132 joerg 1073: #
1074: # Please make sure that the following packages and
1075: # only the following packages set BOOTSTRAP_PKG=yes.
1076: #
1.101 joerg 1077: echo_msg "Installing packages"
1078: build_package "pkgtools/bootstrap-mk-files"
1.127 tnn 1079: case "$need_bsd_install" in
1080: yes) build_package "sysutils/install-sh";;
1081: esac
1.125 tnn 1082: case "$need_ksh" in
1083: yes) build_package "shells/pdksh";;
1084: esac
1.101 joerg 1085: build_package "devel/bmake"
1.61 jlam 1086: case "$need_awk" in
1.101 joerg 1087: yes) build_package "lang/nawk";;
1.61 jlam 1088: esac
1089: case "$need_sed" in
1.141 joerg 1090: yes) build_package "textproc/nbsed";;
1.67 jlam 1091: esac
1092: case "$need_extras" in
1.101 joerg 1093: yes) build_package "pkgtools/bootstrap-extras";;
1.61 jlam 1094: esac
1.101 joerg 1095: build_package "pkgtools/pkg_install"
1.61 jlam 1096:
1.89 rillig 1097: etc_mk_conf="$sysconfdir/mk.conf"
1098:
1099: # Install the example mk.conf so that it is used, but only if it doesn't
1.101 joerg 1100: # exist yet. This can happen with non-default sysconfdir settings.
1.89 rillig 1101: mkdir_p "$sysconfdir"
1102: if [ ! -f "$etc_mk_conf" ]; then
1.101 joerg 1103: cp "$TARGET_MKCONF" "$etc_mk_conf"
1104: TARGET_MKCONF="$etc_mk_conf"
1.89 rillig 1105: fi
1106:
1.85 rillig 1107: hline="==========================================================================="
1108: echo ""
1109: echo "$hline"
1.1 grant 1110: echo ""
1.9 grant 1111: echo "Please remember to add $prefix/bin to your PATH environment variable"
1.77 jlam 1112: echo "and $mandir to your MANPATH environment variable, if necessary."
1.9 grant 1113: echo ""
1.85 rillig 1114: echo "An example mk.conf file with the settings you provided to \"bootstrap\""
1115: echo "has been created for you. It can be found in:"
1116: echo ""
1.101 joerg 1117: echo " ${TARGET_MKCONF}"
1.85 rillig 1118: echo ""
1.101 joerg 1119: if [ "$TARGET_MKCONF" != "$etc_mk_conf" ]; then
1.89 rillig 1120: echo "Please copy it to $etc_mk_conf to use it."
1121: echo ""
1122: fi
1.1 grant 1123: echo "You can find extensive documentation of the NetBSD Packages Collection"
1.92 wiz 1124: echo "in $pkgsrcdir/doc/pkgsrc.txt."
1.1 grant 1125: echo ""
1126: echo "Hopefully everything is now complete."
1127: echo "Thank you"
1.85 rillig 1128: echo ""
1129: echo "$hline"
1130: echo ""
1.1 grant 1131:
1.118 joerg 1132: [ ! -z "${binary_kit}" ] && mkbinarykit_tar
1133: [ ! -z "${binary_gzip_kit}" ] && mkbinarykit_tgz
1134: [ ! -z "${binary_macpkg}" ] && mkbinarykit_macpkg
1135:
1.1 grant 1136: echo_msg "bootstrap started: $build_start"
1137: echo_msg "bootstrap ended: `date`"
1138:
1139: exit 0
CVSweb <webmaster@jp.NetBSD.org>