Added modified version of patch from gentoo bug #238707
[genkernel.git] / gen_determineargs.sh
index 6a7b8720132d3bea7d496eb745f30c487a670791..0fd2e7d13f3b6672c32b5ce6a2b8874976220a1e 100644 (file)
@@ -6,24 +6,15 @@ get_KV() {
                /bin/tar -xj -C ${TEMP} -f ${KERNCACHE} kerncache.config 
                if [ -e ${TEMP}/kerncache.config ]
                then
-                       KERN_24=0
                        VER=`grep ^VERSION\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
                        PAT=`grep ^PATCHLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
                        SUB=`grep ^SUBLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
                        EXV=`grep ^EXTRAVERSION\ \= ${TEMP}/kerncache.config | sed -e "s/EXTRAVERSION =//" -e "s/ //g"`
-                       if [ "${PAT}" -gt '4' -a "${VER}" -ge '2' ]
-                       then
-                               LOV=`grep ^CONFIG_LOCALVERSION\= ${TEMP}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/"`
-                               KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
-                       else
-                               KERN_24=1
-                               KV=${VER}.${PAT}.${SUB}${EXV}
-                       fi
-
+                       LOV=`grep ^CONFIG_LOCALVERSION\= ${TEMP}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/"`
+                       KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
                else
                        gen_die "Could not find kerncache.config in the kernel cache! Exiting."
                fi
-
        else
                # Configure the kernel
                # If BUILD_KERNEL=0 then assume --no-clean, menuconfig is cleared
@@ -32,34 +23,36 @@ get_KV() {
                PAT=`grep ^PATCHLEVEL\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
                SUB=`grep ^SUBLEVEL\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
                EXV=`grep ^EXTRAVERSION\ \= ${KERNEL_DIR}/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g" -e 's/\$([a-z]*)//gi'`
-               if [ "${PAT}" -gt '4' -a "${VER}" -ge '2' -a -e ${KERNEL_DIR}/.config ]
+
+               if [ -z "${SUB}" ]; 
                then
-                       KERN_24=0
-                       cd ${KERNEL_DIR}
-                       #compile_generic prepare kernel > /dev/null 2>&1
-                       cd - > /dev/null 2>&1
-                       [ -f "${KERNEL_DIR}/include/linux/version.h" ] && \
-                               VERSION_SOURCE="${KERNEL_DIR}/include/linux/version.h"
-                       [ -f "${KERNEL_DIR}/include/linux/utsrelease.h" ] && \
-                               VERSION_SOURCE="${KERNEL_DIR}/include/linux/utsrelease.h"
-                       # Handle new-style releases where version.h doesn't have UTS_RELEASE
-                       if [ -f ${KERNEL_DIR}/include/config/kernel.release ]
-                       then
-                               UTS_RELEASE=`cat ${KERNEL_DIR}/include/config/kernel.release`
-                               LOV=`echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//"`
-                               KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
-                       elif [ -n "${VERSION_SOURCE}" ]
-                       then
-                               UTS_RELEASE=`grep UTS_RELEASE ${VERSION_SOURCE} | sed -e 's/#define UTS_RELEASE "\(.*\)"/\1/'`
-                               LOV=`echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//"`
-                               KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
-                       else
-                               LCV=`grep ^CONFIG_LOCALVERSION= ${KERNEL_DIR}/.config | sed -r -e "s/.*=\"(.*)\"/\1/"`
-                               KV=${VER}.${PAT}.${SUB}${EXV}${LCV}
-                       fi
+                       # Handle O= build directories
+                       KERNEL_SOURCE_DIR=`grep ^MAKEARGS\ \:\=  ${KERNEL_DIR}/Makefile | awk '{ print $4 };'`
+                       SUB=`grep ^SUBLEVEL\ \= ${KERNEL_SOURCE_DIR}/Makefile | awk '{ print $3 };'`
+                       EXV=`grep ^EXTRAVERSION\ \= ${KERNEL_SOURCE_DIR}/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g" -e 's/\$([a-z]*)//gi'`
+               fi
+
+               cd ${KERNEL_DIR}
+               #compile_generic prepare kernel > /dev/null 2>&1
+               cd - > /dev/null 2>&1
+               [ -f "${KERNEL_DIR}/include/linux/version.h" ] && \
+                       VERSION_SOURCE="${KERNEL_DIR}/include/linux/version.h"
+               [ -f "${KERNEL_DIR}/include/linux/utsrelease.h" ] && \
+                       VERSION_SOURCE="${KERNEL_DIR}/include/linux/utsrelease.h"
+               # Handle new-style releases where version.h doesn't have UTS_RELEASE
+               if [ -f ${KERNEL_DIR}/include/config/kernel.release ]
+               then
+                       UTS_RELEASE=`cat ${KERNEL_DIR}/include/config/kernel.release`
+                       LOV=`echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//"`
+                       KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
+               elif [ -n "${VERSION_SOURCE}" ]
+               then
+                       UTS_RELEASE=`grep UTS_RELEASE ${VERSION_SOURCE} | sed -e 's/#define UTS_RELEASE "\(.*\)"/\1/'`
+                       LOV=`echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//"`
+                       KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
                else
-                       KERN_24=1
-                       KV=${VER}.${PAT}.${SUB}${EXV}
+                       LCV=`grep ^CONFIG_LOCALVERSION= ${KERNEL_DIR}/.config | sed -r -e "s/.*=\"(.*)\"/\1/"`
+                       KV=${VER}.${PAT}.${SUB}${EXV}${LCV}
                fi
        fi
 }
@@ -97,12 +90,11 @@ determine_real_args() {
        set_config_with_override 2 MINKERNPACKAGE       CMD_MINKERNPACKAGE
        set_config_with_override 2 MODULESPACKAGE       CMD_MODULESPACKAGE
        set_config_with_override 2 KERNCACHE            CMD_KERNCACHE
-       set_config_with_override 1 NOINITRDMODULES      CMD_NOINITRDMODULES
-       set_config_with_override 1 ALLINITRDMODULES     CMD_ALLINITRDMODULES
+       set_config_with_override 1 NORAMDISKMODULES     CMD_NORAMDISKMODULES
+       set_config_with_override 1 ALLRAMDISKMODULES    CMD_ALLRAMDISKMODULES
        set_config_with_override 2 INITRAMFS_OVERLAY    CMD_INITRAMFS_OVERLAY
        set_config_with_override 1 MOUNTBOOT            CMD_MOUNTBOOT
        set_config_with_override 1 BUILD_STATIC         CMD_STATIC
-       set_config_with_override 1 BUILD_INITRAMFS      CMD_INITRAMFS
        set_config_with_override 1 SAVE_CONFIG          CMD_SAVE_CONFIG
        set_config_with_override 1 SYMLINK              CMD_SYMLINK
        set_config_with_override 2 INSTALL_MOD_PATH     CMD_INSTALL_MOD_PATH
@@ -111,14 +103,20 @@ determine_real_args() {
        set_config_with_override 1 EVMS                 CMD_EVMS
        set_config_with_override 1 DMRAID               CMD_DMRAID
        set_config_with_override 1 BUSYBOX              CMD_BUSYBOX              "yes"
+       set_config_with_override 1 UNIONFS                              CMD_UNIONFS
        set_config_with_override 1 DISKLABEL            CMD_DISKLABEL
        set_config_with_override 1 LUKS                 CMD_LUKS
        set_config_with_override 1 MDADM                CMD_MDADM
        set_config_with_override 1 FIRMWARE             CMD_FIRMWARE
        set_config_with_override 2 FIRMWARE_DIR         CMD_FIRMWARE_DIR         "/lib/firmware"
+       set_config_with_override 2 FIRMWARE_FILES       CMD_FIRMWARE_FILES
+       set_config_with_override 1 INTEGRATED_INITRAMFS CMD_INTEGRATED_INITRAMFS
+       set_config_with_override 1 GENZIMAGE            CMD_GENZIMAGE
+       set_config_with_override 1 KEYMAP               CMD_KEYMAP               "yes"
+       set_config_with_override 1 DOKEYMAPAUTO         CMD_DOKEYMAPAUTO
 
-               BOOTDIR=`arch_replace "${BOOTDIR}"`
-               BOOTDIR=${BOOTDIR%/}    # Remove any trailing slash
+       BOOTDIR=`arch_replace "${BOOTDIR}"`
+       BOOTDIR=${BOOTDIR%/}    # Remove any trailing slash
 
        CACHE_DIR=`arch_replace "${CACHE_DIR}"`
        BUSYBOX_BINCACHE=`cache_replace "${BUSYBOX_BINCACHE}"`
@@ -126,6 +124,8 @@ determine_real_args() {
        LVM_BINCACHE=`cache_replace "${LVM_BINCACHE}"`
        DMRAID_BINCACHE=`cache_replace "${DMRAID_BINCACHE}"`
        BLKID_BINCACHE=`cache_replace "${BLKID_BINCACHE}"`
+       FUSE_BINCACHE=`cache_replace "${FUSE_BINCACHE}"`
+       UNIONFS_FUSE_BINCACHE=`cache_replace "${UNIONFS_FUSE_BINCACHE}"`
   
        DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"`
        BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"`
@@ -134,19 +134,9 @@ determine_real_args() {
        LVM_BINCACHE=`arch_replace "${LVM_BINCACHE}"`
        DMRAID_BINCACHE=`arch_replace "${DMRAID_BINCACHE}"`
        BLKID_BINCACHE=`arch_replace "${BLKID_BINCACHE}"`
+       FUSE_BINCACHE=`arch_replace "${FUSE_BINCACHE}"`
+       UNIONFS_FUSE_BINCACHE=`arch_replace "${UNIONFS_FUSE_BINCACHE}"`
        
-
-       if [ "${CMD_BOOTLOADER}" != '' ]
-       then
-               BOOTLOADER="${CMD_BOOTLOADER}"
-
-               if [ "${CMD_BOOTLOADER}" != "${CMD_BOOTLOADER/:/}" ]
-       then
-                       BOOTFS=`echo "${CMD_BOOTLOADER}" | cut -f2- -d:`
-                       BOOTLOADER=`echo "${CMD_BOOTLOADER}" | cut -f1 -d:`
-       fi
-       fi
-
        if [ "${NO_KERNEL_SOURCES}" != "1" ]
        then
                if [ ! -d ${KERNEL_DIR} ]
@@ -196,6 +186,11 @@ determine_real_args() {
        then
                mkdir -p `dirname ${KERNCACHE}`
        fi
+
+       if ! isTrue "${BUILD_RAMDISK}"
+       then
+               INTEGRATED_INITRAMFS=0
+       fi
        
        get_KV
 }