aboutsummaryrefslogtreecommitdiff
blob: 070131ceaa21df18ffc629a3c7511d5368cc25c6 (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
#!/bin/bash
# $Id$

mod_dep_list() {
	if [ ! -f "${TEMP}/moddeps" ]
	then
		gen_dep_list > "${TEMP}/moddeps"
	fi

	cat "${TEMP}/moddeps"
}

xbasename() {
	local -a moddeplist=( $( </dev/stdin ) )

	if (( ${#moddeplist[@]} > 0 ))
	then
		# prepend slash to each moddeplist element
		# to avoid passing elements as basename options
		basename -s "${KEXT}" "${moddeplist[@]/#/\/}"
	fi
}

gen_dep_list() {
	local moddir="${KERNEL_MODULES_PREFIX%/}/lib/modules/${KV}"

	if isTrue "${ALLRAMDISKMODULES}"
	then
		cat "${moddir}/modules.builtin"
		cat "${moddir}/modules.dep" | cut -d':' -f1
	else
		local -a modlist=() moddeplist=()

		local mygroups
		for mygroups in ${!MODULES_*} GK_INITRAMFS_ADDITIONAL_KMODULES
		do
			modlist+=( ${!mygroups} )
		done

		modlist=( $(printf '%s\n' "${modlist[@]}" | sort | uniq) )

		modlist+=( $(
			local -a rxargs=( "${modlist[@]}" )

			rxargs=( "${rxargs[@]/#/-ealias\ }" )
			rxargs=( "${rxargs[@]/%/\ }" )

			cat "${moddir}/modules.alias" \
				| grep -F "${rxargs[@]}" \
				| cut -d' ' -f3-
		) )

		modlist=( $(printf '%s\n' "${modlist[@]}" | sort | uniq) )

		local mydeps mymod
		while IFS=" " read -r -u 3 mymod mydeps
		do
			moddeplist+=( ${mymod%:} ${mydeps} )
		done 3< <(
			local -a rxargs=( "${modlist[@]}" )

			rxargs=( "${rxargs[@]/#/-e\/}" )
			rxargs=( "${rxargs[@]/%/${KEXT}:}" )

			cat "${moddir}/modules.builtin" \
				| xargs printf '%s:\n' \
				| grep -F "${rxargs[@]}"

			cat "${moddir}/modules.dep" \
				| grep -F "${rxargs[@]}"
		)

		printf '%s\n' "${moddeplist[@]}"
	fi | xbasename | sort | uniq
}