--- /i686/usr/share/genkernel/gen_initramfs.sh 2006-02-18 09:01:51.000000000 +0100 +++ /x86_64/usr/share/genkernel/gen_initramfs.sh 2006-02-18 19:55:18.040974750 +0100 @@ -317,6 +317,12 @@ done } +# check for static linked file with objdump +is_static() { + objdump -T $1 2>&1 | grep "not a dynamic object" > /dev/null + return $? +} + create_initramfs_modules() { local group local group_modules @@ -368,6 +374,7 @@ fi mkdir -p "${TEMP}/initramfs-aux-temp/etc" mkdir -p "${TEMP}/initramfs-aux-temp/sbin" + mkdir -p "${TEMP}/initramfs-aux-temp/bin" if [ -f "${CMD_LINUXRC}" ] then cp "${CMD_LINUXRC}" "${TEMP}/initramfs-aux-temp/init" @@ -430,6 +437,14 @@ chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.scripts" chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.defaults" chmod +x "${TEMP}/initramfs-aux-temp/sbin/modprobe" + + if [ "${LUKS}" = '1' ] + then + is_static /bin/cryptsetup || gen_die "LUKS support requires static cryptsetup-luks. USE=-dynamic emerge cryptsetup-luks" + rm -f ${TEMP}/initramfs-aux-temp/bin/cryptsetup + cp /bin/cryptsetup ${TEMP}/initramfs-aux-temp/bin/cryptsetup + fi + cd "${TEMP}/initramfs-aux-temp/" find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-aux.cpio.gz rm -r "${TEMP}/initramfs-aux-temp/" --- /i686/usr/share/genkernel/gen_initrd.sh 2006-02-18 09:01:51.000000000 +0100 +++ /x86_64/usr/share/genkernel/gen_initrd.sh 2006-02-18 20:01:05.898714500 +0100 @@ -1,5 +1,11 @@ #!/bin/bash +# check for static linked file with objdump +is_static() { + objdump -T $1 2>&1 | grep "not a dynamic object" > /dev/null + return $? +} + # create_initrd_loop(size) create_initrd_loop() { local inodes @@ -212,6 +218,14 @@ ln ${TEMP}/initrd-temp/bin/busybox ${TEMP}/initrd-temp/bin/$i || gen_die "Busybox error: could not link ${i}!" done + + # LUKS + if [ "${LUKS}" = '1' ] + then + is_static /bin/cryptsetup || gen_die "LUKS support requires static cryptsetup-luks. USE=-dynamic emerge cryptsetup-luks" + rm -f ${TEMP}/initramfs-aux-temp/bin/cryptsetup + cp /bin/cryptsetup ${TEMP}/initramfs-aux-temp/bin/cryptsetup + fi } print_list() --- /i686/usr/share/genkernel/generic/linuxrc 2006-02-18 09:01:51.000000000 +0100 +++ /x86_64/usr/share/genkernel/generic/linuxrc 2006-02-18 20:04:10.002220250 +0100 @@ -385,6 +385,25 @@ elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "/dev/nfs" ] then got_good_root=1 + elif [ `echo ${REAL_ROOT} | sed -e "s/\([^:]*\):.*/\1/"` = "luks" ] + then + LUKSdev=`echo ${REAL_ROOT} | sed -e "s/luks:\(.*\)/\1/"` + if [ -e /bin/cryptsetup ] + then + if cryptsetup isLuks ${LUKSdev} + then + echo "LUKS partition - opening $LUKSdev" + cryptsetup luksOpen ${LUKSdev} root && + REAL_ROOT=/dev/mapper/root && + got_good_root=1 + else + echo "${LUKSDEV} is not a LUKS partition" + REAL_ROOT="" + fi + else + echo "This initrd does not support LUKS" + REAL_ROOT="" + fi else bad_msg "Block device ${REAL_ROOT} is not a valid root device..." REAL_ROOT="" --- /tmp/genkernel.conf 2006-02-18 20:06:28.094850500 +0100 +++ /x86_64/etc/genkernel.conf 2006-02-17 08:33:48.000000000 +0100 @@ -33,6 +33,9 @@ # Add new kernel to grub? # BOOTLOADER="grub" +# Add LUKS support? +LUKS="1" + # Add UDEV support? UDEV="1"