From 27093dc578ebd6aaf920154470131ff6fd6669fe Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Tue, 19 Feb 2013 16:56:41 +0000 Subject: [PATCH] [matter] add build-only parameter support, wrapping --buildpkgonly + --buildpkg --- matter/matter/binpms/base.py | 11 ++---- matter/matter/builder.py | 36 ++++++++++++++----- matter/matter/spec.py | 7 ++++ matter/matter_examples/entropy.particle | 8 ++++- matter/matter_examples/fail.particle | 8 ++++- matter/matter_examples/misc.particle | 8 ++++- matter/matter_examples/zlib.injected.particle | 8 ++++- 7 files changed, 64 insertions(+), 22 deletions(-) diff --git a/matter/matter/binpms/base.py b/matter/matter/binpms/base.py index 8d73f2e0f..794d04ef1 100644 --- a/matter/matter/binpms/base.py +++ b/matter/matter/binpms/base.py @@ -205,14 +205,6 @@ class BaseBinaryPMS(object): "preserved libraries are found on " "the system, aborting.") - def _is_build_only(self, spec): - """ - Return whether packages have been only built and not installed - into the system. - """ - _action, opts, _files = self._parse_opts(spec["build-args"]) - return opts["--buildpkgonly"] - def _commit_build_only(self, spec, packages): """ Commit packages that have been built with -B. @@ -283,7 +275,8 @@ class BaseBinaryPMS(object): Commit packages to the BinaryPMS repository specified in the Spec object. """ - if self._is_build_only(spec): + build_only = spec["build-only"] == "yes" + if build_only: return self._commit_build_only(spec, packages) return self._commit(spec, packages) diff --git a/matter/matter/builder.py b/matter/matter/builder.py index 1a3335c1a..9d27a3151 100644 --- a/matter/matter/builder.py +++ b/matter/matter/builder.py @@ -526,6 +526,29 @@ class PackageBuilder(object): settings["ACCEPT_KEYWORDS"] = keywords settings.lock() + @classmethod + def _setup_build_args(cls, spec): + """ + Filter out invalid or unwanted Portage build arguments, + like --ask and --buildpkgonly and add other ones. + """ + unwanted_args = ["--ask", "-a", "--buildpkgonly", "-B"] + + for builtin_arg in PackageBuilder.PORTAGE_BUILTIN_ARGS: + yield builtin_arg + + for build_arg in spec["build-args"]: + if build_arg not in unwanted_args: + yield build_arg + else: + print_warning("cannot use emerge %s argument, you idiot", + build_arg) + + build_only = spec["build-only"] == "yes" + if build_only: + yield "--buildpkg" + yield "--buildpkgonly" + def _run_builder(self, dirs_cleanup_queue): """ This method is called by _run and executes the whole package build @@ -622,17 +645,13 @@ class PackageBuilder(object): # non interactive properties, this is not really required # accept-properties just sets os.environ... - build_args = [] - build_args += PackageBuilder.PORTAGE_BUILTIN_ARGS - build_args += self._params["build-args"] + build_args = list(self._setup_build_args(self._params)) build_args += ["=" + best_v for _x, best_v in packages] + myaction, myopts, myfiles = parse_opts(build_args) adjust_configs(myopts, emerge_trees) apply_priorities(settings) - if "--ask" in myopts: - print_warning("cannot use --ask emerge argument, you idiot") - del myopts["--ask"] spinner = stdout_spinner() if "--quiet" in myopts: spinner.update = spinner.update_basic @@ -760,9 +779,8 @@ class PackageBuilder(object): emerge_settings, emerge_trees, mtimedb = emerge_config if "yes" == emerge_settings.get("AUTOCLEAN"): print_info("executing post-build operations, please wait...") - builtin_args = PackageBuilder.PORTAGE_BUILTIN_ARGS - _action, opts, _files = parse_opts( - builtin_args + spec["build-args"]) + build_args = list(cls._setup_build_args(spec)) + _action, opts, _files = parse_opts(build_args) unmerge(emerge_trees[emerge_settings["ROOT"]]["root_config"], opts, "clean", [], mtimedb["ldpath"], autoclean=1) diff --git a/matter/matter/spec.py b/matter/matter/spec.py index 11b82b2e6..1d2fb3c9b 100644 --- a/matter/matter/spec.py +++ b/matter/matter/spec.py @@ -137,6 +137,13 @@ class MatterSpec(GenericSpecFunctions): "desc": "Portage build arguments (default is --verbose\n " "--nospinner)", }, + "build-only": { + "cb": self.valid_yes_no, + "ve": self.ve_string_stripper, + "default": "no", + "desc": "Only build the packages without merging them\n " + "into the system.", + }, "dependencies": { "cb": self.valid_yes_no, "ve": self.ve_string_stripper, diff --git a/matter/matter_examples/entropy.particle b/matter/matter_examples/entropy.particle index 0c5032a39..c32de3214 100644 --- a/matter/matter_examples/entropy.particle +++ b/matter/matter_examples/entropy.particle @@ -30,8 +30,14 @@ repository: community0 stable: inherit # Provide custom build arguments to Portage. +# --ask and --buildpkgonly are not allowed and automatically filtered. # Default is: --verbose --nospinner -build-args: --verbose --nospinner +# build-args: --verbose --nospinner + +# Only build the packages without merging them into the system. +# Valid values are either "yes" or "no" +# Default is: no +# build-only: no # Allow Source Package Manager (Portage) repository change? # Valid values are either "yes" or "no" diff --git a/matter/matter_examples/fail.particle b/matter/matter_examples/fail.particle index 28f7fd461..edb10f320 100644 --- a/matter/matter_examples/fail.particle +++ b/matter/matter_examples/fail.particle @@ -18,8 +18,14 @@ stable: inherit repository: community0 # Provide custom build arguments to Portage. +# --ask and --buildpkgonly are not allowed and automatically filtered. # Default is: --verbose --nospinner -build-args: --verbose --nospinner +# build-args: --verbose --nospinner + +# Only build the packages without merging them into the system. +# Valid values are either "yes" or "no" +# Default is: no +# build-only: no # Allow Source Package Manager (Portage) repository change? # Valid values are either "yes" or "no" diff --git a/matter/matter_examples/misc.particle b/matter/matter_examples/misc.particle index a855e960f..a781cf0b2 100644 --- a/matter/matter_examples/misc.particle +++ b/matter/matter_examples/misc.particle @@ -18,8 +18,14 @@ stable: inherit repository: community0 # Provide custom build arguments to Portage. +# --ask and --buildpkgonly are not allowed and automatically filtered. # Default is: --verbose --nospinner -build-args: --verbose --nospinner +# build-args: --verbose --nospinner + +# Only build the packages without merging them into the system. +# Valid values are either "yes" or "no" +# Default is: no +# build-only: no # Allow Source Package Manager (Portage) repository change? # Valid values are either "yes" or "no" diff --git a/matter/matter_examples/zlib.injected.particle b/matter/matter_examples/zlib.injected.particle index 7bd630c8f..52de0c7f5 100644 --- a/matter/matter_examples/zlib.injected.particle +++ b/matter/matter_examples/zlib.injected.particle @@ -18,8 +18,14 @@ stable: inherit repository: community0 # Provide custom build arguments to Portage. +# --ask and --buildpkgonly are not allowed and automatically filtered. # Default is: --verbose --nospinner -build-args: --verbose --nospinner --buildpkgonly --buildpkg +# build-args: --verbose --nospinner + +# Only build the packages without merging them into the system. +# Valid values are either "yes" or "no" +# Default is: no +build-only: yes # Allow Source Package Manager (Portage) repository change? # Valid values are either "yes" or "no"