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