[matter] add build-only parameter support, wrapping --buildpkgonly + --buildpkg

This commit is contained in:
Fabio Erculiani
2013-02-19 16:56:41 +00:00
parent dc5bc3aa08
commit 27093dc578
7 changed files with 64 additions and 22 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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