f91b394772
list for bulk builds. (Revert previous on bootstrap; the PKG_PRESERVE hack didn't work as expected.)
938 lines
25 KiB
Bash
Executable file
938 lines
25 KiB
Bash
Executable file
#! /bin/sh
|
|
|
|
# $NetBSD: bootstrap,v 1.88 2006/11/06 21:08:42 tv Exp $
|
|
#
|
|
#
|
|
# Copyright (c) 2001-2002 Alistair G. Crooks. All rights reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without
|
|
# modification, are permitted provided that the following conditions
|
|
# are met:
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
# notice, this list of conditions and the following disclaimer.
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
# documentation and/or other materials provided with the distribution.
|
|
# 3. All advertising materials mentioning features or use of this software
|
|
# must display the following acknowledgement:
|
|
# This product includes software developed by Alistair G. Crooks
|
|
# for the NetBSD project.
|
|
# 4. The name of the author may not be used to endorse or promote
|
|
# products derived from this software without specific prior written
|
|
# permission.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
#
|
|
#set -x
|
|
|
|
# the following environment variables are honored:
|
|
# compiler/linker flags: CFLAGS, CPPFLAGS, LDFLAGS
|
|
# tools: CP, GREP, ID, MKDIR, TEST, TOUCH, XARGS
|
|
|
|
|
|
BOOTSTRAP_VERSION=20060721
|
|
|
|
ignorecasecheck=no
|
|
ignoreusercheck=no
|
|
|
|
preserve_path=no
|
|
|
|
# where the building takes place
|
|
bootstrapdir=`dirname "$0"`
|
|
bootstrapdir=`cd "${bootstrapdir}" && pwd`
|
|
pkgsrcdir=`dirname "${bootstrapdir}"`
|
|
wrkdir="`pwd`/work"
|
|
|
|
usage="Usage: $0 "'
|
|
[ --workdir <workdir> ]
|
|
[ --prefix <prefix> ]
|
|
[ --pkgdbdir <pkgdbdir> ]
|
|
[ --pkgmandir <pkgmandir> ]
|
|
[ --sysconfdir <sysconfdir> ]
|
|
[ --varbase <varbase> ]
|
|
[ --fetch-cmd <ftp command> ]
|
|
[ --ignore-case-check ]
|
|
[ --unprivileged | --ignore-user-check ]
|
|
[ --preserve-path ]
|
|
[ --compiler <compiler> ]
|
|
[ --full ]
|
|
[ --quiet ]
|
|
[ --help ]'
|
|
|
|
# this replicates some of the logic in bsd.prefs.mk. until
|
|
# bootstrap-pkgsrc is merged into pkgsrc, we need to determine the
|
|
# right value for OPSYS and MACHINE_ARCH.
|
|
|
|
# strip / for BSD/OS
|
|
opsys=`uname -s | tr -d /`
|
|
|
|
die()
|
|
{
|
|
echo >&2 "$@"
|
|
exit 1
|
|
}
|
|
|
|
echo_msg()
|
|
{
|
|
echo "===> $@"
|
|
}
|
|
|
|
# see if we're using gcc. If so, set $compiler_is_gnu to '1'.
|
|
get_compiler()
|
|
{
|
|
testcc="${CC}"
|
|
# normally, we'd just use 'cc', but certain configure tools look
|
|
# for gcc specifically, so we have to see if that comes first
|
|
if [ -z "${testcc}" ]; then
|
|
save_IFS="${IFS}"
|
|
IFS=':'
|
|
for dir in ${PATH}; do
|
|
test -z "$dir" && dir=.
|
|
if [ -x "$dir/gcc" ]; then
|
|
testcc="$dir/gcc"
|
|
break
|
|
fi
|
|
done
|
|
IFS="${save_IFS}"
|
|
fi
|
|
|
|
cat >${wrkdir}/$$.c <<EOF
|
|
#ifdef __GNUC__
|
|
indeed
|
|
#endif
|
|
EOF
|
|
compiler_is_gnu=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed`
|
|
rm -f ${wrkdir}/$$.c
|
|
|
|
}
|
|
get_abi()
|
|
{
|
|
abi_opsys=$@
|
|
case "$abi_opsys" in
|
|
IRIX)
|
|
if [ `uname -r` -ge 6 ]; then
|
|
abi=`sed -e 's/.*\(abi=\)\([on]*[36][24]\).*/\2/' /etc/compiler.defaults`
|
|
isa=`sed -e 's/.*\(isa=mips\)\([1234]\).*/\2/' /etc/compiler.defaults`
|
|
case "$abi" in
|
|
o32)
|
|
imakeopts="-DBuildO32 -DSgiISAo32=$isa"
|
|
abi=""
|
|
;;
|
|
n32) imakeopts="-DBuildN32 -DSgiISA32=$isa"
|
|
abi="32"
|
|
;;
|
|
64 | n64)
|
|
imakeopts="-DBuild64bit -DSgiISA64=$isa"
|
|
abi="64"
|
|
;;
|
|
esac
|
|
else # IRIX before 6
|
|
abi=32
|
|
fi
|
|
;;
|
|
esac
|
|
}
|
|
|
|
get_machine_arch_aix()
|
|
{
|
|
_cpuid=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
|
|
if /usr/sbin/lsattr -El $_cpuid | grep ' POWER' >/dev/null 2>&1; then
|
|
echo rs6000
|
|
else
|
|
echo powerpc
|
|
fi
|
|
}
|
|
|
|
check_prog()
|
|
{
|
|
_var="$1"; _name="$2"
|
|
|
|
eval _tmp=\"\$$_var\"
|
|
if [ "x$_tmp" != "x" ]; then
|
|
# Variable is already set (by the user, for example)
|
|
return 0
|
|
fi
|
|
|
|
for _d in `echo $PATH | tr ':' ' '`; do
|
|
if [ -x "$_d/$_name" ]; then
|
|
# Program found
|
|
eval $_var=\""$_d/$_name"\"
|
|
return 1
|
|
fi
|
|
done
|
|
|
|
die "$_name not found in path."
|
|
}
|
|
|
|
opsys_finish()
|
|
{
|
|
case "$opsys" in
|
|
IRIX)
|
|
if [ ! -z "$imakeopts" ]; then
|
|
echo "IMAKEOPTS+= $imakeopts" >> ${MKCONF_EXAMPLE}
|
|
fi
|
|
if [ `uname -r` -lt 6 ]; then
|
|
echo_msg "Installing fake ldd script"
|
|
run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/fakeldd $prefix/sbin"
|
|
need_extras=yes
|
|
echo "LDD= $prefix/sbin/fakeldd" >> ${MKCONF_EXAMPLE}
|
|
fi
|
|
;;
|
|
esac
|
|
}
|
|
|
|
is_root()
|
|
{
|
|
if [ `uname -s` = "IRIX" ]; then
|
|
if [ `uname -r` -lt 6 -a -z "$ID" ]; then
|
|
# older version of IRIX have an id command with limited features
|
|
if [ "`$idprog`" != "uid=0(root) gid=0(sys)" ]; then
|
|
return 0
|
|
fi
|
|
return 1
|
|
fi
|
|
fi
|
|
if [ `$idprog -u` != 0 ]; then
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
# run a command, abort if it fails
|
|
run_cmd()
|
|
{
|
|
echo_msg "running: $@"
|
|
eval "$@"
|
|
ret=$?
|
|
if [ $ret -ne 0 ]; then
|
|
echo_msg "exited with status $ret"
|
|
die "aborted."
|
|
fi
|
|
}
|
|
|
|
# Some versions of mkdir (notably SunOS) bail out too easily, so use the
|
|
# install-sh wrapper instead.
|
|
mkdir_p()
|
|
{
|
|
for dir in $@; do
|
|
run_cmd "$install_sh -d -o $user -g $group $dir"
|
|
done
|
|
}
|
|
|
|
copy_src()
|
|
{
|
|
_src="$1"; _dst="$2"
|
|
if [ ! -d $wrkdir/$_dst ]; then
|
|
mkdir_p $wrkdir/$_dst
|
|
fi
|
|
$cpprog -r $_src/* $wrkdir/$_dst
|
|
}
|
|
|
|
get_optarg()
|
|
{
|
|
expr "x$1" : "x[^=]*=\\(.*\\)"
|
|
}
|
|
|
|
build_start=`date`
|
|
echo_msg "bootstrap command: $0 $@"
|
|
echo_msg "bootstrap started: $build_start"
|
|
|
|
# ensure system locations are empty; we will set them later when we know
|
|
# whether they will be system wide or user specific
|
|
prefix=
|
|
pkgdbdir=
|
|
pkgmandir=
|
|
sysconfdir=
|
|
varbase=
|
|
|
|
full=no
|
|
compiler=""
|
|
quiet=no
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case $1 in
|
|
--workdir=*) wrkdir=`get_optarg "$1"` ;;
|
|
--workdir) wrkdir="$2"; shift ;;
|
|
--prefix=*) prefix=`get_optarg "$1"` ;;
|
|
--prefix) prefix="$2"; shift ;;
|
|
--pkgdbdir=*) pkgdbdir=`get_optarg "$1"` ;;
|
|
--pkgdbdir) pkgdbdir="$2"; shift ;;
|
|
--pkgmandir=*) pkgmandir=`get_optarg "$1"` ;;
|
|
--pkgmandir) pkgmandir="$2"; shift ;;
|
|
--sysconfdir=*) sysconfdir=`get_optarg "$1"` ;;
|
|
--sysconfdir) sysconfdir="$2"; shift ;;
|
|
--varbase=*) varbase=`get_optarg "$1"` ;;
|
|
--varbase) varbase="$2"; shift ;;
|
|
--fetch-cmd=*) fetch_cmd=`get_optarg "$1"` ;;
|
|
--fetch-cmd) fetch_cmd="$a"; shift ;;
|
|
--compiler=*) compiler=`get_optarg "$1"` ;;
|
|
--compiler) compiler="$2"; shift ;;
|
|
--ignore-case-check) ignorecasecheck=yes ;;
|
|
--unprivileged | --ignore-user-check) ignoreusercheck=yes ;;
|
|
--preserve-path) preserve_path=yes ;;
|
|
--full) full=yes ;;
|
|
--quiet) quiet=yes ;;
|
|
--help) echo "$usage"; exit ;;
|
|
-h) echo "$usage"; exit ;;
|
|
--*) echo "$usage"; exit 1 ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
# set defaults for system locations if not already set by the user
|
|
wrkobjdir=${wrkdir}/pkgsrc
|
|
if [ "$ignoreusercheck" = "yes" ]; then
|
|
[ -z "$prefix" ] && prefix=${HOME}/pkg
|
|
[ -z "$pkgdbdir" ] && pkgdbdir=${prefix}/var/db/pkg
|
|
[ -z "$varbase" ] && varbase=${prefix}/var
|
|
else
|
|
[ -z "$prefix" ] && prefix=/usr/pkg
|
|
[ -z "$pkgdbdir" ] && pkgdbdir=/var/db/pkg
|
|
[ -z "$varbase" ] && varbase=/var
|
|
fi
|
|
if [ "$prefix" = "/usr" ]; then
|
|
[ -z "$pkgmandir" ] && pkgmandir=share/man
|
|
else
|
|
[ -z "$pkgmandir" ] && pkgmandir=man
|
|
fi
|
|
mandir=${prefix}/${pkgmandir}
|
|
[ -z "$sysconfdir" ] && sysconfdir=${prefix}/etc
|
|
|
|
if [ "x$preserve_path" != "xyes" ]; then
|
|
PATH="$PATH:/sbin:/usr/sbin"
|
|
fi
|
|
|
|
overpath=""
|
|
root_user=root
|
|
bmakexenv=
|
|
bmakexargs=
|
|
tnftpxflags=
|
|
need_extras=no
|
|
case "$opsys" in
|
|
Darwin)
|
|
root_group=wheel
|
|
need_pax=yes
|
|
need_mtree=no
|
|
need_bsd_install=no
|
|
need_awk=no
|
|
need_sed=no
|
|
set_opsys=no
|
|
check_prog mtreeprog mtree
|
|
machine_arch=`uname -p`
|
|
;;
|
|
DragonFly)
|
|
root_group=wheel
|
|
need_pax=yes
|
|
need_mtree=no
|
|
need_bsd_install=no
|
|
need_awk=no
|
|
need_sed=no
|
|
set_opsys=no
|
|
check_prog tarprog tar
|
|
check_prog mtreeprog mtree
|
|
machine_arch=`uname -p`
|
|
case `uname -r` in
|
|
1.1[0-9]*)
|
|
[ -z "$fetch_cmd" ] && fetch_cmd="/usr/bin/ftp"
|
|
;;
|
|
1.0* | 1.1 | 1.2.* | 1.3.*)
|
|
;;
|
|
*)
|
|
[ -z "$fetch_cmd" ] && fetch_cmd="/usr/bin/ftp"
|
|
;;
|
|
esac
|
|
;;
|
|
FreeBSD)
|
|
root_group=wheel
|
|
need_pax=yes
|
|
need_mtree=yes
|
|
need_bsd_install=no
|
|
need_awk=no
|
|
need_sed=no
|
|
set_opsys=no
|
|
machine_arch=`uname -p`
|
|
;;
|
|
HP-UX)
|
|
root_group=root
|
|
need_pax=yes
|
|
need_mtree=yes
|
|
need_bsd_install=yes
|
|
need_awk=yes
|
|
need_sed=yes
|
|
set_opsys=no
|
|
;;
|
|
IRIX*)
|
|
if [ -d "/usr/freeware/bin" ]; then
|
|
overpath="/usr/freeware/bin:$overpath"
|
|
fi
|
|
if [ -d "/usr/bsd/bin" ]; then
|
|
overpath="/usr/bsd/bin:$overpath"
|
|
fi
|
|
root_group=sys
|
|
need_mtree=yes
|
|
need_bsd_install=yes
|
|
need_pax=yes
|
|
get_abi "IRIX"
|
|
opsys=IRIX
|
|
need_awk=yes
|
|
need_sed=yes
|
|
set_opsys=yes
|
|
machine_arch=mipseb
|
|
bmakexargs="MACHINE_ARCH=$machine_arch"
|
|
bmakexenv="MAKE=pmake"
|
|
check_compiler=yes
|
|
if [ `uname -r` -lt 6 ]; then
|
|
# IRIX 5's mkdir bails out with an error when trying to create with the -p
|
|
# option an already existing directory
|
|
need_mkdir=yes
|
|
# IRIX 5 does not have uint32_t typedef'd in sys/types.h
|
|
tnftpxflags="-DUINT32_T=int"
|
|
# IRIX 5 is lacking fnmatch.h needed to build mtree
|
|
needfnmatchh=yes
|
|
fi
|
|
;;
|
|
Linux)
|
|
if [ -f /etc/debian_version ]; then
|
|
DEBIAN=yes
|
|
fi
|
|
root_group=root
|
|
need_pax=yes
|
|
need_mtree=yes
|
|
need_bsd_install=no
|
|
need_awk=no
|
|
need_sed=no
|
|
set_opsys=no
|
|
machine_arch=`uname -m | sed -e 's/i.86/i386/'`
|
|
;;
|
|
NetBSD)
|
|
root_group=wheel
|
|
need_pax=no
|
|
need_mtree=no
|
|
need_bsd_install=no
|
|
need_awk=no
|
|
need_sed=no
|
|
set_opsys=no
|
|
check_prog paxprog pax
|
|
check_prog tarprog tar
|
|
check_prog mtreeprog mtree
|
|
machine_arch=`uname -p`
|
|
;;
|
|
OpenBSD)
|
|
root_group=wheel
|
|
need_pax=yes
|
|
need_mtree=no
|
|
need_bsd_install=no
|
|
need_awk=no
|
|
need_sed=no
|
|
set_opsys=no
|
|
check_prog mtreeprog mtree
|
|
machine_arch=`uname -m`
|
|
;;
|
|
SunOS)
|
|
if [ -d "/usr/xpg4/bin" ]; then
|
|
overpath="/usr/xpg4/bin:$overpath"
|
|
fi
|
|
root_group=root
|
|
need_pax=yes
|
|
need_mtree=yes
|
|
need_bsd_install=no
|
|
need_awk=yes
|
|
need_sed=yes
|
|
set_opsys=no
|
|
whoamiprog=/usr/ucb/whoami
|
|
machine_arch=`uname -p | sed -e 's/i86pc/i386/'`
|
|
check_compiler=yes
|
|
;;
|
|
AIX)
|
|
root_group=system
|
|
need_pax=yes
|
|
need_mtree=yes
|
|
need_bsd_install=yes
|
|
need_awk=yes
|
|
need_sed=yes
|
|
need_fixed_strip=yes
|
|
set_opsys=no
|
|
machine_arch=`get_machine_arch_aix`
|
|
;;
|
|
Interix)
|
|
is_root () {
|
|
if id -G | grep -q 131616; then
|
|
return 1
|
|
fi
|
|
return 0
|
|
}
|
|
mkdir_p () {
|
|
mkdir -p "$@" # allows umask to take effect
|
|
}
|
|
default_install_mode=0775
|
|
root_user=`id -u`
|
|
root_group=131616
|
|
need_pax=yes
|
|
need_mtree=yes
|
|
need_bsd_install=yes
|
|
need_awk=yes
|
|
need_sed=yes
|
|
set_opsys=no
|
|
# only used for unprivileged builds
|
|
groupsprog="id -gn"
|
|
# for bootstrap only; pkgsrc uses CPPFLAGS
|
|
CC="gcc -D_ALL_SOURCE"; export CC
|
|
ac_cv_header_poll_h=no; export ac_cv_header_poll_h
|
|
ac_cv_func_poll=no; export ac_cv_func_poll
|
|
;;
|
|
UnixWare)
|
|
root_group=sys
|
|
need_pax=yes
|
|
need_mtree=yes
|
|
need_bsd_install=no
|
|
BSTRAP_ENV="INSTALL=/usr/ucb/install $BSTRAP_ENV"
|
|
need_mkdir=yes
|
|
need_awk=yes
|
|
need_sed=yes
|
|
whoamiprog=/usr/ucb/whoami
|
|
set_opsys=no
|
|
CC="gcc -DUNIXWARE"; export CC
|
|
;;
|
|
OSF1)
|
|
root_group=system
|
|
need_pax=yes
|
|
need_mtree=yes
|
|
need_bsd_install=yes
|
|
need_awk=yes
|
|
need_sed=yes
|
|
set_opsys=no
|
|
;;
|
|
*)
|
|
echo "This platform ($opsys) is untried - good luck, and thanks for using pkgsrc"
|
|
root_group=wheel
|
|
need_pax=yes
|
|
need_mtree=yes
|
|
need_bsd_install=yes
|
|
need_awk=yes
|
|
need_sed=yes
|
|
set_opsys=no
|
|
;;
|
|
esac
|
|
|
|
# If "--full" is specified, then install all of the platform-independent
|
|
# bootstrap software.
|
|
#
|
|
case "$full" in
|
|
yes)
|
|
need_pax=yes
|
|
need_mtree=yes
|
|
need_bsd_install=yes
|
|
need_awk=yes
|
|
need_sed=yes
|
|
;;
|
|
esac
|
|
|
|
case "$quiet" in
|
|
yes)
|
|
configure_quiet_flags="--quiet"
|
|
make_quiet_flags="-s"
|
|
;;
|
|
no)
|
|
configure_quiet_flags=""
|
|
make_quiet_flags=""
|
|
esac
|
|
|
|
# export OPSYS and MACHINE_ARCH for pkg_install. we only set
|
|
# MACHINE_ARCH on platforms where we override bmake's value.
|
|
OPSYS=${opsys}
|
|
export OPSYS
|
|
if [ "${machine_arch}" != "" ]; then
|
|
MACHINE_ARCH=${machine_arch}
|
|
export MACHINE_ARCH
|
|
fi
|
|
|
|
if [ "x$preserve_path" != "xyes" ]; then
|
|
PATH="$overpath:$PATH"
|
|
fi
|
|
|
|
check_prog awkprog awk
|
|
check_prog chmodprog chmod
|
|
if [ -n "$CP" ]; then
|
|
cpprog="$CP"
|
|
else
|
|
check_prog cpprog cp
|
|
fi
|
|
if [ -n "$ID" ]; then
|
|
idprog="$ID"
|
|
else
|
|
check_prog idprog id
|
|
fi
|
|
check_prog groupsprog groups
|
|
check_prog lnprog ln
|
|
check_prog lsprog ls
|
|
check_prog rmdirprog rmdir
|
|
check_prog sedprog sed
|
|
check_prog shprog sh
|
|
check_prog whoamiprog whoami
|
|
|
|
|
|
if [ ! -d ${wrkdir} ]; then
|
|
if mkdir ${wrkdir}; then
|
|
:
|
|
else
|
|
echo "Could not create the working directory \"${wrkdir}\". Try $0 -h.";
|
|
exit 1
|
|
fi
|
|
fi
|
|
if touch ${wrkdir}/.writeable; then
|
|
:
|
|
else
|
|
echo "\"${wrkdir}\" is not writeable. Try $0 -h.";
|
|
exit 1
|
|
fi
|
|
echo "Working directory is: ${wrkdir}"
|
|
|
|
if [ "$compiler" = "" ] && [ x"$check_compiler" = x"yes" ]; then
|
|
get_compiler
|
|
if [ $compiler_is_gnu -gt 0 ]; then
|
|
compiler="gcc"
|
|
else
|
|
case "$opsys" in
|
|
IRIX)
|
|
if [ `uname -r` -ge 6 ]; then
|
|
compiler="mipspro"
|
|
else
|
|
compiler="ido"
|
|
fi
|
|
test -n "$CC" || CC=cc
|
|
;;
|
|
SunOS) compiler="sunpro"
|
|
test -n "$CC" || CC=cc
|
|
;;
|
|
esac
|
|
fi
|
|
fi
|
|
|
|
# build install-sh
|
|
run_cmd "$sedprog -e 's|@DEFAULT_INSTALL_MODE@|'${default_install_mode-0755}'|' $pkgsrcdir/sysutils/install-sh/files/install-sh.in > $wrkdir/install-sh"
|
|
run_cmd "$chmodprog +x $wrkdir/install-sh"
|
|
install_sh="$shprog $wrkdir/install-sh"
|
|
|
|
is_root
|
|
if [ $? = 1 ]; then
|
|
user=$root_user
|
|
group=$root_group
|
|
else
|
|
if [ $ignoreusercheck = "no" ]; then
|
|
die "You must be root to install bootstrap-pkgsrc."
|
|
fi
|
|
|
|
user=`$whoamiprog`
|
|
group=`$groupsprog | $awkprog '{print $1}'`
|
|
echo_msg "building as unprivileged user $user/$group"
|
|
|
|
# force bmake install target to use $user and $group
|
|
echo "BINOWN=$user
|
|
BINGRP=$group
|
|
LIBOWN=$user
|
|
LIBGRP=$group
|
|
MANOWN=$user
|
|
MANGRP=$group" > ${wrkdir}/Makefile.inc
|
|
fi
|
|
|
|
# make sure we're using a case-sensitive file system on Darwin
|
|
if [ $ignorecasecheck = "no" ]; then
|
|
case "$opsys" in
|
|
Darwin|Interix)
|
|
echo_msg "Testing file system case sensitivity"
|
|
for fs in "$prefix" "$pkgsrcdir"; do
|
|
testdir="pkgsrc-REQUIRES-case-SENSITIVE-filesystem"
|
|
testdir_mangled="PKGSRC-requires-CASE-sensitive-FILESYSTEM"
|
|
mkdir_p "$fs/$testdir" || die "can't verify filesystem ($fs) case-sensitivity"
|
|
if [ -d "$fs/$testdir_mangled" ]; then
|
|
$rmdirprog "$fs/$testdir"
|
|
die "\"$fs\" needs to be on a case-sensitive filesystem (see README.$opsys)"
|
|
fi
|
|
$rmdirprog "$fs/$testdir"
|
|
done
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
# export the proper environment
|
|
PATH=$prefix/bin:$prefix/sbin:${PATH}; export PATH
|
|
if [ -d /usr/ccs/bin -a -x /usr/ccs/bin/make ]; then
|
|
PATH=${PATH}:/usr/ccs/bin; export PATH
|
|
fi
|
|
PKG_DBDIR=$pkgdbdir; export PKG_DBDIR
|
|
LOCALBASE=$prefix; export LOCALBASE
|
|
VARBASE=$varbase; export VARBASE
|
|
|
|
# build libnbcompat
|
|
echo_msg "Building libnbcompat"
|
|
copy_src $pkgsrcdir/pkgtools/libnbcompat/files libnbcompat
|
|
run_cmd "(cd $wrkdir/libnbcompat; $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --mandir=$mandir --sysconfdir=$sysconfdir && make $make_quiet_flags)"
|
|
|
|
if [ x"$needfnmatchh" = x"yes" ]; then
|
|
$lnprog -s nbcompat/fnmatch.h $wrkdir/libnbcompat/fnmatch.h
|
|
fi
|
|
|
|
# set up an example mk.conf file
|
|
MKCONF_EXAMPLE=${wrkdir}/mk.conf.example
|
|
export MKCONF_EXAMPLE
|
|
echo_msg "Creating mk.conf.example in ${wrkdir}"
|
|
echo "# Example ${sysconfdir}/mk.conf file produced by bootstrap-pkgsrc" > ${MKCONF_EXAMPLE}
|
|
echo "# `date`" >> ${MKCONF_EXAMPLE}
|
|
echo "" >> ${MKCONF_EXAMPLE}
|
|
echo ".ifdef BSD_PKG_MK # begin pkgsrc settings" >> ${MKCONF_EXAMPLE}
|
|
echo "" >> ${MKCONF_EXAMPLE}
|
|
|
|
# IRIX64 needs to be set to IRIX, for example
|
|
if [ "$set_opsys" = "yes" ]; then
|
|
echo "OPSYS= $opsys" >> ${MKCONF_EXAMPLE}
|
|
fi
|
|
|
|
if [ ! -z "$abi" ]; then
|
|
echo "ABI= $abi" >> ${MKCONF_EXAMPLE}
|
|
fi
|
|
if [ "$compiler" != "" ]; then
|
|
echo "PKGSRC_COMPILER= $compiler" >> ${MKCONF_EXAMPLE}
|
|
fi
|
|
|
|
# enable unprivileged builds if not root
|
|
if [ "$ignoreusercheck" = "yes" ]; then
|
|
echo "UNPRIVILEGED= yes" >> ${MKCONF_EXAMPLE}
|
|
fi
|
|
|
|
# save environment in example mk.conf
|
|
echo "PKG_DBDIR= $pkgdbdir" >> ${MKCONF_EXAMPLE}
|
|
echo "LOCALBASE= $prefix" >> ${MKCONF_EXAMPLE}
|
|
echo "VARBASE= $varbase" >> ${MKCONF_EXAMPLE}
|
|
if [ "${sysconfdir}" != "${prefix}/etc" ]; then
|
|
echo "PKG_SYSCONFBASE= $sysconfdir" >> ${MKCONF_EXAMPLE}
|
|
fi
|
|
echo "PKG_TOOLS_BIN= $prefix/sbin" >> ${MKCONF_EXAMPLE}
|
|
echo "PKGMANDIR= $pkgmandir" >> ${MKCONF_EXAMPLE}
|
|
echo "" >> ${MKCONF_EXAMPLE}
|
|
|
|
# create directories
|
|
mkdir_p $prefix $pkgdbdir $prefix/sbin
|
|
mkdir_p $mandir/man1 $mandir/cat1
|
|
mkdir_p $mandir/man8 $mandir/cat8
|
|
|
|
# bootstrap make and *.mk files
|
|
mkdir_p $prefix/share/mk $prefix/lib
|
|
copy_src $pkgsrcdir/pkgtools/bootstrap-mk-files/files mk-files
|
|
|
|
(
|
|
cd ${wrkdir}/mk-files
|
|
for file in bsd.* sys.mk; do
|
|
[ ! -f mods/$opsys.$file ] ||
|
|
run_cmd "$cpprog mods/$opsys.$file $file"
|
|
done
|
|
if [ -f mods/$opsys.own.mk.in ]; then
|
|
own_mk=mods/$opsys.own.mk.in
|
|
else
|
|
own_mk=mods/bsd.own.mk.in
|
|
fi
|
|
run_cmd "$sedprog -e 's|@ROOT_GROUP@|'$root_group'|g;s|@ROOT_USER@|'$root_user'|g;s|@SYSCONFDIR@|'$sysconfdir'|g' $own_mk > bsd.own.mk"
|
|
run_cmd "$cpprog bsd.* sys.mk $prefix/share/mk"
|
|
)
|
|
|
|
if [ "$need_bsd_install" = "yes" ]; then
|
|
echo_msg "Installing BSD compatible install script"
|
|
run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/install-sh $prefix/bin/install-sh"
|
|
BSTRAP_ENV="INSTALL='$prefix/bin/install-sh -c' $BSTRAP_ENV"
|
|
echo "TOOLS_PLATFORM.install?= $prefix/bin/install-sh" >> ${MKCONF_EXAMPLE}
|
|
fi
|
|
|
|
if [ "$need_fixed_strip" = "yes" ] ; then
|
|
echo_msg "Installing fixed strip script"
|
|
run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/strip-sh $prefix/bin/strip"
|
|
echo "TOOLS_PLATFORM.strip?= $prefix/bin/strip" >> ${MKCONF_EXAMPLE}
|
|
need_extras=yes
|
|
fi
|
|
|
|
if [ "$need_mkdir" = "yes" -a -z "$MKDIR" ]; then
|
|
echo_msg "Installing fixed mkdir script \"mkdir-sh\""
|
|
run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/mkdir-sh $prefix/bin/mkdir-sh"
|
|
echo "TOOLS_PLATFORM.mkdir?= $prefix/bin/mkdir-sh -p" >> ${MKCONF_EXAMPLE}
|
|
need_extras=yes
|
|
fi
|
|
|
|
echo_msg "Installing bmake"
|
|
copy_src $pkgsrcdir/devel/bmake/files bmake
|
|
run_cmd "(cd $wrkdir/bmake && env CPPFLAGS='$CPPFLAGS -I../../libnbcompat' LDFLAGS='$LDFLAGS -L../../libnbcompat' LIBS='-lnbcompat' $bmakexenv $shprog ./boot-strap $configure_quiet_flags -q -o $opsys --prefix=$prefix --sysconfdir=$sysconfdir --mksrc none --with-default-sys-path="$prefix/share/mk" $bmakexargs)"
|
|
run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/bmake/$opsys/bmake $prefix/bin/bmake"
|
|
run_cmd "$install_sh -c -o $user -g $group -m 644 $wrkdir/bmake/bmake.1 $mandir/man1/bmake.1"
|
|
|
|
bmake="$prefix/bin/bmake $make_quiet_flags"
|
|
|
|
# bootstrap awk if necessary
|
|
case "$need_awk" in
|
|
yes) echo_msg "Installing awk"
|
|
copy_src $pkgsrcdir/lang/nawk/files awk
|
|
test -n "$CC" || CC=gcc # default to gcc if no compiler is specified
|
|
run_cmd "(cd $wrkdir/awk && $bmake -f Makefile CC=\"${CC}\" CFLAGS=\"${CFLAGS}\")"
|
|
run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/awk/a.out $prefix/bin/nawk"
|
|
run_cmd "$install_sh -c -o $user -g $group -m 644 $wrkdir/awk/nawk.1 $mandir/man1/nawk.1"
|
|
echo "TOOLS_PLATFORM.awk?= $prefix/bin/nawk" >> ${MKCONF_EXAMPLE}
|
|
BSTRAP_ENV="AWK=\"$prefix/bin/nawk\" $BSTRAP_ENV"
|
|
;;
|
|
esac
|
|
|
|
# bootstrap sed if necessary
|
|
case "$need_sed" in
|
|
yes) echo_msg "Installing sed"
|
|
copy_src $pkgsrcdir/textproc/nbsed/files sed
|
|
run_cmd "(cd $wrkdir/sed; env $BSTRAP_ENV CPPFLAGS='$CPPFLAGS -I../libnbcompat' LDFLAGS='$LDFLAGS -L../libnbcompat' LIBS='-lnbcompat' $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --mandir=$mandir --sysconfdir=$sysconfdir --program-transform-name='s,sed,nbsed,' && $bmake && $bmake install)"
|
|
echo "TOOLS_PLATFORM.sed?= $prefix/bin/nbsed" >> ${MKCONF_EXAMPLE}
|
|
BSTRAP_ENV="SED=\"$prefix/bin/nbsed\" $BSTRAP_ENV"
|
|
;;
|
|
esac
|
|
|
|
if [ -z "$fetch_cmd" ]; then
|
|
need_ftp=yes
|
|
else
|
|
need_ftp=no
|
|
fi
|
|
|
|
case "$need_ftp" in
|
|
yes) # bootstrap tnftp
|
|
fetch_cmd="$prefix/bin/ftp"
|
|
case "$DEBIAN" in
|
|
yes)
|
|
LIBS="-lncurses"
|
|
;;
|
|
esac
|
|
echo_msg "Installing tnftp"
|
|
copy_src $pkgsrcdir/net/tnftp/files tnftp
|
|
run_cmd "(cd $wrkdir/tnftp; env $BSTRAP_ENV CPPFLAGS=\"$CPPFLAGS $tnftpxflags\" $shprog ./configure $configure_quiet_flags --prefix=$prefix --mandir=$mandir --sysconfdir=$sysconfdir && $bmake && (cd src && $bmake install))"
|
|
;;
|
|
esac
|
|
|
|
pkg_install_args="$pkg_install_args --with-ftp=$fetch_cmd"
|
|
|
|
FETCH_CMD="$fetch_cmd"
|
|
export FETCH_CMD
|
|
echo "FETCH_CMD= $fetch_cmd" >> ${MKCONF_EXAMPLE}
|
|
|
|
# we often need NetBSD's pax as well, nowadays, to make binary packages
|
|
case "$need_pax" in
|
|
yes) echo_msg "Installing pax"
|
|
copy_src $pkgsrcdir/archivers/pax/files pax
|
|
run_cmd "(cd $wrkdir/pax; env $BSTRAP_ENV CPPFLAGS='$CPPFLAGS -I../libnbcompat' LDFLAGS='$LDFLAGS -L../libnbcompat' LIBS='-lnbcompat' $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --mandir=$mandir --sysconfdir=$sysconfdir && $bmake && $bmake install)"
|
|
echo "TOOLS_PLATFORM.pax?= $prefix/bin/pax" >> ${MKCONF_EXAMPLE}
|
|
echo "TOOLS_PLATFORM.tar?= $prefix/bin/tar" >> ${MKCONF_EXAMPLE}
|
|
pkg_install_args="$pkg_install_args --with-pax=$prefix/bin/pax --with-tar=$prefix/bin/tar"
|
|
;;
|
|
*)
|
|
pkg_install_args="$pkg_install_args --with-pax=$paxprog --with-tar=$tarprog"
|
|
;;
|
|
esac
|
|
|
|
# bootstrap mtree if necessary
|
|
case "$need_mtree" in
|
|
yes) echo_msg "Installing mtree"
|
|
copy_src $pkgsrcdir/pkgtools/mtree/files mtree
|
|
run_cmd "(cd $wrkdir/mtree; env $BSTRAP_ENV CPPFLAGS='$CPPFLAGS -I../libnbcompat' LDFLAGS='$LDFLAGS -L../libnbcompat' LIBS='-lnbcompat' $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --mandir=$mandir --sysconfdir=$sysconfdir && $bmake && $bmake install)"
|
|
echo "TOOLS_PLATFORM.mtree?= $prefix/sbin/mtree" >> ${MKCONF_EXAMPLE}
|
|
pkg_install_args="$pkg_install_args --with-mtree=$prefix/sbin/mtree"
|
|
;;
|
|
*) pkg_install_args="$pkg_install_args --with-mtree=$mtreeprog"
|
|
;;
|
|
esac
|
|
|
|
# bootstrap pkg_install
|
|
echo_msg "Installing pkgtools"
|
|
copy_src $pkgsrcdir/pkgtools/pkg_install/files pkg_install
|
|
run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV CPPFLAGS='$CPPFLAGS -I../libnbcompat -I../../libnbcompat' LDFLAGS='$LDFLAGS -L../libnbcompat -L../../libnbcompat' LIBS='-lnbcompat' $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --sysconfdir=$sysconfdir --with-pkgdbdir=$pkgdbdir --mandir=$mandir $pkg_install_args && $bmake && $bmake install)"
|
|
|
|
# preserve compiler and tool environment variables settings
|
|
test -z "$CP" || echo "TOOLS_PLATFORM.cp?= $CP" >> ${MKCONF_EXAMPLE}
|
|
test -z "$GREP" || echo "TOOLS_PLATFORM.grep?= $GREP" >> ${MKCONF_EXAMPLE}
|
|
test -z "$ID" || echo "TOOLS_PLATFORM.id?= $ID" >> ${MKCONF_EXAMPLE}
|
|
test -z "$MKDIR" || echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${MKCONF_EXAMPLE}
|
|
test -z "$TEST" || echo "TOOLS_PLATFORM.test?= $TEST" >> ${MKCONF_EXAMPLE}
|
|
test -z "$TOUCH" || echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${MKCONF_EXAMPLE}
|
|
test -z "$XARGS" || echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${MKCONF_EXAMPLE}
|
|
test -z "$CFLAGS" || (
|
|
echo "CFLAGS+= $CFLAGS" >> ${MKCONF_EXAMPLE}
|
|
echo "DBG= # prevent DBG from adding default optimizer flags" >> ${MKCONF_EXAMPLE}
|
|
)
|
|
test -z "$CPPFLAGS" || echo "CPPFLAGS+= $CPPFLAGS" >> ${MKCONF_EXAMPLE}
|
|
test -z "$LDFLAGS" || echo "LDFLAGS+= $LDFLAGS" >> ${MKCONF_EXAMPLE}
|
|
|
|
# opsys specific fiddling
|
|
opsys_finish
|
|
|
|
echo "" >> ${MKCONF_EXAMPLE}
|
|
echo ".endif # end pkgsrc settings" >> ${MKCONF_EXAMPLE}
|
|
|
|
# register packages
|
|
# usage: register_package <packagedirectory> [additional arguments]
|
|
register_package() {
|
|
run_cmd "(cd $pkgsrcdir/$1 && $bmake MAKECONF=${MKCONF_EXAMPLE} WRKOBJDIR=${wrkobjdir} ${2-} bootstrap-register)"
|
|
}
|
|
|
|
echo_msg "Registering installed packages"
|
|
run_cmd "(cd $pkgsrcdir/pkgtools/bootstrap-mk-files && $bmake MAKECONF=${MKCONF_EXAMPLE} WRKOBJDIR=$wrkobjdir bootstrap-register)"
|
|
case "$need_awk" in
|
|
yes) register_package "lang/nawk";;
|
|
esac
|
|
case "$need_sed" in
|
|
yes) register_package "textproc/nbsed" "LIBNBCOMPAT_STYLE=inplace";;
|
|
esac
|
|
case "$need_bsd_install" in
|
|
yes) register_package "sysutils/install-sh";;
|
|
esac
|
|
case "$need_extras" in
|
|
yes) register_package "pkgtools/bootstrap-extras";;
|
|
esac
|
|
case "$need_ftp" in
|
|
yes) register_package "pkgtools/tnftp";;
|
|
esac
|
|
case "$need_mtree" in
|
|
yes) register_package "pkgtools/mtree";;
|
|
esac
|
|
case "$need_pax" in
|
|
yes) register_package "pkgtools/pax";;
|
|
esac
|
|
register_package "pkgtools/pkg_install"
|
|
|
|
# Install the man page.
|
|
echo_msg "Installing packages(7) man page"
|
|
run_cmd "(cd $pkgsrcdir/pkgtools/pkgmanpages && $bmake PKG_VERBOSE=yes MAKECONF=${MKCONF_EXAMPLE} WRKOBJDIR=$wrkobjdir CREATE_WRKDIR_SYMLINK=no install)"
|
|
|
|
hline="==========================================================================="
|
|
echo ""
|
|
echo "$hline"
|
|
echo ""
|
|
echo "Please remember to add $prefix/bin to your PATH environment variable"
|
|
echo "and $mandir to your MANPATH environment variable, if necessary."
|
|
echo ""
|
|
echo "An example mk.conf file with the settings you provided to \"bootstrap\""
|
|
echo "has been created for you. It can be found in:"
|
|
echo ""
|
|
echo " ${MKCONF_EXAMPLE}"
|
|
echo ""
|
|
echo "Please copy it to ${sysconfdir}/mk.conf to use it."
|
|
echo ""
|
|
echo "You can find extensive documentation of the NetBSD Packages Collection"
|
|
echo "in $pkgsrcdir/doc/pkgsrc.txt and packages(7)."
|
|
echo ""
|
|
echo "Hopefully everything is now complete."
|
|
echo "Thank you"
|
|
echo ""
|
|
echo "$hline"
|
|
echo ""
|
|
|
|
echo_msg "bootstrap started: $build_start"
|
|
echo_msg "bootstrap ended: `date`"
|
|
|
|
exit 0
|