From 3f2a0649930609e1147cdfcec1e9155bfec3b287 Mon Sep 17 00:00:00 2001 From: Daniele Debernardi Date: Fri, 3 Jan 2020 19:11:06 +0100 Subject: [PATCH] pmb.aportgen: add Contributor/Maintainer to APKBUILD templates (!1852) --- pmb/aportgen/device.py | 2 ++ pmb/aportgen/linux.py | 2 ++ test/test_aportgen_device_wizard.py | 24 ++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pmb/aportgen/device.py b/pmb/aportgen/device.py index 268c7976..30afb9fd 100644 --- a/pmb/aportgen/device.py +++ b/pmb/aportgen/device.py @@ -206,6 +206,8 @@ def generate_apkbuild(args, pkgname, name, arch, flash_method): # Whole APKBUILD content = """\ + # Contributor: Firstname Lastname (CHANGEME!) + # Maintainer: Firstname Lastname (CHANGEME!) # Reference: pkgname=\"""" + pkgname + """\" pkgdesc=\"""" + name + """\" diff --git a/pmb/aportgen/linux.py b/pmb/aportgen/linux.py index 6c2100cf..9e0ea3f5 100644 --- a/pmb/aportgen/linux.py +++ b/pmb/aportgen/linux.py @@ -65,6 +65,8 @@ def generate_apkbuild(args, pkgname, deviceinfo, patches): "$pkgdir/boot/dt.img\"""" content = """\ + # Contributor: Firstname Lastname (CHANGEME!) + # Maintainer: Firstname Lastname (CHANGEME!) # Reference: # Kernel config based on: arch/""" + carch + """/configs/(CHANGEME!) diff --git a/test/test_aportgen_device_wizard.py b/test/test_aportgen_device_wizard.py index a91b9580..8e19f8bf 100644 --- a/test/test_aportgen_device_wizard.py +++ b/test/test_aportgen_device_wizard.py @@ -82,12 +82,17 @@ def generate(args, monkeypatch, answers): pmb.aportgen.generate(args, "linux-testsuite-testdevice") monkeypatch.undo() - # Parse the deviceinfo and apkbuilds - args.cache["apkbuild"] = {} apkbuild_path = (args.aports + "/device/device-testsuite-testdevice/" "APKBUILD") apkbuild_path_linux = (args.aports + "/device/" "linux-testsuite-testdevice/APKBUILD") + + # The build fails if the email is not a valid email, so remove them just for tests + remove_contributor_maintainer_lines(args, apkbuild_path) + remove_contributor_maintainer_lines(args, apkbuild_path_linux) + + # Parse the deviceinfo and apkbuilds + args.cache["apkbuild"] = {} apkbuild = pmb.parse.apkbuild(args, apkbuild_path) apkbuild_linux = pmb.parse.apkbuild(args, apkbuild_path_linux, check_pkgver=False) @@ -95,6 +100,21 @@ def generate(args, monkeypatch, answers): return (deviceinfo, apkbuild, apkbuild_linux) +def remove_contributor_maintainer_lines(args, path): + with open(path, "r+", encoding="utf-8") as handle: + lines_new = [] + for line in handle.readlines(): + # Skip maintainer/contributor + if line.startswith("# Maintainer") or line.startswith( + "# Contributor"): + continue + lines_new.append(line) + # Write back + handle.seek(0) + handle.write("".join(lines_new)) + handle.truncate() + + def test_aportgen_device_wizard(args, monkeypatch): """ Generate a device-testsuite-testdevice and linux-testsuite-testdevice