Bug #397947: Run depmod on new modules to avoid need to run at every boot on unionfs...
[genkernel.git] / gen_compile.sh
index 68dabdb05728bd1b62007aeeee438505a0f06816..c92396717cd2599e2f8c2163b8b6e8172c9f4026 100755 (executable)
@@ -80,6 +80,10 @@ export_utils_args()
        then
                export AS="${UTILS_AS}"
        fi
+       if [ "${UTILS_CROSS_COMPILE}" != '' ]
+       then
+               export CROSS_COMPILE="${UTILS_CROSS_COMPILE}"
+       fi
 }
 
 unset_utils_args()
@@ -100,6 +104,10 @@ unset_utils_args()
        then
                unset AS
        fi
+       if [ "${UTILS_CROSS_COMPILE}" != '' ]
+       then
+               unset CROSS_COMPILE
+       fi
        reset_args
 }
 
@@ -289,6 +297,8 @@ compile_modules() {
        export UNAME_MACHINE="${ARCH}"
        [ "${INSTALL_MOD_PATH}" != '' ] && export INSTALL_MOD_PATH
        MAKEOPTS="${MAKEOPTS} -j1" compile_generic "modules_install" kernel
+       print_info 1 "        >> Generating module dependency data..."
+       depmod -a -e -b "${INSTALL_MOD_PATH}"/lib/modules/$KV ${KV}
        unset UNAME_MACHINE
 }
 
