2017-10-23 20:15:32 +00:00
|
|
|
_flavor=postmarketos-mainline
|
2017-07-25 20:08:35 +00:00
|
|
|
_config="config-${_flavor}.${CARCH}"
|
|
|
|
|
|
|
|
pkgname=linux-${_flavor}
|
|
|
|
|
2018-01-01 23:53:01 +00:00
|
|
|
pkgver=4.15_rc6
|
2017-11-04 02:13:25 +00:00
|
|
|
_pkgver=${pkgver/_/-}
|
|
|
|
_kernver=${pkgver%_rc*}
|
2017-10-23 20:15:32 +00:00
|
|
|
_mainver=${_kernver%.*}
|
|
|
|
_patchlevel=${_kernver/$_mainver./}
|
|
|
|
_basever=${_mainver}.$((_patchlevel-1))
|
2018-02-17 17:26:31 +00:00
|
|
|
pkgrel=3
|
2017-07-25 20:08:35 +00:00
|
|
|
|
2018-02-17 17:26:31 +00:00
|
|
|
arch="x86_64 armhf aarch64"
|
2017-10-23 20:15:32 +00:00
|
|
|
pkgdesc="Linux for pmOS supported chipsets (mainline, more bleeding-edge than stable)"
|
2017-07-25 20:08:35 +00:00
|
|
|
url="https://kernel.org/"
|
2018-02-17 17:26:31 +00:00
|
|
|
depends=""
|
Package kernel-scripts separately (#1234)
We have two methods of cross-compiling:
* native: everything runs with the host architecture, QEMU is not
involved. This is the fastest, but requires the build system to be
working with it. We use this for all linux-* packages currently.
* distcc: everything runs through QEMU emulating the target arch,
*except* for the compiler. This is the most compatible approach
working with all packages.
When compiling `linux-*` packages natively, kernel scripts needed
during the build process get generated. Some of these are C files that
get compiled as executables. In native mode, these get compied to the
native architecture, in distcc mode to the target architecture.
The problem is, that we need these scripts compiled for the target
architecture in the kernel's dev package in order to compile kernel
modules outside of the kernel's package (e.g. wireguard).
It is not possible to just rewrite this logic to generate target-arch
binaries when running in native mode, because these binaries require
musl-dev, linux-headers and some other packages to be installed for the
target architecture inside the native chroot.
We solve this by introducing a new `kernel-scripts` package. which
contains just the binary scripts. In case the dev package was
cross-compiled, it depends on `kernel-scripts` and symlinks these
binaries. The `kernel-scripts` package always gets compiled in distcc
mode since it does not have a `linux-` prefix.
Fixes #1230.
2018-02-16 21:00:37 +00:00
|
|
|
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev libressl-dev file"
|
2017-07-25 20:08:35 +00:00
|
|
|
options="!strip !check !tracedeps"
|
|
|
|
install=
|
|
|
|
source="
|
2017-10-23 20:15:32 +00:00
|
|
|
https://cdn.kernel.org/pub/linux/kernel/v$_mainver.x/linux-$_basever.tar.xz
|
2018-01-01 23:53:01 +00:00
|
|
|
linux-v$_basever-v$_pkgver.patch::https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/rawdiff/?id=v$_pkgver&id2=v$_basever
|
2017-07-25 20:08:35 +00:00
|
|
|
config-${_flavor}.armhf
|
2017-08-09 20:26:40 +00:00
|
|
|
config-${_flavor}.aarch64
|
2017-07-25 20:08:35 +00:00
|
|
|
config-${_flavor}.x86_64
|
2018-01-01 23:53:01 +00:00
|
|
|
0001-sony-amami-dts.patch
|
|
|
|
0002-tools-objtool-Makefile-don-t-assume-sync-check.sh-is.patch
|
2017-07-25 20:08:35 +00:00
|
|
|
"
|
2017-08-02 16:48:06 +00:00
|
|
|
|
2018-02-14 23:20:40 +00:00
|
|
|
subpackages="$pkgname-dev"
|
2017-07-25 20:08:35 +00:00
|
|
|
|
2017-08-02 16:48:06 +00:00
|
|
|
license="GPL2"
|
2017-11-04 02:13:25 +00:00
|
|
|
_abi_release=$_pkgver
|
2017-07-25 20:08:35 +00:00
|
|
|
_carch=${CARCH}
|
|
|
|
case "$_carch" in
|
|
|
|
aarch64*) _carch="arm64" ;;
|
|
|
|
arm*) _carch="arm" ;;
|
|
|
|
ppc*) _carch="powerpc" ;;
|
|
|
|
s390*) _carch="s390" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
HOSTCC="${CC:-gcc}"
|
|
|
|
HOSTCC="${HOSTCC#${CROSS_COMPILE}}"
|
|
|
|
|
2017-10-23 20:15:32 +00:00
|
|
|
ksrcdir="$srcdir/linux-$_basever"
|
2017-07-25 20:08:35 +00:00
|
|
|
|
|
|
|
prepare() {
|
|
|
|
local _patch_failed=
|
|
|
|
cd "$ksrcdir"
|
|
|
|
# first apply patches in specified order
|
|
|
|
for i in $source; do
|
|
|
|
case $i in
|
2017-10-23 20:15:32 +00:00
|
|
|
*.patch|*.patch::*)
|
|
|
|
_patch=${i%::*}
|
|
|
|
msg "Applying $_patch..."
|
|
|
|
if ! patch -s -p1 -N -i "$srcdir"/$_patch; then
|
|
|
|
echo $_patch >>failed
|
2017-07-25 20:08:35 +00:00
|
|
|
_patch_failed=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if ! [ -z "$_patch_failed" ]; then
|
|
|
|
error "The following patches failed:"
|
|
|
|
cat failed
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "$srcdir"/build
|
2017-10-04 15:05:00 +00:00
|
|
|
cp -v "$srcdir"/$_config "$srcdir"/build/.config
|
2017-07-25 20:08:35 +00:00
|
|
|
make -C "$ksrcdir" O="$srcdir"/build ARCH="$_carch" HOSTCC="$HOSTCC" \
|
2017-10-06 18:45:47 +00:00
|
|
|
olddefconfig
|
2017-07-25 20:08:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# this is so we can do: 'abuild menuconfig' to reconfigure kernel
|
|
|
|
menuconfig() {
|
2017-10-04 15:05:00 +00:00
|
|
|
cd "$srcdir"/build
|
2017-07-25 20:08:35 +00:00
|
|
|
make ARCH="$_carch" menuconfig
|
|
|
|
cp .config "$startdir"/$_config
|
|
|
|
}
|
|
|
|
|
|
|
|
build() {
|
|
|
|
cd "$srcdir"/build
|
|
|
|
unset LDFLAGS
|
|
|
|
make ARCH="$_carch" CC="${CC:-gcc}" \
|
2017-10-23 20:15:32 +00:00
|
|
|
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-${_flavor}" \
|
2017-09-07 22:29:15 +00:00
|
|
|
CFLAGS_MODULE=-fno-pic
|
2017-07-25 20:08:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
package() {
|
|
|
|
cd "$srcdir/build/arch/${_carch}/boot"
|
2017-10-04 15:05:00 +00:00
|
|
|
|
2017-08-09 20:26:40 +00:00
|
|
|
if [ "$CARCH" == "aarch64" ]; then
|
|
|
|
install -Dm644 "$srcdir/build/arch/${_carch}/boot/Image" \
|
|
|
|
"$pkgdir/boot/vmlinuz-$_flavor"
|
|
|
|
else
|
|
|
|
install -Dm644 "$srcdir/build/arch/${_carch}/boot/"*zImage \
|
|
|
|
"$pkgdir/boot/vmlinuz-$_flavor"
|
|
|
|
fi
|
2017-07-25 20:08:35 +00:00
|
|
|
|
|
|
|
install -D "$srcdir/build/include/config/kernel.release" \
|
|
|
|
"$pkgdir/usr/share/kernel/$_flavor/kernel.release"
|
|
|
|
|
|
|
|
cd "$srcdir"/build
|
|
|
|
|
|
|
|
local _install
|
|
|
|
case "$CARCH" in
|
|
|
|
aarch64*|arm*) _install="modules_install dtbs_install" ;;
|
|
|
|
*) _install="modules_install" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
make -j1 $_install \
|
|
|
|
ARCH="$_carch" \
|
|
|
|
INSTALL_MOD_PATH="$pkgdir" \
|
2017-10-04 15:05:00 +00:00
|
|
|
INSTALL_DTBS_PATH="$pkgdir/usr/share/dtb"
|
2017-07-25 20:08:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dev() {
|
|
|
|
# copy the only the parts that we really need for build 3rd party
|
|
|
|
# kernel modules and install those as /usr/src/linux-headers,
|
|
|
|
# simlar to what ubuntu does
|
|
|
|
#
|
|
|
|
# this way you dont need to install the 300-400 kernel sources to
|
|
|
|
# build a tiny kernel module
|
|
|
|
#
|
|
|
|
pkgdesc="Headers and script for third party modules for postmarketos kernel"
|
|
|
|
depends="gmp-dev bash perl"
|
|
|
|
local dir="$subpkgdir"/usr/src/linux-headers-${_abi_release}
|
|
|
|
|
|
|
|
# first we import config, run prepare to set up for building
|
|
|
|
# external modules, and create the scripts
|
|
|
|
mkdir -p "$dir"
|
|
|
|
cp "$srcdir"/$_config "$dir"/.config
|
2017-10-23 20:15:32 +00:00
|
|
|
make -j1 -C "$ksrcdir" O="$dir" ARCH="$_carch" HOSTCC="$HOSTCC" \
|
2017-10-06 18:45:47 +00:00
|
|
|
olddefconfig prepare modules_prepare scripts
|
2017-07-25 20:08:35 +00:00
|
|
|
|
|
|
|
# needed for 3rd party modules
|
|
|
|
# https://bugzilla.kernel.org/show_bug.cgi?id=11143
|
|
|
|
case "$CARCH" in
|
|
|
|
ppc*) (cd "$dir" && make arch/powerpc/lib/crtsavres.o);;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# remove the stuff that points to real sources. we want 3rd party
|
|
|
|
# modules to believe this is the soruces
|
|
|
|
rm "$dir"/Makefile "$dir"/source
|
|
|
|
|
|
|
|
# copy the needed stuff from real sources
|
|
|
|
#
|
|
|
|
# this is taken from ubuntu kernel build script
|
|
|
|
# http://kernel.ubuntu.com/git/ubuntu/ubuntu-zesty.git/tree/debian/rules.d/3-binary-indep.mk
|
|
|
|
|
2017-10-23 20:15:32 +00:00
|
|
|
cd "$ksrcdir"
|
2017-07-25 20:08:35 +00:00
|
|
|
find . -path './include/*' -prune \
|
|
|
|
-o -path './scripts/*' -prune -o -type f \
|
|
|
|
\( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
|
|
|
|
-name '*.sh' -o -name '*.pl' -o -name '*.lds' \) \
|
2017-10-04 15:05:00 +00:00
|
|
|
-print | cpio -pdm "$dir"
|
2017-07-25 20:08:35 +00:00
|
|
|
cp -a scripts include "$dir"
|
|
|
|
find $(find arch -name include -type d -print) -type f \
|
|
|
|
| cpio -pdm "$dir"
|
|
|
|
|
|
|
|
install -Dm644 "$srcdir"/build/Module.symvers \
|
|
|
|
"$dir"/Module.symvers
|
|
|
|
|
|
|
|
mkdir -p "$subpkgdir"/lib/modules/${_abi_release}
|
|
|
|
ln -sf /usr/src/linux-headers-${_abi_release} \
|
|
|
|
"$subpkgdir"/lib/modules/${_abi_release}/build
|
Package kernel-scripts separately (#1234)
We have two methods of cross-compiling:
* native: everything runs with the host architecture, QEMU is not
involved. This is the fastest, but requires the build system to be
working with it. We use this for all linux-* packages currently.
* distcc: everything runs through QEMU emulating the target arch,
*except* for the compiler. This is the most compatible approach
working with all packages.
When compiling `linux-*` packages natively, kernel scripts needed
during the build process get generated. Some of these are C files that
get compiled as executables. In native mode, these get compied to the
native architecture, in distcc mode to the target architecture.
The problem is, that we need these scripts compiled for the target
architecture in the kernel's dev package in order to compile kernel
modules outside of the kernel's package (e.g. wireguard).
It is not possible to just rewrite this logic to generate target-arch
binaries when running in native mode, because these binaries require
musl-dev, linux-headers and some other packages to be installed for the
target architecture inside the native chroot.
We solve this by introducing a new `kernel-scripts` package. which
contains just the binary scripts. In case the dev package was
cross-compiled, it depends on `kernel-scripts` and symlinks these
binaries. The `kernel-scripts` package always gets compiled in distcc
mode since it does not have a `linux-` prefix.
Fixes #1230.
2018-02-16 21:00:37 +00:00
|
|
|
|
|
|
|
# cross-compiling: delete binaries with host arch and replace them with
|
|
|
|
# symlinks to binaries with the target arch (packaged in kernel-scripts)
|
|
|
|
if [ -n "$CROSS_COMPILE" ]; then
|
|
|
|
msg "Symlinking binary scripts..."
|
|
|
|
depends="$depends kernel-scripts"
|
|
|
|
cd "$dir/scripts"
|
|
|
|
local i
|
|
|
|
for i in $(find . -type f); do
|
|
|
|
local type="$(file -b --mime-type "$i")"
|
|
|
|
[ "$type" != "application/x-sharedlib" ] && continue
|
|
|
|
local native="/usr/bin/kernel-scripts/$(echo "$i" | cut -d '/' -f 2-)"
|
|
|
|
ln -svf "$native" "$i"
|
|
|
|
done
|
|
|
|
fi
|
2017-07-25 20:08:35 +00:00
|
|
|
}
|
2018-01-01 23:53:01 +00:00
|
|
|
sha512sums="77e43a02d766c3d73b7e25c4aafb2e931d6b16e870510c22cef0cdb05c3acb7952b8908ebad12b10ef982c6efbe286364b1544586e715cf38390e483927904d8 linux-4.14.tar.xz
|
2018-02-14 23:20:40 +00:00
|
|
|
5d05754adc696f180405acda79e2678075f99d12252fc1f7e6af46f5ab39076de926db6de900c28b2e05dd3753df60d3515bb805b71d3bff991a5ed040b91167 linux-v4.14-v4.15-rc6.patch
|
2017-10-23 20:15:32 +00:00
|
|
|
a75225750193cf31c8b6c15e7748699f842ecadc9ed573f0b10f42bb5343b4e092bcb65b359d170a42a102a4ddfe09d63c1d67550f4b99c29295fa22e1d7b995 config-postmarketos-mainline.armhf
|
|
|
|
6310035a0a4c028cc98cab92919cca54be9b79ee9fe63211e7a05876d7befdbd8506a2f80548e228e014e99b0f91f63946352789d8d2f2134c66914163f66ab3 config-postmarketos-mainline.aarch64
|
|
|
|
3d42c60061d12a436d19ffdf00623ea71ca31f16f690ae82ebf872d35177c283b4038cd5e270f4e610d6cf6861cef73ac63c995f1f4cfe9d6f2a4a8648ba28fb config-postmarketos-mainline.x86_64
|
2018-01-01 23:53:01 +00:00
|
|
|
e0fb34032fe70d9a4713ed521b8a5e29cf7f76cb7c56ceb24ed7206a8445ba743226e4873fa2069077952e21f99fb36eabf7c4daa779f565961f0dded4591887 0001-sony-amami-dts.patch
|
|
|
|
04863696e5ed64a8fe41b3ac49c4f7e3028a945c3abf74467e0b0b39d57748f1f89269776f4e0301e2f996738f29a1e1932b3c121d6530a889eb3c1fd91a7af4 0002-tools-objtool-Makefile-don-t-assume-sync-check.sh-is.patch"
|