Replaced /bin/sh by /bin/bash
[hvlinux.git] / stage2 / cis-kernel
index a435e06..acc2b8b 100755 (executable)
@@ -1,57 +1,48 @@
-#!/bin/sh
+#!/bin/bash
+set -o errexit
 
 # Reading system configuration informations, functions and package versions.
 source ../sysinfos
 source ../functions
 source ../packages-list
 
-# The ARCH variable must be exported for this script
-# to work correctly for architectures other than PC.
-#   eg. export ARCH=powerpc
-
-# We don't compile anything, we only install headers
-#unset CROSS_COMPILE &&
-
-SYSROOT=${SYSROOT:-""}
+PACKAGE=${1}
+shift
+CONFIGURE_OPTS=${*}
 
 # Applying patches (if any)
-apply_patches ${1} &&
-
-# Move files to their final destination 
-mkdir -pv ${SYSROOT}/usr/src &&
-mv ${LFS_TMP}/${1} ${SYSROOT}/usr/src &&
-
-# Remove any previous link. Otherwise, the
-# new link would be created inside kernel directory.
-cd ${SYSROOT}/usr/src &&
-rm -fv linux &&
-ln -sfv ${1} linux &&
-
-# First step, install kernel API headers:
-cd ${SYSROOT}/usr/src/${1} &&
-make -j ${MAKEJOBS} mrproper &&
-make -j ${MAKEJOBS} headers_check &&
-make -j ${MAKEJOBS} INSTALL_HDR_PATH=dest headers_install &&
-mkdir -pv ${SYSROOT}/usr/include &&
-cp -rv dest/include/* ${SYSROOT}/usr/include &&
-
-# Second, install HV kernel compilation script:
-cd ${SYSROOT}/usr/src &&
-
-VERSION=$(get_pkg_ver ${1}) &&
-
-echo "#!/bin/sh" > compile-kernel &&
-echo "KERNEL_VERSION=${VERSION}" >> compile-kernel &&
-echo "DEST=/boot" >> compile-kernel &&
-cat >> compile-kernel << "EOF" &&
-
-make bzImage &&
-make modules &&
-make modules_install &&
-
-cp arch/x86/boot/bzImage ${DEST}/vmlinuz-${KERNEL_VERSION} &&
-cp System.map            ${DEST}/System-${KERNEL_VERSION}.map &&
-cp .config               ${DEST}/config-${KERNEL_VERSION}
+apply_patches ${PACKAGE}
+
+# The kernel sources were already copied into /usr/src in stage0
+cd /usr/src/${PACKAGE}
+make mrproper
+make headers_check
+# Remove any previous headers install
+rm -rf dest
+make INSTALL_HDR_PATH=dest headers_install
+cp -rv dest/include/* /usr/include
+find /usr/include -name .install -or -name ..install.cmd | xargs rm -fv
+rm -rf dest
+
+# Install HV kernel compilation script:
+VERSION=$(get_pkg_ver ${PACKAGE})
+SCRIPT=/usr/src/compile-kernel
+
+echo "#!/bin/bash" > ${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}
+
+cat >> ${SCRIPT} << "EOF"
 
 if [ $? -ne 0 ]; then
     echo "*** Kernel compilation error ***."
@@ -61,7 +52,6 @@ fi
 exit 0
 EOF
 
-chmod -v u+x compile-kernel
+chmod -v u+x ${SCRIPT}
 
-# Return last error
 exit $?