Hi Thomas

This is a V2 for ostree patch, and i have attached it.  In the new patch,  I adjust some codes ,  would you please check it? thanks.


On 12/3/24 20:27, Thomas Lange wrote:
CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know 
the content is safe.

The lintian error may come from the fact that you are using a
backports version of dracut which still has the services files in
/lib. We already have this in debian/lintian:

dracut-core: systemd-service-file-shutdown-problems 
[usr/lib/systemd/system/*dracut-*.service]


The patch for ostree support is a wishlist bug. We are currently not
happy with the removal of linux-version and using ls in old style
backticks (twice).

We have to think about your patch.

--
regards Thomas
From 5c4fd703f66be4fba6b8176d0eab90d9f75cac5c Mon Sep 17 00:00:00 2001
From: Wenlin Kang <[email protected]>
Date: Sun, 1 Dec 2024 23:13:46 -0800
Subject: [PATCH] debian/postinst: add support for the system with ostree

In general, dracut work is good, but on the system with ostree, it
cannot correctly find the location of the initramfs and regenerate
it, the patch gives it a chance to find the location on the system
with ostree.

Meanwhile, also replace linux-version with ls, the cause is linux-version
only find kernel image from /boot, but on the system with ostree, the
kernel image usually is in /boot/ostree/${osname}-${bootcsum}.

Signed-off-by: Wenlin Kang <[email protected]>
---
 debian/changelog                |  6 ++++++
 debian/dracut.postinst          | 18 +++++++++++++-----
 debian/kernel/postinst.d/dracut | 12 +++++++++---
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index d1aa7c13..f74c5c0a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+dracut (105-2) unstable; urgency=medium
+
+  * debian/postinst: add support for the system with ostree
+
+ -- Wenlin Kang <[email protected]>  Sun, 01 Dec 2024 23:26:47 -0800
+
 dracut (105-2) unstable; urgency=medium
 
   * autopkgtest:
diff --git a/debian/dracut.postinst b/debian/dracut.postinst
index c435bc58..e4a8cb24 100644
--- a/debian/dracut.postinst
+++ b/debian/dracut.postinst
@@ -4,11 +4,19 @@ set -e
 
 
 mk_initrd() {
-    local latest_version
-    latest_version=$(linux-version list | linux-version sort | tail -n 1)
-    linux-version list | while read -r kversion; do
-        if test "$kversion" = "$latest_version" || ! test -e "/boot/initrd.img-$kversion"; then
-            /etc/kernel/postinst.d/dracut "$kversion"
+    local bootdir=/boot
+    local ostree="$(cat /proc/cmdline | grep -o 'ostree=[^ ]*' | cut -d'=' -f2)"
+    if [ -n "${ostree}" ]; then
+        osname="$(echo ${ostree} | awk -F/ '{print $4}')"
+        bootcsum="$(echo ${ostree} | awk -F/ '{print $5}')"
+        bootdir=${bootdir}/ostree/${osname}-${bootcsum}
+    fi
+
+    local latest_version=$(ls ${bootdir}/vmlinu[zx]-* 2>/dev/null | sed -e "s#${bootdir}/vmlinu.-##" | sort -V | tail -n 1)
+    ls ${bootdir}/vmlinu[zx]-* 2>/dev/null | sed -e "s#${bootdir}/vmlinu.-##" | while read -r kversion; do
+        local kernel=$(ls ${bootdir}/vmlinu[zx]-${kversion})
+        if test "$kversion" = "$latest_version" || ! test -e "${bootdir}/initrd.img-$kversion"; then
+            /etc/kernel/postinst.d/dracut $kversion $kernel
         fi
     done
 }
diff --git a/debian/kernel/postinst.d/dracut b/debian/kernel/postinst.d/dracut
index b202df4d..126bcad1 100755
--- a/debian/kernel/postinst.d/dracut
+++ b/debian/kernel/postinst.d/dracut
@@ -27,10 +27,16 @@ fi
 
 # check if modules.dep already exists. If not create it
 # maybe this problem could also be solved via Debian triggers
-if [ ! -f $bootdir/../lib/modules/$version/modules.dep ]; then
+if [ ! -f $bootdir/../lib/modules/$version/modules.dep ] &&
+   [ ! -f /lib/modules/$version/modules.dep ]; then
     depmod -a -F $bootdir/System.map-$version $version
 fi
 
 # we're good - create initramfs
-echo "dracut: Generating $bootdir/initrd.img-${version}"
-dracut -q --force $bootdir/initrd.img-${version} "${version}" >&2
+# keep original name if it exists
+initrd="$(ls ${bootdir}/initr*-${version}* 2>/dev/null)"
+if [ -z "${initrd}" ]; then
+    initrd=$bootdir/initrd.img-${version}
+fi
+echo "dracut: Generating ${initrd}"
+dracut -q --force ${initrd} "${version}" >&2
-- 
2.42.0

Reply via email to