Fail hard on LUKS inclusion error (bug #409277), advise about sys-fs/cryptsetup[stati...
authorSebastian Pipping <sebastian@pipping.org>
Thu, 22 Mar 2012 15:07:23 +0000 (16:07 +0100)
committerSebastian Pipping <sebastian@pipping.org>
Sat, 12 May 2012 13:47:42 +0000 (15:47 +0200)
Conflicts:

ChangeLog

ChangeLog
gen_initramfs.sh

index 2a04479e5dbdc14b4d011f8899305f9d6eb6b039..2c48001dbd841b6e5eb11e39c19a6623e49b792b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,10 @@
 # Distributed under the GPL v2
 # $Id$
 
+  22 Mar 2012; Sebastian Pipping <sping@gentoo.org> gen_initramfs.sh:
+  Fail hard on LUKS inclusion error (bug #409277), advise about
+  sys-fs/cryptsetup[static], drop support for cryptsetup binary from /bin/
+
   17 Mar 2012; Sebastian Pipping <sping@gentoo.org> defaults/initrd.scripts,
   defaults/linuxrc:
   Fix docache (bug #397309)
index cfcfe9792bd9c0197cd5e5200b3174a9ba828dde..814b1e5312e1fb76c760cd65535fcbde2d4244c3 100755 (executable)
@@ -380,6 +380,10 @@ append_overlay(){
 }
 
 append_luks() {
+       local _luks_error_format="LUKS support cannot be included: %s.  Please emerge sys-fs/cryptsetup[static]."
+       local _luks_source=/sbin/cryptsetup
+       local _luks_dest=/sbin/cryptsetup
+
        if [ -d "${TEMP}/initramfs-luks-temp" ]
        then
                rm -r "${TEMP}/initramfs-luks-temp/"
@@ -391,20 +395,15 @@ append_luks() {
 
        if isTrue ${LUKS}
        then
-               if is_static /bin/cryptsetup
-               then
-                       print_info 1 "Including LUKS support"
-                       cp /bin/cryptsetup ${TEMP}/initramfs-luks-temp/sbin/cryptsetup
-                       chmod +x "${TEMP}/initramfs-luks-temp/sbin/cryptsetup"
-               elif is_static /sbin/cryptsetup
-               then
-                       print_info 1 "Including LUKS support"
-                       cp /sbin/cryptsetup ${TEMP}/initramfs-luks-temp/sbin/cryptsetup
-                       chmod +x "${TEMP}/initramfs-luks-temp/sbin/cryptsetup"
-               else
-                       print_info 1 "LUKS support requires static cryptsetup at /bin/cryptsetup or /sbin/cryptsetup"
-                       print_info 1 "Not including LUKS support"
-               fi
+               [ -x "${_luks_source}" ] \
+                               || gen_die "$(printf "${_luks_error_format}" "no file ${_luks_source}")"
+
+               is_static "${_luks_source}" \
+                               || gen_die "$(printf "${_luks_error_format}" "${_luks_source} not a static binary")"
+
+               print_info 1 "Including LUKS support"
+               cp "${_luks_source}" ${TEMP}/initramfs-luks-temp${_luks_dest}
+               chmod +x "${TEMP}/initramfs-luks-temp${_luks_dest}"
        fi
 
        find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \