enable CONFIG_INSMOD in all arch busy-config files
[genkernel.git] / gen_compile.sh
index c8abc5ea14cf629f2737fcd750d28e384bd15cc9..665e2d12186873a138b659d5c2cac865ecef610a 100644 (file)
@@ -183,6 +183,7 @@ reset_args()
        fi
 }
 
+
 compile_generic() {
        local RET
        [ "$#" -lt '2' ] &&
@@ -298,14 +299,19 @@ compile_kernel() {
        fi
        if ! isTrue "${CMD_NOINSTALL}"
        then
-               cp "${KERNEL_BINARY}" "${BOOTDIR}/kernel-${KNAME}-${ARCH}-${KV}" ||
-                       gen_die 'Could not copy the kernel binary to ${BOOTDIR}!'
-               cp "System.map" "${BOOTDIR}/System.map-${KNAME}-${ARCH}-${KV}" ||
-                       gen_die 'Could not copy System.map to ${BOOTDIR}!'
+               copy_image_with_preserve "kernel" \
+                       "${KERNEL_BINARY}" \
+                       "kernel-${KNAME}-${ARCH}-${KV}"
+
+               copy_image_with_preserve "System.map" \
+                       "System.map" \
+                       "System.map-${KNAME}-${ARCH}-${KV}"
+
                if [ "${KERNEL_BINARY_2}" != '' -a "${GENERATE_Z_IMAGE}" = '1' ]
                then
-                       cp "${KERNEL_BINARY_2}" "${BOOTDIR}/kernelz-${KV}" ||
-                               gen_die 'Could not copy the kernelz binary to ${BOOTDIR}!'
+                       copy_image_with_preserve "kernelz" \
+                               "${KERNEL_BINARY_2}" \
+                               "kernelz-${KV}"
                fi
        else
                cp "${KERNEL_BINARY}" "${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}" ||
@@ -327,9 +333,9 @@ compile_unionfs_modules() {
                        gen_die "Could not find unionfs source tarball: ${UNIONFS_SRCTAR}!"
                cd "${TEMP}"
                rm -rf ${UNIONFS_DIR} > /dev/null
-               rm -rf unionfs > /dev/null
-               mkdir -p unionfs
-               /bin/tar -zxpf ${UNIONFS_SRCTAR} ||
+               rm -rf unionfs* > /dev/null
+               mkdir unionfs
+               /bin/tar xzpf ${UNIONFS_SRCTAR} ||
                        gen_die 'Could not extract unionfs source tarball!'
                [ -d "${UNIONFS_DIR}" ] ||
                        gen_die 'Unionfs directory ${UNIONFS_DIR} is invalid!'
@@ -338,6 +344,7 @@ compile_unionfs_modules() {
                echo "LINUXSRC=${KERNEL_DIR}" >> fistdev.mk
                echo 'TOPINC=-I$(LINUXSRC)/include' >> fistdev.mk
                echo "MODDIR= /lib/modules/${KV}" >> fistdev.mk
+               echo "KVERS=${KV}" >> fistdev.mk
                echo "KERNELVERSION=${KV}" >> fistdev.mk
                # Fix for hardened/selinux systems to have extened attributes
                # per r2d2's request.  Also add -DUNIONFS_UNSUPPORTED for 2.6.16
@@ -350,11 +357,13 @@ compile_unionfs_modules() {
 
                if [ "${PAT}" -ge '6' ]
                then
-                       cd "${TEMP}"
-                       cd "${UNIONFS_DIR}"
+                       # ARCH is used by unionfs - and conflicts with genkernel
+                       ARCH_PUSH=${ARCH}
+                       unset ARCH
                        # Compile unionfs module within the unionfs
                        # environment not within the kernelsrc dir
                        make unionfs.ko || gen_die 'failed to compile unionfs'
+                       ARCH=${ARCH_PUSH}
                else
                        gen_die 'unionfs is only supported on 2.6 targets'
                fi
@@ -386,7 +395,7 @@ compile_unionfs_utils() {
                        gen_die "Could not find unionfs source tarball: ${UNIONFS_SRCTAR}!"
                cd "${TEMP}"
                rm -rf ${UNIONFS_DIR} > /dev/null
-               rm -rf unionfs > /dev/null
+               rm -rf unionfs* > /dev/null
                mkdir -p unionfs/sbin
                /bin/tar -zxpf ${UNIONFS_SRCTAR} ||
                        gen_die 'Could not extract unionfs source tarball!'
@@ -394,16 +403,20 @@ compile_unionfs_utils() {
                        gen_die 'Unionfs directory ${UNIONFS_DIR} is invalid!'
                cd "${UNIONFS_DIR}"
                print_info 1 'unionfs tools: >> Compiling...'
+               sed -i utils/Makefile -e 's|${CC} -o|${CC} -static -o|g'
                sed -i Makefile -e 's|${CC} -o|${CC} -static -o|g'
                compile_generic utils utils
-               
+
+               if [ ! -e "uniondbg" ]; then
+                       cd utils
+               fi
                print_info 1 'unionfs: >> Copying to cache...'
                strip uniondbg unionctl
                cp uniondbg ${TEMP}/unionfs/sbin/ || 
                        gen_die 'Could not copy the uniondbg binary to the tmp directory'
                cp unionctl ${TEMP}/unionfs/sbin/ ||
                        gen_die 'Could not copy the unionctl binary to the tmp directory'
-               cd ${TEMP}/unionfs      
+               cd ${TEMP}/unionfs
                /bin/tar -cjf "${UNIONFS_BINCACHE}" . ||
                        gen_die 'Could not create unionfs tools binary cache'
                
@@ -414,23 +427,38 @@ compile_unionfs_utils() {
 }
 
 compile_busybox() {
+       [ -f "${BUSYBOX_SRCTAR}" ] ||
+               gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!"
+       [ -f "${BUSYBOX_CONFIG}" ] ||
+               gen_die "Cound not find busybox config file: ${BUSYBOX_CONFIG}!"
+       cd "${TEMP}"
+       rm -rf "${BUSYBOX_DIR}" > /dev/null
+       /bin/tar -jxpf ${BUSYBOX_SRCTAR} ||
+               gen_die 'Could not extract busybox source tarball!'
+       [ -d "${BUSYBOX_DIR}" ] ||
+               gen_die 'Busybox directory ${BUSYBOX_DIR} is invalid!'
+       cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
+       sed -i ${BUSYBOX_DIR}/.config -e 's/#\? \?CONFIG_FEATURE_INSTALLER[ =].*/CONFIG_FEATURE_INSTALLER=y/g'
+       cd "${BUSYBOX_DIR}"
+       print_info 1 'busybox: >> Configuring...'
+       yes '' 2>/dev/null | compile_generic oldconfig utils
+
+       # Delete cache if stored config's MD5 does not match one to be used
+       if [ -f "${BUSYBOX_BINCACHE}" -a -f "${BUSYBOX_CONFIG}" ]
+       then
+               oldconfig_md5=$(tar -xjf "${BUSYBOX_BINCACHE}" -O .config | md5sum)
+               newconfig_md5=$(md5sum < .config)
+               if [ "${oldconfig_md5}" != "${newconfig_md5}" ]
+               then
+                       print_info 1 "busybox: >> Removing stale cache..."
+                       rm -rf "${BUSYBOX_BINCACHE}"
+               else
+                       print_info 1 "busybox: >> Using cache"
+               fi
+       fi
+
        if [ ! -f "${BUSYBOX_BINCACHE}" ]
        then
-               [ -f "${BUSYBOX_SRCTAR}" ] ||
-                       gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!"
-               [ -f "${BUSYBOX_CONFIG}" ] ||
-                       gen_die "Cound not find busybox config file: ${BUSYBOX_CONFIG}!"
-               cd "${TEMP}"
-               rm -rf ${BUSYBOX_DIR} > /dev/null
-               /bin/tar -jxpf ${BUSYBOX_SRCTAR} ||
-                       gen_die 'Could not extract busybox source tarball!'
-               [ -d "${BUSYBOX_DIR}" ] ||
-                       gen_die 'Busybox directory ${BUSYBOX_DIR} is invalid!'
-               cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
-               sed -i ${BUSYBOX_DIR}/.config -e 's/#\? \?CONFIG_FEATURE_INSTALLER[ =].*/CONFIG_FEATURE_INSTALLER=y/g'
-               cd "${BUSYBOX_DIR}"
-               print_info 1 'busybox: >> Configuring...'
-               yes '' 2>/dev/null | compile_generic oldconfig utils
                print_info 1 'busybox: >> Compiling...'
                compile_generic all utils
                print_info 1 'busybox: >> Copying to cache...'
@@ -438,14 +466,12 @@ compile_busybox() {
                        gen_die 'Busybox executable does not exist!'
                strip "${TEMP}/${BUSYBOX_DIR}/busybox" ||
                        gen_die 'Could not strip busybox binary!'
-               bzip2 "${TEMP}/${BUSYBOX_DIR}/busybox" ||
-                       gen_die 'bzip2 compression of busybox failed!'
-               mv "${TEMP}/${BUSYBOX_DIR}/busybox.bz2" "${BUSYBOX_BINCACHE}" ||
-                       gen_die 'Could not copy the busybox binary to the package directory, does the directory exist?'
-
-               cd "${TEMP}"
-               rm -rf "${BUSYBOX_DIR}" > /dev/null
+               tar -cj -C "${TEMP}/${BUSYBOX_DIR}" -f "${BUSYBOX_BINCACHE}" busybox .config ||
+                       gen_die 'Could not create the busybox bincache!'
        fi
+
+       cd "${TEMP}"
+       rm -rf "${BUSYBOX_DIR}" > /dev/null
 }
 
 compile_lvm2() {
@@ -567,114 +593,6 @@ compile_suspend() {
        rm -rf bincache suspend-0.5
 }
 
-compile_modutils() {
-       # I've disabled dietlibc support for the time being since the
-       # version we use misses a few needed system calls.
-
-       local ARGS
-       if [ ! -f "${MODUTILS_BINCACHE}" ]
-       then
-               [ ! -f "${MODUTILS_SRCTAR}" ] &&
-                       gen_die "Could not find modutils source tarball: ${MODUTILS_SRCTAR}!"
-               cd "${TEMP}"
-               rm -rf "${MODUTILS_DIR}"
-               /bin/tar -jxpf "${MODUTILS_SRCTAR}"
-               [ ! -d "${MODUTILS_DIR}" ] &&
-                       gen_die "Modutils directory ${MODUTILS_DIR} invalid!"
-               cd "${MODUTILS_DIR}"
-               print_info 1 "modutils: >> Configuring..."
-
-#              if [ "${USE_DIETLIBC}" -eq '1' ]
-#              then
-#                      extract_dietlibc_bincache
-#                      OLD_CC="${UTILS_CC}"
-#                      UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
-#              fi
-
-               export_utils_args
-               export ARCH=${ARCH}
-               ./configure --disable-combined --enable-insmod-static >> ${DEBUGFILE} 2>&1 ||
-                       gen_die 'Configuring modutils failed!'
-               unset_utils_args
-
-               print_info 1 'modutils: >> Compiling...'
-               compile_generic all utils
-
-#              if [ "${USE_DIETLIBC}" -eq '1' ]
-#              then
-#                      clean_dietlibc_bincache
-#                      UTILS_CC="${OLD_CC}"
-#              fi
-
-               print_info 1 'modutils: >> Copying to cache...'
-               [ -f "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ] ||
-                       gen_die 'insmod.static does not exist after the compilation of modutils!'
-               strip "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ||
-                       gen_die 'Could not strip insmod.static!'
-               bzip2 "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ||
-                       gen_die 'Compression of insmod.static failed!'
-               mv "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static.bz2" "${MODUTILS_BINCACHE}" ||
-                       gen_die 'Could not move the compressed insmod binary to the package cache!'
-
-               cd "${TEMP}"
-               rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null
-       fi
-}
-
-compile_module_init_tools() {
-       # I've disabled dietlibc support for the time being since the
-       # version we use misses a few needed system calls.
-
-       local ARGS
-       if [ ! -f "${MODULE_INIT_TOOLS_BINCACHE}" ]
-       then
-               [ ! -f "${MODULE_INIT_TOOLS_SRCTAR}" ] &&
-                       gen_die "Could not find module-init-tools source tarball: ${MODULE_INIT_TOOLS_SRCTAR}"
-               cd "${TEMP}"
-               rm -rf "${MODULE_INIT_TOOLS_DIR}"
-               /bin/tar -jxpf "${MODULE_INIT_TOOLS_SRCTAR}"
-               [ ! -d "${MODULE_INIT_TOOLS_DIR}" ] &&
-                       gen_die "Module-init-tools directory ${MODULE_INIT_TOOLS_DIR} is invalid"
-               cd "${MODULE_INIT_TOOLS_DIR}"
-               print_info 1 'module-init-tools: >> Configuring'
-
-#              if [ "${USE_DIETLIBC}" -eq '1' ]
-#              then
-#                      extract_dietlibc_bincache
-#                      OLD_CC="${UTILS_CC}"
-#                      UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
-#              fi
-
-               export_utils_args
-               ./configure >> ${DEBUGFILE} 2>&1 ||
-                       gen_die 'Configure of module-init-tools failed!'
-               unset_utils_args
-               print_info 1 '                   >> Compiling...'
-               compile_generic "all" utils
-
-#              if [ "${USE_DIETLIBC}" -eq '1' ]
-#              then
-#                      clean_dietlibc_bincache
-#                      UTILS_CC="${OLD_CC}"
-#              fi
-
-               print_info 1 '                   >> Copying to cache...'
-               [ -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ] ||
-                       gen_die 'insmod.static does not exist after the compilation of module-init-tools!'
-               strip "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ||
-                       gen_die 'Could not strip insmod.static!'
-               bzip2 "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ||
-                       gen_die 'Compression of insmod.static failed!'
-               [ -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" ] ||
-                       gen_die 'Could not find compressed insmod.static.bz2 binary!'
-               mv "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" "${MODULE_INIT_TOOLS_BINCACHE}" ||
-                       gen_die 'Could not move the compressed insmod binary to the package cache!'
-
-               cd "${TEMP}"
-               rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null
-       fi
-}
-
 compile_devfsd() {
        # I've disabled dietlibc support for the time being since the
        # version we use misses a few needed system calls.
@@ -739,10 +657,9 @@ compile_device_mapper() {
                [ ! -d "${DEVICE_MAPPER_DIR}" ] &&
                        gen_die "device-mapper directory ${DEVICE_MAPPER_DIR} invalid"
                cd "${DEVICE_MAPPER_DIR}"
-               mymapperconf="--enable-static_link"
-               ###mymapperconf="--disable-selinux ${mymapperconf}"
-               ./configure  --prefix=${TEMP}/device-mapper ${mymapperconf} \
-                       >> ${DEBUGFILE} 2>&1 || gen_die 'Configuring device-mapper failed!'
+               ./configure --prefix=${TEMP}/device-mapper --enable-static_link \
+                       --disable-selinux >> ${DEBUGFILE} 2>&1 ||
+                       gen_die 'Configuring device-mapper failed!'
                print_info 1 'device-mapper: >> Compiling...'
                compile_generic '' utils
                compile_generic 'install' utils