Skip to content

Instantly share code, notes, and snippets.

@cr1901
Last active August 29, 2015 14:03
Show Gist options
  • Save cr1901/07b8e6810caedc31fe7c to your computer and use it in GitHub Desktop.
Save cr1901/07b8e6810caedc31fe7c to your computer and use it in GitHub Desktop.
NetBSD ./build.sh generator for separate builds
#!/bin/sh
define(`_CONTAINER_NAME', `ARCH'`-'`TARGET')dnl
define(`_CAPITALIZE', `translit($1, a-z, A-Z)')dnl
define(`_NETBSD_XSRC', ifdef(`BUILD_X', ` -x -X ../xsrc'))dnl
define(`_TOOLS_SUB', ifdef(`TOOLS_SUBDIR', TOOLS_SUBDIR, _CONTAINER_NAME))dnl
NETBSD_SRC=NETBSD_SRC_DIR
MAKECONF=MAKECONF_DIR/mk.conf._CONTAINER_NAME
print_usage_and_exit()
{
echo "Usage: $0 [-u] [-j num_jobs]"
exit -1
}
UPDATE=""
JOBS=""
if [ "$#" -eq 1 ]; then
if [ "$1" = "-u" ]; then
UPDATE="-u"
elif [ "$1" = "-uj" ]; then
echo "-j requires an argument."
exit -2
else
print_usage_and_exit
fi
elif [ "$#" -eq 2 ]; then
if [ "$1" = "-j" ]; then
JOBS="-j $2"
elif [ "$1" = "-uj" ]; then
JOBS="-j $2"
UPDATE="-u"
else
print_usage_and_exit
fi
elif [ "$#" -eq 3 ]; then
if [ "$1" = "-j" ]; then
JOBS="-j $2"
if [ "$3" = "-u" ]; then
UPDATE="-u"
else
print_usage_and_exit
fi
elif [ "$1" = "-u" ]; then
UPDATE="-u"
if [ "$2" = "-j" ]; then
JOBS="-j $3"
else
print_usage_and_exit
fi
else
print_usage_and_exit
fi
fi
define(_CTRG, _CAPITALIZE(TARGET))dnl
_CTRG`'BUILD="./build.sh -m ARCH -U -O ../objdir/_CONTAINER_NAME -T ../tools/_TOOLS_SUB -D ../destdir/_CONTAINER_NAME -R ../releasedir/_CONTAINER_NAME`'_NETBSD_XSRC"
#Assumes MAKECONF_DIR is writeable!
if [ ! -e "$MAKECONF" ] ; then
touch "$MAKECONF"
fi
cd $NETBSD_SRC
export MAKECONF
$_CTRG`'BUILD $UPDATE $JOBS tools kernel=KERNEL_NAME release || exit $?
#!/bin/sh
NETBSD_SRC_DIR=/usr/src
MAKECONF_DIR=/etc
TOOLS_SUBDIR=.
#Make sure to change $NETBSD_SRC_DIR_HERE and $MAKECONF_DIR_HERE to the proper locations :)!
m4 -DARCH=evbearmv6hf-el -DTARGET=rpi -DNETBSD_SRC_DIR=$NETBSD_SRC_DIR -DMAKECONF_DIR=$MAKECONF_DIR -DTOOLS_SUBDIR=$TOOLS_SUBDIR -DKERNEL_NAME=RPI build.m4 > rpibuild.sh
m4 -DARCH=i386 -DTARGET=std -DNETBSD_SRC_DIR=$NETBSD_SRC_DIR -DMAKECONF_DIR=$MAKECONF_DIR -DTOOLS_SUBDIR=$TOOLS_SUBDIR -DKERNEL_NAME=GENERIC -DBUILD_X build.m4 > gen_i386build.sh
chmod 755 *build.sh
#!/bin/sh
NETBSD_SRC_DIR=/usr/src
if [ $# != 1 ]; then
echo "Please select a build to remove."
exit 1
fi
cd $NETBSD_SRC_DIR
rm -rf ./objdir/$1
rm -rf ./destdir/$1
rm -rf ./releasedir/$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment