pmb.aportgen: add Contributor/Maintainer to APKBUILD templates (!1852)

This commit is contained in:
Daniele Debernardi 2020-01-03 19:11:06 +01:00
parent 948e3f931f
commit 3f2a064993
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
3 changed files with 26 additions and 2 deletions

View File

@ -206,6 +206,8 @@ def generate_apkbuild(args, pkgname, name, arch, flash_method):
# Whole APKBUILD
content = """\
# Contributor: Firstname Lastname <email> (CHANGEME!)
# Maintainer: Firstname Lastname <email> (CHANGEME!)
# Reference: <https://postmarketos.org/devicepkg>
pkgname=\"""" + pkgname + """\"
pkgdesc=\"""" + name + """\"

View File

@ -65,6 +65,8 @@ def generate_apkbuild(args, pkgname, deviceinfo, patches):
"$pkgdir/boot/dt.img\""""
content = """\
# Contributor: Firstname Lastname <email> (CHANGEME!)
# Maintainer: Firstname Lastname <email> (CHANGEME!)
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/""" + carch + """/configs/(CHANGEME!)

View File

@ -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