build/configure: persistent build options

Inspired by: Shawn Webb's HardenedBSD patches
This commit is contained in:
Franco Fichtner 2015-05-12 11:07:47 +02:00
parent 82f28d8c8c
commit c553750143
3 changed files with 69 additions and 1 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/config/build.conf

View File

@ -27,6 +27,13 @@
set -e
BUILD_CONF=../config/build.conf
# load previous settings
if [ -f ${BUILD_CONF} ]; then
. ${BUILD_CONF}
fi
# important build settings
export PRODUCT_VERSION=${PRODUCT_VERSION:-$(date '+%Y%m%d%H%M')}
export PRODUCT_FLAVOUR=${PRODUCT_FLAVOUR:-"OpenSSL"}
@ -67,7 +74,17 @@ export VGAIMG="${IMAGESDIR}/${PRODUCT_RELEASE}-vga-${ARCH}.img"
export NANOIMG="${IMAGESDIR}/${PRODUCT_RELEASE}-nano-${ARCH}.img"
# print environment to showcase all of our variables
env
env | sort
setup_env()
{
rm -f ${BUILD_CONF}
# 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()
{

50
build/configure.sh Executable file
View File

@ -0,0 +1,50 @@
#!/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}"