scripts/kernel.sh: be smarter about kernel building

Also install the kernel as a "--oneshot" so it doesn't take up space in
the image.
This commit is contained in:
Albert Hopkins 2016-07-23 11:34:37 +00:00
parent 9e1441231f
commit 8494820fb3
1 changed files with 4 additions and 8 deletions

View File

@ -2,22 +2,18 @@ set -ev
# (possibly) build the kernel
current_kernel=""
if [ -d "/var/db/pkg/sys-kernel" ]
then
cd "/var/db/pkg/sys-kernel"
current_kernel=`/bin/ls -d1 "${KERNEL}-"* | tail -n 1|sed s/"${KERNEL}-//;s/-r[1-9]\+$//"`
fi
current_kernel=$(emerge -qp ${KERNEL}|awk '{print $4}'|cut -d/ -f2|sed s/"${KERNEL}-//;s/-r[1-9]\+$//")
echo $current_kernel
# If there is already a kernel in /boot and emerging the kernel only
# re-installs the same package, we can skip this
# re-installs the same kernel, we can skip this
if [ -n "$current_kernel" ] && [ -e /boot/vmlinuz ] && \
readlink /boot/vmlinuz | grep $current_kernel > /dev/null
then
exit
fi
${EMERGE} ${USEPKG} --newuse --noreplace sys-kernel/${KERNEL}
${EMERGE} ${USEPKG} --oneshot --newuse --noreplace sys-kernel/${KERNEL}
cp /root/kernel.config /usr/src/linux/.config
gcc-config 1
cd /usr/src/linux