[BACK]Return to bootstrap CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / bootstrap

Annotation of pkgsrc/bootstrap/bootstrap, Revision 1.120

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

CVSweb <webmaster@jp.NetBSD.org>