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-08-23 01:15:57 +00:00
|
|
|
pkgver=4.18
|
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-12-22 19:03:50 +00:00
|
|
|
pkgrel=2
|
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=""
|
2018-12-22 19:03:50 +00:00
|
|
|
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev openssl-dev file bison flex"
|
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
|
|
|
|
"
|
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}}"
|
|
|
|
|
2018-02-19 22:04:01 +00:00
|
|
|
builddir="$srcdir/linux-$_basever"
|
2017-07-25 20:08:35 +00:00
|
|
|
|
|
|
|
prepare() {
|
|
|
|
local _patch_failed=
|
2018-02-19 22:04:01 +00:00
|
|
|
cd "$builddir"
|
2017-07-25 20:08:35 +00:00
|
|
|
# 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
|
2018-02-19 22:04:01 +00:00
|
|
|
make -C "$builddir" O="$srcdir"/build ARCH="$_carch" HOSTCC="$HOSTCC" \
|
2017-10-06 18:45:47 +00:00
|
|
|
olddefconfig
|
2017-07-25 20:08:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2018-02-19 22:04:01 +00:00
|
|
|
make -j1 -C "$builddir" 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
|
|
|
|
|
2018-02-19 22:04:01 +00:00
|
|
|
cd "$builddir"
|
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"
|
2018-09-03 07:45:32 +00:00
|
|
|
local found="false"
|
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
|
|
|
cd "$dir/scripts"
|
|
|
|
local i
|
|
|
|
for i in $(find . -type f); do
|
|
|
|
local type="$(file -b --mime-type "$i")"
|
2018-09-03 07:45:32 +00:00
|
|
|
[ "$type" != "application/x-pie-executable" ] && continue
|
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
|
|
|
local native="/usr/bin/kernel-scripts/$(echo "$i" | cut -d '/' -f 2-)"
|
|
|
|
ln -svf "$native" "$i"
|
2018-09-03 07:45:32 +00:00
|
|
|
found="true"
|
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
|
|
|
done
|
2018-09-03 07:45:32 +00:00
|
|
|
if [ "$found" = "false" ]; then
|
|
|
|
error "Failed to symlink binary scripts!"
|
|
|
|
error "Did the mime-type change (see #1659)?"
|
|
|
|
return 1
|
|
|
|
fi
|
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
|
|
|
fi
|
2017-07-25 20:08:35 +00:00
|
|
|
}
|
2018-08-23 01:15:57 +00:00
|
|
|
sha512sums="4d9de340a26155a89ea8773131c76220cc2057f2b5d031b467b60e8b14c1842518e2d60a863d8c695f0f7640f3f18d43826201984a238dade857b6cef79837db linux-4.17.tar.xz
|
|
|
|
da3d10fd0206e006e0d4448624cb0d5de61dce1e80dcc5272b088fa7284d360e5bac464a369bbf5d06625fc20d73991ee81f09bb1c8c271eb45646d3ce7927e7 linux-v4.17-v4.18.patch
|
2018-07-04 01:15:32 +00:00
|
|
|
581d889683f64fc8d9b31d1f87dc75b7b4f466a17b486ba2cb280b7cfa56003dd7c2e876e02c7e4395b8df28164b1efa4281670fb33aa814c2fa92b36ddfecf8 config-postmarketos-mainline.armhf
|
|
|
|
2257ce6abd1596e46b69cd8622785fdc8bd2e6b5d6448520b45c3d5151e839fd1f0ad31d673a3ee6984db9792cc5a70226e6f6a13be16e0d2e064e8ae200c681 config-postmarketos-mainline.aarch64
|
2018-08-23 01:15:57 +00:00
|
|
|
34e818059bd94b0431f986d7cb63fa779fe2aaa6c2199a054bd6f56a3df037555e80f20eeb78ac2dde5a517fd7dd7385e8be15aa6280685ee02129119638bdea config-postmarketos-mainline.x86_64"
|