summaryrefslogtreecommitdiff
path: root/pcr/openrc/use-optional-modules-load-d.patch
blob: 81ef5be3bb5459e81b0ed1f4215e5a94aba4d2c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
diff -aur openrc-0.20.5.orig/conf.d/modules openrc-0.20.5/conf.d/modules
--- openrc-0.20.5.orig/conf.d/modules	2016-04-20 10:54:37.686042847 -0700
+++ openrc-0.20.5/conf.d/modules	2016-04-20 10:56:27.900232387 -0700
@@ -1,6 +1,11 @@
 # You can define a list modules for a specific kernel version,
 # a released kernel version, a main kernel version or just a list.
 # The most specific versioned variable will take precedence.
+
+# if openrc should make use of /etc/modules-load.d
+# systemd places stuff there
+use_modules_load_d=false
+
 #modules_2_6_23_gentoo_r5="ieee1394 ohci1394"
 #modules_2_6_23="tun ieee1394"
 #modules_2_6="tun"
diff -aur openrc-0.20.5.orig/init.d/modules.in openrc-0.20.5/init.d/modules.in
--- openrc-0.20.5.orig/init.d/modules.in	2016-04-20 10:54:37.689376105 -0700
+++ openrc-0.20.5/init.d/modules.in	2016-04-20 10:55:41.671271452 -0700
@@ -23,6 +23,61 @@
 	# support compiled in ...
 	[ ! -f /proc/modules ] && return 0
 
+	if yesno "${use_modules_load_d:-false}";then
+		local conf_s=/etc/modules-load.d
+		einfo "using ${conf_s}"
+
+		local mhwd=
+		if [ -f "${conf_s}/mwhd-gpu.conf" ];then
+			for m in $(cat ${conf_s}/mhwd-gpu.conf | sed '/^.*#/d'); do
+				mhwd="$mhwd $m"
+			done
+		fi
+
+		if [ -d "${conf_s}" ]; then
+			local mods= fn= kv= gmods= kv_cache=
+
+			for f in $(ls ${conf_s}/*.conf); do
+				fn="$( expr "$(basename "$f")" : '\(.*\).conf' )"
+
+				if [ "$fn" != mhwd-gpu ];then
+					kv="$(expr "$fn" : 'linux\([0-9]\+\)-')"
+					echo "$fn || $kv"
+
+					if expr "$fn" : "linux${kv}-.*" > /dev/null; then
+						for m in $(cat $f | sed '/^.*#/d'); do
+							mods="$mods $m"
+						done
+
+						local kv_major="$(expr "$kv" : "\([0-9]\)" )"
+						local kv_minor="$(expr "$kv" : "[0-9]\([0-9]\)" )"
+
+						local kvr_k="${kv_major}_${kv_minor}"
+
+						if expr \( "${kv_cache}" : "${kvr_k}" \) = 0; then
+							kv_cache="${kv_cache} ${kvr_k}"
+						fi
+
+						eval local "_cache_${kvr_k}=\"\${_cache_${kvr_k}} ${mods}\""
+						mods=
+					else
+						for m in $(cat $f | sed '/^.*#/d'); do
+							gmods="$gmods $m"
+						done
+					fi
+				fi
+			done
+
+			for kv_key in $(echo "${kv_cache}"|tr ' ' '\n'); do
+				kv_val="$(eval "echo \"\${_cache_${kv_key}}"\")"
+				eval "modules_${kv_key}=\"${kv_val} ${mhwd} ${gmods}\""
+				unset "_cache_${kv_key}"
+			done
+
+			eval "modules=\"${mhwd} ${gmods}\""
+		fi
+	fi
+
 	local KV x y kv_variant_list
 	KV=$(uname -r)
 	# full $KV