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

View File

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

View File

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