Compare commits

...

9 Commits

Author SHA1 Message Date
Dusty Mabe 98fb2cfbe8 Support MACAddressPolicy=none for bond/bridge/team devices
In Fedora Linux there was a new 98-default-mac-none.link file added
to set the MACAddressPolicy=none for bond/bridge/team devices. We'd
like for this policy to apply in the initramfs as well. See

- https://fedoraproject.org/wiki/Changes/MAC_Address_Policy_none
- https://src.fedoraproject.org/rpms/systemd/pull-request/100#
2023-03-21 12:48:22 +01:00
Pavel Valena 546406c68c revert(network-manager): avoid restarting NetworkManager
https://github.com/dracutdevs/dracut/pull/2134
2023-03-21 12:48:22 +01:00
Pavel Valena eafb53bf7d fix(dracut.sh): handle --kmoddir with trailing /
https://github.com/dracutdevs/dracut/pull/2237

Resolves: #2173100
2023-03-21 12:48:22 +01:00
Pavel Valena 838fd4ef63 fix(dmsquash-live): restore compatibility with earlier releases
as current revert breaks NFS. Also re-add overlayfs module.

https://github.com/dracutdevs/dracut/pull/2233

Resolves: rhbz#2172269
2023-03-21 12:48:21 +01:00
Pavel Valena 6ccd6ab537 Fixup .gitignore file. 2023-02-21 10:26:11 +01:00
Pavel Valena 6de3d96c7b feat(kernel-modules): add driver needed for macbook keyboards 2023-02-21 02:11:18 +01:00
Pavel Valena ec3ccd4eec Skip creating initrd when initrd already provided,
or different generator is configured.

