build: ignore invalid checksums unless --strict (MR 2252)

We can fairly easily patch abuild by appending anything we want to the
APKBUILD file after copying it to the chroot.

Leverage this to override the verify() function so that it doesn't die
when checksums don't match.

Instead let's build the package anyway, but set a flag and print a
warning with instructions on how to generate the checksums.

We should continue to require APKBUILDs in pmaports to have valid
checksums.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-06-14 05:13:24 +02:00 committed by Oliver Smith
parent d75f1cf525
commit 7d85bb31d5
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
4 changed files with 39 additions and 3 deletions

View file

@ -21,7 +21,7 @@ from pmb.core import Chroot
from pmb.core.context import get_context
def copy_to_buildpath(package, chroot: Chroot=Chroot.native()):
def copy_to_buildpath(package, chroot: Chroot=Chroot.native(), no_override: bool=False):
# Sanity check
aport = pmb.helpers.pmaports.find(package)
if not os.path.exists(aport / "APKBUILD"):
@ -44,9 +44,24 @@ def copy_to_buildpath(package, chroot: Chroot=Chroot.native()):
continue
pmb.helpers.run.root(["cp", "-rL", aport / file, build / file])
if not no_override:
abuild_overrides(build / "APKBUILD")
pmb.chroot.root(["chown", "-R", "pmos:pmos",
"/home/pmos/build"], chroot)
def abuild_overrides(apkbuild: Path):
"""Override some abuild functions by patching the APKBUILD file."""
if apkbuild.is_relative_to(get_context().config.work / "cache_git"):
raise ValueError(f"Refusing to patch file in pmaports repo: {apkbuild}")
# Patch the APKBUILD file
override_path = pmb.config.pmb_src / "pmb/data/abuild_overrides.sh"
pmb.helpers.run.root(["sh", "-c", f"cat {override_path} >> {apkbuild}"])
class BuildStatus(enum.StrEnum):
# The binary package is outdated
OUTDATED = "outdated"