-Fixed error for new tar package and root user
[hvlinux.git] / stage2 / pkg / linux
index 2065bf0..dd0af0b 100644 (file)
@@ -2,17 +2,24 @@
 
 hvbuild()
 {
-    # The kernel sources were already copied into /usr/src in stage0
-    cd /usr/src/${PACKAGE}
-    make mrproper
-    make headers_check
+    # Check if kernel sources from stage0 are still there
+    if [ ! -d /usr/src/${PACKAGE} ]; then
+        # If no, then copy them. We don't install headers and
+        # assume that it is a new kernel version installation.
+        mv ${LFS_TMP}/${PACKAGE} /usr/src
+    else
+        # Install headers
+        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
+        # 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
+    fi
 
     # Install HV kernel compilation script:
     VERSION=$(get_pkg_ver ${PACKAGE})