0a12b7b9cb
difference on some platforms is an exercise left to the reader, but the current pkgsrc convention is #!<program> without the space, so this is if nothing else, a consistency fix.
127 lines
3.3 KiB
Bash
Executable file
127 lines
3.3 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
# $NetBSD: mkbinarykit,v 1.5 2004/04/04 02:01:28 grant Exp $
|
|
#
|
|
# Make a binary bootstrap kit and place it in targetdir (or current
|
|
# working directory if not specified). The mk.conf.example file is
|
|
# copied to /etc/mk.conf (or /etc/mk.conf.example on systems which
|
|
# may already have a /etc/mk.conf file) or to the location specified
|
|
# by using --mkconf. Run this program from the bootstrap-pkgsrc
|
|
# directory.
|
|
|
|
usage="Usage: $0 "'
|
|
[ --force ] [ --targetdir=<tar target dir> ] [ --mkconf=<target> ]
|
|
[ --no-build ] [ --workdir=<work dir> ] [ bootstrap script arguments ]'
|
|
|
|
opsys=`uname -s`
|
|
osrev=`uname -r`
|
|
ospro=`uname -p`
|
|
date=`date +%Y%m%d`
|
|
|
|
prefix=/usr/pkg
|
|
pkgdbdir=/var/db/pkg
|
|
pkgsrcdir=/usr/pkgsrc
|
|
mkfile=/etc/mk.conf
|
|
ignorecasecheck=no
|
|
force=no
|
|
build=yes
|
|
targetdir=`pwd`
|
|
wrkdir=work # default: relative to pkgsrc/bootstrap
|
|
|
|
sedprog="sed"
|
|
|
|
case "$opsys" in
|
|
AIX)
|
|
mkfile=/usr/pkg/etc/mk.conf
|
|
pkgdbdir=/usr/pkg/pkgdb
|
|
;;
|
|
FreeBSD)
|
|
# Don't use the ports /var/db/pkg
|
|
pkgdbdir=/usr/pkg/pkgdb
|
|
;;
|
|
Interix)
|
|
mkfile=/etc/mk.conf.example
|
|
# Don't use the interopsystems.com package dir
|
|
pkgdbdir=/usr/pkg/pkgdb
|
|
ospro=i386
|
|
;;
|
|
NetBSD)
|
|
# Don't overwrite the system's mk.conf
|
|
mkfile=/etc/mk.conf.example
|
|
;;
|
|
OpenBSD)
|
|
# Don't overwrite the system's mk.conf
|
|
mkfile=/etc/mk.conf.example
|
|
# Don't use the ports /var/db/pkg
|
|
pkgdbdir=/usr/pkg/pkgdb
|
|
# Use "arch -s" instead of uname -p
|
|
ospro=`arch -s`
|
|
;;
|
|
SunOS)
|
|
sedprog=/usr/xpg4/bin/sed
|
|
;;
|
|
esac
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case $1 in
|
|
--force) force=yes ;;
|
|
--no-build) build=no ;;
|
|
--targetdir=*) targetdir=`echo $1 | $sedprog -e 's|--targetdir=||'` ;;
|
|
--prefix=*) prefix=`echo $1 | $sedprog -e 's|--prefix=||'` ;;
|
|
--mkconf=*) mkfile=`echo $1 | $sedprog -e 's|--mkconf=||'` ;;
|
|
--pkgdbdir=*) pkgdbdir=`echo $1 | $sedprog -e 's|--pkgdbdir=||'` ;;
|
|
--pkgsrcdir=*) pkgsrcdir=`echo $1 | $sedprog -e 's|--pkgsrcdir=||'` ;;
|
|
--ignore-case-check) ignorecasecheck=yes ;;
|
|
--workdir=*) wrkdir=`echo $1 | $sedprog -e 's|--workdir=||'` ;;
|
|
--*) echo "$usage"; exit 1 ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [ "$build" = "yes" ] && [ "$force" != "yes" ]; then
|
|
if [ -d "$prefix" ] || [ -d "$pkgdbdir" ]; then
|
|
echo "Some pkgsrc infrastructure exists on this system already."
|
|
echo "Use --force to move it out of the way."
|
|
exit 1
|
|
fi
|
|
elif [ "$build" = "yes" ]; then
|
|
mv -f "$prefix" "$prefix.$$"
|
|
mv -f "$pkgdbdir" "$pkgdbdir.$$"
|
|
mv -f "$mkfile" "$mkfile.$$"
|
|
fi
|
|
|
|
if [ "$build" != "no" ]; then
|
|
|
|
# Bootstrap
|
|
bootstrap_flags="--prefix=$prefix --pkgsrcdir=$pkgsrcdir --pkgdbdir=$pkgdbdir --workdir=$wrkdir"
|
|
if [ "$ignorecasecheck" = "yes" ]; then
|
|
bootstrap_flags="$bootstrap_flags --ignore-case-check"
|
|
fi
|
|
|
|
echo "Making bootstrap kit with"
|
|
echo "prefix = $prefix"
|
|
echo "pkgsrcdir = $pkgsrcdir"
|
|
echo "pkgdbdir = $pkgdbdir"
|
|
echo "mk.conf.example will be copied to $mkfile"
|
|
echo ""
|
|
|
|
./cleanup $wrkdir
|
|
./bootstrap $bootstrap_flags
|
|
if [ $? != "0" ]; then
|
|
echo "Bootstrap error."
|
|
exit 1;
|
|
fi
|
|
fi
|
|
|
|
# Make a tar ball
|
|
|
|
echo "Stripping binaries..."
|
|
strip "$prefix/"bin/*
|
|
strip "$prefix/"sbin/*
|
|
|
|
echo "Making binary kit."
|
|
cp ${wrkdir}/mk.conf.example $mkfile && \
|
|
cd / && \
|
|
tar -hcf "$targetdir/bootstrap-pkgsrc-$opsys-$osrev-$ospro-$date.tar" \
|
|
.$prefix .$pkgdbdir .$mkfile && \
|
|
ls -l "$targetdir/bootstrap-pkgsrc-$opsys-$osrev-$ospro-$date.tar"
|