Skip to content

Fix apkbuild parsing

Oliver Smith requested to merge fix-apkbuild-parsing into master

Two patches fixing build.postmarketos.org#61 (closed).

This is blocking build.postmarketos.org development, so I'm merging this right after CI passes.

pmb/parse/_apkbuild: fix parsing commented lines

Properly ignore comments at the end of lines, instead of assuming that
all lines below belong to the attribute:
	subpackages="$pkgname-dev" # $pkgname-lang

Fixes build.postmarketos.org#61, where pmbootstrap would assume that a
random package provides "make", just because the word "make" is written
somewhere below subpackages=" in the APKBUILD and it is parsed
incorrectly.

While at it, also support the ' character for quotations and detect if
a quotation for a value was started, but there is no end quotation sign
in the rest of the file.

I've added tests, and manually checked that this did not introduce any
parsing bugs for all the APKBUILDs in pmaports.git, by running
'pmbootstrap apkbuild_parse' with the old and new code, and diffing the
result.
replace_aports_packages_with_path: better error

Because of an APKINDEX subpkg parsing bug, pmbootstrap currently assumes
that "ktp-common-internals" provides "make". It fails with a cryptic
error when trying to build a package without an existing postmarketOS
binary packages mirror (like done in the build.postmarketos.org
testsuite):

  File "/home/user/code/pmbootstrap/pmb/chroot/apk.py", line 174, in replace_aports_packages_with_path
    package + "-" + data_repo["version"] + ".apk")
TypeError: 'NoneType' object is not subscriptable

Replace this error with a more meaningful message, that points to the
issue analyzing this bug.

Related: build.postmarketos.org#61

Merge request reports