build: make repositories customisable; fixes #8

This commit is contained in:
Franco Fichtner 2015-06-09 10:14:37 +02:00
parent a5814e2465
commit 7ddb44e22e
2 changed files with 40 additions and 9 deletions

View File

@ -19,6 +19,10 @@ NAME?= OPNsense
FLAVOUR?= OpenSSL
_VERSION!= date '+%Y%m%d%H%M'
VERSION?= ${_VERSION}
TOOLSDIR?= /usr/tools
PORTSDIR?= /usr/ports
COREDIR?= /usr/core
SRCDIR?= /usr/src
# A couple of meta-targets for easy use:
@ -44,5 +48,7 @@ ${TARGET}: ${_TARGET}
.for STEP in ${STEPS}
${STEP}:
@cd build && sh ./${.TARGET}.sh \
-f ${FLAVOUR} -n ${NAME} -v ${VERSION} ${${STEP}_ARGS}
-f ${FLAVOUR} -n ${NAME} -v ${VERSION} \
-S ${SRCDIR} -P ${PORTSDIR} -T ${TOOLSDIR} \
-C ${COREDIR} ${${STEP}_ARGS}
.endfor

View File

@ -29,8 +29,21 @@ set -e
SCRUB_ARGS=:
while getopts n:f:v: OPT; do
# clear these to make sure they are passed by the caller
PRODUCT_FLAVOUR=
PRODUCT_VERSION=
PRODUCT_NAME=
TOOLSDIR=
PORTSDIR=
COREDIR=
SRCDIR=
while getopts C:f:n:P:S:T:v: OPT; do
case ${OPT} in
C)
export COREDIR=${OPTARG}
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
;;
f)
export PRODUCT_FLAVOUR=${OPTARG}
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
@ -39,6 +52,18 @@ while getopts n:f:v: OPT; do
export PRODUCT_NAME=${OPTARG}
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
;;
P)
export PORTSDIR=${OPTARG}
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
;;
S)
export SRCDIR=${OPTARG}
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
;;
T)
export TOOLSDIR=${OPTARG}
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
;;
v)
export PRODUCT_VERSION=${OPTARG}
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
@ -50,7 +75,13 @@ while getopts n:f:v: OPT; do
esac
done
if [ -z "${PRODUCT_NAME}" -o -z "${PRODUCT_FLAVOUR}" -o -z "${PRODUCT_VERSION}" ]; then
if [ -z "${PRODUCT_NAME}" -o \
-z "${PRODUCT_FLAVOUR}" -o \
-z "${PRODUCT_VERSION}" -o \
-z "${TOOLSDIR}" -o \
-z "${PORTSDIR}" -o \
-z "${COREDIR}" -o \
-z "${SRCDIR}" ]; then
echo "Oops, please use the make targets to execute the build step." >&2
exit 1
fi
@ -58,12 +89,6 @@ fi
# full name for easy use
export PRODUCT_RELEASE="${PRODUCT_NAME}-${PRODUCT_VERSION}_${PRODUCT_FLAVOUR}"
# code reositories
export TOOLSDIR="/usr/tools"
export PORTSDIR="/usr/ports"
export COREDIR="/usr/core"
export SRCDIR="/usr/src"
# misc. foo
export PRODUCT_CONFIG="${TOOLSDIR}/config/${PRODUCT_NAME}"
export CPUS=$(sysctl kern.smp.cpus | awk '{ print $2 }')