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.
This commit is contained in:
parent
f05438b4e4
commit
6aba5f73d4
4 changed files with 113 additions and 6 deletions
62
main/kernel-scripts/APKBUILD
Normal file
62
main/kernel-scripts/APKBUILD
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
pkgname=kernel-scripts
|
||||||
|
pkgver=4.15.0
|
||||||
|
pkgrel=0
|
||||||
|
pkgdesc="Binary scripts needed to build kernel packages"
|
||||||
|
url="http://kernel.org"
|
||||||
|
depends=""
|
||||||
|
makedepends="perl gmp-dev elfutils-dev bash sed bc linux-headers file openssl-dev"
|
||||||
|
options="!check"
|
||||||
|
arch="all"
|
||||||
|
license="GPL-2.0"
|
||||||
|
|
||||||
|
# Sources
|
||||||
|
case $pkgver in
|
||||||
|
*.*.*) _kernver=${pkgver%.*};;
|
||||||
|
*.*) _kernver=$pkgver;;
|
||||||
|
esac
|
||||||
|
source="https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz"
|
||||||
|
if [ "${pkgver%.0}" = "$pkgver" ]; then
|
||||||
|
source="$source
|
||||||
|
https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Arch
|
||||||
|
_carch=${CARCH}
|
||||||
|
case "$_carch" in
|
||||||
|
aarch64*) _carch="arm64" ;;
|
||||||
|
arm*) _carch="arm" ;;
|
||||||
|
mips*) _carch="mips" ;;
|
||||||
|
ppc*) _carch="powerpc" ;;
|
||||||
|
s390*) _carch="s390" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
builddir="$srcdir/linux-$_kernver"
|
||||||
|
prepare() {
|
||||||
|
cd "$builddir"
|
||||||
|
|
||||||
|
# Apply patch
|
||||||
|
if [ "$_kernver" != "$pkgver" ]; then
|
||||||
|
msg "Applying patch-$pkgver.xz"
|
||||||
|
unxz -c < "$srcdir"/patch-$pkgver.xz | patch -p1 -N
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
unset LDFLAGS
|
||||||
|
mkdir -p "$srcdir/build"
|
||||||
|
make -j1 -C "$builddir" O="$srcdir/build" ARCH="$_carch" \
|
||||||
|
HOSTCC="${CC:-gcc}" defconfig scripts
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "$srcdir/build/scripts"
|
||||||
|
msg "Finding and installing binaries..."
|
||||||
|
local i
|
||||||
|
for i in $(find . -type f); do
|
||||||
|
local type="$(file -b --mime-type "$i")"
|
||||||
|
[ "$type" != "application/x-sharedlib" ] && continue
|
||||||
|
echo "$i"
|
||||||
|
install -Dm755 "$i" "$pkgdir/usr/bin/kernel-scripts/$i"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
sha512sums="c00d92659df815a53dcac7dde145b742b1f20867d380c07cb09ddb3295d6ff10f8931b21ef0b09d7156923a3957b39d74d87c883300173b2e20690d2b4ec35ea linux-4.15.tar.xz"
|
|
@ -8,13 +8,13 @@ case $pkgver in
|
||||||
*.*.*) _kernver=${pkgver%.*};;
|
*.*.*) _kernver=${pkgver%.*};;
|
||||||
*.*) _kernver=$pkgver;;
|
*.*) _kernver=$pkgver;;
|
||||||
esac
|
esac
|
||||||
pkgrel=1
|
pkgrel=2
|
||||||
|
|
||||||
arch="all"
|
arch="all"
|
||||||
pkgdesc="Linux for pmOS supported chipsets (LTS)"
|
pkgdesc="Linux for pmOS supported chipsets (LTS)"
|
||||||
url="https://kernel.org/"
|
url="https://kernel.org/"
|
||||||
depends="postmarketos-mkinitfs"
|
depends="postmarketos-mkinitfs"
|
||||||
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev"
|
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev file"
|
||||||
options="!strip !check !tracedeps"
|
options="!strip !check !tracedeps"
|
||||||
install=
|
install=
|
||||||
source="
|
source="
|
||||||
|
@ -174,6 +174,21 @@ dev() {
|
||||||
mkdir -p "$subpkgdir"/lib/modules/${_abi_release}
|
mkdir -p "$subpkgdir"/lib/modules/${_abi_release}
|
||||||
ln -sf /usr/src/linux-headers-${_abi_release} \
|
ln -sf /usr/src/linux-headers-${_abi_release} \
|
||||||
"$subpkgdir"/lib/modules/${_abi_release}/build
|
"$subpkgdir"/lib/modules/${_abi_release}/build
|
||||||
|
|
||||||
|
# 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
|
||||||
}
|
}
|
||||||
|
|
||||||
sha512sums="bf67ff812cc3cb7e5059e82cc5db0d9a7c5637f7ed9a42e4730c715bf7047c81ed3a571225f92a33ef0b6d65f35595bc32d773356646df2627da55e9bc7f1f1a linux-4.9.tar.xz
|
sha512sums="bf67ff812cc3cb7e5059e82cc5db0d9a7c5637f7ed9a42e4730c715bf7047c81ed3a571225f92a33ef0b6d65f35595bc32d773356646df2627da55e9bc7f1f1a linux-4.9.tar.xz
|
||||||
|
|
|
@ -9,13 +9,13 @@ _kernver=${pkgver%_rc*}
|
||||||
_mainver=${_kernver%.*}
|
_mainver=${_kernver%.*}
|
||||||
_patchlevel=${_kernver/$_mainver./}
|
_patchlevel=${_kernver/$_mainver./}
|
||||||
_basever=${_mainver}.$((_patchlevel-1))
|
_basever=${_mainver}.$((_patchlevel-1))
|
||||||
pkgrel=1
|
pkgrel=2
|
||||||
|
|
||||||
arch="all"
|
arch="all"
|
||||||
pkgdesc="Linux for pmOS supported chipsets (mainline, more bleeding-edge than stable)"
|
pkgdesc="Linux for pmOS supported chipsets (mainline, more bleeding-edge than stable)"
|
||||||
url="https://kernel.org/"
|
url="https://kernel.org/"
|
||||||
depends="postmarketos-mkinitfs"
|
depends="postmarketos-mkinitfs"
|
||||||
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev libressl-dev"
|
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev libressl-dev file"
|
||||||
options="!strip !check !tracedeps"
|
options="!strip !check !tracedeps"
|
||||||
install=
|
install=
|
||||||
source="
|
source="
|
||||||
|
@ -170,6 +170,21 @@ dev() {
|
||||||
mkdir -p "$subpkgdir"/lib/modules/${_abi_release}
|
mkdir -p "$subpkgdir"/lib/modules/${_abi_release}
|
||||||
ln -sf /usr/src/linux-headers-${_abi_release} \
|
ln -sf /usr/src/linux-headers-${_abi_release} \
|
||||||
"$subpkgdir"/lib/modules/${_abi_release}/build
|
"$subpkgdir"/lib/modules/${_abi_release}/build
|
||||||
|
|
||||||
|
# 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
|
||||||
}
|
}
|
||||||
sha512sums="77e43a02d766c3d73b7e25c4aafb2e931d6b16e870510c22cef0cdb05c3acb7952b8908ebad12b10ef982c6efbe286364b1544586e715cf38390e483927904d8 linux-4.14.tar.xz
|
sha512sums="77e43a02d766c3d73b7e25c4aafb2e931d6b16e870510c22cef0cdb05c3acb7952b8908ebad12b10ef982c6efbe286364b1544586e715cf38390e483927904d8 linux-4.14.tar.xz
|
||||||
5d05754adc696f180405acda79e2678075f99d12252fc1f7e6af46f5ab39076de926db6de900c28b2e05dd3753df60d3515bb805b71d3bff991a5ed040b91167 linux-v4.14-v4.15-rc6.patch
|
5d05754adc696f180405acda79e2678075f99d12252fc1f7e6af46f5ab39076de926db6de900c28b2e05dd3753df60d3515bb805b71d3bff991a5ed040b91167 linux-v4.14-v4.15-rc6.patch
|
||||||
|
|
|
@ -9,13 +9,13 @@ case $pkgver in
|
||||||
*.*.*) _kernver=${pkgver%.*};;
|
*.*.*) _kernver=${pkgver%.*};;
|
||||||
*.*) _kernver=$pkgver;;
|
*.*) _kernver=$pkgver;;
|
||||||
esac
|
esac
|
||||||
pkgrel=1
|
pkgrel=2
|
||||||
|
|
||||||
arch="all"
|
arch="all"
|
||||||
pkgdesc="Linux for pmOS supported chipsets (stable)"
|
pkgdesc="Linux for pmOS supported chipsets (stable)"
|
||||||
url="https://kernel.org/"
|
url="https://kernel.org/"
|
||||||
depends="postmarketos-mkinitfs"
|
depends="postmarketos-mkinitfs"
|
||||||
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev"
|
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev file"
|
||||||
options="!strip !check !tracedeps"
|
options="!strip !check !tracedeps"
|
||||||
install=
|
install=
|
||||||
source="
|
source="
|
||||||
|
@ -175,6 +175,21 @@ dev() {
|
||||||
mkdir -p "$subpkgdir"/lib/modules/${_abi_release}
|
mkdir -p "$subpkgdir"/lib/modules/${_abi_release}
|
||||||
ln -sf /usr/src/linux-headers-${_abi_release} \
|
ln -sf /usr/src/linux-headers-${_abi_release} \
|
||||||
"$subpkgdir"/lib/modules/${_abi_release}/build
|
"$subpkgdir"/lib/modules/${_abi_release}/build
|
||||||
|
|
||||||
|
# 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
|
||||||
}
|
}
|
||||||
|
|
||||||
sha512sums="77e43a02d766c3d73b7e25c4aafb2e931d6b16e870510c22cef0cdb05c3acb7952b8908ebad12b10ef982c6efbe286364b1544586e715cf38390e483927904d8 linux-4.14.tar.xz
|
sha512sums="77e43a02d766c3d73b7e25c4aafb2e931d6b16e870510c22cef0cdb05c3acb7952b8908ebad12b10ef982c6efbe286364b1544586e715cf38390e483927904d8 linux-4.14.tar.xz
|
||||||
|
|
Loading…
Reference in a new issue