NetBSD/makeall

From Segfault
Jump to: navigation, search
#!/bin/sh
#
# (c) lists@nerdbynature.de
#
# Update & compile kernel, userland and X11
#
KERNEL="$HOME"/config/VAIO
BEGIN="`date +%s`"

# use a proper kernelconfig
if [ ! -f "$KERNEL" ]; then
	KERNEL=GENERIC
fi

# which flavour do you want to try today?
if [ ! "$1" ]; then
	echo "Usage: "$0" RELEASE"
	echo "e.g. "$0" netbsd-3-1-RELEASE"
	exit 1
else
	RELEASE="$1"
fi

# set DEBUG to execute this script without compiling anything
if [ "$DEBUG" ]; then
	DEBUG=echo
	clear
	echo "DEBUG is enabled!"
else
	clear
fi

# sanity checks
echo 
echo    "This script will compile and install kernel, userland and x11 on `uname -n`."
echo    "Make sure you can run sudo(8) without a password!"
echo -n "Target release is "$RELEASE"/`uname -m`, kernel config is "$KERNEL", continue? (y/N) " && read c
if [ ! "$c" = "y" ]; then
	echo "Aborted."
	exit 1
fi

####################################################################
# kernel_cvs
cd /usr
$DEBUG export CVSROOT=anoncvs@anoncvs.be.NetBSD.org:/cvsroot
$DEBUG cvs -q -d$CVSROOT co -r $RELEASE -P src
cd src
$DEBUG cvs update

# kernel_compile
BEGIN_KRN="`date +%s`"

cd /usr/src/sys/arch/`uname -m`/conf
$DEBUG cp "$KERNEL" MYCONF
$DEBUG /usr/sbin/config MYCONF
cd ../compile/MYCONF
$DEBUG make depend
$DEBUG make
$DEBUG sudo mv /netbsd /netbsd.old
$DEBUG sudo cp netbsd /
END_KRN="`date +%s`"
echo "+++ Kernel compiled in `echo "scale=2; ($END_KRN - $BEGIN_KRN) / 60" | bc -l` minutes."

####################################################################
# userland_cvs
cd /usr/src
$DEBUG cvs -q -r $RELEASE update -P

# userland_compile
BEGIN_USR="`date +%s`"
$DEBUG sudo make build
END_USR="`date +%s`"
echo "+++ Userland compiled in `echo "scale=2; ($END_USR - $BEGIN_USR) / 60 / 60" | bc -l` hours."

####################################################################
# x11_cvs
cd /usr/xsrc
$DEBUG cvs -q -r $RELEASE update -P

# x11_compile
BEGIN_X11="`date +%s`"
$DEBUG sudo make build
END_X11="`date +%s`"
echo "+++ X11 compiled in `echo "scale=2; ($END_X11 - $BEGIN_X11) / 60 / 60" | bc -l` hours."
echo "+++ Skript took `echo "scale=2; ($END_X11 - $BEGIN) / 60 / 60" | bc -l` hours to complete."