diff --git a/srcpkgs/mkinitcpio/files/11-dm-initramfs.rules b/srcpkgs/mkinitcpio/files/11-dm-initramfs.rules deleted file mode 100644 index d2c16732452..00000000000 --- a/srcpkgs/mkinitcpio/files/11-dm-initramfs.rules +++ /dev/null @@ -1,3 +0,0 @@ -# needed with new udev/mkinitcpio and as implemented in dracut: -# -SUBSYSTEM=="block", KERNEL=="dm-[0-9]*", ACTION=="add|change", OPTIONS="db_persist" diff --git a/srcpkgs/mkinitcpio/files/69-dm-lvm-metad.rules b/srcpkgs/mkinitcpio/files/69-dm-lvm-metad.rules deleted file mode 100644 index c032108b46b..00000000000 --- a/srcpkgs/mkinitcpio/files/69-dm-lvm-metad.rules +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright (C) 2012 Red Hat, Inc. All rights reserved. -# -# This file is part of LVM2. - -# Udev rules for LVM. -# -# Scan all block devices having a PV label for LVM metadata. -# Store this information in LVMetaD (the LVM metadata daemon) and maintain LVM -# metadata state for improved performance by avoiding further scans while -# running subsequent LVM commands or while using lvm2app library. -# Also, notify LVMetaD about any relevant block device removal. -# -# This rule is essential for having the information in LVMetaD up-to-date. -# It also requires blkid to be called on block devices before so only devices -# used as LVM PVs are processed (ID_FS_TYPE="LVM2_member" or "LVM1_member"). - -SUBSYSTEM!="block", GOTO="lvm_end" - - -ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="lvm_end" - -# If the PV label got lost, inform lvmetad immediately. -# Detect the lost PV label by comparing previous ID_FS_TYPE value with current one. -ENV{.ID_FS_TYPE_NEW}="$env{ID_FS_TYPE}" -IMPORT{db}="ID_FS_TYPE" -ENV{ID_FS_TYPE}=="LVM2_member|LVM1_member", ENV{.ID_FS_TYPE_NEW}!="LVM2_member|LVM1_member", ENV{LVM_PV_GONE}="1" -ENV{ID_FS_TYPE}="$env{.ID_FS_TYPE_NEW}" -ENV{LVM_PV_GONE}=="1", GOTO="lvm_scan" - -# Only process devices already marked as a PV - this requires blkid to be called before. -ENV{ID_FS_TYPE}!="LVM2_member|LVM1_member", GOTO="lvm_end" -ENV{DM_MULTIPATH_DEVICE_PATH}=="1", GOTO="lvm_end" - -# Inform lvmetad about any PV that is gone. -ACTION=="remove", GOTO="lvm_scan" - -# Create /dev/disk/by-id/lvm-pv-uuid- symlink for each PV -ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-id/lvm-pv-uuid-$env{ID_FS_UUID_ENC}" - -# If the PV is a special device listed below, scan only if the device is -# properly activated. These devices are not usable after an ADD event, -# but they require an extra setup and they are ready after a CHANGE event. -# Also support coldplugging with ADD event but only if the device is already -# properly activated. -# This logic should be eventually moved to rules where those particular -# devices are processed primarily (MD and loop). - -# DM device: -KERNEL!="dm-[0-9]*", GOTO="next" -ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", ENV{DM_ACTIVATION}=="1", GOTO="lvm_scan" -GOTO="lvm_end" - -# MD device: -LABEL="next" -KERNEL!="md[0-9]*", GOTO="next" -IMPORT{db}="LVM_MD_PV_ACTIVATED" -ACTION=="add", ENV{LVM_MD_PV_ACTIVATED}=="1", GOTO="lvm_scan" -ACTION=="change", ENV{LVM_MD_PV_ACTIVATED}!="1", TEST=="md/array_state", ENV{LVM_MD_PV_ACTIVATED}="1", GOTO="lvm_scan" -ACTION=="add", KERNEL=="md[0-9]*p[0-9]*", GOTO="lvm_scan" -ENV{LVM_MD_PV_ACTIVATED}!="1", ENV{SYSTEMD_READY}="0" -GOTO="lvm_end" - -# Loop device: -LABEL="next" -KERNEL!="loop[0-9]*", GOTO="next" -ACTION=="add", ENV{LVM_LOOP_PV_ACTIVATED}=="1", GOTO="lvm_scan" -ACTION=="change", ENV{LVM_LOOP_PV_ACTIVATED}!="1", TEST=="loop/backing_file", ENV{LVM_LOOP_PV_ACTIVATED}="1", GOTO="lvm_scan" -ENV{LVM_LOOP_PV_ACTIVATED}!="1", ENV{SYSTEMD_READY}="0" -GOTO="lvm_end" - -# If the PV is not a special device listed above, scan only after device addition (ADD event) -LABEL="next" -ACTION!="add", GOTO="lvm_end" - -LABEL="lvm_scan" - -# The table below summarises the situations in which we reach the LABEL="lvm_scan". -# Marked by X, X* means only if the special dev is properly set up. -# The artificial ADD is supported for coldplugging. We avoid running the pvscan -# on artificial CHANGE so there's no unexpected autoactivation when WATCH rule fires. -# N.B. MD and loop never actually reaches lvm_scan on REMOVE as the PV label is gone -# within a CHANGE event (these are caught by the "LVM_PV_GONE" rule at the beginning). -# -# | real ADD | real CHANGE | artificial ADD | artificial CHANGE | REMOVE -# ============================================================================= -# DM | | X | X* | | X -# MD | | X | X* | | -# loop | | X | X* | | -# other | X | | X | | X -ENV{SYSTEMD_READY}="1" -RUN+="/usr/bin/lvm pvscan --background --cache --activate ay --major $major --minor $minor", ENV{LVM_SCANNED}="1" - -LABEL="lvm_end" diff --git a/srcpkgs/mkinitcpio/files/lvm2_hook b/srcpkgs/mkinitcpio/files/lvm2_hook deleted file mode 100644 index 284b6ee3fbf..00000000000 --- a/srcpkgs/mkinitcpio/files/lvm2_hook +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/ash - -run_earlyhook() { - mkdir /run/lvm - lvmetad -} - -# We suffer a race condition without systemd: if lvmetad is killed before -# pvscan processes finish, we have stale processes and uninitialized physical -# volume. Wait up to 10 seconds for pvscan to finish. -run_latehook() { - local i=50 - - while [ $i -gt 0 ] && pgrep -f pvscan >/dev/null 2>/dev/null; do - sleep 0.2 - i=$((i - 1)) - done -} - -run_cleanuphook() { - kill $(cat /run/lvmetad.pid) -} - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/srcpkgs/mkinitcpio/patches/lvm2.patch b/srcpkgs/mkinitcpio/patches/lvm2.patch deleted file mode 100644 index 2471f7d3dc0..00000000000 --- a/srcpkgs/mkinitcpio/patches/lvm2.patch +++ /dev/null @@ -1,42 +0,0 @@ -Void adds a custom runscript and udev rules to work around missing systemd. - ---- a/install/lvm2 -+++ b/install/lvm2 -@@ -19,6 +19,14 @@ - 'raid456' \ - 'dm-integrity' - -+ # from lvm2 -+ map add_binary \ -+ 'lvm' \ -+ 'lvmetad' -+ -+ # from device-mapper -+ add_binary 'dmsetup' -+ - # from thin-provisioning-tools - add_binary 'pdata_tools' - while IFS='' read -r -d '' symlink; do -@@ -39,18 +47,14 @@ - '11-dm-lvm.rules' \ - '13-dm-disk.rules' \ - '95-dm-notify.rules' \ -- '/usr/lib/initcpio/udev/11-dm-initramfs.rules' -- -- # this udev rule is specific for systemd and non-systemd systems -- if declare -F add_systemd_unit &>/dev/null; then -- add_udev_rule '69-dm-lvm.rules' -- else -- add_udev_rule '/usr/lib/initcpio/udev/69-dm-lvm.rules' -- fi -+ '/usr/lib/initcpio/udev/11-dm-initramfs.rules' \ -+ '/usr/lib/initcpio/udev/69-dm-lvm-metad.rules' - - # config file - sed -e 's/^[[:space:]#]*monitoring = [[:digit:]]\+\s*$/\tmonitoring = 0/' \ - -e '/^$/d' -e '/^[[:space:]]*#/d' "/etc/lvm/lvm.conf" | add_file - '/etc/lvm/lvm.conf' 644 -+ -+ add_runscript - } - - help() { diff --git a/srcpkgs/mkinitcpio/patches/udev-rules.patch b/srcpkgs/mkinitcpio/patches/udev-rules.patch new file mode 100644 index 00000000000..a1515228448 --- /dev/null +++ b/srcpkgs/mkinitcpio/patches/udev-rules.patch @@ -0,0 +1,140 @@ +From 4afcb3aaae2ca86582c21ee5b4c3f52a43168b83 Mon Sep 17 00:00:00 2001 +From: classabbyamp +Date: Wed, 18 Dec 2024 16:06:31 -0500 +Subject: [PATCH 1/2] udev: add 11-dm-initramfs.rules + +referenced in sd-encrypt, encrypt, and lvm2 install hooks but originated +in arch's device-mapper package[1], so it did not exist in other distros + +[1]: https://gitlab.archlinux.org/archlinux/packaging/packages/lvm2/-/blob/14768631e41e23715cb02f1d00531cb3683bfb4d/11-dm-initramfs.rules +--- + Makefile | 1 + + udev/11-dm-initramfs.rules | 3 +++ + 2 files changed, 4 insertions(+) + create mode 100644 udev/11-dm-initramfs.rules + +diff --git a/Makefile b/Makefile +index 0feb3a3..d63b8f0 100644 +--- a/Makefile ++++ b/Makefile +@@ -71,6 +71,7 @@ install-generator: all prepare + install -m755 -t $(DESTDIR)/usr/lib/initcpio init shutdown functions + install -m644 -t $(DESTDIR)/usr/lib/initcpio init_functions + install -m644 udev/01-memdisk.rules $(DESTDIR)/usr/lib/initcpio/udev/01-memdisk.rules ++ install -m644 udev/11-dm-initramfs.rules $(DESTDIR)/usr/lib/initcpio/udev/11-dm-initramfs.rules + + cp -at $(DESTDIR)/usr/lib/initcpio hooks install + install -m644 -t $(DESTDIR)/usr/share/mkinitcpio mkinitcpio.d/* +diff --git a/udev/11-dm-initramfs.rules b/udev/11-dm-initramfs.rules +new file mode 100644 +index 0000000..d2c1673 +--- /dev/null ++++ b/udev/11-dm-initramfs.rules +@@ -0,0 +1,3 @@ ++# needed with new udev/mkinitcpio and as implemented in dracut: ++# ++SUBSYSTEM=="block", KERNEL=="dm-[0-9]*", ACTION=="add|change", OPTIONS="db_persist" +-- +2.47.1 + + +From 8f09f64772bb9779b0927d6ebb0ed2cbe423dd2f Mon Sep 17 00:00:00 2001 +From: classabbyamp +Date: Wed, 18 Dec 2024 16:08:18 -0500 +Subject: [PATCH 2/2] udev: add patched 69-dm-lvm.rules + +referenced in the lvm2 install hook for nonsystemd initcpios, but originated +in arch's lvm2 package[1], so it did not exist in other distros. this is a +patched version of the upstream udev rule. + +[1]: https://gitlab.archlinux.org/archlinux/packaging/packages/lvm2/-/blob/14768631e41e23715cb02f1d00531cb3683bfb4d/0001-udev-initcpio.patch +--- + Makefile | 1 + + udev/69-dm-lvm.rules | 63 ++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 64 insertions(+) + create mode 100644 udev/69-dm-lvm.rules + +diff --git a/Makefile b/Makefile +index d63b8f0..c675e8c 100644 +--- a/Makefile ++++ b/Makefile +@@ -72,6 +72,7 @@ install-generator: all prepare + install -m644 -t $(DESTDIR)/usr/lib/initcpio init_functions + install -m644 udev/01-memdisk.rules $(DESTDIR)/usr/lib/initcpio/udev/01-memdisk.rules + install -m644 udev/11-dm-initramfs.rules $(DESTDIR)/usr/lib/initcpio/udev/11-dm-initramfs.rules ++ install -m644 udev/69-dm-lvm.rules $(DESTDIR)/usr/lib/initcpio/udev/69-dm-lvm.rules + + cp -at $(DESTDIR)/usr/lib/initcpio hooks install + install -m644 -t $(DESTDIR)/usr/share/mkinitcpio mkinitcpio.d/* +diff --git a/udev/69-dm-lvm.rules b/udev/69-dm-lvm.rules +new file mode 100644 +index 0000000..743d1cb +--- /dev/null ++++ b/udev/69-dm-lvm.rules +@@ -0,0 +1,63 @@ ++# Copyright (C) 2012,2021 Red Hat, Inc. All rights reserved. ++# ++# This file is part of LVM. ++# ++# This rule requires blkid to be called on block devices before so only devices ++# used as LVM PVs are processed (ID_FS_TYPE="LVM2_member"). ++ ++SUBSYSTEM!="block", GOTO="lvm_end" ++ ++ ++ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="lvm_end" ++ ++# Only process devices already marked as a PV - this requires blkid to be called before. ++ENV{ID_FS_TYPE}!="LVM2_member", GOTO="lvm_end" ++ENV{DM_MULTIPATH_DEVICE_PATH}=="1", GOTO="lvm_end" ++ACTION=="remove", GOTO="lvm_end" ++ ++# Create /dev/disk/by-id/lvm-pv-uuid- symlink for each PV ++ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-id/lvm-pv-uuid-$env{ID_FS_UUID_ENC}" ++ ++# If the PV is a special device listed below, scan only if the device is ++# properly activated. These devices are not usable after an ADD event, ++# but they require an extra setup and they are ready after a CHANGE event. ++# Also support coldplugging with ADD event but only if the device is already ++# properly activated. ++# This logic should be eventually moved to rules where those particular ++# devices are processed primarily (MD and loop). ++ ++# DM device: ++KERNEL!="dm-[0-9]*", GOTO="next" ++ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", ENV{DM_ACTIVATION}=="1", GOTO="lvm_scan" ++GOTO="lvm_end" ++ ++# MD device: ++LABEL="next" ++KERNEL!="md[0-9]*", GOTO="next" ++IMPORT{db}="LVM_MD_PV_ACTIVATED" ++ACTION=="add", ENV{LVM_MD_PV_ACTIVATED}=="1", GOTO="lvm_scan" ++ACTION=="change", ENV{LVM_MD_PV_ACTIVATED}!="1", TEST=="md/array_state", ENV{LVM_MD_PV_ACTIVATED}="1", GOTO="lvm_scan" ++ACTION=="add", KERNEL=="md[0-9]*p[0-9]*", GOTO="lvm_scan" ++GOTO="lvm_end" ++ ++# Loop device: ++LABEL="next" ++KERNEL!="loop[0-9]*", GOTO="next" ++ACTION=="add", ENV{LVM_LOOP_PV_ACTIVATED}=="1", GOTO="lvm_scan" ++ACTION=="change", ENV{LVM_LOOP_PV_ACTIVATED}!="1", TEST=="loop/backing_file", ENV{LVM_LOOP_PV_ACTIVATED}="1", GOTO="lvm_scan" ++GOTO="lvm_end" ++ ++LABEL="next" ++ACTION!="add", GOTO="lvm_end" ++ ++LABEL="lvm_scan" ++ ++RUN+="/usr/bin/lvm pvscan --background --cache --activate ay --major $major --minor $minor", ENV{LVM_SCANNED}="1" ++GOTO="lvm_end" ++ ++LABEL="lvm_direct_vgchange" ++ENV{LVM_VG_NAME_COMPLETE}=="?*", RUN+="/usr/bin/lvm vgchange -aay --autoactivation event $env{LVM_VG_NAME_COMPLETE}" ++GOTO="lvm_end" ++ ++LABEL="lvm_end" ++ +-- +2.47.1 + diff --git a/srcpkgs/mkinitcpio/template b/srcpkgs/mkinitcpio/template index e9e53f253ed..81ec4647943 100644 --- a/srcpkgs/mkinitcpio/template +++ b/srcpkgs/mkinitcpio/template @@ -1,7 +1,7 @@ # Template file for 'mkinitcpio' pkgname=mkinitcpio version=39.2 -revision=2 +revision=3 build_style=gnu-makefile hostmakedepends="asciidoc" depends="busybox-static bsdtar bash zstd" @@ -26,9 +26,6 @@ pre_check() { } post_install() { - # Install udev rule used by both lvm2 and encrypt hook - vinstall ${FILESDIR}/11-dm-initramfs.rules 644 usr/lib/initcpio/udev - # Remove unneeded systemd bits rm -r ${DESTDIR}/usr/lib/kernel rm -r ${DESTDIR}/usr/lib/systemd @@ -52,8 +49,7 @@ mkinitcpio-lvm2_package() { depends="${sourcepkg}>=${version}_${revision} lvm2 thin-provisioning-tools" short_desc+=" - lvm2 support" pkg_install() { - vinstall ${FILESDIR}/lvm2_hook 644 usr/lib/initcpio/hooks lvm2 - vinstall ${FILESDIR}/69-dm-lvm-metad.rules 644 usr/lib/initcpio/udev + vmove usr/lib/initcpio/udev/69-dm-lvm.rules vmove usr/lib/initcpio/install/lvm2 } }