apkbuild parser: support depends="$depends ..." (!1795)
Properly handle the following two cases in APKBUILDs: * depends="$depends ..." * depends="${depends} ..." First I've attempted to refactor the parsing code to do this in a more generic way. But I've realized that it would make more sense to retire the python based APKBUILD parsing approach altogether and finally use a shell script parser. Let's discuss this in #1801.
This commit is contained in:
parent
75411694ff
commit
f5db1b4306
|
@ -170,6 +170,13 @@ def apkbuild(args, path, check_pkgver=True, check_pkgname=True):
|
||||||
i += 1
|
i += 1
|
||||||
line_value = lines[i][:-1]
|
line_value = lines[i][:-1]
|
||||||
|
|
||||||
|
# Support depends="$depends hello-world" (#1800)
|
||||||
|
if attribute == "depends" and ("${depends}" in value or
|
||||||
|
"$depends" in value):
|
||||||
|
previous = " ".join(ret["depends"]) if "depends" in ret else ""
|
||||||
|
value = value.replace("${depends}", previous)
|
||||||
|
value = value.replace("$depends", previous)
|
||||||
|
|
||||||
# Split up arrays, delete empty strings inside the list
|
# Split up arrays, delete empty strings inside the list
|
||||||
if options["array"]:
|
if options["array"]:
|
||||||
if value:
|
if value:
|
||||||
|
|
|
@ -72,3 +72,9 @@ def test_kernels(args):
|
||||||
ret = {"downstream": "Downstream description",
|
ret = {"downstream": "Downstream description",
|
||||||
"mainline": "Mainline description"}
|
"mainline": "Mainline description"}
|
||||||
assert func(args, device) == ret
|
assert func(args, device) == ret
|
||||||
|
|
||||||
|
|
||||||
|
def test_depends_in_depends(args):
|
||||||
|
path = pmb_src + "/test/testdata/apkbuild/APKBUILD.depends-in-depends"
|
||||||
|
apkbuild = pmb.parse.apkbuild(args, path, check_pkgname=False)
|
||||||
|
assert apkbuild["depends"] == ["first", "second", "third"]
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
pkgname="depends-in-depends"
|
||||||
|
pkgver="1.0.0"
|
||||||
|
pkgrel=0
|
||||||
|
arch="armhf"
|
||||||
|
depends="first"
|
||||||
|
depends="$depends second"
|
||||||
|
depends="${depends} third"
|
||||||
|
pkgdesc="depends-in-depends test"
|
Loading…
Reference in New Issue