enforce E501 partially in pmb/aportgen (MR 2058)

This commit is contained in:
Caio Fontes 2021-05-19 16:08:17 -03:00 committed by Oliver Smith
parent cfa5bc2cf7
commit fb98ad5329
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
5 changed files with 26 additions and 19 deletions

View File

@ -37,14 +37,16 @@ def properties(pkgname):
def generate(args, pkgname):
if args.fork_alpine:
prefix, folder, options = (pkgname, "temp", {"confirm_overwrite": True})
prefix, folder, options = (pkgname, "temp",
{"confirm_overwrite": True})
else:
prefix, folder, options = properties(pkgname)
path_target = args.aports + "/" + folder + "/" + pkgname
# Confirm overwrite
if options["confirm_overwrite"] and os.path.exists(path_target):
logging.warning("WARNING: Target folder already exists: " + path_target)
logging.warning("WARNING: Target folder already exists: "
f"{path_target}")
if not pmb.helpers.cli.confirm(args, "Continue and overwrite?"):
raise RuntimeError("Aborted.")
@ -52,8 +54,10 @@ def generate(args, pkgname):
pmb.helpers.run.user(args, ["rm", "-r", args.work + "/aportgen"])
if args.fork_alpine:
upstream = pmb.aportgen.core.get_upstream_aport(args, pkgname)
pmb.helpers.run.user(args, ["cp", "-r", upstream, args.work + "/aportgen"])
pmb.aportgen.core.rewrite(args, pkgname, replace_simple={"# Contributor:*": None, "# Maintainer:*": None})
pmb.helpers.run.user(args, ["cp", "-r", upstream,
f"{args.work}/aportgen"])
pmb.aportgen.core.rewrite(args, pkgname, replace_simple={
"# Contributor:*": None, "# Maintainer:*": None})
else:
# Run pmb.aportgen.PREFIX.generate()
getattr(pmb.aportgen, prefix.replace("-", "_")).generate(args, pkgname)

View File

@ -14,7 +14,7 @@ def generate(args, pkgname):
# Rewrite APKBUILD
fields = {
"pkgname": pkgname,
"pkgdesc": "Tools necessary to build programs for " + arch + " targets",
"pkgdesc": f"Tools necessary to build programs for {arch} targets",
"arch": args.arch_native,
"makedepends_build": "",
"makedepends_host": "",

View File

@ -54,19 +54,20 @@ def rewrite(args, pkgname, path_original="", fields={}, replace_pkgname=None,
lines (so they won't be bugged with issues regarding our generated aports),
and add reference to the original aport.
:param path_original: The original path of the automatically generated aport
:param path_original: The original path of the automatically generated
aport.
:param fields: key-value pairs of fields, that shall be changed in the
APKBUILD. For example: {"pkgdesc": "my new package", "subpkgs": ""}
:param replace_pkgname: When set, $pkgname gets replaced with that string in
every line.
:param replace_pkgname: When set, $pkgname gets replaced with that string
in every line.
:param replace_functions: Function names and new bodies, for example:
{"build": "return 0"}
The body can also be None (deletes the function)
:param replace_simple: Lines, that fnmatch the pattern, get
replaced/deleted. Example: {"*test*": "# test", "*mv test.bin*": None}
:param below_header: String, that gets directly placed below the header.
:param remove_indent: Number of spaces to remove from function body provided
to replace_functions.
:param remove_indent: Number of spaces to remove from function body
provided to replace_functions.
"""
# Header
@ -109,8 +110,8 @@ def rewrite(args, pkgname, path_original="", fields={}, replace_pkgname=None,
if line.startswith(func + "() {"):
skip_in_func = True
if body:
lines_new += format_function(func, body,
remove_indent=remove_indent)
lines_new += format_function(
func, body, remove_indent=remove_indent)
break
if skip_in_func:
continue

View File

@ -19,7 +19,7 @@ def generate(args, pkgname):
upstream = args.aports + "/main/gcc6"
based_on = "main/gcc6 (from postmarketOS)"
else:
raise ValueError("Invalid prefix '" + prefix + "', expected gcc, gcc4 or"
raise ValueError(f"Invalid prefix '{prefix}', expected gcc, gcc4 or"
" gcc6.")
pmb.helpers.run.user(args, ["cp", "-r", upstream, args.work + "/aportgen"])
@ -30,8 +30,10 @@ def generate(args, pkgname):
"pkgdesc": "Stage2 cross-compiler for " + arch,
"arch": args.arch_native,
"depends": "isl binutils-" + arch + " mpc1",
"makedepends_build": "gcc g++ paxmark bison flex texinfo gawk zip gmp-dev mpfr-dev mpc1-dev zlib-dev",
"makedepends_host": "linux-headers gmp-dev mpfr-dev mpc1-dev isl-dev zlib-dev musl-dev-" + arch + " binutils-" + arch,
"makedepends_build": "gcc g++ paxmark bison flex texinfo gawk zip"
" gmp-dev mpfr-dev mpc1-dev zlib-dev",
"makedepends_host": "linux-headers gmp-dev mpfr-dev mpc1-dev isl-dev"
f" zlib-dev musl-dev-{arch} binutils-{arch}",
"subpackages": "g++-" + arch + ":gpp" if prefix == "gcc" else "",
# gcc6: options is already there, so we need to replace it and not only

View File

@ -10,8 +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
@ -96,9 +96,9 @@ def generate_apkbuild(args, pkgname, deviceinfo, patches):
"""
# Write the file
with open(args.work + "/aportgen/APKBUILD", "w", encoding="utf-8") as handle:
with open(f"{args.work}/aportgen/APKBUILD", "w", encoding="utf-8") as hndl:
for line in content.rstrip().split("\n"):
handle.write(line[8:].replace(" " * 4, "\t") + "\n")
hndl.write(line[8:].replace(" " * 4, "\t") + "\n")
def generate(args, pkgname):