Annotation of pkgsrc/bootstrap/bootstrap, Revision 1.104
1.1 grant 1: #! /bin/sh
2:
1.104 ! joerg 3: # $NetBSD: bootstrap,v 1.103 2007/07/31 14:31:27 joerg 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
40: # tools: CP, GREP, ID, MKDIR, TEST, TOUCH, XARGS
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
51: ignoreusercheck=no
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.102 joerg 73: [ --mk-fragment <mk.conf> ]
1.76 jlam 74: [ --full ]
1.86 rillig 75: [ --quiet ]
1.1 grant 76: [ --help ]'
77:
78: # this replicates some of the logic in bsd.prefs.mk. until
79: # bootstrap-pkgsrc is merged into pkgsrc, we need to determine the
80: # right value for OPSYS and MACHINE_ARCH.
81:
1.95 tnn 82: # strip / for BSD/OS, strip - for HP-UX
83: opsys=`uname -s | tr -d /-`
1.1 grant 84:
85: die()
86: {
87: echo >&2 "$@"
88: exit 1
89: }
90:
91: echo_msg()
92: {
93: echo "===> $@"
94: }
95:
1.33 jschauma 96: # see if we're using gcc. If so, set $compiler_is_gnu to '1'.
97: get_compiler()
98: {
99: testcc="${CC}"
100: # normally, we'd just use 'cc', but certain configure tools look
101: # for gcc specifically, so we have to see if that comes first
102: if [ -z "${testcc}" ]; then
103: save_IFS="${IFS}"
104: IFS=':'
105: for dir in ${PATH}; do
106: test -z "$dir" && dir=.
107: if [ -x "$dir/gcc" ]; then
108: testcc="$dir/gcc"
109: break
110: fi
111: done
112: IFS="${save_IFS}"
113: fi
114:
115: cat >${wrkdir}/$$.c <<EOF
116: #ifdef __GNUC__
117: indeed
118: #endif
119: EOF
120: compiler_is_gnu=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed`
121: rm -f ${wrkdir}/$$.c
122:
123: }
1.1 grant 124: get_abi()
125: {
126: abi_opsys=$@
127: case "$abi_opsys" in
128: IRIX)
1.48 schwarz 129: if [ `uname -r` -ge 6 ]; then
1.1 grant 130: abi=`sed -e 's/.*\(abi=\)\([on]*[36][24]\).*/\2/' /etc/compiler.defaults`
131: isa=`sed -e 's/.*\(isa=mips\)\([1234]\).*/\2/' /etc/compiler.defaults`
132: case "$abi" in
133: o32)
134: imakeopts="-DBuildO32 -DSgiISAo32=$isa"
135: abi=""
136: ;;
137: n32) imakeopts="-DBuildN32 -DSgiISA32=$isa"
138: abi="32"
139: ;;
140: 64 | n64)
141: imakeopts="-DBuild64bit -DSgiISA64=$isa"
142: abi="64"
143: ;;
144: esac
1.48 schwarz 145: else # IRIX before 6
146: abi=32
147: fi
1.1 grant 148: ;;
149: esac
150: }
151:
1.31 grant 152: get_machine_arch_aix()
153: {
154: _cpuid=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
155: if /usr/sbin/lsattr -El $_cpuid | grep ' POWER' >/dev/null 2>&1; then
156: echo rs6000
157: else
158: echo powerpc
159: fi
160: }
161:
1.1 grant 162: check_prog()
163: {
164: _var="$1"; _name="$2"
165:
166: eval _tmp=\"\$$_var\"
167: if [ "x$_tmp" != "x" ]; then
168: # Variable is already set (by the user, for example)
169: return 0
170: fi
171:
172: for _d in `echo $PATH | tr ':' ' '`; do
173: if [ -x "$_d/$_name" ]; then
174: # Program found
175: eval $_var=\""$_d/$_name"\"
176: return 1
177: fi
178: done
179:
180: die "$_name not found in path."
181: }
182:
183: opsys_finish()
184: {
185: case "$opsys" in
186: IRIX)
1.48 schwarz 187: if [ ! -z "$imakeopts" ]; then
1.101 joerg 188: echo "IMAKEOPTS+= $imakeopts" >> ${TARGET_MKCONF}
1.1 grant 189: fi
1.48 schwarz 190: if [ `uname -r` -lt 6 ]; then
191: echo_msg "Installing fake ldd script"
1.78 rillig 192: run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/fakeldd $prefix/sbin"
1.67 jlam 193: need_extras=yes
1.101 joerg 194: echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF}
1.1 grant 195: fi
196: ;;
197: esac
198: }
199:
200: is_root()
201: {
1.48 schwarz 202: if [ `uname -s` = "IRIX" ]; then
1.81 schwarz 203: if [ `uname -r` -lt 6 -a -z "$ID" ]; then
1.48 schwarz 204: # older version of IRIX have an id command with limited features
205: if [ "`$idprog`" != "uid=0(root) gid=0(sys)" ]; then
206: return 0
207: fi
208: return 1
209: fi
210: fi
1.1 grant 211: if [ `$idprog -u` != 0 ]; then
212: return 0
213: fi
214: return 1
215: }
216:
217: # run a command, abort if it fails
218: run_cmd()
219: {
220: echo_msg "running: $@"
221: eval "$@"
222: ret=$?
223: if [ $ret -ne 0 ]; then
224: echo_msg "exited with status $ret"
225: die "aborted."
226: fi
227: }
228:
1.4 sketch 229: # Some versions of mkdir (notably SunOS) bail out too easily, so use the
230: # install-sh wrapper instead.
231: mkdir_p()
232: {
1.7 tv 233: for dir in $@; do
1.67 jlam 234: run_cmd "$install_sh -d -o $user -g $group $dir"
1.7 tv 235: done
1.4 sketch 236: }
237:
1.101 joerg 238: mkdir_p_early()
239: {
240: if [ ! -d "$1" ]; then
241: if mkdir -p "$1"; then
242: :
243: else
244: echo_msg "mkdir $1 exited with status $?"
245: die "aborted."
246: fi
247: fi
248: }
249:
1.2 grant 250: copy_src()
251: {
252: _src="$1"; _dst="$2"
253: if [ ! -d $wrkdir/$_dst ]; then
1.4 sketch 254: mkdir_p $wrkdir/$_dst
1.2 grant 255: fi
1.48 schwarz 256: $cpprog -r $_src/* $wrkdir/$_dst
1.2 grant 257: }
258:
1.38 rillig 259: get_optarg()
260: {
261: expr "x$1" : "x[^=]*=\\(.*\\)"
262: }
263:
1.1 grant 264: build_start=`date`
265: echo_msg "bootstrap command: $0 $@"
266: echo_msg "bootstrap started: $build_start"
267:
1.39 jmmv 268: # ensure system locations are empty; we will set them later when we know
269: # whether they will be system wide or user specific
270: prefix=
271: pkgdbdir=
1.55 jlam 272: pkgmandir=
1.39 jmmv 273: sysconfdir=
274: varbase=
1.79 rillig 275:
276: full=no
277: compiler=""
1.85 rillig 278: quiet=no
1.102 joerg 279: mk_fragment=
1.39 jmmv 280:
1.33 jschauma 281: while [ $# -gt 0 ]; do
282: case $1 in
1.38 rillig 283: --workdir=*) wrkdir=`get_optarg "$1"` ;;
1.33 jschauma 284: --workdir) wrkdir="$2"; shift ;;
1.41 reed 285: --prefix=*) prefix=`get_optarg "$1"` ;;
286: --prefix) prefix="$2"; shift ;;
1.38 rillig 287: --pkgdbdir=*) pkgdbdir=`get_optarg "$1"` ;;
1.33 jschauma 288: --pkgdbdir) pkgdbdir="$2"; shift ;;
1.55 jlam 289: --pkgmandir=*) pkgmandir=`get_optarg "$1"` ;;
290: --pkgmandir) pkgmandir="$2"; shift ;;
1.38 rillig 291: --sysconfdir=*) sysconfdir=`get_optarg "$1"` ;;
1.33 jschauma 292: --sysconfdir) sysconfdir="$2"; shift ;;
1.40 jmmv 293: --varbase=*) varbase=`get_optarg "$1"` ;;
1.39 jmmv 294: --varbase) varbase="$2"; shift ;;
1.49 joerg 295: --fetch-cmd=*) fetch_cmd=`get_optarg "$1"` ;;
296: --fetch-cmd) fetch_cmd="$a"; shift ;;
1.79 rillig 297: --compiler=*) compiler=`get_optarg "$1"` ;;
298: --compiler) compiler="$2"; shift ;;
1.33 jschauma 299: --ignore-case-check) ignorecasecheck=yes ;;
1.86 rillig 300: --unprivileged | --ignore-user-check) ignoreusercheck=yes ;;
1.33 jschauma 301: --preserve-path) preserve_path=yes ;;
1.102 joerg 302: --mk-fragment=*)
303: mk_fragment=`get_optarg "$1"` ;;
304: --mk-fragment)
305: mk_fragment="$2"; shift ;;
1.76 jlam 306: --full) full=yes ;;
1.85 rillig 307: --quiet) quiet=yes ;;
1.33 jschauma 308: --help) echo "$usage"; exit ;;
309: -h) echo "$usage"; exit ;;
310: --*) echo "$usage"; exit 1 ;;
311: esac
312: shift
313: done
314:
1.39 jmmv 315: # set defaults for system locations if not already set by the user
1.67 jlam 316: wrkobjdir=${wrkdir}/pkgsrc
1.39 jmmv 317: if [ "$ignoreusercheck" = "yes" ]; then
318: [ -z "$prefix" ] && prefix=${HOME}/pkg
319: [ -z "$pkgdbdir" ] && pkgdbdir=${prefix}/var/db/pkg
320: [ -z "$varbase" ] && varbase=${prefix}/var
321: else
322: [ -z "$prefix" ] && prefix=/usr/pkg
323: [ -z "$pkgdbdir" ] && pkgdbdir=/var/db/pkg
324: [ -z "$varbase" ] && varbase=/var
325: fi
1.55 jlam 326: if [ "$prefix" = "/usr" ]; then
327: [ -z "$pkgmandir" ] && pkgmandir=share/man
328: else
329: [ -z "$pkgmandir" ] && pkgmandir=man
330: fi
331: mandir=${prefix}/${pkgmandir}
332: [ -z "$sysconfdir" ] && sysconfdir=${prefix}/etc
1.39 jmmv 333:
1.33 jschauma 334: if [ "x$preserve_path" != "xyes" ]; then
335: PATH="$PATH:/sbin:/usr/sbin"
1.16 danw 336: fi
337:
1.1 grant 338: overpath=""
1.3 tv 339: root_user=root
1.48 schwarz 340: bmakexenv=
341: bmakexargs=
1.80 schwarz 342: tnftpxflags=
1.67 jlam 343: need_extras=no
1.1 grant 344: case "$opsys" in
345: Darwin)
346: root_group=wheel
347: need_pax=yes
348: need_bsd_install=no
1.62 jlam 349: need_awk=no
350: need_sed=no
1.1 grant 351: set_opsys=no
352: machine_arch=`uname -p`
353: ;;
1.23 wiz 354: DragonFly)
355: root_group=wheel
1.29 agc 356: need_pax=yes
1.23 wiz 357: need_bsd_install=no
1.57 jlam 358: need_awk=no
1.23 wiz 359: need_sed=no
360: set_opsys=no
1.26 agc 361: check_prog tarprog tar
1.23 wiz 362: machine_arch=`uname -p`
1.49 joerg 363: case `uname -r` in
1.50 joerg 364: 1.1[0-9]*)
365: [ -z "$fetch_cmd" ] && fetch_cmd="/usr/bin/ftp"
366: ;;
367: 1.0* | 1.1 | 1.2.* | 1.3.*)
1.49 joerg 368: ;;
369: *)
370: [ -z "$fetch_cmd" ] && fetch_cmd="/usr/bin/ftp"
371: ;;
372: esac
1.23 wiz 373: ;;
1.1 grant 374: FreeBSD)
375: root_group=wheel
376: need_pax=yes
377: need_bsd_install=no
1.57 jlam 378: need_awk=no
1.1 grant 379: need_sed=no
380: set_opsys=no
381: machine_arch=`uname -p`
382: ;;
1.95 tnn 383: HPUX)
384: root_group=sys
1.1 grant 385: need_pax=yes
386: need_bsd_install=yes
1.57 jlam 387: need_awk=yes
1.1 grant 388: need_sed=yes
389: set_opsys=no
1.96 tnn 390: machine_arch=`uname -m | sed 's/^9000.*$/hppa/'`
1.1 grant 391: ;;
392: IRIX*)
393: if [ -d "/usr/freeware/bin" ]; then
394: overpath="/usr/freeware/bin:$overpath"
395: fi
396: if [ -d "/usr/bsd/bin" ]; then
397: overpath="/usr/bsd/bin:$overpath"
398: fi
399: root_group=sys
400: need_bsd_install=yes
401: need_pax=yes
402: get_abi "IRIX"
403: opsys=IRIX
1.57 jlam 404: need_awk=yes
1.1 grant 405: need_sed=yes
406: set_opsys=yes
1.27 jschauma 407: machine_arch=mipseb
1.47 jschauma 408: bmakexargs="MACHINE_ARCH=$machine_arch"
409: bmakexenv="MAKE=pmake"
1.33 jschauma 410: check_compiler=yes
1.48 schwarz 411: if [ `uname -r` -lt 6 ]; then
1.80 schwarz 412: # IRIX 5's mkdir bails out with an error when trying to create with the -p
413: # option an already existing directory
414: need_mkdir=yes
1.48 schwarz 415: # IRIX 5 does not have uint32_t typedef'd in sys/types.h
1.80 schwarz 416: tnftpxflags="-DUINT32_T=int"
1.81 schwarz 417: # IRIX 5 is lacking fnmatch.h needed to build mtree
1.48 schwarz 418: needfnmatchh=yes
419: fi
1.1 grant 420: ;;
421: Linux)
422: if [ -f /etc/debian_version ]; then
423: DEBIAN=yes
424: fi
425: root_group=root
426: need_pax=yes
427: need_bsd_install=no
1.57 jlam 428: need_awk=no
1.1 grant 429: need_sed=no
430: set_opsys=no
431: machine_arch=`uname -m | sed -e 's/i.86/i386/'`
432: ;;
433: NetBSD)
434: root_group=wheel
435: need_pax=no
436: need_bsd_install=no
1.57 jlam 437: need_awk=no
1.1 grant 438: need_sed=no
439: set_opsys=no
440: check_prog paxprog pax
441: check_prog tarprog tar
442: machine_arch=`uname -p`
443: ;;
444: OpenBSD)
445: root_group=wheel
446: need_pax=yes
447: need_bsd_install=no
1.57 jlam 448: need_awk=no
1.1 grant 449: need_sed=no
450: set_opsys=no
1.8 grant 451: machine_arch=`uname -m`
1.1 grant 452: ;;
453: SunOS)
454: if [ -d "/usr/xpg4/bin" ]; then
455: overpath="/usr/xpg4/bin:$overpath"
456: fi
457: root_group=root
458: need_pax=yes
459: need_bsd_install=no
1.57 jlam 460: need_awk=yes
1.1 grant 461: need_sed=yes
462: set_opsys=no
463: whoamiprog=/usr/ucb/whoami
464: machine_arch=`uname -p | sed -e 's/i86pc/i386/'`
1.79 rillig 465: check_compiler=yes
1.1 grant 466: ;;
467: AIX)
468: root_group=system
469: need_pax=yes
470: need_bsd_install=yes
1.57 jlam 471: need_awk=yes
1.1 grant 472: need_sed=yes
473: need_fixed_strip=yes
474: set_opsys=no
1.31 grant 475: machine_arch=`get_machine_arch_aix`
1.1 grant 476: ;;
477: Interix)
1.3 tv 478: is_root () {
1.17 tv 479: if id -G | grep -q 131616; then
1.3 tv 480: return 1
481: fi
482: return 0
483: }
1.14 tv 484: mkdir_p () {
485: mkdir -p "$@" # allows umask to take effect
486: }
1.15 tv 487: default_install_mode=0775
1.17 tv 488: root_user=`id -u`
489: root_group=131616
1.5 tv 490: need_pax=yes
1.1 grant 491: need_bsd_install=yes
1.57 jlam 492: need_awk=yes
1.1 grant 493: need_sed=yes
494: set_opsys=no
1.99 tnn 495: need_xargs=yes
1.10 tv 496: # only used for unprivileged builds
497: groupsprog="id -gn"
498: # for bootstrap only; pkgsrc uses CPPFLAGS
1.1 grant 499: CC="gcc -D_ALL_SOURCE"; export CC
1.17 tv 500: ac_cv_header_poll_h=no; export ac_cv_header_poll_h
501: ac_cv_func_poll=no; export ac_cv_func_poll
1.1 grant 502: ;;
1.12 heinz 503: UnixWare)
504: root_group=sys
505: need_pax=yes
506: need_bsd_install=no
507: BSTRAP_ENV="INSTALL=/usr/ucb/install $BSTRAP_ENV"
508: need_mkdir=yes
1.57 jlam 509: need_awk=yes
1.12 heinz 510: need_sed=yes
511: whoamiprog=/usr/ucb/whoami
512: set_opsys=no
513: CC="gcc -DUNIXWARE"; export CC
514: ;;
1.24 grant 515: OSF1)
516: root_group=system
517: need_pax=yes
518: need_bsd_install=yes
1.57 jlam 519: need_awk=yes
1.24 grant 520: need_sed=yes
521: set_opsys=no
522: ;;
1.1 grant 523: *)
524: echo "This platform ($opsys) is untried - good luck, and thanks for using pkgsrc"
525: root_group=wheel
526: need_pax=yes
527: need_bsd_install=yes
1.57 jlam 528: need_awk=yes
1.1 grant 529: need_sed=yes
530: set_opsys=no
531: ;;
532: esac
533:
1.101 joerg 534: if [ -z "$fetch_cmd" ]; then
535: need_ftp=yes
536: else
537: need_ftp=no
538: fi
539:
1.76 jlam 540: # If "--full" is specified, then install all of the platform-independent
541: # bootstrap software.
542: #
543: case "$full" in
544: yes)
545: need_pax=yes
546: need_bsd_install=yes
547: need_awk=yes
548: need_sed=yes
1.101 joerg 549: need_ftp=yes
1.76 jlam 550: ;;
551: esac
552:
1.85 rillig 553: case "$quiet" in
554: yes)
555: configure_quiet_flags="--quiet"
556: make_quiet_flags="-s"
557: ;;
558: no)
559: configure_quiet_flags=""
560: make_quiet_flags=""
561: esac
562:
1.1 grant 563: # export OPSYS and MACHINE_ARCH for pkg_install. we only set
564: # MACHINE_ARCH on platforms where we override bmake's value.
565: OPSYS=${opsys}
566: export OPSYS
567: if [ "${machine_arch}" != "" ]; then
568: MACHINE_ARCH=${machine_arch}
569: export MACHINE_ARCH
570: fi
571:
1.33 jschauma 572: if [ "x$preserve_path" != "xyes" ]; then
1.1 grant 573: PATH="$overpath:$PATH"
574: fi
575:
576: check_prog awkprog awk
1.15 tv 577: check_prog chmodprog chmod
1.81 schwarz 578: if [ -n "$CP" ]; then
579: cpprog="$CP"
580: else
581: check_prog cpprog cp
582: fi
583: if [ -n "$ID" ]; then
584: idprog="$ID"
585: else
586: check_prog idprog id
587: fi
1.1 grant 588: check_prog groupsprog groups
1.48 schwarz 589: check_prog lnprog ln
1.1 grant 590: check_prog lsprog ls
591: check_prog rmdirprog rmdir
592: check_prog sedprog sed
593: check_prog shprog sh
594: check_prog whoamiprog whoami
595:
1.101 joerg 596: mkdir_p_early ${wrkdir}
1.9 grant 597: if touch ${wrkdir}/.writeable; then
598: :
599: else
600: echo "\"${wrkdir}\" is not writeable. Try $0 -h.";
601: exit 1
602: fi
603: echo "Working directory is: ${wrkdir}"
604:
1.79 rillig 605: if [ "$compiler" = "" ] && [ x"$check_compiler" = x"yes" ]; then
1.33 jschauma 606: get_compiler
607: if [ $compiler_is_gnu -gt 0 ]; then
608: compiler="gcc"
609: else
610: case "$opsys" in
611: IRIX)
1.48 schwarz 612: if [ `uname -r` -ge 6 ]; then
613: compiler="mipspro"
614: else
615: compiler="ido"
616: fi
1.80 schwarz 617: test -n "$CC" || CC=cc
1.33 jschauma 618: ;;
1.79 rillig 619: SunOS) compiler="sunpro"
1.80 schwarz 620: test -n "$CC" || CC=cc
1.79 rillig 621: ;;
1.33 jschauma 622: esac
623: fi
624: fi
625:
1.101 joerg 626: mkdir_p_early ${wrkdir}/bin
627:
1.67 jlam 628: # build install-sh
1.101 joerg 629: run_cmd "$sedprog -e 's|@DEFAULT_INSTALL_MODE@|'${default_install_mode-0755}'|' $pkgsrcdir/sysutils/install-sh/files/install-sh.in > $wrkdir/bin/install-sh"
630: run_cmd "$chmodprog +x $wrkdir/bin/install-sh"
631: install_sh="$shprog $wrkdir/bin/install-sh"
1.15 tv 632:
1.1 grant 633: is_root
634: if [ $? = 1 ]; then
1.3 tv 635: user=$root_user
1.1 grant 636: group=$root_group
637: else
638: if [ $ignoreusercheck = "no" ]; then
639: die "You must be root to install bootstrap-pkgsrc."
640: fi
641:
642: user=`$whoamiprog`
643: group=`$groupsprog | $awkprog '{print $1}'`
644: echo_msg "building as unprivileged user $user/$group"
645:
646: # force bmake install target to use $user and $group
647: echo "BINOWN=$user
648: BINGRP=$group
649: LIBOWN=$user
650: LIBGRP=$group
651: MANOWN=$user
1.9 grant 652: MANGRP=$group" > ${wrkdir}/Makefile.inc
1.1 grant 653: fi
654:
1.98 schmonz 655: # make sure we're using a case-sensitive file system
1.1 grant 656: if [ $ignorecasecheck = "no" ]; then
657: case "$opsys" in
1.6 tv 658: Darwin|Interix)
1.1 grant 659: echo_msg "Testing file system case sensitivity"
1.98 schmonz 660: for fs in "$prefix"; do
1.1 grant 661: testdir="pkgsrc-REQUIRES-case-SENSITIVE-filesystem"
662: testdir_mangled="PKGSRC-requires-CASE-sensitive-FILESYSTEM"
1.4 sketch 663: mkdir_p "$fs/$testdir" || die "can't verify filesystem ($fs) case-sensitivity"
1.1 grant 664: if [ -d "$fs/$testdir_mangled" ]; then
665: $rmdirprog "$fs/$testdir"
1.6 tv 666: die "\"$fs\" needs to be on a case-sensitive filesystem (see README.$opsys)"
1.1 grant 667: fi
668: $rmdirprog "$fs/$testdir"
669: done
670: ;;
671: esac
672: fi
673:
674: # export the proper environment
675: PATH=$prefix/bin:$prefix/sbin:${PATH}; export PATH
676: if [ -d /usr/ccs/bin -a -x /usr/ccs/bin/make ]; then
1.28 grant 677: PATH=${PATH}:/usr/ccs/bin; export PATH
1.1 grant 678: fi
679: PKG_DBDIR=$pkgdbdir; export PKG_DBDIR
680: LOCALBASE=$prefix; export LOCALBASE
1.39 jmmv 681: VARBASE=$varbase; export VARBASE
1.1 grant 682:
1.19 jlam 683: # build libnbcompat
684: echo_msg "Building libnbcompat"
1.78 rillig 685: copy_src $pkgsrcdir/pkgtools/libnbcompat/files libnbcompat
1.85 rillig 686: run_cmd "(cd $wrkdir/libnbcompat; $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --mandir=$mandir --sysconfdir=$sysconfdir && make $make_quiet_flags)"
1.19 jlam 687:
1.48 schwarz 688: if [ x"$needfnmatchh" = x"yes" ]; then
689: $lnprog -s nbcompat/fnmatch.h $wrkdir/libnbcompat/fnmatch.h
690: fi
691:
1.1 grant 692: # set up an example mk.conf file
1.101 joerg 693: TARGET_MKCONF=${wrkdir}/mk.conf.example
694: echo_msg "Creating default mk.conf. in ${wrkdir}"
695: echo "# Example ${sysconfdir}/mk.conf file produced by bootstrap-pkgsrc" > ${TARGET_MKCONF}
696: echo "# `date`" >> ${TARGET_MKCONF}
697: echo "" >> ${TARGET_MKCONF}
698: echo ".ifdef BSD_PKG_MK # begin pkgsrc settings" >> ${TARGET_MKCONF}
699: echo "" >> ${TARGET_MKCONF}
1.1 grant 700:
701: # IRIX64 needs to be set to IRIX, for example
702: if [ "$set_opsys" = "yes" ]; then
1.101 joerg 703: echo "OPSYS= $opsys" >> ${TARGET_MKCONF}
1.1 grant 704: fi
705:
706: if [ ! -z "$abi" ]; then
1.101 joerg 707: echo "ABI= $abi" >> ${TARGET_MKCONF}
1.1 grant 708: fi
1.79 rillig 709: if [ "$compiler" != "" ]; then
1.101 joerg 710: echo "PKGSRC_COMPILER= $compiler" >> ${TARGET_MKCONF}
1.33 jschauma 711: fi
1.1 grant 712:
1.39 jmmv 713: # enable unprivileged builds if not root
714: if [ "$ignoreusercheck" = "yes" ]; then
1.101 joerg 715: echo "UNPRIVILEGED= yes" >> ${TARGET_MKCONF}
1.39 jmmv 716: fi
717:
1.1 grant 718: # save environment in example mk.conf
1.101 joerg 719: echo "PKG_DBDIR= $pkgdbdir" >> ${TARGET_MKCONF}
720: echo "LOCALBASE= $prefix" >> ${TARGET_MKCONF}
721: echo "VARBASE= $varbase" >> ${TARGET_MKCONF}
1.11 jmmv 722: if [ "${sysconfdir}" != "${prefix}/etc" ]; then
1.101 joerg 723: echo "PKG_SYSCONFBASE= $sysconfdir" >> ${TARGET_MKCONF}
1.11 jmmv 724: fi
1.101 joerg 725: echo "PKG_TOOLS_BIN= $prefix/sbin" >> ${TARGET_MKCONF}
726: echo "PKGMANDIR= $pkgmandir" >> ${TARGET_MKCONF}
727: echo "" >> ${TARGET_MKCONF}
728:
729: cp ${TARGET_MKCONF} $wrkdir/mk.conf
730: BOOTSTRAP_MKCONF=${wrkdir}/mk.conf
731:
732: # sbin is used by pkg_install, share/mk by bootstrap-mk-files
733: mkdir_p $wrkdir/sbin $wrkdir/share/mk
734: mkdir_p_early ${wrkdir}
735:
1.1 grant 736: if [ "$need_bsd_install" = "yes" ]; then
737: BSTRAP_ENV="INSTALL='$prefix/bin/install-sh -c' $BSTRAP_ENV"
1.101 joerg 738: echo "TOOLS_PLATFORM.install?= $prefix/bin/install-sh" >> ${TARGET_MKCONF}
739: echo "TOOLS_PLATFORM.install?= $wrkdir/bin/install-sh" >> ${BOOTSTRAP_MKCONF}
1.1 grant 740: fi
741:
742: if [ "$need_fixed_strip" = "yes" ] ; then
743: echo_msg "Installing fixed strip script"
1.101 joerg 744: run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/strip-sh $wrkdir/bin/strip"
745: echo "TOOLS_PLATFORM.strip?= $prefix/bin/strip" >> ${TARGET_MKCONF}
746: echo "TOOLS_PLATFORM.strip?= $wrkdir/bin/strip" >> ${BOOTSTRAP_MKCONF}
1.67 jlam 747: need_extras=yes
1.1 grant 748: fi
749:
1.81 schwarz 750: if [ "$need_mkdir" = "yes" -a -z "$MKDIR" ]; then
1.13 heinz 751: echo_msg "Installing fixed mkdir script \"mkdir-sh\""
1.101 joerg 752: run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/mkdir-sh $wrkdir/bin/mkdir-sh"
753: echo "TOOLS_PLATFORM.mkdir?= $prefix/bin/mkdir-sh -p" >> ${TARGET_MKCONF}
754: echo "TOOLS_PLATFORM.mkdir?= $wrkdir/bin/mkdir-sh -p" >> ${BOOTSTRAP_MKCONF}
1.67 jlam 755: need_extras=yes
1.12 heinz 756: fi
757:
1.99 tnn 758: if [ "$need_xargs" = "yes" ]; then
759: echo_msg "Installing fixed xargs script"
760: run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/xargs-sh $prefix/bin/xargs"
1.101 joerg 761: echo "TOOLS_PLATFORM.xargs?= $prefix/bin/xargs" >> ${TARGET_MKCONF}
762: echo "TOOLS_PLATFORM.xargs?= $wrkdir/bin/xargs" >> ${BOOTSTRAP_MKCONF}
1.99 tnn 763: need_extras=yes
764: fi
765:
1.101 joerg 766: echo_msg "Bootstrapping mk-files"
767: run_cmd "(cd ${pkgsrcdir}/pkgtools/bootstrap-mk-files/files && env CP=${cpprog} \
768: OPSYS=${opsys} MK_DST=${wrkdir}/share/mk ROOT_GROUP=${root_group} \
769: ROOT_USER=${root_user} SED=${sedprog} SYSCONFDIR=${sysconfdir} \
770: $shprog ./bootstrap.sh)"
771:
772: echo_msg "Bootstrapping bmake"
1.78 rillig 773: copy_src $pkgsrcdir/devel/bmake/files bmake
1.101 joerg 774: run_cmd "(cd $wrkdir/bmake && env CPPFLAGS='$CPPFLAGS -I../../libnbcompat' LDFLAGS='$LDFLAGS -L../../libnbcompat' LIBS='-lnbcompat' $bmakexenv $shprog ./boot-strap $configure_quiet_flags -q -o $opsys --prefix=$wrkdir --sysconfdir=$wrkdir --mksrc none --with-default-sys-path="$wrkdir/share/mk" $bmakexargs)"
775: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/bmake/$opsys/bmake $wrkdir/bin/bmake"
1.1 grant 776:
1.101 joerg 777: bmake="$wrkdir/bin/bmake $make_quiet_flags"
1.53 jlam 778:
1.57 jlam 779: # bootstrap awk if necessary
780: case "$need_awk" in
1.101 joerg 781: yes) echo_msg "Bootstrapping awk"
1.78 rillig 782: copy_src $pkgsrcdir/lang/nawk/files awk
1.71 jlam 783: test -n "$CC" || CC=gcc # default to gcc if no compiler is specified
1.80 schwarz 784: run_cmd "(cd $wrkdir/awk && $bmake -f Makefile CC=\"${CC}\" CFLAGS=\"${CFLAGS}\")"
1.101 joerg 785: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/awk/a.out $wrkdir/bin/nawk"
786: echo "TOOLS_PLATFORM.awk?= $prefix/bin/nawk" >> ${TARGET_MKCONF}
787: echo "TOOLS_PLATFORM.awk?= $wrkdir/bin/nawk" >> ${BOOTSTRAP_MKCONF}
1.57 jlam 788: ;;
789: esac
790:
791: # bootstrap sed if necessary
792: case "$need_sed" in
1.101 joerg 793: yes) echo_msg "Bootstrapping sed"
1.78 rillig 794: copy_src $pkgsrcdir/textproc/nbsed/files sed
1.101 joerg 795: 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)"
796: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/sed/sed $wrkdir/bin/sed"
797: echo "TOOLS_PLATFORM.sed?= $prefix/bin/nbsed" >> ${TARGET_MKCONF}
798: echo "TOOLS_PLATFORM.sed?= $wrkdir/bin/sed" >> ${BOOTSTRAP_MKCONF}
1.57 jlam 799: ;;
800: esac
801:
1.1 grant 802: case "$need_pax" in
1.101 joerg 803: yes)
804: echo "TOOLS_PLATFORM.pax?= $prefix/bin/pax" >> ${TARGET_MKCONF}
805: echo "TOOLS_PLATFORM.pax?= $prefix/bin/pax" >> ${BOOTSTRAP_MKCONF}
806: echo "TOOLS_PLATFORM.tar?= $prefix/bin/tar" >> ${TARGET_MKCONF}
807: echo "TOOLS_PLATFORM.tar?= $prefix/bin/tar" >> ${BOOTSTRAP_MKCONF}
1.1 grant 808: ;;
809: *)
1.101 joerg 810: echo "TOOLS_PLATFORM.pax?= $paxprog" >> ${TARGET_MKCONF}
811: echo "TOOLS_PLATFORM.pax?= $paxprog" >> ${BOOTSTRAP_MKCONF}
812: echo "TOOLS_PLATFORM.tar?= $tarprog" >> ${TARGET_MKCONF}
813: echo "TOOLS_PLATFORM.tar?= $tarprog" >> ${BOOTSTRAP_MKCONF}
1.1 grant 814: ;;
815: esac
816:
1.101 joerg 817:
1.1 grant 818: # bootstrap pkg_install
1.101 joerg 819: echo_msg "Bootstrapping pkgtools"
1.78 rillig 820: copy_src $pkgsrcdir/pkgtools/pkg_install/files pkg_install
1.101 joerg 821: run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV \
822: CPPFLAGS='$CPPFLAGS -I../libnbcompat -I../../libnbcompat' \
823: LDFLAGS='$LDFLAGS -L../libnbcompat -L../../libnbcompat' \
824: LIBS='-lnbcompat' $shprog ./configure $configure_quiet_flags -C \
1.104 ! joerg 825: --enable-bootstrap --prefix=$prefix --sysconfdir=$sysconfdir \
! 826: --with-pkgdbdir=$pkgdbdir --mandir=$mandir $pkg_install_args && $bmake)"
1.101 joerg 827: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/admin/pkg_admin $wrkdir/sbin/pkg_admin"
828: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/create/pkg_create $wrkdir/sbin/pkg_create"
829: run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/info/pkg_info $wrkdir/sbin/pkg_info"
830: echo "PKG_ADMIN_CMD?= $wrkdir/sbin/pkg_admin" >> ${BOOTSTRAP_MKCONF}
831: echo "PKG_CREATE_CMD?= $wrkdir/sbin/pkg_create" >> ${BOOTSTRAP_MKCONF}
832: echo "PKG_INFO_CMD?= $wrkdir/sbin/pkg_info" >> ${BOOTSTRAP_MKCONF}
833:
1.103 joerg 834: if [ -n "${fetch_cmd}" ]; then
835: echo "FETCH_CMD= $fetch_cmd" >> ${TARGET_MKCONF}
836: fi
1.101 joerg 837:
838: MAKECONF=$wrkdir/mk.conf
839: export MAKECONF
1.1 grant 840:
1.90 rillig 841: # On some newer Ubuntu installations, /bin/sh is a symlink to /bin/dash,
842: # whose echo(1) is not POSIX-compliant.
843: dash_echo_test=`echo "\\100"`
844: if [ "$dash_echo_test" = "@" ]; then
1.101 joerg 845: echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${TARGET_MKCONF}
846: echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${BOOTSTRAP_MKCONF}
1.90 rillig 847: fi
848:
1.81 schwarz 849: # preserve compiler and tool environment variables settings
1.101 joerg 850: if test -n "$CP"; then
851: echo "TOOLS_PLATFORM.cp?= $CP" >> ${TARGET_MKCONF}
852: echo "TOOLS_PLATFORM.cp?= $CP" >> ${BOOTSTRAP_MKCONF}
853: fi
854: if test -n "$GREP"; then
855: echo "TOOLS_PLATFORM.grep?= $GREP" >> ${TARGET_MKCONF}
856: echo "TOOLS_PLATFORM.grep?= $GREP" >> ${BOOTSTRAP_MKCONF}
857: fi
858: if test -n "$ID"; then
859: echo "TOOLS_PLATFORM.id?= $ID" >> ${TARGET_MKCONF}
860: echo "TOOLS_PLATFORM.id?= $ID" >> ${BOOTSTRAP_MKCONF}
861: fi
862: if test -n "$MKDIR"; then
863: echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${TARGET_MKCONF}
864: echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${BOOTSTRAP_MKCONF}
865: fi
866: if test -n "$TEST"; then
867: echo "TOOLS_PLATFORM.test?= $TEST" >> ${TARGET_MKCONF}
868: echo "TOOLS_PLATFORM.test?= $TEST" >> ${BOOTSTRAP_MKCONF}
869: fi
870: if test -n "$TOUCH"; then
871: echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${TARGET_MKCONF}
872: echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${BOOTSTRAP_MKCONF}
873: fi
874: if test -n "$XARGS"; then
875: echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${TARGET_MKCONF}
876: echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${BOOTSTRAP_MKCONF}
877: fi
878: if test -n "$CFLAGS"; then
879: echo "CFLAGS+= $CFLAGS" >> ${TARGET_MKCONF}
880: echo "CFLAGS+= $CFLAGS" >> ${BOOTSTRAP_MKCONF}
881: echo "DBG= # prevent DBG from adding default optimizer flags" >> ${TARGET_MKCONF}
882: echo "DBG= # prevent DBG from adding default optimizer flags" >> ${BOOTSTRAP_MKCONF}
883: fi
884: if test -n "$CPPFLAGS"; then
885: echo "CPPFLAGS+= $CPPFLAGS" >> ${TARGET_MKCONF}
886: echo "CPPFLAGS+= $CPPFLAGS" >> ${BOOTSTRAP_MKCONF}
887: fi
888: if test -n "$LDFLAGS"; then
889: echo "LDFLAGS+= $LDFLAGS" >> ${TARGET_MKCONF}
890: echo "LDFLAGS+= $LDFLAGS" >> ${BOOTSTRAP_MKCONF}
891: fi
1.81 schwarz 892:
1.1 grant 893: # opsys specific fiddling
894: opsys_finish
895:
1.101 joerg 896: echo "WRKOBJDIR= ${wrkdir}/wrk" >> ${BOOTSTRAP_MKCONF}
897:
898: echo "" >> ${TARGET_MKCONF}
899: echo "" >> ${BOOTSTRAP_MKCONF}
1.102 joerg 900: if test -n "${mk_fragment}"; then
901: cat "${mk_fragment}" >> ${TARGET_MKCONF}
902: echo "" >> ${TARGET_MKCONF}
903: fi
1.101 joerg 904: echo ".endif # end pkgsrc settings" >> ${TARGET_MKCONF}
905: echo ".endif # end pkgsrc settings" >> ${BOOTSTRAP_MKCONF}
1.1 grant 906:
1.61 jlam 907: # register packages
1.85 rillig 908: # usage: register_package <packagedirectory> [additional arguments]
1.101 joerg 909: build_package() {
910: run_cmd "(cd $pkgsrcdir/$1 && $bmake -DPKG_PRESERVE MAKECONF=${BOOTSTRAP_MKCONF} install)"
1.85 rillig 911: }
912:
1.101 joerg 913: echo_msg "Installing packages"
914: build_package "pkgtools/bootstrap-mk-files"
915: build_package "devel/bmake"
1.61 jlam 916: case "$need_awk" in
1.101 joerg 917: yes) build_package "lang/nawk";;
1.61 jlam 918: esac
919: case "$need_sed" in
1.101 joerg 920: yes) build_package "textproc/nbsed" "LIBNBCOMPAT_STYLE=inplace";;
1.67 jlam 921: esac
922: case "$need_bsd_install" in
1.101 joerg 923: yes) build_package "sysutils/install-sh";;
1.67 jlam 924: esac
925: case "$need_extras" in
1.101 joerg 926: yes) build_package "pkgtools/bootstrap-extras";;
1.61 jlam 927: esac
928: case "$need_ftp" in
1.101 joerg 929: yes) build_package "pkgtools/tnftp";;
1.61 jlam 930: esac
931: case "$need_pax" in
1.101 joerg 932: yes) build_package "pkgtools/pax";;
1.61 jlam 933: esac
1.101 joerg 934: build_package "pkgtools/pkg_install"
1.61 jlam 935:
1.89 rillig 936: etc_mk_conf="$sysconfdir/mk.conf"
937:
938: # Install the example mk.conf so that it is used, but only if it doesn't
1.101 joerg 939: # exist yet. This can happen with non-default sysconfdir settings.
1.89 rillig 940: mkdir_p "$sysconfdir"
941: if [ ! -f "$etc_mk_conf" ]; then
1.101 joerg 942: cp "$TARGET_MKCONF" "$etc_mk_conf"
943: TARGET_MKCONF="$etc_mk_conf"
1.89 rillig 944: fi
945:
1.85 rillig 946: hline="==========================================================================="
947: echo ""
948: echo "$hline"
1.1 grant 949: echo ""
1.9 grant 950: echo "Please remember to add $prefix/bin to your PATH environment variable"
1.77 jlam 951: echo "and $mandir to your MANPATH environment variable, if necessary."
1.9 grant 952: echo ""
1.85 rillig 953: echo "An example mk.conf file with the settings you provided to \"bootstrap\""
954: echo "has been created for you. It can be found in:"
955: echo ""
1.101 joerg 956: echo " ${TARGET_MKCONF}"
1.85 rillig 957: echo ""
1.101 joerg 958: if [ "$TARGET_MKCONF" != "$etc_mk_conf" ]; then
1.89 rillig 959: echo "Please copy it to $etc_mk_conf to use it."
960: echo ""
961: fi
1.1 grant 962: echo "You can find extensive documentation of the NetBSD Packages Collection"
1.92 wiz 963: echo "in $pkgsrcdir/doc/pkgsrc.txt."
1.1 grant 964: echo ""
965: echo "Hopefully everything is now complete."
966: echo "Thank you"
1.85 rillig 967: echo ""
968: echo "$hline"
969: echo ""
1.1 grant 970:
971: echo_msg "bootstrap started: $build_start"
972: echo_msg "bootstrap ended: `date`"
973:
974: exit 0
CVSweb <webmaster@jp.NetBSD.org>