# 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"
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)
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
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,
# 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.
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):
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)
import logging
log = logging.getLogger("pakfire")
-import pakfire.api
import pakfire.base
import pakfire.config
import pakfire.downloader