]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Fallback to external blkid and path_id in udev rules for <udev-176.
authorAmadeusz Żołnowski <aidecoe@aidecoe.name>
Thu, 1 Nov 2012 10:06:22 +0000 (11:06 +0100)
committerHarald Hoyer <harald@redhat.com>
Fri, 14 Dec 2012 08:04:56 +0000 (09:04 +0100)
Starting with commit 24a38bc1cbe461c344ce61c7e10b6d51d5689c93 dracut
uses udev builtins but still depends on >=udev-166 in dracut.spec.  This
patch makes dracut work with older udev again.

All credits go to Alexander Tsoy <alexander@tsoy.me>; see

  https://bugs.gentoo.org/show_bug.cgi?id=437700

modules.d/95udev-rules/59-persistent-storage.rules
modules.d/95udev-rules/61-persistent-storage.rules
modules.d/95udev-rules/module-setup.sh
modules.d/95udev-rules/udev-rules-prepare.sh [new file with mode: 0644]
modules.d/99base/init.sh

index f2756eef886f8655bae188516935cfff87350176..c221cda5db4572c9bfd486f61b5715715a44651e 100644 (file)
@@ -3,8 +3,8 @@ ACTION!="add|change", GOTO="ps_end"
 # Also don't process disks that are slated to be a multipath device
 ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="ps_end"
 
-KERNEL=="cciss[0-9]*", IMPORT{builtin}="blkid"
-KERNEL=="nbd[0-9]*", IMPORT{builtin}="blkid"
+KERNEL=="cciss[0-9]*", IMPORT BLKID
+KERNEL=="nbd[0-9]*", IMPORT BLKID
 
 
 KERNEL!="md[0-9]*|md_d[0-9]*|md/*", KERNEL!="md*", GOTO="md_end"
@@ -21,7 +21,7 @@ ATTR{md/array_state}=="|clear|inactive", GOTO="md_end"
 LABEL="md_ignore_state"
 
 IMPORT{program}="/sbin/mdadm --detail --export $tempnode"
-IMPORT{builtin}="blkid"
+IMPORT BLKID
 OPTIONS+="link_priority=100"
 OPTIONS+="watch"
 LABEL="md_end"
@@ -34,7 +34,7 @@ ENV{DM_NAME}!="?*", GOTO="ps_end"
 ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="ps_end"
 ENV{DM_UUID}=="CRYPT-TEMP-?*", GOTO="ps_end"
 ENV{DM_UUID}!="?*", ENV{DM_NAME}=="temporary-cryptsetup-?*", GOTO="ps_end"
-IMPORT{builtin}="blkid"
+IMPORT BLKID
 
 
 LABEL="ps_end"
index 7dbd1510057770708b9d4d5e100fb42de192e14d..37148b071e57dc0741a446231fe641771ae09119 100644 (file)
@@ -12,7 +12,7 @@ GOTO="pss_end"
 
 LABEL="do_pss"
 # by-path (parent device path)
-ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="", DEVPATH!="*/virtual/*", IMPORT{builtin}="path_id"
+ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="", DEVPATH!="*/virtual/*", IMPORT PATH_ID
 ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}"
 ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"
 
index 533dfeb22c59cfff072820b56fd43e577a570e52..54a192ecdb7874c29c654a02212643f204699559 100755 (executable)
@@ -74,5 +74,7 @@ install() {
         inst_script "$moddir/load-modules.sh" /lib/udev/load-modules.sh
 
     inst_libdir_file "libnss_files*"
+
+    inst_hook pre-udev 10 "$moddir/udev-rules-prepare.sh"
 }
 
diff --git a/modules.d/95udev-rules/udev-rules-prepare.sh b/modules.d/95udev-rules/udev-rules-prepare.sh
new file mode 100644 (file)
index 0000000..08263ea
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+for f in /etc/udev/rules.d/*-persistent-storage.rules; do
+    [ -e "$f" ] || continue
+    while read line; do
+        if [ "${line%%IMPORT PATH_ID}" != "$line" ]; then
+            if [ $UDEVVERSION -ge 174 ]; then
+                printf '%sIMPORT{builtin}="path_id"\n' "${line%%IMPORT PATH_ID}"
+            else
+                printf '%sIMPORT{program}="path_id %%p"\n' "${line%%IMPORT PATH_ID}"
+            fi
+        elif [ "${line%%IMPORT BLKID}" != "$line" ]; then
+            if [ $UDEVVERSION -ge 176 ]; then
+                printf '%sIMPORT{builtin}="blkid"\n' "${line%%IMPORT BLKID}"
+            else
+                printf '%sIMPORT{program}="/sbin/blkid -o udev -p $tempnode"\n' "${line%%IMPORT BLKID}"
+            fi
+        else
+            echo "$line"
+        fi
+    done < "${f}" > "${f}.new"
+    mv "${f}.new" "$f"
+done
index 16c8958ca0c28840131604c52af24ccd1d7e5214..0259053a7c6a1d9bc658bae7bb730981e7e3615e 100755 (executable)
@@ -83,7 +83,7 @@ trap "emergency_shell Signal caught!" 0
 
 [ -d /run/initramfs ] || mkdir -p -m 0755 /run/initramfs
 
-UDEVVERSION=$(udevadm --version)
+export UDEVVERSION=$(udevadm --version)
 if [ $UDEVVERSION -gt 166 ]; then
     # newer versions of udev use /run/udev/rules.d
     export UDEVRULESD=/run/udev/rules.d