https://github.com/dracutdevs/dracut/pull/1825/
2023-02-20 23:39:19 +01:00
Pavel Valena ac8a9b0f0b Update to 059 2023-02-20 23:36:58 +01:00
Fedora Release Engineering a4900f1415 Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-01-19 01:45:55 +00:00
12 changed files with 326 additions and 536 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
/dracut-*.tar.xz
/*.tar.*

View File

@ -0,0 +1,93 @@
From f47bcdd7342ca0d46b889e712a1c7446e18434bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 18 Jan 2022 18:08:42 +0100
Subject: [PATCH 1/2] feat(kernel-install): do nothing when
$KERNEL_INSTALL_INITRD_GENERATOR says so
dracut may be installed without being actually used. This is very common in
binary distros where a package may be pulled in through dependencies, even
though the user does not need it in a particular setup. KERNEL_INSTALL_INITRD_GENERATOR
is being added in systemd's kernel-install to select which of the possibly many
initrd generation mechanisms will be used.
For backwards compat, if it not set, continue as before. But if set to
something else, skip our kernel-install plugins.
---
install.d/50-dracut.install | 8 +++++++-
install.d/51-dracut-rescue.install | 5 +++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/install.d/50-dracut.install b/install.d/50-dracut.install
index 70632ec7f..552fd0338 100755
--- a/install.d/50-dracut.install
+++ b/install.d/50-dracut.install
@@ -6,11 +6,17 @@ BOOT_DIR_ABS="$3"
KERNEL_IMAGE="$4"
# If KERNEL_INSTALL_MACHINE_ID is defined but empty, BOOT_DIR_ABS is a fake directory.
-# So, let's skip to create initrd.
+# In this case, do not create the initrd.
if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
exit 0
fi
+# Skip this plugin if we're using a different generator. If nothing is specified,
+# assume we're wanted since we're installed.
+if [ "${KERNEL_INSTALL_INITRD_GENERATOR:-dracut}" != "dracut" ]; then
+ exit 0
+fi
+
if [[ -d "$BOOT_DIR_ABS" ]]; then
INITRD="initrd"
else
diff --git a/install.d/51-dracut-rescue.install b/install.d/51-dracut-rescue.install
index 8bf9a6d95..93483931a 100755
--- a/install.d/51-dracut-rescue.install
+++ b/install.d/51-dracut-rescue.install
@@ -7,6 +7,11 @@ KERNEL_VERSION="$2"
BOOT_DIR_ABS="${3%/*}/0-rescue"
KERNEL_IMAGE="$4"
+# Skip this plugin if we're using a different generator. If nothing is specified,
+# assume we're wanted since we're installed.
+if [ "${KERNEL_INSTALL_INITRD_GENERATOR:-dracut}" != "dracut" ]; then
+ exit 0
+fi
dropindirs_sort()
{
From 0b72cf5c4eca0e0db76e3e210cfdc48e6b49bb74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 18 Jan 2022 18:58:58 +0100
Subject: [PATCH 2/2] fix(kernel-install): do not generate an initrd when one
was specified
According to the synopsis, kernel-install can be called with an
already-prepared initrd. In that case, no initrd should be generated by dracut.
---
install.d/50-dracut.install | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/install.d/50-dracut.install b/install.d/50-dracut.install
index 552fd0338..836251e92 100755
--- a/install.d/50-dracut.install
+++ b/install.d/50-dracut.install
@@ -4,6 +4,7 @@ COMMAND="$1"
KERNEL_VERSION="$2"
BOOT_DIR_ABS="$3"
KERNEL_IMAGE="$4"
+INITRD_OPTIONS_SHIFT=4
# If KERNEL_INSTALL_MACHINE_ID is defined but empty, BOOT_DIR_ABS is a fake directory.
# In this case, do not create the initrd.
@@ -27,6 +28,9 @@ fi
ret=0
case "$COMMAND" in
add)
+ # If the initrd was provided on the kernel command line, we shouldn't generate our own.
+ [ "$#" -gt "$INITRD_OPTIONS_SHIFT" ] && exit 0
+
INITRD_IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/initrd
if [[ -f ${INITRD_IMAGE_PREGENERATED} ]]; then
# we found an initrd at the same place as the kernel

View File

@ -1,90 +0,0 @@
From 0636c42eaddef24903b66aa8d0cb392ba24b9a3d Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
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"

View File

@ -1,400 +0,0 @@
From 732361736810166aeba87616c93206b3e252aabe Mon Sep 17 00:00:00 2001
From: Matt Coleman <matt@datto.com>
Date: Fri, 23 Sep 2022 19:28:25 -0400
Subject: [PATCH] feat(dmsquash-live): add new dmsquash-live-autooverlay module
(cherry picked from commit a3c67d27e75223bb45df19f850d246ced9a09938)
---
man/dracut.cmdline.7.asc | 4 +
.../create-overlay-genrules.sh | 10 ++
.../create-overlay.sh | 119 ++++++++++++++++++
.../module-setup.sh | 25 ++++
pkgbuild/dracut.spec | 3 +-
test/TEST-16-DMSQUASH/create-root.sh | 12 +-
test/TEST-16-DMSQUASH/test-init.sh | 6 +
test/TEST-16-DMSQUASH/test.sh | 38 +++++-
test/container/Dockerfile-Arch | 4 +-
test/container/Dockerfile-Debian | 1 +
test/container/Dockerfile-Fedora-latest | 1 +
test/container/Dockerfile-OpenSuse-latest | 2 +-
12 files changed, 216 insertions(+), 9 deletions(-)
create mode 100755 modules.d/90dmsquash-live-autooverlay/create-overlay-genrules.sh
create mode 100755 modules.d/90dmsquash-live-autooverlay/create-overlay.sh
create mode 100755 modules.d/90dmsquash-live-autooverlay/module-setup.sh
diff --git a/man/dracut.cmdline.7.asc b/man/dracut.cmdline.7.asc
index fda62fd1..40d13d83 100644
--- a/man/dracut.cmdline.7.asc
+++ b/man/dracut.cmdline.7.asc
@@ -1161,6 +1161,10 @@ rd.live.overlay=/dev/sdb1:persistent-overlay.img
rd.live.overlay=UUID=99440c1f-8daa-41bf-b965-b7240a8996f4
--
+**rd.live.overlay.cowfs=**__[btrfs|ext4|xfs]__::
+Specifies the filesystem to use when formatting the overlay partition.
+The default is ext4.
+
**rd.live.overlay.size=**__<size_MiB>__::
Specifies a non-persistent Device-mapper overlay size in MiB. The default is
_32768_.
diff --git a/modules.d/90dmsquash-live-autooverlay/create-overlay-genrules.sh b/modules.d/90dmsquash-live-autooverlay/create-overlay-genrules.sh
new file mode 100755
index 00000000..ed168d9f
--- /dev/null
+++ b/modules.d/90dmsquash-live-autooverlay/create-overlay-genrules.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# shellcheck disable=SC2154
+case "$root" in
+ live:/dev/*)
+ printf 'SYMLINK=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/create-overlay %s"\n' \
+ "${root#live:/dev/}" "${root#live:}" >> /etc/udev/rules.d/95-create-overlay.rules
+ wait_for_dev -n "${root#live:}"
+ ;;
+esac
diff --git a/modules.d/90dmsquash-live-autooverlay/create-overlay.sh b/modules.d/90dmsquash-live-autooverlay/create-overlay.sh
new file mode 100755
index 00000000..c89bda2b
--- /dev/null
+++ b/modules.d/90dmsquash-live-autooverlay/create-overlay.sh
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
+
+if getargbool 0 rd.live.debug -n -y rdlivedebug; then
+ exec > /tmp/create-overlay.$$.out
+ exec 2>> /tmp/create-overlay.$$.out
+ set -x
+fi
+
+gatherData() {
+ overlay=$(getarg rd.live.overlay)
+ if [ -z "$overlay" ]; then
+ info "Skipping overlay creation: kernel command line parameter 'rd.live.overlay' is not set"
+ exit 0
+ fi
+ # shellcheck disable=SC2086
+ if ! str_starts ${overlay} LABEL=; then
+ die "Overlay creation failed: the partition must be set by LABEL in the 'rd.live.overlay' kernel parameter"
+ fi
+
+ overlayLabel=${overlay#LABEL=}
+ # shellcheck disable=SC2086
+ if [ -b /dev/disk/by-label/${overlayLabel} ]; then
+ info "Skipping overlay creation: overlay already exists"
+ exit 0
+ fi
+
+ filesystem=$(getarg rd.live.overlay.cowfs)
+ [ -z "$filesystem" ] && filesystem="ext4"
+ if [ "$filesystem" != "ext4" ] && [ "$filesystem" != "xfs" ] && [ "$filesystem" != "btrfs" ]; then
+ die "Overlay creation failed: only ext4, xfs, and btrfs are supported in the 'rd.live.overlay.cowfs' kernel parameter"
+ fi
+
+ live_dir=$(getarg rd.live.dir)
+ [ -z "$live_dir" ] && live_dir="LiveOS"
+
+ [ -z "$1" ] && exit 1
+ rootDevice=$1
+
+ # The kernel command line's 'root=' parameter was parsed into the $root variable by the dmsquash-live module.
+ # $root contains the path to a symlink within /dev/disk/by-label, which points to a partition.
+ # This script needs that partition's parent block device.
+ # shellcheck disable=SC2046
+ # shellcheck disable=SC2086
+ rootDeviceAbsolutePath=$(readlink -f ${rootDevice})
+ rootDeviceSysfsPath=/sys/class/block/${rootDeviceAbsolutePath##*/}
+ if [ -f "${rootDeviceSysfsPath}/partition" ]; then
+ # shellcheck disable=SC2086
+ partition=$(cat ${rootDeviceSysfsPath}/partition)
+ else
+ partition=0
+ fi
+ # shellcheck disable=SC2086
+ readonly=$(cat ${rootDeviceSysfsPath}/ro)
+ # shellcheck disable=SC2086
+ if [ "$partition" != "1" ] || [ "$readonly" != "0" ]; then
+ info "Skipping overlay creation: unpartitioned or read-only media detected"
+ exit 0
+ fi
+ # shellcheck disable=SC2046
+ # shellcheck disable=SC2086
+ fullDriveSysfsPath=$(readlink -f ${rootDeviceSysfsPath}/..)
+ blockDevice=/dev/${fullDriveSysfsPath##*/}
+ currentPartitionCount=$(grep --count -E "${blockDevice#/dev/}[0-9]+" /proc/partitions)
+
+ # shellcheck disable=SC2086
+ freeSpaceStart=$(parted --script ${blockDevice} unit % print free \
+ | awk -v x=${currentPartitionCount} '$1 == x {getline; print $1}')
+ if [ -z "$freeSpaceStart" ]; then
+ info "Skipping overlay creation: there is no free space after the last partition"
+ exit 0
+ fi
+ partitionStart=$((${freeSpaceStart%.*} + 1))
+ if [ $partitionStart -eq 100 ]; then
+ info "Skipping overlay creation: there is not enough free space after the last partition"
+ exit 0
+ fi
+
+ overlayPartition=${blockDevice}$((currentPartitionCount + 1))
+
+ label=$(blkid --match-tag LABEL --output value "$rootDevice")
+ uuid=$(blkid --match-tag UUID --output value "$rootDevice")
+ if [ -z "$label" ] || [ -z "$uuid" ]; then
+ die "Overlay creation failed: failed to look up root device label and UUID"
+ fi
+}
+
+createPartition() {
+ # shellcheck disable=SC2086
+ parted --script --align optimal ${blockDevice} mkpart primary ${partitionStart}% 100%
+}
+
+createFilesystem() {
+ # shellcheck disable=SC2086
+ mkfs.${filesystem} -L ${overlayLabel} ${overlayPartition}
+
+ baseDir=/run/initramfs/create-overlayfs
+ mkdir -p ${baseDir}
+ # shellcheck disable=SC2086
+ mount -t auto ${overlayPartition} ${baseDir}
+
+ mkdir -p ${baseDir}/${live_dir}/ovlwork
+ # shellcheck disable=SC2086
+ mkdir ${baseDir}/${live_dir}/overlay-${label}-${uuid}
+
+ umount ${baseDir}
+ rm -r ${baseDir}
+}
+
+main() {
+ gatherData "$1"
+ createPartition
+ udevsettle
+ createFilesystem
+ udevsettle
+}
+
+main "$1"
diff --git a/modules.d/90dmsquash-live-autooverlay/module-setup.sh b/modules.d/90dmsquash-live-autooverlay/module-setup.sh
new file mode 100755
index 00000000..c3712eba
--- /dev/null
+++ b/modules.d/90dmsquash-live-autooverlay/module-setup.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+check() {
+ # including a module dedicated to live environments in a host-only initrd doesn't make sense
+ [[ $hostonly ]] && return 1
+ return 255
+}
+
+depends() {
+ echo dmsquash-live
+ return 0
+}
+
+installkernel() {
+ instmods btrfs ext4 xfs
+}
+
+install() {
+ inst_multiple awk blkid cat grep mkdir mount parted readlink rmdir tr umount
+ inst_multiple -o mkfs.btrfs mkfs.ext4 mkfs.xfs
+ # shellcheck disable=SC2154
+ inst_hook pre-udev 25 "$moddir/create-overlay-genrules.sh"
+ inst_script "$moddir/create-overlay.sh" "/sbin/create-overlay"
+ dracut_need_initqueue
+}
diff --git a/pkgbuild/dracut.spec b/pkgbuild/dracut.spec
index 71b7421c..0f3efda7 100644
--- a/pkgbuild/dracut.spec
+++ b/pkgbuild/dracut.spec
@@ -141,7 +141,7 @@ Requires: %{name} >= %{version}-%{dist_free_release}
Requires: %{name} = %{version}-%{release}
%endif
Requires: %{name}-network = %{version}-%{release}
-Requires: tar gzip coreutils bash device-mapper curl
+Requires: tar gzip coreutils bash device-mapper curl parted
%if 0%{?fedora}
Requires: fuse ntfs-3g
%endif
@@ -464,6 +464,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%files live
%{dracutlibdir}/modules.d/99img-lib
%{dracutlibdir}/modules.d/90dmsquash-live
+%{dracutlibdir}/modules.d/90dmsquash-live-autooverlay
%{dracutlibdir}/modules.d/90dmsquash-live-ntfs
%{dracutlibdir}/modules.d/90livenet
diff --git a/test/TEST-16-DMSQUASH/create-root.sh b/test/TEST-16-DMSQUASH/create-root.sh
index 9bc1aa5d..c11e17e0 100755
--- a/test/TEST-16-DMSQUASH/create-root.sh
+++ b/test/TEST-16-DMSQUASH/create-root.sh
@@ -11,9 +11,17 @@ udevadm control --reload
set -e
udevadm settle
-mkfs.ext4 -q -L dracut /dev/disk/by-id/ata-disk_root
+
+# create a single partition using 50% of the capacity of the image file created by test_setup() in test.sh
+sfdisk /dev/disk/by-id/ata-disk_root << EOF
+2048,161792
+EOF
+
+udevadm settle
+
+mkfs.ext4 -q -L dracut /dev/disk/by-id/ata-disk_root-part1
mkdir -p /root
-mount /dev/disk/by-id/ata-disk_root /root
+mount /dev/disk/by-id/ata-disk_root-part1 /root
mkdir -p /root/run /root/testdir
echo "Creating squashfs"
mksquashfs /source /root/testdir/rootfs.img -quiet
diff --git a/test/TEST-16-DMSQUASH/test-init.sh b/test/TEST-16-DMSQUASH/test-init.sh
index 068e8f38..959fa25f 100755
--- a/test/TEST-16-DMSQUASH/test-init.sh
+++ b/test/TEST-16-DMSQUASH/test-init.sh
@@ -9,6 +9,12 @@ exec > /dev/console 2>&1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker
+if grep -qF ' rd.live.overlay=LABEL=persist ' /proc/cmdline; then
+ # Writing to a file in the root filesystem lets test_run() verify that the autooverlay module successfully created
+ # and formatted the overlay partition and that the dmsquash-live module used it when setting up the rootfs overlay.
+ echo "dracut-autooverlay-success" > /overlay-marker
+fi
+
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
diff --git a/test/TEST-16-DMSQUASH/test.sh b/test/TEST-16-DMSQUASH/test.sh
index cf433489..a446b3c9 100755
--- a/test/TEST-16-DMSQUASH/test.sh
+++ b/test/TEST-16-DMSQUASH/test.sh
@@ -5,8 +5,9 @@ TEST_DESCRIPTION="live root on a squash filesystem"
KVERSION="${KVERSION-$(uname -r)}"
-# Uncomment this to debug failures
-# DEBUGFAIL="rd.shell rd.debug loglevel=7"
+# Uncomment these to debug failures
+#DEBUGFAIL="rd.shell rd.debug rd.live.debug loglevel=7"
+#DEBUGTOOLS="setsid ls cat sfdisk"
test_run() {
dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1
@@ -23,6 +24,27 @@ test_run() {
-initrd "$TESTDIR"/initramfs.testing
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-success -- "$TESTDIR"/marker.img || return 1
+
+ rootPartitions=$(sfdisk -d "$TESTDIR"/root.img | grep -c 'root\.img[0-9]')
+ [ "$rootPartitions" -eq 1 ] || return 1
+
+ "$testdir"/run-qemu \
+ "${disk_args[@]}" \
+ -boot order=d \
+ -append "rd.live.image rd.live.overlay.overlayfs=1 rd.live.overlay=LABEL=persist rd.live.dir=testdir root=LABEL=dracut console=ttyS0,115200n81 quiet selinux=0 rd.info rd.shell=0 panic=1 oops=panic softlockup_panic=1 $DEBUGFAIL" \
+ -initrd "$TESTDIR"/initramfs.testing-autooverlay
+
+ rootPartitions=$(sfdisk -d "$TESTDIR"/root.img | grep -c 'root\.img[0-9]')
+ [ "$rootPartitions" -eq 2 ] || return 1
+
+ (
+ # Ensure that this test works when run with the `V=1` parameter, which runs the script with `set -o pipefail`.
+ set +o pipefail
+
+ # Verify that the string "dracut-autooverlay-success" occurs in the second partition in the image file.
+ dd if="$TESTDIR"/root.img bs=1MiB skip=80 status=none \
+ | grep -U --binary-files=binary -F -m 1 -q dracut-autooverlay-success
+ ) || return 1
}
test_setup() {
@@ -49,7 +71,7 @@ test_setup() {
ln -s dracut-util "${initdir}/usr/bin/dracut-getarg"
ln -s dracut-util "${initdir}/usr/bin/dracut-getargs"
- inst_multiple mkdir ln dd stty mount poweroff
+ inst_multiple mkdir ln dd stty mount poweroff grep "$DEBUGTOOLS"
cp -a -- /etc/ld.so.conf* "$initdir"/etc
ldconfig -r "$initdir"
@@ -113,6 +135,16 @@ test_setup() {
--force "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
ls -sh "$TESTDIR"/initramfs.testing
+
+ "$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
+ --modules "dmsquash-live-autooverlay qemu" \
+ --omit "rngd" \
+ --drivers "ext4 sd_mod" \
+ --no-hostonly --no-hostonly-cmdline \
+ --force "$TESTDIR"/initramfs.testing-autooverlay "$KVERSION" || return 1
+
+ ls -sh "$TESTDIR"/initramfs.testing-autooverlay
+
rm -rf -- "$TESTDIR"/overlay
}
diff --git a/test/container/Dockerfile-Arch b/test/container/Dockerfile-Arch
index 922b8ede..4112cc5b 100644
--- a/test/container/Dockerfile-Arch
+++ b/test/container/Dockerfile-Arch
@@ -9,10 +9,10 @@ RUN echo 'export DRACUT_NO_XATTR=1 KVERSION=$(cd /lib/modules; ls -1 | tail -1)'
# Install needed packages for the dracut CI container
RUN pacman --noconfirm -Sy \
- linux dash strace dhclient asciidoc cpio pigz \
+ linux dash strace dhclient asciidoc cpio pigz squashfs-tools \
qemu btrfs-progs mdadm dmraid nfs-utils nfsidmap lvm2 nbd \
dhcp networkmanager multipath-tools vi tcpdump open-iscsi \
- git shfmt shellcheck astyle which base-devel && yes | pacman -Scc
+ git shfmt shellcheck astyle which base-devel glibc parted && yes | pacman -Scc
RUN useradd -m build
RUN su build -c 'cd && git clone https://aur.archlinux.org/perl-config-general.git && cd perl-config-general && makepkg -s --noconfirm'
diff --git a/test/container/Dockerfile-Debian b/test/container/Dockerfile-Debian
index b4c1704e..15eb9958 100644
--- a/test/container/Dockerfile-Debian
+++ b/test/container/Dockerfile-Debian
@@ -42,6 +42,7 @@ RUN apt-get update -y -qq && apt-get upgrade -y -qq && DEBIAN_FRONTEND=nonintera
network-manager \
nfs-common \
open-iscsi \
+ parted \
pigz \
pkg-config \
procps \
diff --git a/test/container/Dockerfile-Fedora-latest b/test/container/Dockerfile-Fedora-latest
index 87c749f9..a38a72ef 100644
--- a/test/container/Dockerfile-Fedora-latest
+++ b/test/container/Dockerfile-Fedora-latest
@@ -49,6 +49,7 @@ RUN dnf -y install --setopt=install_weak_deps=False \
which \
ShellCheck \
shfmt \
+ parted \
&& dnf -y update && dnf clean all
# Set default command
diff --git a/test/container/Dockerfile-OpenSuse-latest b/test/container/Dockerfile-OpenSuse-latest
index 637d50c6..9aaf07b1 100644
--- a/test/container/Dockerfile-OpenSuse-latest
+++ b/test/container/Dockerfile-OpenSuse-latest
@@ -13,7 +13,7 @@ RUN dnf -y install --setopt=install_weak_deps=False \
strace libkmod-devel gcc bzip2 xz tar wget rpm-build make git bash-completion \
sudo kernel dhcp-client qemu-kvm /usr/bin/qemu-system-$(uname -m) e2fsprogs \
tcpdump iproute iputils kbd NetworkManager btrfsprogs tgt dbus-broker \
- iscsiuio open-iscsi which ShellCheck procps pigz \
+ iscsiuio open-iscsi which ShellCheck procps pigz parted squashfs \
&& dnf -y update && dnf clean all
RUN shfmt_version=3.2.4; wget "https://github.com/mvdan/sh/releases/download/v${shfmt_version}/shfmt_v${shfmt_version}_linux_amd64" -O /usr/local/bin/shfmt \
--
2.36.1

View File

@ -1,29 +0,0 @@
From 16f1daa9015b4cac6f390c0832f37479bc1377ba Mon Sep 17 00:00:00 2001
From: Neal Gompa <neal@gompa.dev>
Date: Sat, 5 Nov 2022 18:28:34 -0400
Subject: [PATCH] fix(kernel-modules): add sysctl to initramfs to handle
modprobe files
Users were seeing errors like this:
[ 2.917246] dracut-pre-udev[717]: sh: line 1: /sbin/sysctl: No such file or directory
This was the result of modprobe.d files that needed to call sysctl
and failing because sysctl wasn't included in the initramfs.
This change makes it so that we have the binary included so those
modprobe configuration files work properly.
---
modules.d/90kernel-modules/module-setup.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/modules.d/90kernel-modules/module-setup.sh b/modules.d/90kernel-modules/module-setup.sh
index b1fb74020..eb478c7ee 100755
--- a/modules.d/90kernel-modules/module-setup.sh
+++ b/modules.d/90kernel-modules/module-setup.sh
@@ -147,4 +147,5 @@ install() {
inst_hook cmdline 01 "$moddir/parse-kernel.sh"
fi
inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh
+ inst_multiple -o sysctl
}

View File

@ -0,0 +1,38 @@
From 5dc6aede4b99f1c76219370660b5b62e935a3cb8 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Tue, 20 Dec 2022 13:06:43 +0100
Subject: [PATCH] revert(network-manager): avoid restarting NetworkManager
This reverts commit 77630365aed201a729c73a9ffda0733a75f3fee4.
Its commit message states:
On EL8.3 the NetworkManager keep restarting even if it exits successfully
while waiting for Clevis to unlock. This patch ensures NetworkManager runs
only once in initrd.
Yes; NetworkManager is run multiple times, so that it's able to
configure interfaces that haven't been seen previously (because bus was
slow to scan or device took time to initialize).
It's not clear what problem was the original commit trying to fix.
I suspect there was no problem, just a misunderstanding.
---
modules.d/35network-manager/nm-run.sh | 4 ----
1 file changed, 4 deletions(-)
diff --git a/modules.d/35network-manager/nm-run.sh b/modules.d/35network-manager/nm-run.sh
index 7d8d61fa7..14b9cb1ad 100755
--- a/modules.d/35network-manager/nm-run.sh
+++ b/modules.d/35network-manager/nm-run.sh
@@ -2,10 +2,6 @@
type source_hook > /dev/null 2>&1 || . /lib/dracut-lib.sh
-if [ -e /tmp/nm.done ]; then
- return
-fi
-
if [ -z "$DRACUT_SYSTEMD" ]; then
# Only start NM if networking is needed
if [ -e /run/NetworkManager/initrd/neednet ]; then

View File

@ -0,0 +1,23 @@
From 3c871a89c281d9ef4447576e4ea072ce38c65ac0 Mon Sep 17 00:00:00 2001
From: Pavel Valena <pvalena@redhat.com>
Date: Tue, 21 Feb 2023 01:57:50 +0100
Subject: [PATCH] feat(kernel-modules): driver support for macbook keyboards
Discussed in: https://bugzilla.redhat.com/show_bug.cgi?id=2166209
---
modules.d/90kernel-modules/module-setup.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules.d/90kernel-modules/module-setup.sh b/modules.d/90kernel-modules/module-setup.sh
index 9bc4c27ac..5b6df776a 100755
--- a/modules.d/90kernel-modules/module-setup.sh
+++ b/modules.d/90kernel-modules/module-setup.sh
@@ -55,7 +55,7 @@ installkernel() {
"=drivers/watchdog"
instmods \
- yenta_socket \
+ yenta_socket spi_pxa2xx_platform \
atkbd i8042 firewire-ohci pcmcia hv-vmbus \
virtio virtio_ring virtio_pci pci_hyperv \
"=drivers/pcmcia"

View File

@ -0,0 +1,67 @@
From f6810b69ae722096184eaaf282e12a2caa6928b9 Mon Sep 17 00:00:00 2001
From: Dusty Mabe <dusty@dustymabe.com>
Date: Tue, 21 Feb 2023 22:21:35 -0500
Subject: [PATCH] feat(network): include 98-default-mac-none.link if it exists
In Fedora Linux there was a new 98-default-mac-none.link file added
to set the MACAddressPolicy=none for bond/bridge/team devices. We'd
like for this policy to apply in the initramfs as well. See
- https://fedoraproject.org/wiki/Changes/MAC_Address_Policy_none
- https://src.fedoraproject.org/rpms/systemd/pull-request/100#
---
modules.d/01systemd-networkd/module-setup.sh | 1 +
modules.d/35network-legacy/module-setup.sh | 6 ++++--
modules.d/35network-manager/module-setup.sh | 6 ++++--
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/modules.d/01systemd-networkd/module-setup.sh b/modules.d/01systemd-networkd/module-setup.sh
index 27d90101..46033549 100755
--- a/modules.d/01systemd-networkd/module-setup.sh
+++ b/modules.d/01systemd-networkd/module-setup.sh
@@ -44,6 +44,7 @@ install() {
"$systemdnetwork"/80-container-vz.network \
"$systemdnetwork"/80-vm-vt.network \
"$systemdnetwork"/80-wifi-adhoc.network \
+ "$systemdnetwork"/98-default-mac-none.link \
"$systemdnetwork"/99-default.link \
"$systemdsystemunitdir"/systemd-networkd.service \
"$systemdsystemunitdir"/systemd-networkd.socket \
diff --git a/modules.d/35network-legacy/module-setup.sh b/modules.d/35network-legacy/module-setup.sh
index 868ea8fc..a42f5797 100755
--- a/modules.d/35network-legacy/module-setup.sh
+++ b/modules.d/35network-legacy/module-setup.sh
@@ -23,9 +23,11 @@ installkernel() {
install() {
local _arch
- #Adding default link
+ # Adding default link and (if exists) 98-default-mac-none.link
if dracut_module_included "systemd"; then
- inst_multiple -o "${systemdnetwork}/99-default.link"
+ inst_multiple -o \
+ "${systemdnetwork}/99-default.link" \
+ "${systemdnetwork}/98-default-mac-none.link"
[[ $hostonly ]] && inst_multiple -H -o "${systemdnetworkconfdir}/*.link"
fi
diff --git a/modules.d/35network-manager/module-setup.sh b/modules.d/35network-manager/module-setup.sh
index c5d568f0..6e6cd6cf 100755
--- a/modules.d/35network-manager/module-setup.sh
+++ b/modules.d/35network-manager/module-setup.sh
@@ -51,8 +51,10 @@ install() {
inst_simple "$moddir"/nm-initrd.service "$systemdsystemunitdir"/nm-initrd.service
inst_simple "$moddir"/nm-wait-online-initrd.service "$systemdsystemunitdir"/nm-wait-online-initrd.service
- # Adding default link
- inst_multiple -o "${systemdnetwork}/99-default.link"
+ # Adding default link and (if exists) 98-default-mac-none.link
+ inst_multiple -o \
+ "${systemdnetwork}/99-default.link" \
+ "${systemdnetwork}/98-default-mac-none.link"
[[ $hostonly ]] && inst_multiple -H -o "${systemdnetworkconfdir}/*.link"
$SYSTEMCTL -q --root "$initdir" enable nm-initrd.service
--
2.39.2

View File

@ -0,0 +1,26 @@
From 0e780720efe6488c4e07af39926575ee12f40339 Mon Sep 17 00:00:00 2001
From: Laszlo Gombos <laszlo.gombos@gmail.com>
Date: Fri, 24 Feb 2023 01:57:19 +0000
Subject: [PATCH] fix(dmsquash-live): restore compatibility with earlier
releases
Follow-up to 40dd5c90e0efcb9ebaa9abb42a38c7316e9706bd .
---
modules.d/90dmsquash-live/dmsquash-live-root.sh | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh
index 62d1b5e7c..a98e258c2 100755
--- a/modules.d/90dmsquash-live/dmsquash-live-root.sh
+++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh
@@ -403,6 +403,10 @@ fi
ROOTFLAGS="$(getarg rootflags)"
+if [ "$overlayfs" = required ]; then
+ echo "rd.live.overlay.overlayfs=1" > /etc/cmdline.d/dmsquash-need-overlay.conf
+fi
+
if [ -n "$overlayfs" ]; then
if [ -n "$FSIMG" ]; then
mkdir -m 0755 -p /run/rootfsbase

View File

@ -0,0 +1,28 @@
From 6fb0f4b4d54eeb1b1e89c06cc54bdcab504138da Mon Sep 17 00:00:00 2001
From: Pavel Valena <pvalena@redhat.com>
Date: Fri, 24 Feb 2023 19:19:59 +0100
Subject: [PATCH] fix(dracut.sh): kmoddir does not handle trailing /
Fixes https://github.com/dracutdevs/dracut/issues/2236
+(/) only works in bash interactive mode. Using any non-interactive
bash run simply doesn't remove anything.
The solution is copied from dracut-lib.sh, trim().
---
dracut.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dracut.sh b/dracut.sh
index 1aa3f8e1f..0c0f85c2d 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -1033,7 +1033,7 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
((stdloglvl < 0)) && stdloglvl=0
[[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l
-drivers_dir="${drivers_dir%%+(/)}"
+drivers_dir="${drivers_dir%"${drivers_dir##*[!/]}"}"
[[ $do_strip_l ]] && do_strip=$do_strip_l
[[ $do_strip ]] || do_strip=yes
[[ $aggressive_strip_l ]] && aggressive_strip=$aggressive_strip_l

View File

@ -7,10 +7,10 @@
%global __requires_exclude pkg-config
# rpmdev-bumpspec and releng automation compatible variable
%global baserelease 5
%global baserelease 2
Name: dracut
Version: 057
Version: 059
Release: %{baserelease}%{?dist}
Summary: Initramfs generator using udev
@ -22,28 +22,41 @@ License: GPLv2+ and LGPLv2+ and GPLv2
URL: https://dracut.wiki.kernel.org/
# Source can be generated by
# http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%%{version};sf=tgz
Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.xz
Source0: https://github.com/dracutdevs/dracut/archive/refs/tags/%{version}.tar.gz
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
# Never auto-enable bluetooth module (but it can be manually included
# for debugging) - workaround for RHBZ #1964879.
# https://github.com/dracutdevs/dracut/pull/1521
Patch1: 1521-Never-enable-the-bluetooth-module-by-default.patch
# Add dmsquash-live-autooverlay module
# https://github.com/dracutdevs/dracut/pull/1991
Patch2: 1991-feat-dmsquash-live-add-new-dmsquash-live-autooverlay.patch
# Skip creating initrd when initrd already provided,
# or different generator is configured
# https://github.com/dracutdevs/dracut/pull/1825/
Patch2: 1825-Skip-creating-initrd-when-initrd-is-provided.patch
# Add sysctl to initramfs to handle modprobe files
# https://github.com/dracutdevs/dracut/pull/2037
Patch3: 2037-Add-sysctl-to-initramfs-to-handle-modprobe-files.patch
# Add kernel module with support for macbook keyboards
# https://github.com/dracutdevs/dracut/pull/2218
Patch3: 2218-add-module-driver-support-for-macbook-keyboards.patch
# fix(dmsquash-live): restore compatibility with earlier releases
# https://github.com/dracutdevs/dracut/pull/2233/
# https://bugzilla.redhat.com/show_bug.cgi?id=2172269
Patch4: 2233-dmsquash-live-restore-compatibility.patch
# Fix: dracut --kmoddir fails on paths with traling /
# https://bugzilla.redhat.com/show_bug.cgi?id=2173100
Patch5: 2237-kmoddir-fix-trailing-forwardslash-handling.patch
# revert(network-manager): avoid restarting NetworkManager
# https://github.com/dracutdevs/dracut/pull/2134
Patch6: 2134-revert-avoid-restarting-NetworkManager.patch
# Support MACAddressPolicy=none for bond/bridge/team devices
# https://fedoraproject.org/wiki/Changes/MAC_Address_Policy_none
# https://github.com/dracutdevs/dracut/pull/2224
Patch7: 2224-network-include-default-mac-none-link.patch
BuildRequires: bash
BuildRequires: git-core
@ -285,6 +298,9 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{dracutlibdir}/modules.d/01systemd-journald
%{dracutlibdir}/modules.d/01systemd-ldconfig
%{dracutlibdir}/modules.d/01systemd-modules-load
%{dracutlibdir}/modules.d/01systemd-pcrphase
%{dracutlibdir}/modules.d/01systemd-portabled
%{dracutlibdir}/modules.d/01systemd-pstore
%{dracutlibdir}/modules.d/01systemd-repart
%{dracutlibdir}/modules.d/01systemd-resolved
%{dracutlibdir}/modules.d/01systemd-rfkill
@ -313,6 +329,9 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{dracutlibdir}/modules.d/62bluetooth
%{dracutlibdir}/modules.d/80lvmmerge
%{dracutlibdir}/modules.d/80lvmthinpool-monitor
%{dracutlibdir}/modules.d/80test
%{dracutlibdir}/modules.d/80test-makeroot
%{dracutlibdir}/modules.d/80test-root
%{dracutlibdir}/modules.d/90btrfs
%{dracutlibdir}/modules.d/90crypt
%{dracutlibdir}/modules.d/90dm
@ -323,6 +342,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{dracutlibdir}/modules.d/90mdraid
%{dracutlibdir}/modules.d/90multipath
%{dracutlibdir}/modules.d/90nvdimm
%{dracutlibdir}/modules.d/90overlayfs
%{dracutlibdir}/modules.d/90ppcmac
%{dracutlibdir}/modules.d/90qemu
%{dracutlibdir}/modules.d/91crypt-gpg
@ -444,6 +464,20 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
%changelog
* Tue Mar 14 2023 Pavel Valena <pvalena@redhat.com> - 059-2
- fix(dmsquash-live): restore compatibility with earlier releases
- fix(dracut.sh): handle --kmoddir with trailing /
- revert(network-manager): avoid restarting NetworkManager
- feat(network): include 98-default-mac-none.link if it exists
* Mon Feb 13 2023 Pavel Valena <pvalena@redhat.com> - 059-1
- Update to 059
- feat(dracut.sh): option to skip creating initrd
- feat(kernel-modules): driver support for macbook keyboards
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 057-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Sun Nov 13 2022 Davide Cavalca <dcavalca@fedoraproject.org> - 057-5
- Backport fix to add sysctl to initramfs to handle modprobe files

View File

@ -1 +1 @@
SHA512 (dracut-057.tar.xz) = 5169dd42c59a1a3fde21da984ab998eb04bf4aac384a6aa4ada3b0febd1e8f0c7fc727b1e8aed30f6584acbe323cbdb4021d18109b8baec907dadcc8cd4ceec9
SHA512 (059.tar.gz) = 196bc8bf18703c72bffb51a7e0493719c58173ad2da7d121eb42f9a8de47e953af36d109214dc4a10b2dc2d3bd19e844f7f51c2bdec087e064ea11f75124032d