From 2df16c5999c93037e93d9f77cf90f8a45baeee64 Mon Sep 17 00:00:00 2001 From: Nick Reitemeyer Date: Wed, 27 Mar 2019 22:31:49 +0100 Subject: [PATCH] Make strict mode available to packages (!1771) Packages can add pmb:strict to their options to enable the --strict mode. This can be used if packages need to get build in a clean chroot or their make dependencies need to get removed. --- pmb/build/_package.py | 9 ++++++--- test/test_build_package.py | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pmb/build/_package.py b/pmb/build/_package.py index da0e4ed0..192b3814 100644 --- a/pmb/build/_package.py +++ b/pmb/build/_package.py @@ -218,7 +218,7 @@ def init_buildenv(args, apkbuild, arch, strict=False, force=False, cross=None, pmb.build.init(args, suffix) pmb.build.other.configure_abuild(args, suffix) pmb.build.other.configure_ccache(args, suffix) - if not strict and len(depends): + if not strict and "pmb:strict" not in apkbuild["options"] and len(depends): pmb.chroot.apk.install(args, depends, suffix) if src: pmb.chroot.apk.install(args, ["rsync"], suffix) @@ -405,7 +405,10 @@ def run_abuild(args, apkbuild, arch, strict=False, force=False, cross=None, # Build the abuild command cmd = ["abuild", "-D", "postmarketOS"] - if strict: + if strict or "pmb:strict" in apkbuild["options"]: + if not strict: + logging.debug(apkbuild["pkgname"] + ": 'pmb:strict' found in" + " options, building in strict mode") cmd += ["-r"] # install depends with abuild else: cmd += ["-d"] # do not install depends with abuild @@ -435,7 +438,7 @@ def finish(args, apkbuild, arch, output, strict=False, suffix="native"): arch + "/APKINDEX.tar.gz") # Uninstall build dependencies (strict mode) - if strict: + if strict or "pmb:strict" in apkbuild["options"]: logging.info("(" + suffix + ") uninstall build dependencies") pmb.chroot.user(args, ["abuild", "undeps"], suffix, "/home/pmos/build", env={"SUDO_APK": "abuild-apk --no-progress"}) diff --git a/test/test_build_package.py b/test/test_build_package.py index f0549013..dd69f09e 100644 --- a/test/test_build_package.py +++ b/test/test_build_package.py @@ -226,7 +226,7 @@ def test_init_buildenv(args, monkeypatch): # Shortcut and fake apkbuild func = pmb.build._package.init_buildenv - apkbuild = {"pkgname": "test", "depends": ["a"], "makedepends": ["b"]} + apkbuild = {"pkgname": "test", "depends": ["a"], "makedepends": ["b"], "options": []} # Build is necessary (various code paths) assert func(args, apkbuild, "armhf", strict=True) is True @@ -297,7 +297,7 @@ def test_finish(args, monkeypatch): # Shortcut and fake apkbuild func = pmb.build._package.finish - apkbuild = {} + apkbuild = {"options": []} # Non-existing output path with pytest.raises(RuntimeError) as e: