commit:     3ef66728b81c05cda2fce8aa09edcf2b3711949f
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 09:56:51 2019 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Sun Jul 14 11:58:17 2019 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=3ef66728

gen_initramfs.sh: Refactor append_zfs()

Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 gen_determineargs.sh |  7 +++++++
 gen_initramfs.sh     | 38 +++++++++++++++++++++-----------------
 2 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index 7d01565..7fd39ef 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -420,6 +420,13 @@ determine_real_args() {
                then
                        gen_die "--multipath requires --lvm but --no-lvm is 
set!"
                fi
+
+               if isTrue "${ZFS}" && isTrue "$(tc-is-cross-compiler)"
+               then
+                       local error_msg="Using binpkg for ZFS is not supported."
+                       error_msg+=" Therefore we cannot cross-compile like 
requested!"
+                       gen_die "${error_msg}"
+               fi
        fi
 
        MICROCODE=${MICROCODE,,}

diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index 2d178bb..7723204 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -547,45 +547,49 @@ append_mdadm() {
                || gen_die "Failed to append ${PN} to cpio!"
 }
 
-append_zfs(){
-       if [ -d "${TEMP}/initramfs-zfs-temp" ]
+append_zfs() {
+       local PN=zfs
+       local TDIR="${TEMP}/initramfs-${PN}-temp"
+       if [ -d "${TDIR}" ]
        then
-               rm -r "${TEMP}/initramfs-zfs-temp"
+               rm -r "${TDIR}" || gen_die "Failed to clean out existing 
'${TDIR}'!"
        fi
 
-       mkdir -p "${TEMP}/initramfs-zfs-temp/etc/zfs"
+       mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!"
+       cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
+
+       mkdir -p "${TDIR}"/etc/zfs || gen_die "Failed to create 
'${TDIR}/etc/zfs'!"
 
        # Copy files to /etc/zfs
        for i in zdev.conf zpool.cache
        do
                if [ -f /etc/zfs/${i} ]
                then
-                       print_info 1 "$(getIndent 2)zfs: >> Including ${i}"
-                       cp -a "/etc/zfs/${i}" 
"${TEMP}/initramfs-zfs-temp/etc/zfs" 2> /dev/null \
-                               || gen_die "Could not copy file ${i} for ZFS"
+                       print_info 2 "$(get_indent 2)${PN}: >> Including ${i}"
+                       cp -aL "/etc/zfs/${i}" "${TDIR}/etc/zfs/${i}" 
2>/dev/null \
+                               || gen_die "Could not copy file '/etc/zfs/${i}' 
for ZFS"
                fi
        done
 
        if [ -f "/etc/hostid" ]
        then
-               local _hostid=$(hostid)
-               print_info 1 "$(getIndent 2)zfs: >> Embedding hostid 
'${_hostid}' into initramfs..."
-               cp -a /etc/hostid "${TEMP}/initramfs-zfs-temp/etc" 2> /dev/null 
\
+               local _hostid=$(hostid 2>/dev/null)
+               print_info 2 "$(get_indent 2)${PN}: >> Embedding hostid 
'${_hostid}' into initramfs ..."
+               cp -aL /etc/hostid "${TDIR}"/etc/hostid 2>/dev/null \
                        || gen_die "Failed to copy /etc/hostid"
 
-               echo "${_hostid}" > "${TEMP}/.embedded_hostid"
+               echo "${_hostid}" > "${TEMP}"/.embedded_hostid \
+                       || gen_die "Failed to record system's hostid!"
        else
-               print_info 2 "$(getIndent 2)zfs: /etc/hostid not found; You 
must use 'spl_hostid' kernel command-line parameter!"
+               print_warning 1 "$(get_indent 2)${PN}: /etc/hostid not found; 
You must use 'spl_hostid' kernel command-line parameter!"
        fi
 
-       copy_binaries "${TEMP}/initramfs-zfs-temp" 
/sbin/{mount.zfs,zdb,zfs,zpool}
+       copy_binaries "${TDIR}" /sbin/{mount.zfs,zdb,zfs,zpool}
 
-       cd "${TEMP}/initramfs-zfs-temp/"
+       cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
        log_future_cpio_content
        find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
-                       || gen_die "compressing zfs cpio"
-       cd "${TEMP}"
-       rm -rf "${TEMP}/initramfs-zfs-temp" > /dev/null
+               || gen_die "Failed to append ${PN} to cpio!"
 }
 
 append_btrfs() {

Reply via email to