devicepkg-dev: implement out-of-tree build for kernel (!1084)

This commit is contained in:
Dolphin von Chips 2020-03-08 20:58:05 +05:00 committed by Oliver Smith
parent 8af4d8c27a
commit a4b1fb8371
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
3 changed files with 24 additions and 23 deletions

View file

@ -1,5 +1,5 @@
pkgname="devicepkg-dev" pkgname="devicepkg-dev"
pkgver=0.12.0 pkgver=0.12.1
pkgrel=0 pkgrel=0
pkgdesc="Provides default device package functions" pkgdesc="Provides default device package functions"
url="https://postmarketos.org" url="https://postmarketos.org"
@ -63,8 +63,8 @@ package() {
sha512sums="d69930dd790b00fb39760a37d95a10899f0d167e10e2804feb05d9ce04f94185dc32d36edc90214aba2ea2aa09bf18f7dab93f1d2eff23f67beb2cc83be30e7c compiler-gcc.h sha512sums="d69930dd790b00fb39760a37d95a10899f0d167e10e2804feb05d9ce04f94185dc32d36edc90214aba2ea2aa09bf18f7dab93f1d2eff23f67beb2cc83be30e7c compiler-gcc.h
332f693abfb3260ad6c1ef5d245062af8cc8eedba7db360d54db5a7fcf7b301a37a299a0004e9ff4de80b5dfcd260d0cd0f99f96ed6d56080bb4dea81116cc82 devicepkg_build.sh 332f693abfb3260ad6c1ef5d245062af8cc8eedba7db360d54db5a7fcf7b301a37a299a0004e9ff4de80b5dfcd260d0cd0f99f96ed6d56080bb4dea81116cc82 devicepkg_build.sh
10bda1a999891d6234bcfa3eb277b125c02361a031c5ff8445dabaae11e289321a6227f9f0973c7aa143a3df0512399bd0e3b2aa5a8ee560b28e1b135bad8635 devicepkg_package.sh 10bda1a999891d6234bcfa3eb277b125c02361a031c5ff8445dabaae11e289321a6227f9f0973c7aa143a3df0512399bd0e3b2aa5a8ee560b28e1b135bad8635 devicepkg_package.sh
69dad4bde05377ec235d72789c80cdfbdaa5a19b97defe9d4c19e0e12aa2c081d6dcf19fb80ebe33c2d6539ce8a39d36d98413404852d6bb2d56cc75d2f1ee95 downstreamkernel_prepare.sh f7583b92a27b39d79762700a48853b8d641845cdd45eb875d6fddc236f4d70598927d4dfc7d237870617b77b42820686692a68220f610dbc01c76402d9edfb2e downstreamkernel_prepare.sh
8a6a0afa6e499b59c5433194298d13eb07712c4344e1dd4f71fdc34a2836950a12247c61aa7563bd646efff6118b377ceb387f09170282896809a160b3d9cd04 downstreamkernel_package.sh 776d7c36afc7bedbd531641abe90fa4bf06a519ad9e300dedf67b6d3b4997b57a398938dd528d5eeda6d17e0d34644472702a4fdd8ff41e0a4a7ad0671f4a216 downstreamkernel_package.sh
cf5ee240cd1c1e9d30cdec833b4a007fd2e00f9a32ba3f265f99aa2e3dd3601cf43c08d3f3e01bade1d5b2648a6754b2f236e5cb4a9945e18e5c4e97aa2ed7c8 devicepkg_subpackage_kernel.sh cf5ee240cd1c1e9d30cdec833b4a007fd2e00f9a32ba3f265f99aa2e3dd3601cf43c08d3f3e01bade1d5b2648a6754b2f236e5cb4a9945e18e5c4e97aa2ed7c8 devicepkg_subpackage_kernel.sh
9bb7f2a0930f397a713e9f4b6d5b83a426d9a2a3f692dcc42ac30717bf26ead869d8823a38f3ad388af12b2b9a02e8ec4d4418e9c2062389ed06d2b891a49ff3 deviceinfo 9bb7f2a0930f397a713e9f4b6d5b83a426d9a2a3f692dcc42ac30717bf26ead869d8823a38f3ad388af12b2b9a02e8ec4d4418e9c2062389ed06d2b891a49ff3 deviceinfo
136247a16ec91dc0c7241eeddb28c2196ae3b29946a9bc7e9566f848491ef1c53b12d05bf2dbc1cc352986712fd76f25c1510bcc8f301af540a2f01c33b299e1 expected-deviceinfo-downstream 136247a16ec91dc0c7241eeddb28c2196ae3b29946a9bc7e9566f848491ef1c53b12d05bf2dbc1cc352986712fd76f25c1510bcc8f301af540a2f01c33b299e1 expected-deviceinfo-downstream

View file

@ -5,22 +5,23 @@ builddir=$1
pkgdir=$2 pkgdir=$2
_carch=$3 _carch=$3
_flavor=$4 _flavor=$4
_outdir=$5
if [ -z "$builddir" ] || [ -z "$pkgdir" ] || [ -z "$_carch" ] || if [ -z "$builddir" ] || [ -z "$pkgdir" ] || [ -z "$_carch" ] ||
[ -z "$_flavor" ]; then [ -z "$_flavor" ]; then
echo "ERROR: missing argument!" echo "ERROR: missing argument!"
echo "Please call downstreamkernel_package() with \$builddir, \$pkgdir," echo "Please call downstreamkernel_package() with \$builddir, \$pkgdir,"
echo "\$_carch and \$_flavor as arguments." echo "\$_carch, \$_flavor (and optionally \$_outdir) as arguments."
exit 1 exit 1
fi fi
# kernel.release # kernel.release
install -D "$builddir/include/config/kernel.release" \ install -D "$builddir/$_outdir/include/config/kernel.release" \
"$pkgdir/usr/share/kernel/$_flavor/kernel.release" "$pkgdir/usr/share/kernel/$_flavor/kernel.release"
# zImage (find the right one) # zImage (find the right one)
# shellcheck disable=SC2164 # shellcheck disable=SC2164
cd "$builddir/arch/$_carch/boot" cd "$builddir/$_outdir/arch/$_carch/boot"
_target="$pkgdir/boot/vmlinuz-$_flavor" _target="$pkgdir/boot/vmlinuz-$_flavor"
if [ -n "$KERNEL_IMAGE_NAME" ]; then if [ -n "$KERNEL_IMAGE_NAME" ]; then

View file

@ -3,6 +3,7 @@
# Replace compiler-gcc.h with one that works with newer GCC versions. # Replace compiler-gcc.h with one that works with newer GCC versions.
# Set REPLACE_GCCH=0 to avoid replacing an existing compiler-gcc.h file. # Set REPLACE_GCCH=0 to avoid replacing an existing compiler-gcc.h file.
install_gcc_h() { install_gcc_h() {
# shellcheck disable=SC2154
_gcch="$builddir/include/linux/compiler-gcc.h" _gcch="$builddir/include/linux/compiler-gcc.h"
if [ -f "$_gcch" ]; then if [ -f "$_gcch" ]; then
if [ "$REPLACE_GCCH" = "0" ]; then if [ "$REPLACE_GCCH" = "0" ]; then
@ -21,23 +22,19 @@ install_gcc_h() {
cp -v "/usr/share/devicepkg-dev/compiler-gcc.h" "$_gcch" cp -v "/usr/share/devicepkg-dev/compiler-gcc.h" "$_gcch"
} }
# Parse arguments if [ "$#" -ne 0 ]; then
srcdir=$1 echo "ERROR: downstreamkernel_prepare should be sourced in APKBUILDs."
builddir=$2 echo "Related: https://postmarketos.org/downstreamkernel-prepare"
_config=$3
_carch=$4
HOSTCC=$5
if [ -z "$srcdir" ] || [ -z "$builddir" ] || [ -z "$_config" ] ||
[ -z "$_carch" ]; then
echo "ERROR: missing argument!"
echo "Please call downstreamkernel_prepare() with \$srcdir, \$builddir,"
echo "\$_config, \$_carch (and optionally \$HOSTCC) as arguments."
exit 1 exit 1
fi fi
# Only override HOSTCC if set (to force use of an old gcc) # Set _outdir to "." if not set
[ -z "$HOSTCC" ] || HOSTCC="HOSTCC=$HOSTCC" if [ -z "$_outdir" ]; then
_outdir="."
fi
# Set _hostcc when HOSTCC is set
[ -z "$HOSTCC" ] || _hostcc="HOSTCC=$HOSTCC"
# Support newer GCC versions # Support newer GCC versions
install_gcc_h install_gcc_h
@ -52,6 +49,9 @@ for i in $makefiles; do
done done
# Prepare kernel config ('yes ""' for kernels lacking olddefconfig) # Prepare kernel config ('yes ""' for kernels lacking olddefconfig)
cp "$srcdir/$_config" "$builddir"/.config mkdir -p "$builddir/$_outdir"
# shellcheck disable=SC2086 # shellcheck disable=SC2154
yes "" | make -C "$builddir" ARCH="$_carch" $HOSTCC oldconfig cp "$srcdir/$_config" "$builddir"/"$_outdir"/.config
# shellcheck disable=SC2086,SC2154
yes "" | make -C "$builddir" ARCH="$_carch" O="$_outdir" \
$_hostcc oldconfig