pmb.aportgen: put dependencies on separate lines (MR 2024)

Generate APKBUILDs with dependencies sorted and placed one per line.
The dependency lists changed are
 - depends in pmb/aportgen/device.py
 - makedepends in pmb/aportgen/linux.py

Sort dependency lists in test/test_aportgen_device_wizard.py
assertions.
This commit is contained in:
nybbled 2021-02-08 22:57:24 +02:00 committed by Oliver Smith
parent df58d35e27
commit 5f485b8ad3
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
3 changed files with 33 additions and 19 deletions

View File

@ -212,14 +212,17 @@ def generate_deviceinfo(args, pkgname, name, manufacturer, year, arch,
def generate_apkbuild(args, pkgname, name, arch, flash_method):
# Dependencies
depends = "postmarketos-base linux-" + "-".join(pkgname.split("-")[1:])
depends = ["postmarketos-base",
"linux-" + "-".join(pkgname.split("-")[1:])]
if flash_method in ["fastboot", "heimdall-bootimg"]:
depends += " mkbootimg"
depends.append("mkbootimg")
if flash_method == "0xffff":
depends += " uboot-tools"
depends += " mesa-dri-gallium"
depends.append("uboot-tools")
depends.append("mesa-dri-gallium")
# Whole APKBUILD
depends.sort()
depends = ("\n" + " " * 12).join(depends)
content = f"""\
# Reference: <https://postmarketos.org/devicepkg>
pkgname={pkgname}
@ -230,7 +233,9 @@ def generate_apkbuild(args, pkgname, name, arch, flash_method):
license="MIT"
arch="{arch}"
options="!check !archcheck"
depends="{depends}"
depends="
{depends}
"
makedepends="devicepkg-dev"
source="deviceinfo"

View File

@ -10,7 +10,8 @@ def generate_apkbuild(args, pkgname, deviceinfo, patches):
device = "-".join(pkgname.split("-")[1:])
carch = pmb.parse.arch.alpine_to_kernel(deviceinfo["arch"])
makedepends = "bash bc bison devicepkg-dev flex openssl-dev perl"
makedepends = ["bash", "bc", "bison", "devicepkg-dev", "flex", "openssl-dev",
"perl"]
build = """
unset LDFLAGS
@ -27,19 +28,19 @@ def generate_apkbuild(args, pkgname, deviceinfo, patches):
soc_vendor = pmb.helpers.cli.ask(args, "SoC vendor", vendors,
vendors[-1], complete=vendors)
if soc_vendor == "spreadtrum":
makedepends += " dtbtool-sprd"
makedepends.append("dtbtool-sprd")
build += """
dtbTool-sprd -p scripts/dtc/ \\
-o "$_outdir/arch/$_carch/boot"/dt.img \\
"$_outdir/arch/$_carch/boot/dts/\""""
elif soc_vendor == "exynos":
codename = "-".join(pkgname.split("-")[2:])
makedepends += " dtbtool-exynos"
makedepends.append("dtbtool-exynos")
build += f"""
dtbTool-exynos -o "$_outdir/arch/$_carch/boot"/dt.img \\
$(find "$_outdir/arch/$_carch/boot/dts/" -name *{codename}*.dtb)"""
else:
makedepends += " dtbtool"
makedepends.append("dtbtool")
build += """
dtbTool -p scripts/dtc/ -o "$_outdir/arch/$_carch/boot"/dt.img \\
"$_outdir/arch/$_carch/boot/\""""
@ -47,6 +48,8 @@ def generate_apkbuild(args, pkgname, deviceinfo, patches):
install -Dm644 "$_outdir/arch/$_carch/boot"/dt.img \\
"$pkgdir"/boot/dt.img"""
makedepends.sort()
makedepends = ("\n" + " " * 12).join(makedepends)
patches = ("\n" + " " * 12).join(patches)
content = f"""\
# Reference: <https://postmarketos.org/vendorkernel>
@ -62,7 +65,9 @@ def generate_apkbuild(args, pkgname, deviceinfo, patches):
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="{makedepends}"
makedepends="
{makedepends}
"
# Source
_repository="(CHANGEME!)"

View File

@ -125,9 +125,9 @@ def test_aportgen_device_wizard(args, monkeypatch):
deviceinfo, apkbuild, apkbuild_linux = generate(args, monkeypatch, answers)
assert apkbuild["pkgname"] == "device-testsuite-testdevice"
assert apkbuild["pkgdesc"] == "Testsuite Testdevice"
assert apkbuild["depends"] == ["postmarketos-base",
"linux-testsuite-testdevice",
"mesa-dri-gallium"]
assert apkbuild["depends"] == ["linux-testsuite-testdevice",
"mesa-dri-gallium",
"postmarketos-base"]
assert apkbuild_linux["pkgname"] == "linux-testsuite-testdevice"
assert apkbuild_linux["pkgdesc"] == "Testsuite Testdevice kernel fork"
@ -162,16 +162,20 @@ def test_aportgen_device_wizard(args, monkeypatch):
answers["Flash method"] = "fastboot"
answers["Path"] = ""
deviceinfo, apkbuild, apkbuild_linux = generate(args, monkeypatch, answers)
assert apkbuild["depends"] == ["postmarketos-base",
"linux-testsuite-testdevice", "mkbootimg",
"mesa-dri-gallium"]
assert apkbuild["depends"] == ["linux-testsuite-testdevice",
"mesa-dri-gallium",
"mkbootimg",
"postmarketos-base"]
assert deviceinfo["flash_method"] == answers["Flash method"]
assert deviceinfo["generate_bootimg"] == "true"
# 0xffff (legacy uboot initfs)
answers["Flash method"] = "0xffff"
deviceinfo, apkbuild, apkbuild_linux = generate(args, monkeypatch, answers)
assert apkbuild["depends"] == ["postmarketos-base",
"linux-testsuite-testdevice", "uboot-tools",
"mesa-dri-gallium"]
assert apkbuild["depends"] == ["linux-testsuite-testdevice",
"mesa-dri-gallium",
"postmarketos-base",
"uboot-tools"]
assert deviceinfo["generate_legacy_uboot_initfs"] == "true"