build: lock down branches, can override through build.conf

Actually, build.conf can hold all overrides from the main Makefile
now.  This is pretty handy for OEMs now.  Thanks for the prodding
on IRC for this one.  :)
This commit is contained in:
Franco Fichtner 2016-12-23 16:27:48 +01:00
parent 5f116deb0b
commit ff437f6c95
15 changed files with 48 additions and 6 deletions

View File

@ -14,11 +14,14 @@ lint:
@sh -n ${.CURDIR}/build/${STEP}.sh
. endfor
# Load the custom options from a file:
# Special vars to load early build.conf settings:
TOOLSDIR?= /usr/tools
SETTINGS?= 16.7
CONFIG?= ${TOOLSDIR}/config/${SETTINGS}/build.conf
.if defined(CONFIG)
.include "${CONFIG}"
.endif
# Bootstrap the build options if not set:
@ -26,7 +29,6 @@ NAME?= OPNsense
TYPE?= ${NAME:tl}
SUFFIX?= #-devel
FLAVOUR?= OpenSSL
SETTINGS?= 16.7
_ARCH!= uname -p
ARCH?= ${_ARCH}
DEVICE?= a10
@ -43,10 +45,13 @@ VERSION?= ${_VERSION}
STAGEDIRPREFIX?=/usr/obj
PORTSREFDIR?= /usr/freebsd-ports
PLUGINSDIR?= /usr/plugins
TOOLSDIR?= /usr/tools
PLUGINSBRANCH?= master
PORTSDIR?= /usr/ports
PORTSBRANCH?= master
COREDIR?= /usr/core
COREBRANCH?= master
SRCDIR?= /usr/src
SRCBRANCH?= master
# A couple of meta-targets for easy use and ordering:

View File

@ -88,6 +88,9 @@ Available build options are:
* UEFI: "yes" for amd64 hybrid images with optional UEFI boot
* VERSION: a version tag (if applicable)
The default CONFIG file is under "config/SUBDIR/build.conf".
It can also be overrided by "/dev/null".
Build the userland binaries, bootloader and administrative
files:

View File

@ -38,6 +38,7 @@ if [ -f "${BASE_SET}" -a -z "${1}" ]; then
exit 0
fi
git_branch ${SRCDIR} ${SRCBRANCH}
git_describe ${SRCDIR}
BASE_SET=${SETSDIR}/base-${REPO_VERSION}-${PRODUCT_ARCH}

View File

@ -246,6 +246,7 @@ git_describe()
VERSION=$(git -C ${1} describe --abbrev=0 --always ${HEAD})
REVISION=$(git -C ${1} rev-list --count ${VERSION}..${HEAD})
COMMENT=$(git -C ${1} rev-list --max-count=1 ${HEAD} | cut -c1-9)
BRANCH=$(git -C ${1} rev-parse --abbrev-ref ${HEAD})
REFTYPE=$(git -C ${1} cat-file -t ${HEAD})
if [ "${REVISION}" != "0" ]; then
@ -256,6 +257,17 @@ git_describe()
export REPO_VERSION=${VERSION}
export REPO_COMMENT=${COMMENT}
export REPO_REFTYPE=${REFTYPE}
export REPO_BRANCH=${BRANCH}
}
git_branch()
{
# only check for consistency
if [ -n "${2}" -a "${2}" != \
"$(git -C ${1} rev-parse --abbrev-ref HEAD)" ]; then
echo ">>> ${1} does not match expected branch: ${2}"
exit 1
fi
}
git_tag()

View File

@ -48,6 +48,7 @@ if [ -z "${*}" ]; then
setup_clone ${STAGEDIR} ${COREDIR}
CORE_TAGS="bogus"
else
git_branch ${CORDIR} ${COREBRANCH}
CORE_TAGS="${*}"
fi

View File

@ -41,6 +41,9 @@ cat ${CONFIGDIR}/skim.conf ${CONFIGDIR}/ports.conf | \
done
)
git_branch ${SRCDIR} ${SRCBRANCH}
git_branch ${PORTSDIR} ${PORTSBRANCH}
setup_stage ${STAGEDIR}
setup_base ${STAGEDIR}
setup_clone ${STAGEDIR} ${PORTSDIR}

View File

@ -40,7 +40,9 @@ info()
{
git_describe ${2} ${TAGNAME}
echo "${1} ${2} ${REPO_VERSION} ${REPO_COMMENT} ${REPO_REFTYPE}"
cat << EOF
${1} ${2} ${REPO_VERSION} ${REPO_COMMENT} ${REPO_REFTYPE} ${REPO_BRANCH}
EOF
}
info tools ${TOOLSDIR}

View File

@ -38,6 +38,7 @@ if [ -f "${KERNEL_SET}" -a -z "${1}" ]; then
exit 0
fi
git_branch ${SRCDIR} ${SRCBRANCH}
git_describe ${SRCDIR}
KERNEL_SET=${SETSDIR}/kernel-${REPO_VERSION}-${PRODUCT_ARCH}

View File

@ -33,6 +33,8 @@ SELF=plugins
check_packages ${SELF} ${@}
git_branch ${PLUGINSDIR} ${PLUGINSBRANCH}
setup_stage ${STAGEDIR}
setup_base ${STAGEDIR}
setup_clone ${STAGEDIR} ${PLUGINSDIR}

View File

@ -53,6 +53,9 @@ done
check_packages ${SELF} ${@}
git_branch ${SRCDIR} ${SRCBRANCH}
git_branch ${PORTSDIR} ${PORTSBRANCH}
setup_stage ${STAGEDIR}
setup_base ${STAGEDIR}
setup_clone ${STAGEDIR} ${PORTSDIR}

View File

@ -45,6 +45,7 @@ cat ${CONFIGDIR}/skim.conf ${CONFIGDIR}/ports.conf | \
done
)
git_branch ${PORTSDIR} ${PORTSBRANCH}
git_update ${PORTSREFDIR} origin/master
git_checkout ${PORTSDIR} HEAD

View File

@ -31,6 +31,9 @@ SELF=test
. ./common.sh && $(${SCRUB_ARGS})
git_branch ${CORDIR} ${COREBRANCH}
git_branch ${PLUGINSDIR} ${PLUGINSBRANCH}
setup_stage ${STAGEDIR}
setup_base ${STAGEDIR}
setup_clone ${STAGEDIR} ${COREDIR}

View File

@ -43,6 +43,7 @@ if [ -f "${XTOOLS_SET}" -a -z "${1}" ]; then
exit 0
fi
git_branch ${SRCDIR} ${SRCBRANCH}
git_describe ${SRCDIR}
XTOOLS_SET=${SETSDIR}/xtools-${REPO_VERSION}-${PRODUCT_ARCH}.txz

2
config/16.7/build.conf Normal file
View File

@ -0,0 +1,2 @@
COREBRANCH?= stable/16.7
SRCBRANCH?= stable/16.7

2
config/17.1/build.conf Normal file
View File

@ -0,0 +1,2 @@
#COREBRANCH?= stable/17.1
#SRCBRANCH?= stable/17.1