@@ -398,7 +408,7 @@ compile_busybox() {
                /bin/tar -jxpf ${BUSYBOX_SRCTAR} ||
                        gen_die 'Could not extract busybox source tarball!'
                [ -d "${BUSYBOX_DIR}" ] ||
-                       gen_die 'Busybox directory ${BUSYBOX_DIR} is invalid!'
+                       gen_die "Busybox directory ${BUSYBOX_DIR} is invalid!"
                cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
                cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config.gk_orig"
                cd "${BUSYBOX_DIR}"
@@ -411,7 +421,7 @@ compile_busybox() {
                print_info 1 'busybox: >> Copying to cache...'
                [ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] ||
                        gen_die 'Busybox executable does not exist!'
-               strip "${TEMP}/${BUSYBOX_DIR}/busybox" ||
+               ${UTILS_CROSS_COMPILE}strip "${TEMP}/${BUSYBOX_DIR}/busybox" ||
                        gen_die 'Could not strip busybox binary!'
                tar -cj -C "${TEMP}/${BUSYBOX_DIR}" -f "${BUSYBOX_BINCACHE}" busybox .config .config.gk_orig ||
                        gen_die 'Could not create the busybox bincache!'
@@ -433,32 +443,33 @@ compile_lvm() {
                /bin/tar -zxpf ${LVM_SRCTAR} ||
                        gen_die 'Could not extract LVM source tarball!'
                [ -d "${LVM_DIR}" ] ||
-                       gen_die 'LVM directory ${LVM_DIR} is invalid!'
+                       gen_die "LVM directory ${LVM_DIR} is invalid!"
                cd "${LVM_DIR}"
                apply_patches lvm ${LVM_VER}
                print_info 1 'lvm: >> Configuring...'
                        CFLAGS="-fPIC" \
-                       ./configure --enable-static_link --prefix=${TEMP}/lvm \
+                       ./configure --enable-static_link --prefix=/ \
                                --with-lvm1=internal --with-clvmd=none --with-cluster=none \
                                --disable-readline --disable-selinux --with-mirrors=internal \
-                               --with-snapshots=internal --with-pool=internal >> ${LOGFILE} 2>&1 || \
+                               --with-snapshots=internal --with-pool=internal \
+                               >> ${LOGFILE} 2>&1 || \
                                gen_die 'Configure of lvm failed!'
                print_info 1 'lvm: >> Compiling...'
-                       compile_generic '' utils
-                       compile_generic 'install' utils
+               compile_generic '' utils
+               compile_generic "install DESTDIR=${TEMP}/lvm/" utils
 
                cd "${TEMP}/lvm"
                print_info 1 '      >> Copying to bincache...'
-               strip "sbin/lvm.static" ||
+               ${UTILS_CROSS_COMPILE}strip "sbin/lvm.static" ||
                        gen_die 'Could not strip lvm.static!'
                # See bug 382555
-               strip "sbin/dmsetup.static" ||
+               ${UTILS_CROSS_COMPILE}strip "sbin/dmsetup.static" ||
                        gen_die 'Could not strip dmsetup.static'
-               /bin/tar -cjf "${LVM_BINCACHE}" sbin/lvm.static sbin/dmsetup.static ||
+               /bin/tar -cjf "${LVM_BINCACHE}" . ||
                        gen_die 'Could not create binary cache'
 
                cd "${TEMP}"
-               rm -rf "${TEMP}/device-mapper" > /dev/null
+               rm -rf "${TEMP}/lvm" > /dev/null
                rm -rf "${LVM_DIR}" lvm
        fi
 }
@@ -475,7 +486,7 @@ compile_mdadm() {
                /bin/tar -jxpf "${MDADM_SRCTAR}" ||
                        gen_die 'Could not extract MDADM source tarball!'
                [ -d "${MDADM_DIR}" ] ||
-                       gen_die 'MDADM directory ${MDADM_DIR} is invalid!'
+                       gen_die "MDADM directory ${MDADM_DIR} is invalid!"
 
                cd "${MDADM_DIR}"
                apply_patches mdadm ${MDADM_VER}
@@ -492,7 +503,7 @@ compile_mdadm() {
                install -m 0755 -s mdmon "${TEMP}/mdadm/sbin/mdmon"
                print_info 1 '      >> Copying to bincache...'
                cd "${TEMP}/mdadm"
-               strip "sbin/mdadm" "sbin/mdmon" ||
+               ${UTILS_CROSS_COMPILE}strip "sbin/mdadm" "sbin/mdmon" ||
                        gen_die 'Could not strip mdadm binaries!'
                /bin/tar -cjf "${MDADM_BINCACHE}" sbin/mdadm sbin/mdmon ||
                        gen_die 'Could not create binary cache'
@@ -513,24 +524,26 @@ compile_dmraid() {
                /bin/tar -jxpf ${DMRAID_SRCTAR} ||
                        gen_die 'Could not extract DMRAID source tarball!'
                [ -d "${DMRAID_DIR}" ] ||
-                       gen_die 'DMRAID directory ${DMRAID_DIR} is invalid!'
-               rm -rf "${TEMP}/device-mapper" > /dev/null
-               /bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" ||
-                       gen_die "Could not extract device-mapper binary cache!";
+                       gen_die "DMRAID directory ${DMRAID_DIR} is invalid!"
+               rm -rf "${TEMP}/lvm" > /dev/null
+               mkdir -p "${TEMP}/lvm"
+               /bin/tar -jxpf "${LVM_BINCACHE}" -C "${TEMP}/lvm" ||
+                       gen_die "Could not extract LVM2 binary cache!";
 
                cd "${DMRAID_DIR}"
                apply_patches dmraid ${DMRAID_VER}
                print_info 1 'dmraid: >> Configuring...'
 
-               LDFLAGS="-L${TEMP}/device-mapper/lib" \
-               CFLAGS="-I${TEMP}/device-mapper/include" \
-               CPPFLAGS="-I${TEMP}/device-mapper/include" \
+               LDFLAGS="-L${TEMP}/lvm/lib" \
+               CFLAGS="-I${TEMP}/lvm/include" \
+               CPPFLAGS="-I${TEMP}/lvm/include" \
+               LIBS="-ldevmapper" \
                ./configure --enable-static_link --prefix=${TEMP}/dmraid >> ${LOGFILE} 2>&1 ||
                        gen_die 'Configure of dmraid failed!'
 
                # We dont necessarily have selinux installed yet... look into
                # selinux global support in the future.
-               sed -i tools/Makefile -e "s|DMRAIDLIBS += -lselinux||g"
+               sed -i tools/Makefile -e "/DMRAID_LIBS +=/s|-lselinux||g"
                ###echo "DMRAIDLIBS += -lselinux -lsepol" >> tools/Makefile
                mkdir -p "${TEMP}/dmraid"
                print_info 1 'dmraid: >> Compiling...'
@@ -545,78 +558,13 @@ compile_dmraid() {
                        gen_die 'Could not create binary cache'
 
                cd "${TEMP}"
-               rm -rf "${TEMP}/device-mapper" > /dev/null
+               rm -rf "${TEMP}/lvm" > /dev/null
                rm -rf "${DMRAID_DIR}" dmraid
        fi
 }
 
 compile_device_mapper() {
-       if [ ! -f "${DEVICE_MAPPER_BINCACHE}" ]
-       then
-               [ ! -f "${DEVICE_MAPPER_SRCTAR}" ] &&
-                       gen_die "Could not find device-mapper source tarball: ${DEVICE_MAPPER_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
-               cd "${TEMP}"
-               rm -rf "${DEVICE_MAPPER_DIR}"
-               /bin/tar -zxpf "${DEVICE_MAPPER_SRCTAR}"
-               [ ! -d "${DEVICE_MAPPER_DIR}" ] &&
-                       gen_die "device-mapper directory ${DEVICE_MAPPER_DIR} invalid"
-               cd "${DEVICE_MAPPER_DIR}"
-               apply_patches device-mapper ${DEVICE_MAPPER_VER}
-               CFLAGS="-fPIC" \
-               ./configure --prefix=${TEMP}/device-mapper --enable-static_link \
-                       --disable-selinux >> ${LOGFILE} 2>&1 ||
-                       gen_die 'Configuring device-mapper failed!'
-               print_info 1 'device-mapper: >> Compiling...'
-               compile_generic '' utils
-               compile_generic 'install' utils
-               print_info 1 '        >> Copying to cache...'
-               cd "${TEMP}"
-               rm -rf "${TEMP}/device-mapper/man" ||
-                       gen_die 'Could not remove manual pages!'
-               strip "${TEMP}/device-mapper/sbin/dmsetup" ||
-                       gen_die 'Could not strip dmsetup binary!'
-               /bin/tar -jcpf "${DEVICE_MAPPER_BINCACHE}" device-mapper ||
-                       gen_die 'Could not tar up the device-mapper binary!'
-               [ -f "${DEVICE_MAPPER_BINCACHE}" ] ||
-                       gen_die 'device-mapper cache not created!'
-               cd "${TEMP}"
-               rm -rf "${DEVICE_MAPPER_DIR}" > /dev/null
-               rm -rf "${TEMP}/device-mapper" > /dev/null
-       fi
-}
-
-compile_e2fsprogs() {
-       if [ -f "${BLKID_BINCACHE}" ]
-       then
-               print_info 1 "blkid: >> Using cache"
-       else
-               [ ! -f "${E2FSPROGS_SRCTAR}" ] &&
-                       gen_die "Could not find e2fsprogs source tarball: ${E2FSPROGS_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
-               cd "${TEMP}"
-               rm -rf "${E2FSPROGS_DIR}"
-               tar -zxpf "${E2FSPROGS_SRCTAR}"
-               [ ! -d "${E2FSPROGS_DIR}" ] &&
-                       gen_die "e2fsprogs directory ${E2FSPROGS_DIR} invalid"
-               cd "${E2FSPROGS_DIR}"
-               apply_patches e2fsprogs ${E2FSPROGS_VER}
-               print_info 1 'e2fsprogs: >> Configuring...'
-               LDFLAGS=-static ./configure >> ${LOGFILE} 2>&1 ||
-                       gen_die 'Configuring e2fsprogs failed!'
-               print_info 1 'e2fsprogs: >> Compiling...'
-               MAKE=${UTILS_MAKE} MAKEOPTS="${MAKEOPTS} -j1" compile_generic "" ""
-               print_info 1 'blkid: >> Copying to cache...'
-               [ -f "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ] ||
-                       gen_die 'Blkid executable does not exist!'
-               strip "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
-                       gen_die 'Could not strip blkid binary!'
-               bzip2 "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
-                       gen_die 'bzip2 compression of blkid failed!'
-               mv "${TEMP}/${E2FSPROGS_DIR}/misc/blkid.bz2" "${BLKID_BINCACHE}" ||
-                       gen_die 'Could not copy the blkid binary to the package directory, does the directory exist?'
-
-               cd "${TEMP}"
-               rm -rf "${E2FSPROGS_DIR}" > /dev/null
-       fi
+       compile_lvm
 }
 
 compile_fuse() {
@@ -632,7 +580,7 @@ compile_fuse() {
                cd "${FUSE_DIR}"
                apply_patches fuse ${FUSE_VER}
                print_info 1 'fuse: >> Configuring...'
-               ./configure  --disable-kernel-module --disable-example >> ${LOGFILE} 2>&1 ||
+               ./configure --disable-example >> ${LOGFILE} 2>&1 ||
                        gen_die 'Configuring fuse failed!'
                print_info 1 'fuse: >> Compiling...'
                MAKE=${UTILS_MAKE} compile_generic "" ""
@@ -641,7 +589,7 @@ compile_fuse() {
 #              print_info 1 'libfuse: >> Copying to cache...'
 #              [ -f "${TEMP}/${FUSE_DIR}/lib/.libs/libfuse.so" ] ||
 #                      gen_die 'libfuse.so does not exist!'
-#              strip "${TEMP}/${FUSE_DIR}/lib/.libs/libfuse.so" ||
+#              ${UTILS_CROSS_COMPILE}strip "${TEMP}/${FUSE_DIR}/lib/.libs/libfuse.so" ||
 #                      gen_die 'Could not strip libfuse.so!'
 #              cd "${TEMP}/${FUSE_DIR}/lib/.libs"
 #              tar -cjf "${FUSE_BINCACHE}" libfuse*so* ||
@@ -670,12 +618,12 @@ compile_unionfs_fuse() {
                apply_patches unionfs-fuse ${UNIONFS_FUSE_VER}
                print_info 1 'unionfs-fuse: >> Compiling...'
                sed -i "/^\(CFLAGS\|CPPFLAGS\)/s:^\\(.*\\)$:\\1 -static -I${TEMP}/${FUSE_DIR}/include -L${TEMP}/${FUSE_DIR}/lib/.libs:" Makefile src/Makefile
-               sed -i "/^LIB = /s:^LIB = \(.*\)$:LIB = -static -L${TEMP}/${FUSE_DIR}/lib/.libs \1 -ldl -lrt:" Makefile src/Makefile
+               sed -i "/^LIB = /s:^LIB = \(.*\)$:LIB = -static -L${TEMP}/${FUSE_DIR}/lib/.libs \1 -ldl -lpthread -lrt:" Makefile src/Makefile
                MAKE=${UTILS_MAKE} compile_generic "" ""
                print_info 1 'unionfs-fuse: >> Copying to cache...'
                [ -f "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs" ] ||
                        gen_die 'unionfs binary does not exist!'
-               strip "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs" ||
+               ${UTILS_CROSS_COMPILE}strip "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs" ||
                        gen_die 'Could not strip unionfs binary!'
                bzip2 "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs" ||
                        gen_die 'bzip2 compression of unionfs binary failed!'
@@ -725,7 +673,7 @@ compile_iscsi() {
                print_info 1 'iscsistart: >> Copying to cache...'
                [ -f "${TEMP}/${ISCSI_DIR}/usr/iscsistart" ] ||
                        gen_die 'iscsistart executable does not exist!'
-               strip "${TEMP}/${ISCSI_DIR}/usr/iscsistart" ||
+               ${UTILS_CROSS_COMPILE}strip "${TEMP}/${ISCSI_DIR}/usr/iscsistart" ||
                        gen_die 'Could not strip iscsistart binary!'
                bzip2 "${TEMP}/${ISCSI_DIR}/usr/iscsistart" ||
                        gen_die 'bzip2 compression of iscsistart failed!'
@@ -772,7 +720,7 @@ compile_gpg() {
                print_info 1 'gnupg: >> Copying to cache...'
                [ -f "${TEMP}/${GPG_DIR}/g10/gpg" ] ||
                        gen_die 'gnupg executable does not exist!'
-               strip "${TEMP}/${GPG_DIR}/g10/gpg" ||
+               ${UTILS_CROSS_COMPILE}strip "${TEMP}/${GPG_DIR}/g10/gpg" ||
                        gen_die 'Could not strip gpg binary!'
                bzip2 -z -c "${TEMP}/${GPG_DIR}/g10/gpg" > "${GPG_BINCACHE}" ||
                        gen_die 'Could not copy the gpg binary to the package directory, does the directory exist?'