aboutsummaryrefslogtreecommitdiff
blob: ac6b3e2d5b5b02313aacdaf69cb9ead20d5b6a1f (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
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

src_prepare() {
	default

	sed -i \
		-e '/--enable-static is not supported by kmod/s:as_fn_error:echo:' \
		configure || die "Failed to re-enable static support"

	# List of symbols which are clashing with (e)udev
	cat <<-EOF >> kmod.syms
	mkdir_p                 _kmod_mkdir_p
	mkdir_parents           _kmod_mkdir_parents
	path_is_absolute        _kmod_path_is_absolute
	path_make_absolute_cwd  _kmod_path_make_absolute_cwd
	EOF
}

src_configure() {
	local myconf=(
		--enable-static
		--disable-manpages
		--disable-python
		--enable-tools
		--with-xz
		--with-zlib
		--with-zstd
		--without-openssl
	)

	gkconf "${myconf[@]}"
}

src_install() {
	default

	# remove hardcoded $BROOT
	sed -i \
		-e 's/-L\/[^ ]*/-L${libdir}/g' \
		"${D}"/usr/lib*/pkgconfig/*.pc \
		|| die

	# rename internal symbols to avoid clashing with (e)udev
	$(tc-getOBJCOPY) \
		--redefine-syms=kmod.syms \
		"${D}"/usr/lib*/libkmod.a \
		|| die

	rm -rf \
		"${D}"/usr/share/

	"${STRIP}" --strip-all "${D}"/usr/bin/kmod \
		|| die "Failed to strip '${D}/usr/bin/kmod'!"

	mkdir "${D}"/bin || die "Failed to create '${D}/bin'!"

	mkdir "${D}"/sbin || die "Failed to create '${D}/sbin'!"

	# We need to install these links where busybox would create them
	local symlink_targets=()
	symlink_targets+=( /sbin/depmod )
	symlink_targets+=( /sbin/insmod )
	symlink_targets+=( /sbin/lsmod )
	symlink_targets+=( /sbin/modinfo )
	symlink_targets+=( /sbin/modprobe )
	symlink_targets+=( /sbin/rmmod )

	local symlink_target=
	for symlink_target in "${symlink_targets[@]}"
	do
		ln -s ../usr/bin/kmod "${D}${symlink_target}" \
			|| die "Failed to create symlink '${D}${symlink_target}' to '${D}/usr/bin/kmod'!"
	done
}