Harald Hoyer 460d2c
From ff2d8bdfb3a56d97bcac9750ff16c3437a96cbe7 Mon Sep 17 00:00:00 2001
Harald Hoyer 460d2c
From: Daniel Molkentin <dmolkentin@suse.com>
Harald Hoyer 460d2c
Date: Mon, 17 Aug 2020 15:46:17 +0200
Harald Hoyer 460d2c
Subject: [PATCH] dracut.sh: Add --version
Harald Hoyer 460d2c
Harald Hoyer 460d2c
---
Harald Hoyer 460d2c
 dracut.sh | 11 +++++++++++
Harald Hoyer 460d2c
 1 file changed, 11 insertions(+)
Harald Hoyer 460d2c
Harald Hoyer 460d2c
diff --git a/dracut.sh b/dracut.sh
Harald Hoyer 460d2c
index 4d83d3ab..2f2fadd1 100755
Harald Hoyer 460d2c
--- a/dracut.sh
Harald Hoyer 460d2c
+++ b/dracut.sh
Harald Hoyer 460d2c
@@ -242,6 +242,7 @@ Creates initial ramdisk images for preloading modules
Harald Hoyer 460d2c
   --kernel-image [FILE] location of the kernel image
Harald Hoyer 460d2c
   --regenerate-all      Regenerate all initramfs images at the default location
Harald Hoyer 460d2c
                         for the kernel versions found on the system
Harald Hoyer 460d2c
+  --version             Display version
Harald Hoyer 460d2c
 
Harald Hoyer 460d2c
 If [LIST] has multiple arguments, then you have to put these in quotes.
Harald Hoyer 460d2c
 
Harald Hoyer 460d2c
@@ -252,6 +253,14 @@ For example:
Harald Hoyer 460d2c
 EOF
Harald Hoyer 460d2c
 }
Harald Hoyer 460d2c
 
Harald Hoyer 460d2c
+long_version() {
Harald Hoyer 460d2c
+    [[ $dracutbasedir ]] || dracutbasedir=$dracutsysrootdir/usr/lib/dracut
Harald Hoyer 460d2c
+    if [[ -f $dracutbasedir/dracut-version.sh ]]; then
Harald Hoyer 460d2c
+        . $dracutbasedir/dracut-version.sh
Harald Hoyer 460d2c
+    fi
Harald Hoyer 460d2c
+    echo "dracut $DRACUT_VERSION"
Harald Hoyer 460d2c
+}
Harald Hoyer 460d2c
+
Harald Hoyer 460d2c
 # Fills up host_devs stack variable and makes sure there are no duplicates
Harald Hoyer 460d2c
 push_host_devs() {
Harald Hoyer 460d2c
     local _dev
Harald Hoyer 460d2c
@@ -416,6 +425,7 @@ rearrange_params()
Harald Hoyer 460d2c
         --long no-hostonly-i18n \
Harald Hoyer 460d2c
         --long hostonly-i18n \
Harald Hoyer 460d2c
         --long no-machineid \
Harald Hoyer 460d2c
+        --long version \
Harald Hoyer 460d2c
         -- "$@")
Harald Hoyer 460d2c
 
Harald Hoyer 460d2c
     if (( $? != 0 )); then
Harald Hoyer 460d2c
@@ -616,6 +626,7 @@ while :; do
Harald Hoyer 460d2c
                        kernel_image_l="$2";            PARMS_TO_STORE+=" '$2'"; shift;;
Harald Hoyer 460d2c
         --no-machineid)
Harald Hoyer 460d2c
                        machine_id_l="no";;
Harald Hoyer 460d2c
+        --version)     long_version; exit 1 ;;
Harald Hoyer 460d2c
         --) shift; break;;
Harald Hoyer 460d2c
 
Harald Hoyer 460d2c
         *)  # should not even reach this point
Harald Hoyer 460d2c