From: Michael Tremer Date: Sat, 27 Oct 2012 20:05:56 +0000 (+0200) Subject: Fix inner builder. X-Git-Tag: 0.9.24~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=013eb9f264ff4b38ea31f76ae4b6ba8a03e5d955;p=pakfire.git Fix inner builder. --- diff --git a/python/pakfire/base.py b/python/pakfire/base.py index 52223d17d..628a79625 100644 --- a/python/pakfire/base.py +++ b/python/pakfire/base.py @@ -589,6 +589,20 @@ class Pakfire(object): # Process the transaction. t.run() + def build(self, makefile, resultdir, stages=None, **kwargs): + b = builder.Builder(self, makefile, resultdir, **kwargs) + + try: + b.build(stages=stages) + + except Error: + raise BuildError, _("Build command has failed.") + + else: + # If the build was successful, cleanup all temporary files. + b.cleanup() + + class PakfireBuilder(Pakfire): mode = "builder" @@ -673,22 +687,6 @@ class PakfireBuilder(Pakfire): finally: b.stop() - def _build(self, pkg, resultdir, nodeps=False, prepare=False, **kwargs): - b = builder.Builder(self, pkg, resultdir, **kwargs) - - stages = None - if prepare: - stages = ("prepare",) - - try: - b.build(stages=stages) - - except Error: - raise BuildError, _("Build command has failed.") - - # If the build was successful, cleanup all temporary files. - b.cleanup() - def shell(self, pkg, **kwargs): b = builder.BuildEnviron(self, pkg, **kwargs) diff --git a/python/pakfire/builder.py b/python/pakfire/builder.py index d655fec0b..4d49b94aa 100644 --- a/python/pakfire/builder.py +++ b/python/pakfire/builder.py @@ -79,6 +79,18 @@ class BuildEnviron(object): if not system.host_supports_arch(self.arch): raise BuildError, _("Cannot build for %s on this host.") % self.arch + # Save the build id and generate one if no build id was provided. + if not build_id: + build_id = "%s" % uuid.uuid4() + + self.build_id = build_id + + # Setup the logging. + self.init_logging(logfile) + + # Initialize a cgroup (if supported). + self.init_cgroup() + # This build is a release build? self.release_build = release_build @@ -98,18 +110,6 @@ class BuildEnviron(object): for line in BUILD_LOG_HEADER.splitlines(): self.log.info(line % logdata) - # Save the build id and generate one if no build id was provided. - if not build_id: - build_id = "%s" % uuid.uuid4() - - self.build_id = build_id - - # Setup the logging. - self.init_logging(logfile) - - # Initialize a cgroup (if supported). - self.init_cgroup() - # XXX need to make this configureable self.settings = { "enable_loop_devices" : True, @@ -993,17 +993,17 @@ class Builder(object): # Build icecream toolchain if icecream is installed. self.create_icecream_toolchain() - if stages is None: - stages = ("prepare", "build", "test", "install") - stop_early = False - else: - stop_early = True + # Process stages in order. + for stage in ("prepare", "build", "test", "install"): + # Skip unwanted stages. + if stages and not stage in stages: + continue - for stage in stages: + # Run stage. self.build_stage(stage) - # Stop if only the prepare stage is wanted. - if stop_early: + # Stop if install stage has not been processed. + if stages and not "install" in stages: return # Run post-build stuff. diff --git a/python/pakfire/cli.py b/python/pakfire/cli.py index e974c0eb9..55e29a358 100644 --- a/python/pakfire/cli.py +++ b/python/pakfire/cli.py @@ -764,23 +764,21 @@ class CliBuilderIntern(Cli): else: raise FileNotFoundError, pkg - conf = config.ConfigBuilder() + # Create pakfire instance. + c = config.ConfigBuilder() + p = base.Pakfire(arch = self.args.arch, config = c) + # Disable all repositories. if self.args.nodeps: - disable_repos = ["*"] + p.repos.disable_repo("*") + + # Limit stages that are to be run. + if self.args.prepare: + stages = ["prepare"] else: - disable_repos = None - - kwargs = { - "arch" : self.args.arch, - "builder_mode" : self.args.mode, - "config" : conf, - "disable_repos" : disable_repos, - "prepare" : self.args.prepare, - "resultdir" : self.args.resultdir, - } + stages = None - self.pakfire._build(pkg, **kwargs) + p.build(pkg, resultdir=self.args.resultdir, stages=stages) class CliClient(Cli): diff --git a/python/pakfire/repository/__init__.py b/python/pakfire/repository/__init__.py index 5d2f4c193..2d0730c67 100644 --- a/python/pakfire/repository/__init__.py +++ b/python/pakfire/repository/__init__.py @@ -173,16 +173,20 @@ class Repositories(object): return self.dummy def enable_repo(self, name): - try: - self.__repos[name].enabled = True - except KeyError: - pass + for repo in self: + if repo == self.local: + continue + + if repo.name == name or name == "*": + repo.enabled = True def disable_repo(self, name): - try: - self.__repos[name].enabled = False - except KeyError: - pass + for repo in self: + if repo == self.local: + continue + + if repo.name == name or name == "*": + repo.enabled = False def whatprovides(self, what): what = self.pakfire.pool.create_relation(what) diff --git a/python/pakfire/server.py b/python/pakfire/server.py index f427a9211..64e3dd519 100644 --- a/python/pakfire/server.py +++ b/python/pakfire/server.py @@ -31,7 +31,6 @@ import xmlrpclib import logging log = logging.getLogger("pakfire") -import pakfire.api import pakfire.base import pakfire.config import pakfire.downloader