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

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

	cat "${TEMP}/moddeps"
}

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

	# Always include firmware for built-in modules
	moddeplist=( $(cat "${moddir}/modules.builtin") )

	if isTrue "${ALLRAMDISKMODULES}"
	then
		moddeplist+=( $(cat "${moddir}/modules.dep" | cut -d':' -f1) )
	else
		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[@]/%/.ko:}"
				"${rxargs[@]/%/${KEXT}:}"
			)

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

	moddeplist=( ${moddeplist[@]##*/} )
	moddeplist=( ${moddeplist[@]%%.*} )

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