diff --git a/buildCurrentSymlinkedKernel.sh b/buildCurrentSymlinkedKernel.sh index e0d3cf3..f7363f8 100755 --- a/buildCurrentSymlinkedKernel.sh +++ b/buildCurrentSymlinkedKernel.sh @@ -1,20 +1,53 @@ #!/usr/bin/env bash -if [ ! -f /usr/src/linux/.config ] && [ -f /proc/config.gz ] ; then +SRC_TREE="/usr/src/linux" +SRC_CONFIG=".config" + +declare -a OUT + +LWD="$PWD" +cd "$SRC_TREE" || exit 1 + +if [[ ! -f $SRC_CONFIG ]] ; then + NOCONFIG="1" +fi +if [[ "$1" == "--force" ]] ; then + FORCE="1" +fi + +if [[ -f /proc/config.gz ]] ; then + OLDCONFIG="1" +fi + + +if [[ "$NOCONFIG" || "$FORCE" ]] ; then echo "**************** building kernel ***********" - LWD="$PWD" TIMESTAMP=$(date +%F-%H_%M_%S) - cd /usr/src/linux || exit 1 - zcat /proc/config.gz > .config + if [[ "$NOCONFIG" ]] ; then + if [[ "$OLDCONFIG" ]] ; then + OUT+=("********** Using old config ************") + echo "${OUT[-1]}" + zcat /proc/config.gz > .config + else + OUT+=("********** WARNING! No old config has been found! Using defconfig! ************") + echo "${OUT[-1]}" + make defconfig + fi + else + OUT+=("Found kernel config in source tree!") + echo "${OUT[-1]}" + fi make olddefconfig - mount /boot - (make -j5 CC="ccache gcc" && make install && make modules_install && make firmware_install) > "buildlog-$TIMESTAMP" || tail -n 20 "buildlog-$TIMESTAMP" + echo mounting boot if not yet mounted + mount /boot 2> /dev/null - GRUBMKONFIG="$(which grub2-mkconfig)" + (make -j17 -l15 CC="ccache gcc" && make install && make modules_install && make firmware_install) > "buildlog-$TIMESTAMP" || tail -n 20 "buildlog-$TIMESTAMP" + + GRUBMKONFIG="$(which grub2-mkconfig 2> /dev/null)" if [[ -z "$GRUBMKONFIG" ]] ; then GRUBMKONFIG="$(which grub-mkconfig)" fi @@ -26,6 +59,13 @@ if [ ! -f /usr/src/linux/.config ] && [ -f /proc/config.gz ] ; then else echo "please update bootloader manually!" fi - cd "${LWD}" || exit 1 + echo + echo + echo Summary: + IFS=$'\n' echo -e "${OUT[*]}" + echo diff between current running und last build config: + diff .config <(zcat /proc/config.gz ) + fi + cd "${LWD}" || exit 1