build: add a Makefile as a sane launch pad...
o Talking to Shawn Webb revealed that build.conf behaviour is still fragile. This will properly invoke all build steps with the variables that are allowed to be overridden. o Adds an external CONFIG that is allowed to set NAME, VERSION, FLAVOUR. o Remove persistent environment awareness. o Document the whole thing. There's still some things to do in order to do parallel builds, but at least now the build scripts can't be poisoned by a changing config file underneath.
This commit is contained in:
parent
18cca8ccbf
commit
5b550b2045
|
@ -1 +0,0 @@
|
|||
/config/build.conf
|
|
@ -0,0 +1,22 @@
|
|||
BUILDSCRIPTS= base kernel ports core iso memstick nano \
|
||||
regress clean release
|
||||
.PHONY: ${BUILDSCRIPTS}
|
||||
|
||||
.if defined(CONFIG)
|
||||
.include "${CONFIG}"
|
||||
.endif
|
||||
|
||||
NAME?= OPNsense
|
||||
FLAVOUR?= OpenSSL
|
||||
_VERSION!= date '+%Y%m%d%H%M'
|
||||
VERSION?= ${_VERSION}
|
||||
|
||||
all:
|
||||
@cat ${.CURDIR}/README.md | ${PAGER}
|
||||
|
||||
.for BUILDSCRIPT in ${BUILDSCRIPTS}
|
||||
${BUILDSCRIPT}:
|
||||
@cd build && sh ./${.TARGET}.sh \
|
||||
-f ${FLAVOUR} -n ${NAME} -v ${VERSION} ${ARGS}
|
||||
.endfor
|
||||
|
44
README.md
44
README.md
|
@ -59,48 +59,45 @@ without affecting the others. All stages can be reinvoked
|
|||
and continue building without cleaning the previous progress.
|
||||
A final stage assembles all three stages into a target image.
|
||||
|
||||
Go to the build directory:
|
||||
All build steps are invoked via make(1):
|
||||
|
||||
# cd /usr/tools/build
|
||||
# make step OPTION="value"
|
||||
|
||||
Setup an additional build configuration (or skip to use the defaults):
|
||||
Available build options are:
|
||||
|
||||
# ./configure.sh -f flavour -n name -v version
|
||||
|
||||
Available options are:
|
||||
|
||||
* flavour: "OpenSSL" (default), "LibreSSL"
|
||||
* version: a version tag (if applicable)
|
||||
* name: "OPNsense" (default)
|
||||
* NAME: "OPNsense" (default)
|
||||
* FLAVOUR: "OpenSSL" (default), "LibreSSL"
|
||||
* VERSION: a version tag (if applicable)
|
||||
* CONFIG: reads the above from the specified file
|
||||
|
||||
Build the userland binaries, bootloader and administrative
|
||||
files:
|
||||
|
||||
# ./base.sh
|
||||
# make base
|
||||
|
||||
Build the kernel and loadable kernel modules:
|
||||
|
||||
# ./kernel.sh
|
||||
# make kernel
|
||||
|
||||
Build all the third-party ports:
|
||||
|
||||
# ./ports.sh
|
||||
# make ports
|
||||
|
||||
Wrap up our core as a package:
|
||||
|
||||
# ./core.sh
|
||||
# make core
|
||||
|
||||
A cdrom live image is created using:
|
||||
|
||||
# ./iso.sh
|
||||
# make iso
|
||||
|
||||
A memstick image for VGA and serial is created using:
|
||||
|
||||
# ./memstick.sh
|
||||
# make memstick
|
||||
|
||||
A direct disk image in NanoBSD style is created using:
|
||||
|
||||
# ./nano.sh
|
||||
# make nano
|
||||
|
||||
Some more random information
|
||||
============================
|
||||
|
@ -109,16 +106,12 @@ Before building images, you can run the regression tests
|
|||
to check the integrity of your core.git modifications plus
|
||||
generate output for the style checker:
|
||||
|
||||
# cd /usr/tools/build && ./regress.sh
|
||||
|
||||
The OPNsense core package can then be rebuilt on its own via:
|
||||
|
||||
# cd /usr/tools/build && ./core.sh
|
||||
# make regress
|
||||
|
||||
For very fast ports rebuilding of already installed packages
|
||||
the following works:
|
||||
|
||||
# cd /usr/tools/build && ./ports.sh [packagename ...]
|
||||
# make ports ARGS="packagename ..."
|
||||
|
||||
Package sets (may be signed depending on whether the key is
|
||||
found under /root) ready for web server deployment are automatically
|
||||
|
@ -126,7 +119,7 @@ generated and modified by ports.sh and core.sh.
|
|||
|
||||
Release sets can be built using:
|
||||
|
||||
# cd /usr/tools/build && ./release.sh [version]
|
||||
# make release [ARGS=version]
|
||||
|
||||
Kernel, base, packages and release sets are stored under /tmp/sets
|
||||
|
||||
|
@ -135,11 +128,10 @@ All final images are stored under /tmp/images
|
|||
A couple of build machine cleanup helpers are available
|
||||
via the clean script:
|
||||
|
||||
# cd /usr/tools/build && ./clean.sh what ...
|
||||
# make clean ARGS="what ..."
|
||||
|
||||
Available options are:
|
||||
|
||||
* env: scrub the build config and use defaults
|
||||
* images: remove all available images
|
||||
* obj: reset the kernel/base build directory
|
||||
* sets: remove all available sets
|
||||
|
|
|
@ -37,9 +37,6 @@ for ARG in ${@}; do
|
|||
obj) # previous staging cleanup
|
||||
setup_stage /usr/obj
|
||||
;;
|
||||
env) # kill config/build.conf
|
||||
scrub_env
|
||||
;;
|
||||
images)
|
||||
echo ">>> Removing ${IMAGESDIR}"
|
||||
rm -rf ${IMAGESDIR}
|
||||
|
|
|
@ -27,18 +27,29 @@
|
|||
|
||||
set -e
|
||||
|
||||
BUILD_CONF=../config/build.conf
|
||||
while getopts n:f:v: OPT; do
|
||||
case ${OPT} in
|
||||
f)
|
||||
export PRODUCT_FLAVOUR=${OPTARG}
|
||||
;;
|
||||
n)
|
||||
export PRODUCT_NAME=${OPTARG}
|
||||
;;
|
||||
v)
|
||||
export PRODUCT_VERSION=${OPTARG}
|
||||
;;
|
||||
*)
|
||||
echo "Usage: ${0} [-f flavour] [-n name] [-v version]" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# load previous settings
|
||||
if [ -f ${BUILD_CONF} ]; then
|
||||
. ${BUILD_CONF}
|
||||
if [ -z "${PRODUCT_NAME}" -o -z "${PRODUCT_FLAVOUR}" -o -z "${PRODUCT_VERSION}"]; then
|
||||
echo "Oops, please use the make targets to execute the build step." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# important build settings
|
||||
export PRODUCT_VERSION=${PRODUCT_VERSION:-$(date '+%Y%m%d%H%M')}
|
||||
export PRODUCT_FLAVOUR=${PRODUCT_FLAVOUR:-"OpenSSL"}
|
||||
export PRODUCT_NAME=${PRODUCT_NAME:-"OPNsense"}
|
||||
|
||||
# full name for easy use
|
||||
export PRODUCT_RELEASE="${PRODUCT_NAME}-${PRODUCT_VERSION}_${PRODUCT_FLAVOUR}"
|
||||
|
||||
|
@ -76,26 +87,6 @@ export NANOIMG="${IMAGESDIR}/${PRODUCT_RELEASE}-nano-${ARCH}.img"
|
|||
# print environment to showcase all of our variables
|
||||
env | sort
|
||||
|
||||
scrub_env()
|
||||
{
|
||||
rm -f ${BUILD_CONF}
|
||||
}
|
||||
|
||||
setup_env()
|
||||
{
|
||||
if [ -z "${1}" -a -z "${2}" -a -z "${3}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# clear previous env just in case
|
||||
scrub_env
|
||||
|
||||
# these variables are allowed to steer the build
|
||||
[ -n "${1}" ] && echo "export PRODUCT_NAME=${1}" >> ${BUILD_CONF}
|
||||
[ -n "${2}" ] && echo "export PRODUCT_FLAVOUR=${2}" >> ${BUILD_CONF}
|
||||
[ -n "${3}" ] && echo "export PRODUCT_VERSION=${3}" >> ${BUILD_CONF}
|
||||
}
|
||||
|
||||
git_clear()
|
||||
{
|
||||
# Reset the git repository into a known state by
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (c) 2015 Franco Fichtner <franco@opnsense.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
set -e
|
||||
|
||||
. ./common.sh
|
||||
|
||||
while getopts n:f:v: OPT; do
|
||||
case ${OPT} in
|
||||
f)
|
||||
FLAVOUR=${OPTARG}
|
||||
;;
|
||||
n)
|
||||
NAME=${OPTARG}
|
||||
;;
|
||||
v)
|
||||
VERSION=${OPTARG}
|
||||
;;
|
||||
*)
|
||||
echo "Usage: configure.sh [-f flavour] [-n name] [-v version]" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
setup_env "${NAME}" "${FLAVOUR}" "${VERSION}"
|
Loading…
Reference in New Issue