Lts kernel compile 5.10 all tarball

From embeddedTS Manuals
Revision as of 12:13, 20 April 2023 by Kris (talk | contribs)
#!/bin/bash

# Generic build script that is designed to output a kernel tarball
# Normally builds zImage, also can build uImage if LOADADDR is defined before calling the
# script.
# Need to export CROSS_COMPILE ahead of time.
export CROSS_COMPILE=arm-linux-gnueabihf-
export ARCH=arm
export WILC=y


TARGETS=zImage
if [ -n "${LOADADDR}" ]; then TARGETS+=uImage; fi

make -j$(nproc) && make "${TARGETS}" && make modules

TEMPDIR=$(mktemp -d)
TEMPFILE=$(mktemp)

mkdir "${TEMPDIR}/boot/"
# Adds "arch/arm/boot/" path prefix to each TARGET
cp "arch/arm/boot/${TARGETS// / arch/arm/boot/}" "${TEMPDIR}"/boot/
# Copy the full .config file to the target, this is optional and can be removed
cp .config "${TEMPDIR}"/boot/config
# Copy all of the generated FDT binary files to the target
# XXX: Tested to find that *ts* only matches our boards in these cases.
cp arch/arm/boot/dts/*ts*.dtb  "${TEMPDIR}"/boot/
# Install kernel modules to the target
INSTALL_MOD_PATH="${TEMPDIR}" make modules_install
# Install kernel headers to the target, this is optional in most cases and can be removed to save space on the target
make headers_install INSTALL_HDR_PATH="${TEMPDIR}"

# XXX: Need to find a way to trigger this build. Maybe an env var?
if [ "${WILC}" == "y" ]; then
    CONFIG_WILC_SPI=m INSTALL_MOD_PATH="${TEMPDIR}" make M=./wilc3000-external-module modules modules_install
fi

# Use fakeroot to properly set permissions on the target folder as well as create a tarball from this.
fakeroot sh -c "chmod 755 ${TEMPDIR};
        chown -R root:root ${TEMPDIR};
        tar czf ${TEMPFILE}.tar.gz -C ${TEMPDIR} .";

cp ${TEMPFILE}.tar.gz embeddedTS-linux-lts-"$(date +"%Y%m%d")"-"$(git describe --abbrev=8 --dirty --always)".tar.gz
rm -rf "${TEMPDIR}" "${TEMPFILE}"