All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] Support old version of module-init-tools
@ 2010-06-09  8:36 Amadeusz Żołnowski
       [not found] ` <20100609103605.50a6acec-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Amadeusz Żołnowski @ 2010-06-09  8:36 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 3275 bytes --]

modprobe included in version prior to 3.7 of module-init-tools doesn't
have -d | --dirname option which allows to give a prefix other than
'/' for kernel modules path. Dracut assumes existence of that
option and uses it even with default '/'. The patch passes -d option
only if it's different from default and also checks module-init-tools
version if user changes the prefix by --kmoddir Dracut option.
---
 dracut           |    8 +++++++-
 dracut-functions |   44 ++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/dracut b/dracut
index 35be7eb..139d0e0 100755
--- a/dracut
+++ b/dracut
@@ -183,7 +183,13 @@ esac
 abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"
 
 srcmods="/lib/modules/$kernel/"
-[[ $drivers_dir ]] && srcmods="$drivers_dir"
+[[ $drivers_dir ]] && {
+    if verlt $(modprobe --version | cut -d' ' -f3) 3.7; then
+        derror 'To use --kmoddir option module-init-tools >= 3.7 is required.'
+        exit 1
+    fi
+    srcmods="$drivers_dir"
+}
 export srcmods
 
 if [[ -f $outfile && ! $force ]]; then
diff --git a/dracut-functions b/dracut-functions
index a76cc22..fbac282 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -24,6 +24,39 @@ IF_dynamic=""
 # Generic substring function.  If $2 is in $1, return 0.
 strstr() { [[ $1 =~ $2 ]]; }
 
+# Version comparision function.  Returns result similar to C strcmp,
+# but instead of -1 is 2.  Function assumes version scheme like does
+# Linux kernel.
+vercmp() {
+    local n1 n2 i=1
+
+    while true
+    do
+        n1=$(echo $1 | cut -d'.' -f$i)
+        n2=$(echo $2 | cut -d'.' -f$i)
+
+        [[ ! $n1 && ! $n2 ]] && return 0
+        [[ $n1 -lt $n2 ]] && return 2
+        [[ $n1 -gt $n2 ]] && return 1
+
+        ((i++))
+    done
+}
+
+# Variation of version comparision function.  If $1 >= $2, return 0.
+verge() {
+    vercmp $1 $2
+
+    [[ $? = 0 || $? = 1 ]]
+}
+
+# Variation of version comparision function.  If $1 < $2, return 0.
+verlt() {
+    vercmp $1 $2
+
+    [[ $? = 2 ]]
+}
+
 # Log initrd creation.
 if ! [[ $dracutlogfile ]]; then
     [[ $dracutbasedir = /usr/share/dracut ]] && \
@@ -487,7 +520,7 @@ filter_kernel_modules () (
 # install kernel modules along with all their dependencies.
 instmods() {
     [[ $no_kernel = yes ]] && return
-    local mod mpargs modpath modname cmd
+    local mod mpargs modpath modname cmd moddirname
     while (($# > 0)); do
 	mod=${1%.ko*}
 	case $mod in
@@ -519,10 +552,17 @@ instmods() {
 	        ! echo $add_drivers | grep -qe "\<${mod}\>" &&	{
 		    shift; continue; 
 		}
+
+		# We use '-d' option in modprobe only if modules prefix path
+		# differs from default '/'.  This allows us to use Dracut with
+		# old version of modprobe which doesn't have '-d' option.
+		moddirname=${srcmods%%/lib/modules/*}
+		[[ -n ${moddirname} ]] && moddirname="-d ${moddirname}/"
+
 		# ok, load the module, all its dependencies, and any firmware
 		# it may require
 		for_each_kmod_dep install_kmod_with_fw $mod \
-		    --set-version $kernel -d ${srcmods%%/lib/modules/*}/
+		    --set-version $kernel ${moddirname}
 		;;
 	esac      
 	shift
-- 
1.7.1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-06-09 15:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-09  8:36 [PATCH 1/3] Support old version of module-init-tools Amadeusz Żołnowski
     [not found] ` <20100609103605.50a6acec-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org>
2010-06-09  8:38   ` [PATCH 2/3] 95uswsusp: Gentoo path for 'resume' binary Amadeusz Żołnowski
     [not found]     ` <20100609103836.6d14d542-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org>
2010-06-09  8:40       ` [PATCH 3/3] 90crypt: 'crypto_LUKS' identifier corrected Amadeusz Żołnowski
     [not found]         ` <20100609104031.01d37912-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org>
2010-06-09  9:04           ` Amadeusz Żołnowski
     [not found]             ` <20100609110405.21e9a39a-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org>
2010-06-09 15:40               ` Harald Hoyer
2010-06-09 15:39       ` [PATCH 2/3] 95uswsusp: Gentoo path for 'resume' binary Harald Hoyer
2010-06-09 10:55   ` [PATCH 1/3] Support old version of module-init-tools Victor Lowther
2010-06-09 15:39   ` Harald Hoyer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.