mirror of
https://github.com/opnsense/tools.git
synced 2026-12-04 01:18:19 +00:00
With this we can make hotfixes much better visible, repeatable
and manageable.
makedist generates the RECIPE distribution file for later
use making sure to use the suffix, repeatable commit hash and
write-tree hash. The package respositories will build upon
all of those when specifying RECIPE which makes checking the
version against tampering very easy. Tree hash visibility
is also available in core and plugin components with
# opnsense-version -T <core_or_plugin_name>
The dist file also has a way of enforcing that the content of the
conf file is valid by registering a hash of its content in dist.
It's true that every whitespace change will change the CONFDIGEST
but I also see no point in touching the recipe if it works.
Let the patch stage know which packages should be run through
the hotfix stage while adhering to RECIPE when building from
the authorative branch even though we may leave it due to the
modifications. It also passes all the to be rebuilt packages
to the hotfix step at once, which may need more scrutiny later
on but should be fine now that we an also expand implicit ports
through hotfix.
The interesting aspects are that:
1. recipe/patch use is entirely optional even for hotfixes or
full patch releases.
2. it uses the same infrastructure but makes the build repeatable
which could also be published especially if commit and tree
hashes are no longer matching what's in the stable branches.
3. it self-documents the used components even if we don't use
the patch build and the dist file also records matching hashes
of src, ports, plugins and core repositories.
While here remove old COREVERSION support because the RECIPE has
the same type of support and it was largely unused because it was
missing the right facility to be used from.
-devel rebuilds are a bit of a hit and miss but that was always
the case before. In the average case offering the rebuild as
well is fine since without EXTRABRANCH=master we don't see these
packages and they are not rebuild. If they are expected they use
the latest master branch state at the time of the build which is
also what should be the expected outcome. In the latter case
one needs to remember to run the update target beforehand. Most
things hotfixed also apply to the master branch wanting these
shipped as well.
119 lines
4.0 KiB
Bash
119 lines
4.0 KiB
Bash
#!/bin/sh
|
|
|
|
# Copyright (c) 2014-2026 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
|
|
|
|
SELF=kernel
|
|
|
|
. ./common.sh
|
|
|
|
KERNELSET=$(find_set kernel)
|
|
|
|
if [ -f "${KERNELSET}" -a -z "${1}" ]; then
|
|
echo ">>> Reusing kernel set: ${KERNELSET}"
|
|
exit 0
|
|
fi
|
|
|
|
git_branch ${SRCDIR} ${SRCBRANCH} SRCBRANCH
|
|
[ -n "${RECIPE}" ] && git_recipe / src SRCDIGEST
|
|
git_version ${SRCDIR}
|
|
|
|
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
|
|
|
|
KERNDEBUG=default
|
|
SRCDEBUG="WITHOUT_DEBUG_FILES=yes"
|
|
|
|
if [ -n "${PRODUCT_DEBUG}" ]; then
|
|
KERNDEBUG=debug
|
|
SRCDEBUG=
|
|
fi
|
|
|
|
if [ -f "${CONFIGDIR}/${PRODUCT_KERNEL}" ]; then
|
|
sed -e "/%%DEBUG%%/r ${CONFIGDIR}/kernel.${KERNDEBUG}" \
|
|
"${CONFIGDIR}/${PRODUCT_KERNEL}" | grep -v %%DEBUG%% > \
|
|
"${SRCDIR}/sys/${PRODUCT_TARGET}/conf/${PRODUCT_KERNEL}"
|
|
else
|
|
echo ">>> Attempting to use external kernel: ${PRODUCT_KERNEL}"
|
|
fi
|
|
|
|
MAKE_ARGS="
|
|
TARGET_ARCH=${PRODUCT_ARCH}
|
|
TARGET=${PRODUCT_TARGET}
|
|
KERNCONF=${PRODUCT_KERNEL}
|
|
SRCCONF=${CONFIGDIR}/src.conf
|
|
${SRCDEBUG}
|
|
__MAKE_CONF=
|
|
${MAKE_ARGS_DEV}
|
|
"
|
|
|
|
${ENV_FILTER} make -s -C${SRCDIR} -j${CPUS} kernel-toolchain ${MAKE_ARGS}
|
|
${ENV_FILTER} make -s -C${SRCDIR} -j${CPUS} buildkernel ${MAKE_ARGS}
|
|
if [ "${1}" = "build" ]; then
|
|
exit 0
|
|
fi
|
|
${ENV_FILTER} make -s -C${SRCDIR}/release obj ${MAKE_ARGS}
|
|
|
|
# reset the distribution directory
|
|
KERNEL_DISTDIR="$(make -C${SRCDIR}/release -v DISTDIR ${MAKE_ARGS})/${SELF}"
|
|
KERNEL_OBJDIR="$(make -C${SRCDIR}/release -v .OBJDIR ${MAKE_ARGS})"
|
|
setup_stage "${KERNEL_OBJDIR}/${KERNEL_DISTDIR}"
|
|
|
|
# remove older object archives, too
|
|
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
|
|
rm -f ${KERNEL_OBJ} ${DEBUG_OBJ}
|
|
|
|
# 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...
|
|
${ENV_FILTER} make -s -C${SRCDIR}/release kernel.txz ${MAKE_ARGS}
|
|
|
|
sh ./clean.sh ${SELF}
|
|
|
|
setup_stage ${STAGEDIR} work
|
|
setup_base ${STAGEDIR}
|
|
setup_chroot ${STAGEDIR}
|
|
|
|
setup_set ${STAGEDIR}/work ${KERNEL_OBJ}
|
|
KERNELSET=${KERNEL_RELEASE_SET}
|
|
|
|
if [ -n "$(test -f ${DEBUG_OBJ} && tar -tf ${DEBUG_OBJ})" ]; then
|
|
setup_set ${STAGEDIR}/work ${DEBUG_OBJ}
|
|
KERNELSET=${KERNEL_DEBUG_SET}
|
|
fi
|
|
|
|
# avoid wrong linker.hints checksum with correct base utility
|
|
chroot ${STAGEDIR} /usr/sbin/kldxref -R /work/boot/kernel
|
|
|
|
setup_version ${STAGEDIR} ${STAGEDIR}/work ${SELF}
|
|
generate_set ${STAGEDIR}/work ${KERNELSET}
|
|
generate_signature ${KERNELSET}
|