/
bcmrpi3-kernel-bin-4.9.48.20170911.ebuild
99 lines (81 loc) · 2.89 KB
/
bcmrpi3-kernel-bin-4.9.48.20170911.ebuild
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Copyright (c) 2017 sakaki <sakaki@deciban.com>
# Distributed under the terms of the GNU General Public License v2
EAPI="6"
inherit eutils autotools
DESCRIPTION="Binary RPi3 64-bit kernel package (bcmrpi3_defconfig)"
HOMEPAGE="https://github.com/sakaki-/bcmrpi3-kernel"
SRC_URI="${HOMEPAGE}/releases/download/${PV}/bcmrpi3-kernel-${PV}.tar.xz -> ${P}.tar.xz"
LICENSE="GPL-2 freedist"
SLOT="0"
KEYWORDS="~arm64"
IUSE="+checkboot firmware +with-matching-boot-fw pitop"
RESTRICT="mirror"
DEPEND=""
RDEPEND="
with-matching-boot-fw? ( ~sys-boot/rpi3-64bit-firmware-1.20170811[pitop(-)?] )
${DEPEND}"
QA_PREBUILT="*"
S="${WORKDIR}"
# ebuild function overrides
pkg_pretend() {
# check /boot directory is mounted, provided $ROOT is /
if use checkboot && [[ "${ROOT%/}" == "" ]]; then
if ! grep -q "^/boot$" <(cut -d " " -f 2 "/proc/mounts") &>/dev/null; then
die "Your /boot directory does not appear to be mounted"
fi
else
ewarn 'Installing into non-default $ROOT'
ewarn "Not checking whether /boot is mounted"
fi
}
src_install() {
local RELEASE_NAME
# just copy tarball contents into temporary install root
insinto /boot
doins -r "${S%/}/boot"/*
insinto /lib/modules
doins -r "${S%/}/lib/modules"/*
if use firmware; then
# NB may cause collisions if linux-firmware installed
insinto /lib/firmware
doins -r "${S%/}/lib/firmware"/*
fi
# note that we installed the libraries, for future cleanup
RELEASE_NAME=$(head -n1 <(ls -t1d "${S}/lib/modules"/*))
RELEASE_NAME="${RELEASE_NAME##*/}"
echo "${PF}" > "${D%/}/lib/modules/${RELEASE_NAME}/owning_binpkg"
}
pkg_postinst() {
elog "Your new kernel has been installed."
elog "Reboot your system to start using it."
}
pkg_postrm() {
# it is possible that if the kernel originally installed by this ebuild
# is currently running, then its /lib/modules/<release_name> directory
# will still be present, due to some of the module files therein having
# been marked as "in use", leading Portage deline to delete them during
# the default uninstall phase
# detect if this has happened and, if so, forcibly (and recursively)
# delete /lib/modules/<release_name>, and print a warning
local MDIR OWNING_BINPKG
shopt -s nullglob
for MDIR in "${ROOT%/}/lib/modules"/*; do
# was this kernel installed by a binary package?
if [[ -s "${MDIR}/owning_binpkg" ]]; then
OWNING_BINPKG="$(<"${MDIR}/owning_binpkg")"
# was it us? (also check this is not a pure re-install)
if [[ "${PF}" == "${OWNING_BINPKG}" && "${PVR}" != "${REPLACED_BY_VERSION}" ]]; then
# yes, we installed it, we need to remove it
ewarn "Forcibly deleting kernel module directory ${MDIR}"
rm -rf "${MDIR}"
# warn user if this is a 'pure' uninstall,
# rather than an upgrade
if [[ -z "${REPLACED_BY_VERSION}" ]]; then
ewarn "Please ensure you have a valid kernel and module set"
ewarn "in place, before rebooting."
fi
fi
fi
done
shopt -u nullglob
}