From adc42dfa9f0f411468b7cfe852c470e818bf2085 Mon Sep 17 00:00:00 2001 From: Pavel Valena Date: Aug 16 2022 14:15:45 +0000 Subject: dmsquash-live-root: Run checkisomd5 on correct device Resolves: #2107858 --- diff --git a/1882-dmsquash-live-root-Run-checkisomd5-on-correct-device.patch b/1882-dmsquash-live-root-Run-checkisomd5-on-correct-device.patch new file mode 100644 index 0000000..8803e85 --- /dev/null +++ b/1882-dmsquash-live-root-Run-checkisomd5-on-correct-device.patch @@ -0,0 +1,90 @@ +From 0636c42eaddef24903b66aa8d0cb392ba24b9a3d Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Fri, 22 Jul 2022 16:10:20 -0700 +Subject: [PATCH] fix(dmsquash-live): run checkisomd5 on correct device + +When the new grub2 iso is written to a usb drive the disk label points +to a partition that does not include the full iso image. This causes +checkisomd5 to run with the wrong data and it fails. + +This patch adds a check that will test to see if there is a parent +device that is a disk, and to run checkisomd5 on it instead of on the +partition pointed to by the label. + +When running from an iso this will return the original +/dev/disk/by-label/ path, and when running from a usb drive it will +return the parent device (eg. /dev/sda). + +Resolves: rhbz#2107858 +--- + .../90dmsquash-live/dmsquash-live-root.sh | 33 +++++++++++++++++-- + modules.d/90dmsquash-live/module-setup.sh | 2 +- + 2 files changed, 31 insertions(+), 4 deletions(-) + +diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh +index abc68407f4..665bff87c1 100755 +--- a/modules.d/90dmsquash-live/dmsquash-live-root.sh ++++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh +@@ -33,8 +33,35 @@ overlay_size=$(getarg rd.live.overlay.size=) + getargbool 0 rd.live.overlay.thin && thin_snapshot="yes" + getargbool 0 rd.live.overlay.overlayfs && overlayfs="yes" + ++# Take a path to a disk label and return the parent disk if it is a partition ++# Otherwise returns the original path ++function get_check_dev() { ++ local _udevinfo ++ dev_path="$(udevadm info -q path --name "$1")" ++ _udevinfo="$(udevadm info -q property --path "${dev_path}")" ++ strstr "$_udevinfo" "DEVTYPE=partition" || { ++ echo "$1" ++ return ++ } ++ parent="${dev_path%/*}" ++ _udevinfo="$(udevadm info -q property --path "${parent}")" ++ strstr "$_udevinfo" "DEVTYPE=disk" || { ++ echo "$1" ++ return ++ } ++ strstr "$_udevinfo" "ID_FS_TYPE=iso9660" || { ++ echo "$1" ++ return ++ } ++ ++ # Return the name of the parent disk device ++ echo "$_udevinfo" | grep "DEVNAME=" | sed 's/DEVNAME=//' ++} ++ ++# Find the right device to run check on ++check_dev=$(get_check_dev "$livedev") + # CD/DVD media check +-[ -b "$livedev" ] && fs=$(blkid -s TYPE -o value "$livedev") ++[ -b "$check_dev" ] && fs=$(blkid -s TYPE -o value "$check_dev") + if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then + check="yes" + fi +@@ -42,10 +69,10 @@ getarg rd.live.check -d check || check="" + if [ -n "$check" ]; then + type plymouth > /dev/null 2>&1 && plymouth --hide-splash + if [ -n "$DRACUT_SYSTEMD" ]; then +- p=$(dev_unit_name "$livedev") ++ p=$(dev_unit_name "$check_dev") + systemctl start checkisomd5@"${p}".service + else +- checkisomd5 --verbose "$livedev" ++ checkisomd5 --verbose "$check_dev" + fi + if [ $? -eq 1 ]; then + die "CD check failed!" +diff --git a/modules.d/90dmsquash-live/module-setup.sh b/modules.d/90dmsquash-live/module-setup.sh +index dc35ba6579..b305ce1aa3 100755 +--- a/modules.d/90dmsquash-live/module-setup.sh ++++ b/modules.d/90dmsquash-live/module-setup.sh +@@ -22,7 +22,7 @@ installkernel() { + + # called by dracut + install() { +- inst_multiple umount dmsetup blkid dd losetup blockdev find rmdir ++ inst_multiple umount dmsetup blkid dd losetup blockdev find rmdir grep + inst_multiple -o checkisomd5 + inst_hook cmdline 30 "$moddir/parse-dmsquash-live.sh" + inst_hook cmdline 31 "$moddir/parse-iso-scan.sh" diff --git a/dracut.spec b/dracut.spec index cb33e60..346cb9a 100644 --- a/dracut.spec +++ b/dracut.spec @@ -5,11 +5,11 @@ # strip the automatically generated dep here and instead co-own the # directory. %global __requires_exclude pkg-config -%define dist_free_release 1 +%define dist_free_release 2 Name: dracut Version: 057 -Release: %{dist_free_release}%{?dist}.1 +Release: %{dist_free_release}%{?dist} Summary: Initramfs generator using udev @@ -26,6 +26,10 @@ Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar Source1: https://www.gnu.org/licenses/lgpl-2.1.txt +# dmsquash-live-root: Run checkisomd5 on correct device +# https://github.com/dracutdevs/dracut/pull/1882 +Patch0: 1882-dmsquash-live-root-Run-checkisomd5-on-correct-device.patch + BuildRequires: bash BuildRequires: git-core BuildRequires: pkgconfig(libkmod) >= 23 @@ -423,6 +427,9 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/ %{_prefix}/lib/kernel/install.d/51-dracut-rescue.install %changelog +* Tue Aug 16 2022 Pavel Valena - 057-2 +- dmsquash-live-root: Run checkisomd5 on correct device + * Thu Jul 21 2022 Fedora Release Engineering - 057-1.1 - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild