+#!/bin/bash
+
+hvbuild()
+{
+ # Check if kernel sources are still in /usr/src.
+ # If not, recopy them.
+ if [ ! -d /usr/src/${PACKAGE} ]; then
+ # Decompress kernel sources
+ decompress_package ${PACKAGE} /usr/src
+ fi
+
+ # Copy kernel configuration file in source tree.
+ cp -v ${SCRDIR}/../config/${KERNEL_CONFIG} /usr/src/${PACKAGE}/.config
+
+ # Install HV kernel compilation script:
+ VERSION=$(get_pkg_ver ${PACKAGE})
+ SCRIPT=/usr/src/compile-kernel
+
+ echo "#!/bin/bash" > ${SCRIPT}
+ echo "set -o errexit" >> ${SCRIPT}
+ echo "KERNEL_VERSION=${VERSION}" >> ${SCRIPT}
+ echo "KERNEL_NAME=clfs-\${KERNEL_VERSION}" >> ${SCRIPT}
+ echo "DEST=/boot" >> ${SCRIPT}
+ echo "ARCH=${HVL_TARGET}" >> ${SCRIPT}
+ echo "unset CROSS_COMPILE" >> ${SCRIPT}
+ echo "" >> ${SCRIPT}
+ echo "make" >> ${SCRIPT}
+ echo "make modules" >> ${SCRIPT}
+ echo "make modules_install" >> ${SCRIPT}
+ echo "cp -v arch/${HVL_TARGET}/boot/bzImage \${DEST}/vmlinuz-\${KERNEL_NAME}" >> ${SCRIPT}
+ echo "cp -v System.map \${DEST}/System.map-\${KERNEL_NAME}" >> ${SCRIPT}
+ echo "cp -v .config \${DEST}/config-\${KERNEL_NAME}" >> ${SCRIPT}
+
+ chmod -v u+x ${SCRIPT}
+
+ cd ${LFS}/usr/src/${PACKAGE}
+
+ # The 'yes' command repeatedly output a line with all specified string, or
+ # 'y' by default. So, you can use it to simply "press enter", which will
+ # result in using the defaults value for the 'make oldconfig' command.
+ yes "" | make oldconfig
+
+ # Execute compilation script
+ ${SCRIPT}
+}