From 7907e91879affdf687dec6d0a5d2c07d0c16467d Mon Sep 17 00:00:00 2001 From: Minecrell Date: Sat, 18 Jan 2020 10:53:46 +0100 Subject: [PATCH] pmb/parse/_apkbuild: Fix locating kernel subpackages with "-" in name (!1857) When defining a new kernel subpackage with a "-" in it (e.g. $pkgname-kernel-mainline-modem), then pmbootstrap is unable to find the function that builds the subpackage: ERROR: Could not find subpackage function, no line starts with 'kernel_mainline-modem() {' This is because it assumes that a $pkgname-kernel- subpackage is built by a kernel_ function, but this does not have to be the case. We should really respect the name of the subpackage function that is specified when defining the subpackage, but unfortunately it is stripped away in cut_off_function_names(). For now let's fix this by replacing "-" with "_", but ideally the APKBUILD parser API should be refactored to expose the subpackage function in the future. --- pmb/parse/_apkbuild.py | 4 +- test/test_parse_apkbuild.py | 7 +++ .../device/device-wileyfox-crackling/APKBUILD | 59 +++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 test/testdata/init_questions_device/aports/device/device-wileyfox-crackling/APKBUILD diff --git a/pmb/parse/_apkbuild.py b/pmb/parse/_apkbuild.py index 303b4eef..40565b3b 100644 --- a/pmb/parse/_apkbuild.py +++ b/pmb/parse/_apkbuild.py @@ -363,7 +363,9 @@ def kernels(args, device): if not subpackage.startswith(subpackage_prefix): continue name = subpackage[len(subpackage_prefix):] - func = "kernel_" + name + # FIXME: We should use the specified function name here, + # but it's removed in cut_off_function_names() + func = "kernel_" + name.replace('-', '_') desc = pmb.parse._apkbuild.subpkgdesc(apkbuild_path, func) ret[name] = desc diff --git a/test/test_parse_apkbuild.py b/test/test_parse_apkbuild.py index f67823eb..509b2bd8 100644 --- a/test/test_parse_apkbuild.py +++ b/test/test_parse_apkbuild.py @@ -73,6 +73,13 @@ def test_kernels(args): "mainline": "Mainline description"} assert func(args, device) == ret + # Long kernel name (e.g. two different mainline kernels) + device = "wileyfox-crackling" + ret = {"mainline": "Mainline kernel (no modem)", + "mainline-modem": "Mainline kernel (with modem)", + "downstream": "Downstream kernel"} + assert func(args, device) == ret + def test_depends_in_depends(args): path = pmb_src + "/test/testdata/apkbuild/APKBUILD.depends-in-depends" diff --git a/test/testdata/init_questions_device/aports/device/device-wileyfox-crackling/APKBUILD b/test/testdata/init_questions_device/aports/device/device-wileyfox-crackling/APKBUILD new file mode 100644 index 00000000..0b4e48a9 --- /dev/null +++ b/test/testdata/init_questions_device/aports/device/device-wileyfox-crackling/APKBUILD @@ -0,0 +1,59 @@ +# Reference: +pkgname="device-wileyfox-crackling" +pkgdesc="Wileyfox Swift" +pkgver=2 +pkgrel=0 +url="https://postmarketos.org" +license="MIT" +arch="aarch64" +options="!check !archcheck" +depends="postmarketos-base mkbootimg" +makedepends="devicepkg-dev" +subpackages=" + $pkgname-kernel-mainline:kernel_mainline + $pkgname-kernel-mainline-modem:kernel_mainline_modem + $pkgname-kernel-downstream:kernel_downstream + $pkgname-nonfree-firmware:nonfree_firmware + $pkgname-nonfree-firmware-modem:nonfree_firmware_modem +" + +source="deviceinfo" + +build() { + devicepkg_build $startdir $pkgname +} + +package() { + devicepkg_package $startdir $pkgname +} + +kernel_mainline() { + pkgdesc="Mainline kernel (no modem)" + depends="linux-postmarketos-qcom-msm8916 soc-qcom-msm8916" + devicepkg_subpackage_kernel $startdir $pkgname $subpkgname +} + +kernel_mainline_modem() { + pkgdesc="Mainline kernel (with modem)" + depends="linux-postmarketos-qcom-msm8916 soc-qcom-msm8916 soc-qcom-msm8916-modem" + devicepkg_subpackage_kernel $startdir $pkgname $subpkgname +} + +kernel_downstream() { + pkgdesc="Downstream kernel" + depends="linux-wileyfox-crackling mesa-dri-swrast mdss-fb-init-hack" + devicepkg_subpackage_kernel $startdir $pkgname $subpkgname +} + +nonfree_firmware() { + pkgdesc="GPU/WiFi/BT/Video firmware" + depends="linux-firmware-qcom firmware-wileyfox-crackling-venus firmware-wileyfox-crackling-wcnss" + mkdir "$subpkgdir" +} + +nonfree_firmware_modem() { + pkgdesc="Modem firmware" + depends="firmware-wileyfox-crackling-modem" + install_if="$pkgname-nonfree-firmware $pkgname-kernel-mainline-modem" + mkdir "$subpkgdir" +}