diff --git a/buildCurrentSymlinkedKernel.sh b/buildCurrentSymlinkedKernel.sh index 369525b..f80a512 100755 --- a/buildCurrentSymlinkedKernel.sh +++ b/buildCurrentSymlinkedKernel.sh @@ -26,6 +26,10 @@ for config in "/proc/config.gz" "$CONFIGDIR/latest" ; do fi done +if [ "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" ]; then + CHROOTED=1 +fi + if [[ "$NOCONFIG" || "$FORCE" ]] ; then echo "**************** building kernel ***********" @@ -35,7 +39,7 @@ if [[ "$NOCONFIG" || "$FORCE" ]] ; then if [[ -n "$OLDCONFIG" ]] ; then OUT+=("********** Using old config ************") echo "${OUT[-1]}" - zcat -f "$config" > .config + zcat -f "$OLDCONFIG" > .config else OUT+=("********** WARNING! No old config has been found! Using defconfig! ************") echo "${OUT[-1]}" @@ -52,19 +56,25 @@ if [[ "$NOCONFIG" || "$FORCE" ]] ; then mount /boot 2> /dev/null CORES="$(getconf _NPROCESSORS_ONLN)" - (nice make -j -l$((CORES-1)) CC="ccache gcc" && make install ; make modules_install) > "buildlog-$TIMESTAMP" || tail -n 20 "buildlog-$TIMESTAMP" + (nice make -j -l$((CORES-1)) CC="ccache gcc") > "buildlog-$TIMESTAMP" || tail -n 20 "buildlog-$TIMESTAMP" + SUCCESS=$? + if [[ $SUCCESS == 0 ]] && [[ $CHROOTED == 1 ]] ; then + ( make tarxz-pkg ) >> "buildlog-$TIMESTAMP" + elif [[ $SUCCESS == 0 ]] + ( make install ; make modules_install ) >> "buildlog-$TIMESTAMP" - GRUBMKONFIG="$(which grub2-mkconfig 2> /dev/null)" - if [[ -z "$GRUBMKONFIG" ]] ; then - GRUBMKONFIG="$(which grub-mkconfig)" - fi + GRUBMKONFIG="$(which grub2-mkconfig 2> /dev/null)" + if [[ -z "$GRUBMKONFIG" ]] ; then + GRUBMKONFIG="$(which grub-mkconfig)" + fi - if [[ -f /boot/grub2/grub.cfg && -n "$GRUBMKONFIG" ]] ; then - "$GRUBMKONFIG" -o /boot/grub2/grub.cfg - elif [[ -f /boot/grub/grub.cfg && -n "$GRUBMKONFIG" ]] ; then - "$GRUBMKONFIG" -o /boot/grub/grub.cfg - else - echo "please update bootloader manually!" + if [[ -f /boot/grub2/grub.cfg && -n "$GRUBMKONFIG" ]] ; then + "$GRUBMKONFIG" -o /boot/grub2/grub.cfg + elif [[ -f /boot/grub/grub.cfg && -n "$GRUBMKONFIG" ]] ; then + "$GRUBMKONFIG" -o /boot/grub/grub.cfg + else + echo "please update bootloader manually!" + fi fi echo echo