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