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:
Oliver Smith 2019-06-26 20:24:24 +02:00
parent 75411694ff
commit f5db1b4306
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
3 changed files with 21 additions and 0 deletions

View File

@ -170,6 +170,13 @@ def apkbuild(args, path, check_pkgver=True, check_pkgname=True):
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
if options["array"]:
if value:

View File

@ -72,3 +72,9 @@ def test_kernels(args):
ret = {"downstream": "Downstream description",
"mainline": "Mainline description"}
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"]

View File

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