Fix dmraid building with LVM/device-mapper
authorRobin H. Johnson <robbat2@gentoo.org>
Tue, 14 Feb 2012 08:31:46 +0000 (08:31 +0000)
committerRobin H. Johnson <robbat2@gentoo.org>
Tue, 14 Feb 2012 08:31:46 +0000 (08:31 +0000)
dmraid is entirely broken if you try to use the system static
LVM/device-mapper. Instead, always build our own LVM2 for the initramfs,
using DESTDIR for cleaner install. Dead code paths for old LVM2 build
not removed yet until more users have tested.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
ChangeLog
gen_compile.sh
gen_initramfs.sh

index 41db029d0a3667732e3a6582029a51765c661791..e5c391b996cafd32cf1940d453eeb67f650147f5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,13 @@
 # Distributed under the GPL v2
 # $Id$
 
+  14 Feb 2012; Robin H. Johnson <robbat2@gentoo.org> gen_compile.sh,
+  gen_initramfs.sh:
+  dmraid is entirely broken if you try to use the system static
+  LVM/device-mapper. Instead start always building LVM2 for the initramfs,
+  using DESTDIR for cleaner install. Dead code paths for old LVM2 build not
+  removed yet until more users have tested.
+
   12 Feb 2012; Robin H. Johnson <robbat2@gentoo.org> gen_compile.sh:
   More UTILS_CROSS_COMPILE prefix on strip calls.
 
index bc93be8dd1c0e79b431bea0ce33bf6ab7d395058..646e0efd21dccb936aeaa8e252a528b013847bfd 100755 (executable)
@@ -406,7 +406,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}"
@@ -441,19 +441,20 @@ 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...'
@@ -462,11 +463,11 @@ compile_lvm() {
                # See bug 382555
                ${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
 }
@@ -483,7 +484,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}
@@ -521,24 +522,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...'
@@ -553,7 +556,7 @@ 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
 }
index 57041731185b19bcb3010819cd3fc03dfa6823ee..9a17b3a1ac9ac595d263b704a90bb3a9afffd6a3 100755 (executable)
@@ -235,7 +235,7 @@ append_lvm(){
        cd ${TEMP}
        mkdir -p "${TEMP}/initramfs-lvm-temp/bin/"
        mkdir -p "${TEMP}/initramfs-lvm-temp/etc/lvm/"
-       if [ -e '/sbin/lvm.static' ]
+       if false && [ -e '/sbin/lvm.static' ]
        then
                print_info 1 '          LVM: Adding support (using local static binary /sbin/lvm.static)...'
                cp /sbin/lvm.static "${TEMP}/initramfs-lvm-temp/bin/lvm" ||
@@ -245,7 +245,7 @@ append_lvm(){
                then
                        cp /sbin/dmsetup.static "${TEMP}/initramfs-lvm-temp/bin/dmsetup"
                fi
-       elif [ -e '/sbin/lvm' ] && LC_ALL="C" ldd /sbin/lvm|grep -q 'not a dynamic executable'
+       elif false && [ -e '/sbin/lvm' ] && LC_ALL="C" ldd /sbin/lvm|grep -q 'not a dynamic executable'
        then
                print_info 1 '          LVM: Adding support (using local static binary /sbin/lvm)...'
                cp /sbin/lvm "${TEMP}/initramfs-lvm-temp/bin/lvm" ||
@@ -265,6 +265,7 @@ append_lvm(){
                # See bug 382555
                mv ${TEMP}/initramfs-lvm-temp/sbin/dmsetup.static ${TEMP}/initramfs-lvm-temp/bin/dmsetup ||
                        gen_die 'LVM error: Could not move dmsetup.static to dmsetup!'
+               rm -rf  ${TEMP}/initramfs-lvm-temp/{lib,share,man,include,sbin/{lvm,dmsetup}}
        fi
        if [ -x /sbin/lvm ]
        then