From 30dc18a5dc4d4cce4682b70688c5269fb7872712 Mon Sep 17 00:00:00 2001 From: layman Date: Tue, 25 Jun 2019 10:33:29 +0200 Subject: [PATCH] buildCurrentSymlinkedKernel: add support for chroot build Save config to /etc/kernelconf and use it for rebuilds. this should prevent raceconditions between enabling a feature and rebooting and upgrading the kernel. (the upgraded kernel should no be based on the new feature build.) --- buildCurrentSymlinkedKernel.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/buildCurrentSymlinkedKernel.sh b/buildCurrentSymlinkedKernel.sh index 2e93820..369525b 100755 --- a/buildCurrentSymlinkedKernel.sh +++ b/buildCurrentSymlinkedKernel.sh @@ -3,6 +3,8 @@ SRC_TREE="/usr/src/linux" SRC_CONFIG=".config" +CONFIGDIR="/etc/kernelconf" + declare -a OUT umask 022 @@ -18,10 +20,11 @@ if [[ "$1" == "--force" ]] ; then FORCE="1" fi -if [[ -f /proc/config.gz ]] ; then - OLDCONFIG="1" -fi - +for config in "/proc/config.gz" "$CONFIGDIR/latest" ; do + if [[ -f "$config" ]] ; then + OLDCONFIG="$config" + fi +done if [[ "$NOCONFIG" || "$FORCE" ]] ; then echo "**************** building kernel ***********" @@ -29,10 +32,10 @@ if [[ "$NOCONFIG" || "$FORCE" ]] ; then TIMESTAMP=$(date +%F-%H_%M_%S) if [[ "$NOCONFIG" ]] ; then - if [[ "$OLDCONFIG" ]] ; then + if [[ -n "$OLDCONFIG" ]] ; then OUT+=("********** Using old config ************") echo "${OUT[-1]}" - zcat /proc/config.gz > .config + zcat -f "$config" > .config else OUT+=("********** WARNING! No old config has been found! Using defconfig! ************") echo "${OUT[-1]}" @@ -68,7 +71,14 @@ if [[ "$NOCONFIG" || "$FORCE" ]] ; then echo Summary: IFS=$'\n' echo -e "${OUT[*]}" echo diff between current running und last build config: - diff .config <(zcat /proc/config.gz ) + diff .config <(zcat -f "${OLDCONFIG}" ) + + if [[ -d "$CONFIGDIR" ]] ; then + VERSIONSTRING=$(basename $(realpath $(pwd))) + TARGET="$CONFIGDIR/${VERSIONSTRING}_$(date --iso=minutes)" + cp .config "$TARGET" + ln -f -rs "$TARGET" "$CONFIGDIR/latest" + fi fi