2014-11-09 10:57:12 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2021-07-08 12:05:40 +02:00
|
|
|
# Copyright (c) 2014-2021 Franco Fichtner <franco@opnsense.org>
|
2014-11-09 10:57:12 +01:00
|
|
|
#
|
|
|
|
# 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.
|
2014-11-09 11:06:26 +01:00
|
|
|
#
|
2014-11-09 10:57:12 +01:00
|
|
|
# 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
|
|
|
|
|
2016-05-05 17:11:45 +02:00
|
|
|
SELF=kernel
|
|
|
|
|
2017-04-27 19:14:36 +02:00
|
|
|
. ./common.sh
|
2014-11-09 10:57:12 +01:00
|
|
|
|
2021-07-08 12:05:40 +02:00
|
|
|
KERNELSET=$(find_set kernel)
|
2016-01-20 10:43:35 +01:00
|
|
|
|
2021-07-08 12:05:40 +02:00
|
|
|
if [ -f "${KERNELSET}" -a -z "${1}" ]; then
|
|
|
|
echo ">>> Reusing kernel set: ${KERNELSET}"
|
2016-01-20 10:43:35 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-01-11 07:31:06 +01:00
|
|
|
git_branch ${SRCDIR} ${SRCBRANCH} SRCBRANCH
|
2021-09-03 20:04:12 +02:00
|
|
|
if [ -z "${VERSION}" ]; then # XXX
|
2021-09-01 14:15:30 +02:00
|
|
|
git_describe ${SRCDIR}
|
2021-09-03 20:04:12 +02:00
|
|
|
PRODUCT_VERSION=${REPO_VERSION}
|
2021-09-01 14:15:30 +02:00
|
|
|
fi
|
2016-01-31 12:12:55 +01:00
|
|
|
|
2021-09-03 20:04:12 +02:00
|
|
|
KERNEL_DEBUG_SET=${SETSDIR}/kernel-dbg-${PRODUCT_VERSION}-${PRODUCT_ARCH}${PRODUCT_DEVICE+"-${PRODUCT_DEVICE}"}.txz
|
|
|
|
KERNEL_RELEASE_SET=${SETSDIR}/kernel-${PRODUCT_VERSION}-${PRODUCT_ARCH}${PRODUCT_DEVICE+"-${PRODUCT_DEVICE}"}.txz
|
2016-01-31 12:12:55 +01:00
|
|
|
|
2017-08-29 09:24:46 +02:00
|
|
|
if [ -f ${CONFIGDIR}/${PRODUCT_KERNEL} ]; then
|
2016-12-26 11:08:46 +01:00
|
|
|
cp "${CONFIGDIR}/${PRODUCT_KERNEL}" \
|
|
|
|
"${SRCDIR}/sys/${PRODUCT_TARGET}/conf/${PRODUCT_KERNEL}"
|
2016-07-18 07:10:15 +02:00
|
|
|
fi
|
2014-11-15 15:54:43 +01:00
|
|
|
|
2017-11-28 07:17:52 +01:00
|
|
|
MAKE_ARGS="
|
|
|
|
TARGET_ARCH=${PRODUCT_ARCH}
|
|
|
|
TARGET=${PRODUCT_TARGET}
|
|
|
|
KERNCONF=${PRODUCT_KERNEL}
|
|
|
|
SRCCONF=${CONFIGDIR}/src.conf
|
|
|
|
__MAKE_CONF=
|
2019-02-13 21:39:48 +01:00
|
|
|
${MAKE_ARGS_DEV}
|
2017-11-28 07:17:52 +01:00
|
|
|
"
|
2014-11-09 10:57:12 +01:00
|
|
|
|
2021-08-19 11:04:01 +02:00
|
|
|
${ENV_FILTER} make -s -C${SRCDIR} -j${CPUS} kernel-toolchain ${MAKE_ARGS} NO_CLEAN=yes
|
2016-07-19 16:39:54 +02:00
|
|
|
${ENV_FILTER} make -s -C${SRCDIR} -j${CPUS} buildkernel ${MAKE_ARGS} NO_KERNELCLEAN=yes
|
2021-08-19 10:18:45 +02:00
|
|
|
if [ "${1}" = "build" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
2016-07-19 16:39:54 +02:00
|
|
|
${ENV_FILTER} make -s -C${SRCDIR}/release obj ${MAKE_ARGS}
|
2017-03-25 04:26:21 +01:00
|
|
|
|
2018-10-12 19:26:06 +02:00
|
|
|
# reset the distribution directory
|
2021-02-24 10:33:10 +01:00
|
|
|
KERNEL_DISTDIR="$(make -C${SRCDIR}/release -v DISTDIR ${MAKE_ARGS})/${SELF}"
|
|
|
|
KERNEL_OBJDIR="$(make -C${SRCDIR}/release -v .OBJDIR ${MAKE_ARGS})"
|
2018-10-12 19:26:06 +02:00
|
|
|
setup_stage "${KERNEL_OBJDIR}/${KERNEL_DISTDIR}"
|
2017-03-25 04:26:21 +01:00
|
|
|
|
2018-10-12 19:26:06 +02:00
|
|
|
# remove older object archives, too
|
2021-02-24 10:33:10 +01:00
|
|
|
KERNEL_OBJ=$(make -C${SRCDIR}/release -v .OBJDIR ${MAKE_ARGS})/kernel.txz
|
|
|
|
DEBUG_OBJ=$(make -C${SRCDIR}/release -v .OBJDIR ${MAKE_ARGS})/kernel-dbg.txz
|
2017-08-07 08:24:56 +02:00
|
|
|
rm -f ${KERNEL_OBJ} ${DEBUG_OBJ}
|
2018-10-12 19:26:06 +02:00
|
|
|
|
|
|
|
# We used kernel.txz because we did not rewrite it,
|
|
|
|
# but as time went on and version info was embedded
|
|
|
|
# for tighter signature verification handling it is
|
|
|
|
# a convoluted action, but the archive gives us a
|
|
|
|
# full update set so we repack it instead of using
|
|
|
|
# src-related commands here too loosely...
|
2016-07-19 16:39:54 +02:00
|
|
|
${ENV_FILTER} make -s -C${SRCDIR}/release kernel.txz ${MAKE_ARGS}
|
2014-11-09 10:57:12 +01:00
|
|
|
|
2016-09-28 01:57:43 +02:00
|
|
|
sh ./clean.sh ${SELF}
|
|
|
|
|
2018-10-12 18:41:12 +02:00
|
|
|
setup_stage ${STAGEDIR} work
|
2018-10-15 07:48:05 +02:00
|
|
|
setup_set ${STAGEDIR}/work ${KERNEL_OBJ}
|
2018-10-12 19:26:06 +02:00
|
|
|
|
2021-07-08 12:05:40 +02:00
|
|
|
KERNELSET=${KERNEL_RELEASE_SET}
|
2018-10-12 18:41:12 +02:00
|
|
|
|
2018-10-12 19:26:06 +02:00
|
|
|
if [ -n "$(test -f ${DEBUG_OBJ} && tar -tf ${DEBUG_OBJ})" ]; then
|
2018-10-15 07:48:05 +02:00
|
|
|
setup_set ${STAGEDIR}/work ${DEBUG_OBJ}
|
2021-07-08 12:05:40 +02:00
|
|
|
KERNELSET=${KERNEL_DEBUG_SET}
|
2017-08-07 08:24:56 +02:00
|
|
|
fi
|
2016-10-03 04:36:00 +02:00
|
|
|
|
2018-10-15 07:48:05 +02:00
|
|
|
setup_version ${STAGEDIR} ${STAGEDIR}/work ${SELF}
|
2021-07-08 12:05:40 +02:00
|
|
|
generate_set ${STAGEDIR}/work ${KERNELSET}
|
|
|
|
generate_signature ${KERNELSET}
|