]> git.ipfire.org Git - pakfire.git/commitdiff
Fix inner builder.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Oct 2012 20:05:56 +0000 (22:05 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Oct 2012 20:05:56 +0000 (22:05 +0200)
python/pakfire/base.py
python/pakfire/builder.py
python/pakfire/cli.py
python/pakfire/repository/__init__.py
python/pakfire/server.py

index 52223d17dab6030dcf0fde3aaa711712ef6ac481..628a7962573e11a2add1127d2215a3a5f3d5e9c1 100644 (file)
@@ -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)
 
index d655fec0b161f9efc923a90f1de6940cac82f7fe..4d49b94aa484d67af84cc0b529e3e90f352f178a 100644 (file)
@@ -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.
index e974c0eb9f5336c1bf431110e6265d0d973d8c95..55e29a35866829ee2ce481946fc71644a585ff05 100644 (file)
@@ -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):
index 5d2f4c193690af87493d9cc5c10bf839756f15a9..2d0730c67c001385256d3fd2035ee12884a3c393 100644 (file)
@@ -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)
index f427a9211098dbf4d748b4164b3ff0648cc139dd..64e3dd5198b4a9bf222b8e44ecb2dbdfde85cc2c 100644 (file)
@@ -31,7 +31,6 @@ import xmlrpclib
 import logging
 log = logging.getLogger("pakfire")
 
-import pakfire.api
 import pakfire.base
 import pakfire.config
 import pakfire.downloader