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