From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 508D0138359 for ; Thu, 23 Jul 2020 23:57:44 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0DF98E0878; Thu, 23 Jul 2020 23:57:42 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E7551E0891 for ; Thu, 23 Jul 2020 23:57:41 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 49DFE34F1AF for ; Thu, 23 Jul 2020 23:57:40 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 96D3F2F9 for ; Thu, 23 Jul 2020 23:57:35 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1595545008.73689f82a7ef090c4d8c22eced7a56471be14156.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: /, defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: defaults/initrd.scripts gen_initramfs.sh X-VCS-Directories: defaults/ / X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: 73689f82a7ef090c4d8c22eced7a56471be14156 X-VCS-Branch: master Date: Thu, 23 Jul 2020 23:57:35 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 52a3f167-2b8b-4164-b308-312436a5930b X-Archives-Hash: 0059e0f6982caa993279f05ee5c62d07 commit: 73689f82a7ef090c4d8c22eced7a56471be14156 Author: Thomas Deutschmann gentoo org> AuthorDate: Thu Jul 23 21:06:51 2020 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Thu Jul 23 22:56:48 2020 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=73689f82 ZFS: Enable UDEV support Signed-off-by: Thomas Deutschmann gentoo.org> defaults/initrd.scripts | 24 +++++++++++++++++------- gen_initramfs.sh | 23 ++++++++++++++++++++++- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index d2db059..304d634 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -1641,12 +1641,11 @@ start_volumes() { local zfs_cmd="run /sbin/zpool import -N -a ${ZPOOL_CACHE} ${ZPOOL_FORCE} 2>&1" is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'" + eval "${zfs_cmd}" - if [ $? -eq 0 ] + if [ $? -ne 0 ] then - good_msg "Importing ZFS pools succeeded!" - else - bad_msg "Imported ZFS pools failed!" + bad_msg "Importing ZFS pools failed!" fi else @@ -1660,22 +1659,33 @@ start_volumes() { local zfs_cmd="run /sbin/zpool export -f '${ZFS_POOL}' 2>&1" is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'" + eval "${zfs_cmd}" + if [ $? -ne 0 ] + then + bad_msg "Exporting ZFS pools failed!" + else + udevsettle + fi zfs_cmd="run /sbin/zpool import -N ${ZPOOL_CACHE} ${ZPOOL_FORCE} '${ZFS_POOL}' 2>&1" is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'" + eval "${zfs_cmd}" + if [ $? -ne 0 ] + then + bad_msg "Re-importing ZFS pools failed!" + fi fi else good_msg "Importing ZFS pool ${ZFS_POOL} ..." local zfs_cmd="run /sbin/zpool import -N ${ZPOOL_CACHE} ${ZPOOL_FORCE} '${ZFS_POOL}' 2>&1" is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'" + eval "${zfs_cmd}" - if [ $? -eq 0 ] + if [ $? -ne 0 ] then - good_msg "Import of ${ZFS_POOL} succeeded!" - else bad_msg "Import of ${ZFS_POOL} failed!" fi fi diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 24b23bb..570100e 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -992,7 +992,6 @@ append_zfs() { fi 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'!" @@ -1022,6 +1021,28 @@ append_zfs() { copy_binaries "${TDIR}" /sbin/{mount.zfs,zdb,zfs,zpool} + local udevdir=$(get_udevdir) + local udevdir_initramfs="/usr/lib/udev" + local udev_files=( $(qlist -e sys-fs/zfs:0 \ + | xargs --no-run-if-empty realpath \ + | grep -E -- "^${udevdir}") + ) + + if [ ${#udev_files[@]} -eq 0 ] + then + gen_die "Something went wrong: Did not found any udev-related files for sys-fs/zfs!" + fi + + mkdir -p "${TDIR}"/usr/lib/udev/rules.d || gen_die "Failed to create '${TDIR}/usr/lib/udev/rules.d'!" + + local udev_files + for udev_file in "${udev_files[@]}" + do + local dest_file="${TDIR%/}${udev_file/${udevdir}/${udevdir_initramfs}}" + cp -aL "${udev_file}" "${dest_file}" \ + || gen_die "Failed to copy '${udev_file}' to '${dest_file}'" + done + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" log_future_cpio_content find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \