196 lines
5.6 KiB
Bash
196 lines
5.6 KiB
Bash
# Template file for 'rpi-kernel'
|
|
#
|
|
_githash="c376c9f540932820080c7ffee571e7248d705335"
|
|
_gitshort="${_githash:0:7}"
|
|
|
|
pkgname=rpi-kernel
|
|
version=4.4.47
|
|
revision=1
|
|
wrksrc="linux-${_githash}"
|
|
maintainer="Juan RP <xtraeme@voidlinux.eu>"
|
|
homepage="http://www.kernel.org"
|
|
license="GPL-2"
|
|
short_desc="The Linux kernel for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
|
|
distfiles="https://github.com/raspberrypi/linux/archive/${_githash}.tar.gz"
|
|
checksum=975c46abbeff0c8d35e1262c7859942e8b923d69f10370aa05c4280849a4bc01
|
|
|
|
_kernver="${version}_${revision}"
|
|
|
|
nodebug=yes
|
|
nostrip=yes
|
|
noverifyrdeps=yes
|
|
noshlibprovides=yes
|
|
|
|
# RPi and RPi2
|
|
only_for_archs="armv6l armv6l-musl armv7l armv7l-musl"
|
|
hostmakedepends="perl kmod uboot-mkimage libressl bc"
|
|
makedepends="ncurses-devel"
|
|
triggers="kernel-hooks"
|
|
# These files could be modified when an external module is built.
|
|
mutable_files="
|
|
/usr/lib/modules/${_kernver}/modules.dep
|
|
/usr/lib/modules/${_kernver}/modules.dep.bin
|
|
/usr/lib/modules/${_kernver}/modules.symbols
|
|
/usr/lib/modules/${_kernver}/modules.symbols.bin
|
|
/usr/lib/modules/${_kernver}/modules.alias
|
|
/usr/lib/modules/${_kernver}/modules.alias.bin
|
|
/usr/lib/modules/${_kernver}/modules.devname"
|
|
|
|
pre_configure() {
|
|
# Remove .git directory, otherwise scripts/setkernelversion.sh
|
|
# modifies KERNELRELEASE and appends + to it.
|
|
rm -rf .git
|
|
}
|
|
do_configure() {
|
|
if [ "$CROSS_BUILD" ]; then
|
|
_args="CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-"
|
|
fi
|
|
|
|
# Use upstream default configuration, no need to maintain ours.
|
|
case "$XBPS_TARGET_MACHINE" in
|
|
armv7l*)
|
|
echo "CONFIG_USER_NS=y" >> arch/arm/configs/bcm2709_defconfig
|
|
make ${makejobs} ${_args} ARCH=arm bcm2709_defconfig
|
|
;;
|
|
armv6l*)
|
|
echo "CONFIG_USER_NS=y" >> arch/arm/configs/bcmrpi_defconfig
|
|
make ${makejobs} ${_args} ARCH=arm bcmrpi_defconfig
|
|
;;
|
|
esac
|
|
|
|
# Always use our revision to CONFIG_LOCALVERSION to match our pkg version.
|
|
sed -i -e "s|^\(CONFIG_LOCALVERSION=\).*|\1\"_${revision}\"|" .config
|
|
}
|
|
do_build() {
|
|
if [ "$CROSS_BUILD" ]; then
|
|
_args="CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-"
|
|
fi
|
|
make ${makejobs} ${_args} ARCH=arm prepare
|
|
make ${makejobs} ${_args} ARCH=arm zImage modules dtbs
|
|
}
|
|
do_install() {
|
|
local hdrdest
|
|
|
|
# Run depmod after compressing modules.
|
|
sed -i '2iexit 0' scripts/depmod.sh
|
|
|
|
# Install kernel, firmware and modules
|
|
make ${makejobs} ARCH=arm INSTALL_MOD_PATH=${DESTDIR} modules_install
|
|
|
|
vmkdir boot
|
|
# Generate kernel.img and install it to destdir.
|
|
case "$XBPS_TARGET_MACHINE" in
|
|
armv7l*)
|
|
scripts/mkknlimg --dtok arch/arm/boot/zImage ${DESTDIR}/boot/kernel7.img
|
|
;;
|
|
armv6l*)
|
|
scripts/mkknlimg --dtok arch/arm/boot/zImage ${DESTDIR}/boot/kernel.img
|
|
;;
|
|
esac
|
|
|
|
vmkdir boot/overlays
|
|
mv arch/arm/boot/dts/overlays/*.dtbo ${DESTDIR}/boot/overlays
|
|
mv arch/arm/boot/dts/*.dtb ${DESTDIR}/boot
|
|
|
|
hdrdest=${DESTDIR}/usr/src/${sourcepkg}-headers-${_kernver}
|
|
|
|
# Switch to /usr.
|
|
vmkdir usr
|
|
mv ${DESTDIR}/lib ${DESTDIR}/usr
|
|
|
|
cd ${DESTDIR}/usr/lib/modules/${_kernver}
|
|
rm -f source build
|
|
ln -sf ../../../src/${sourcepkg}-headers-${_kernver} build
|
|
|
|
cd ${wrksrc}
|
|
# Install required headers to build external modules
|
|
install -Dm644 Makefile ${hdrdest}/Makefile
|
|
install -Dm644 kernel/Makefile ${hdrdest}/kernel/Makefile
|
|
install -Dm644 .config ${hdrdest}/.config
|
|
mkdir -p ${hdrdest}/include
|
|
|
|
# Remove firmware stuff provided by the "linux-firmware" pkg.
|
|
rm -rf ${DESTDIR}/usr/lib/firmware
|
|
|
|
for i in acpi asm-generic config crypto drm generated linux math-emu \
|
|
media net pcmcia scsi sound trace uapi video xen; do
|
|
[ -d include/$i ] && cp -a include/$i ${hdrdest}/include
|
|
done
|
|
|
|
cd ${wrksrc}
|
|
# Copy files necessary for later builds.
|
|
cp Module.symvers ${hdrdest}
|
|
cp -a scripts ${hdrdest}
|
|
|
|
# fix permissions on scripts dir
|
|
chmod og-w -R ${hdrdest}/scripts
|
|
|
|
# copy arch includes for external modules
|
|
mkdir -p ${hdrdest}/arch/arm
|
|
cp -a arch/arm/include ${hdrdest}/arch/arm
|
|
case "$XBPS_TARGET_MACHINE" in
|
|
armv7l*)
|
|
mkdir -p ${hdrdest}/arch/arm/mach-bcm2709
|
|
cp -a arch/arm/mach-bcm2709/include ${hdrdest}/arch/arm/mach-bcm2709
|
|
;;
|
|
armv6l*)
|
|
mkdir -p ${hdrdest}/arch/arm/mach-bcm2708
|
|
cp -a arch/arm/mach-bcm2708/include ${hdrdest}/arch/arm/mach-bcm2708
|
|
;;
|
|
esac
|
|
|
|
mkdir -p ${hdrdest}/arch/arm/kernel
|
|
|
|
cp arch/arm/Makefile ${hdrdest}/arch/arm
|
|
cp arch/arm/kernel/asm-offsets.s ${hdrdest}/arch/arm/kernel
|
|
|
|
# Add docbook makefile
|
|
install -Dm644 Documentation/DocBook/Makefile \
|
|
${hdrdest}/Documentation/DocBook/Makefile
|
|
|
|
# Add md headers
|
|
mkdir -p ${hdrdest}/drivers/md
|
|
cp drivers/md/*.h ${hdrdest}/drivers/md
|
|
|
|
# Add inotify.h
|
|
mkdir -p ${hdrdest}/include/linux
|
|
cp include/linux/inotify.h ${hdrdest}/include/linux
|
|
|
|
# Add wireless headers
|
|
mkdir -p ${hdrdest}/net/mac80211/
|
|
cp net/mac80211/*.h ${hdrdest}/net/mac80211
|
|
|
|
# add dvb headers for external modules
|
|
mkdir -p ${hdrdest}/include/config/dvb/
|
|
cp include/config/dvb/*.h ${hdrdest}/include/config/dvb/
|
|
|
|
# Copy in Kconfig files
|
|
for i in $(find . -name "Kconfig*"); do
|
|
mkdir -p ${hdrdest}/$(echo $i | sed 's|/Kconfig.*||')
|
|
cp $i ${hdrdest}/$i
|
|
done
|
|
|
|
# Remove unneeded architectures
|
|
for arch in alpha arm26 avr32 blackfin cris frv h8300 \
|
|
ia64 m* p* s* um v850 x86 xtensa; do
|
|
rm -rf ${hdrdest}/arch/${arch}
|
|
done
|
|
|
|
# Compress all modules with xz to save a few MBs.
|
|
msg_normal "$pkgver: compressing kernel modules with gzip, please wait...\n"
|
|
find ${DESTDIR} -name '*.ko' | xargs -n1 -P0 gzip -9
|
|
|
|
# ... and run depmod again.
|
|
depmod -b ${DESTDIR}/usr -F System.map ${_kernver}
|
|
}
|
|
|
|
rpi-kernel-headers_package() {
|
|
nostrip=yes
|
|
noverifyrdeps=yes
|
|
noshlibprovides=yes
|
|
short_desc="The Linux kernel headers for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
|
|
pkg_install() {
|
|
vmove usr/src
|
|
vmove usr/lib/modules/${_kernver}/build
|
|
}
|
|
}
|