From 5457e2427161b661d07f5b89c479bda7928fcaf1 Mon Sep 17 00:00:00 2001 From: Tim Yamin Date: Sat, 27 Nov 2004 13:52:43 +0000 Subject: [PATCH] LVM2 compilation support; thanks to Eric Edgar for the patch. Bug #72129. git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@151 67a159dc-881f-0410-a524-ba9dfbe2cb84 --- gen_cmdline.sh | 8 ++--- gen_compile.sh | 72 ++++++++++++++++++++++++++++++++++++++++++++ gen_determineargs.sh | 4 +++ gen_initrd.sh | 34 ++++++++++++++++----- genkernel | 2 -- genkernel.conf | 10 ++++++ 6 files changed, 117 insertions(+), 13 deletions(-) diff --git a/gen_cmdline.sh b/gen_cmdline.sh index 276f898..b02e105 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -63,7 +63,7 @@ longusage() { echo " --bootsplash= Force bootsplash using " echo " --gensplash= Force gensplash using " echo " --do-keymap-auto Forces keymap selection at boot" - echo " --no-lvm2 Don't include LVM2 support" + echo " --lvm2 Include LVM2 support" echo " --bootloader=grub Add new kernel to GRUB configuration" echo " --linuxrc= Specifies a user created linuxrc" echo " Internals" @@ -153,9 +153,9 @@ parse_cmdline() { CMD_NOEVMS2=1 print_info 2 'CMD_NOEVMS2: 1' ;; - --no-lvm2) - CMD_NOLVM2=1 - print_info 2 'CMD_NOLVM2: 1' + --lvm2) + CMD_LVM2=1 + print_info 2 'CMD_LVM2: 1' ;; --bootloader=*) CMD_BOOTLOADER=`parse_opt "$*"` diff --git a/gen_compile.sh b/gen_compile.sh index 94f068c..d8754bb 100644 --- a/gen_compile.sh +++ b/gen_compile.sh @@ -277,6 +277,46 @@ compile_busybox() { fi } +compile_lvm2() { + compile_device_mapper + if [ ! -f "${LVM2_BINCACHE}" ] + then + [ -f "${LVM2_SRCTAR}" ] || + gen_die "Could not find LVM2 source tarball: ${LVM2_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!" + cd "${TEMP}" + rm -rf ${LVM2_DIR} > /dev/null + tar -zxpf ${LVM2_SRCTAR} || + gen_die 'Could not extract LVM2 source tarball!' + [ -d "${LVM2_DIR}" ] || + gen_die 'LVM2 directory ${LVM2_DIR} is invalid!' + rm -rf "${TEMP}/device-mapper" > /dev/null + tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" || + gen_die "Could not extract device-mapper binary cache!"; + + cd "${LVM2_DIR}" + print_info 1 'lvm2: >> Configuring...' + LDFLAGS="-L${TEMP}/device-mapper/lib" \ + CFLAGS="-I${TEMP}/device-mapper/include" \ + CPPFLAGS="-I${TEMP}/device-mapper/include" \ + ./configure --enable-static_link --prefix=${TEMP}/lvm2 >> ${DEBUGFILE} 2>&1 || + gen_die 'Configure of lvm2 failed!' + print_info 1 'lvm2: >> Compiling...' + compile_generic '' utils + compile_generic 'install' utils + + cd "${TEMP}/lvm2" + print_info 1 ' >> Copying to bincache...' + strip "sbin/lvm.static" || + gen_die 'Could not strip lvm.static!' + tar -cjf "${LVM2_BINCACHE}" sbin/lvm.static || + gen_die 'Could not create binary cache' + + cd "${TEMP}" + rm -rf "${TEMP}/device-mapper" > /dev/null + rm -rf "${LVM2_DIR}" lvm2 + fi +} + compile_modutils() { # I've disabled dietlibc support for the time being since the # version we use misses a few needed system calls. @@ -438,6 +478,38 @@ compile_devfsd() { 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}" + tar -zxpf "${DEVICE_MAPPER_SRCTAR}" + [ ! -d "${DEVICE_MAPPER_DIR}" ] && + gen_die "device-mapper directory ${DEVICE_MAPPER_DIR} invalid" + cd "${DEVICE_MAPPER_DIR}" + ./configure --prefix=${TEMP}/device-mapper --enable-static_link >> ${DEBUGFILE} 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 -r "${TEMP}/device-mapper/man" || + gen_die 'Could not remove manual pages!' + strip "${TEMP}/device-mapper/sbin/dmsetup" || + gen_die 'Could not strip dmsetup binary!' + 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_dietlibc() { local BUILD_DIETLIBC local ORIGTEMP diff --git a/gen_determineargs.sh b/gen_determineargs.sh index c5feead..b407cf7 100644 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -92,6 +92,8 @@ determine_real_args() { DEVFSD_BINCACHE=`cache_replace "${DEVFSD_BINCACHE}"` DEVFSD_CONF_BINCACHE=`cache_replace "${DEVFSD_CONF_BINCACHE}"` UDEV_BINCACHE=`cache_replace "${UDEV_BINCACHE}"` + DEVICE_MAPPER_BINCACHE=`cache_replace "${DEVICE_MAPPER_BINCACHE}"` + LVM2_BINCACHE=`cache_replace "${LVM2_BINCACHE}"` DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"` BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"` @@ -103,6 +105,8 @@ determine_real_args() { DEVFSD_BINCACHE=`arch_replace "${DEVFSD_BINCACHE}"` DEVFSD_CONF_BINCACHE=`arch_replace "${DEVFSD_CONF_BINCACHE}"` UDEV_BINCACHE=`arch_replace "${UDEV_BINCACHE}"` + DEVICE_MAPPER_BINCACHE=`arch_replace "${DEVICE_MAPPER_BINCACHE}"` + LVM2_BINCACHE=`arch_replace "${LVM2_BINCACHE}"` if [ "${CMD_BOOTSPLASH}" != '' ] then diff --git a/gen_initrd.sh b/gen_initrd.sh index 7923276..7a44702 100644 --- a/gen_initrd.sh +++ b/gen_initrd.sh @@ -93,26 +93,46 @@ create_base_initrd_sys() { # gen_die "could not uncompress devfsd.conf" # LVM2 - if [ -e '/sbin/lvm' ] && ldd /sbin/lvm|grep -q 'not a dynamic executable'; + if [ "${CMD_LVM2}" -eq '1' ] then - if [ "${CMD_NOLVM2}" != '1' ] + if [ -e '/sbin/lvm' ] && ldd /sbin/lvm|grep -q 'not a dynamic executable'; then - print_info 1 'lvm2: Adding support...' + print_info 1 'LVM2: Adding support (using local static binaries)...' cp /sbin/lvm "${TEMP}/initrd-temp/bin/lvm" || gen_die 'Could not copy over lvm!' - ln -sf "./lvm" "${TEMP}/initrd-temp/bin/vgscan" || + ln -sf "${TEMP}/initrd-temp/bin/lvm" "${TEMP}/initrd-temp/bin/vgscan" || gen_die 'Could not symlink lvm -> vgscan!' - ln -sf "./lvm" "${TEMP}/initrd-temp/bin/vgchange" || + ln -sf "${TEMP}/initrd-temp/bin/lvm" "${TEMP}/initrd-temp/bin/vgchange" || gen_die 'Could not symlink lvm -> vgchange!' + else + print_info 1 'LVM2: Adding support (compiling binaries)...' + compile_lvm2 + + tar -jxpf "${LVM2_BINCACHE}" -C "${TEMP}/initrd-temp" || + gen_die "Could not extract lvm2 binary cache!"; + mv ${TEMP}/initrd-temp/bin/lvm.static ${TEMP}/initrd-temp/bin/lvm || + gen_die 'LVM2 error: Could not move lvm.static to lvm!' + for i in vgchange vgscan; do + ln ${TEMP}/initrd-temp/bin/lvm ${TEMP}/initrd-temp/bin/$i || + gen_die "LVM2 error: Could not link ${i}!" + done + fi + else # Deprecation warning; remove in a few versions. + if [ -e '/sbin/lvm' ] + then + if ldd /sbin/lvm|grep -q 'not a dynamic executable'; + then + print_warning 1 'LVM2: For support, use --lvm2!' + fi fi fi - #EVMS2 + # EVMS2 if [ -e '/sbin/evms_activate' ] then if [ "${CMD_NOEVMS2}" -ne '1' ] then - print_info 1 'evms2: Adding support...' + print_info 1 'EVMS2: Adding support...' mkdir -p ${TEMP}/initrd-temp/lib cp -a /lib/ld-* "${TEMP}/initrd-temp/lib" || gen_die 'Could not copy files for EVMS2!' cp -a /lib/libc-* /lib/libc.* "${TEMP}/initrd-temp/lib" || gen_die 'Could not copy files for EVMS2!' diff --git a/genkernel b/genkernel index 29cda30..35477a7 100755 --- a/genkernel +++ b/genkernel @@ -265,8 +265,6 @@ then fi compile_devfsd - #UDEV=0 - #[ "${VER}" -gt '2' ] || [ "${VER}" -eq '2' -a "${PAT}" -ge '6' -a "${NOUDEV}" -eq '0' ] && UDEV=1 && print_info 1 'udev: Target is a 2.6 kernel, support enabled.' [ "${UDEV}" -eq '1' ] && compile_udev # Create initrd diff --git a/genkernel.conf b/genkernel.conf index e925fd2..74b6717 100755 --- a/genkernel.conf +++ b/genkernel.conf @@ -94,3 +94,13 @@ UDEV_VER="039" UDEV_DIR="udev-${UDEV_VER}" UDEV_SRCTAR="${GK_SHARE}/pkg/udev-${UDEV_VER}.tar.bz2" UDEV_BINCACHE="%%CACHE%%/udev-${UDEV_VER}-%%ARCH%%.tar.bz2" + +DEVICE_MAPPER_VER="1.00.17" +DEVICE_MAPPER_DIR="device-mapper.${DEVICE_MAPPER_VER}" +DEVICE_MAPPER_SRCTAR="${GK_SHARE}/pkg/device-mapper.${DEVICE_MAPPER_VER}.tgz" +DEVICE_MAPPER_BINCACHE="%%CACHE%%/device-mapper-${DEVICE_MAPPER_VER}-%%ARCH%%.tar.bz2" + +LVM2_VER="2.00.25" +LVM2_DIR="LVM2.${LVM2_VER}" +LVM2_SRCTAR="${GK_SHARE}/pkg/LVM2.${LVM2_VER}.tgz" +LVM2_BINCACHE="%%CACHE%%/LVM2.${LVM2_VER}-%%ARCH%%.tar.bz2" -- 2.26.2