From 0d96815e44f87a79afeb052128213e58956f0dc6 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 27 Sep 2011 11:13:12 +0200 Subject: [PATCH] Rework BUILDROOT. The buildroot directory was accidentially removed when a build had an error. --- macros/constants.macro | 5 +---- macros/quality-agent.macro | 2 +- pakfire/base.py | 5 +++-- pakfire/builder.py | 18 +++++++----------- pakfire/packages/make.py | 5 ++++- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/macros/constants.macro b/macros/constants.macro index f7bcfd74e..27e086bae 100644 --- a/macros/constants.macro +++ b/macros/constants.macro @@ -1,9 +1,6 @@ -# XXX just for now -PARALLELISMFLAGS = -j2 - +BUILDROOT = %{DIR_TMP}/buildroot_%{name}-%{thisver} BASEDIR = /build -BUILDROOT = /buildroot DIR_APP = %{DIR_SRC}/%{thisapp} DIR_DL = %{BASEDIR}/files diff --git a/macros/quality-agent.macro b/macros/quality-agent.macro index b82cba96b..a2e6b2627 100644 --- a/macros/quality-agent.macro +++ b/macros/quality-agent.macro @@ -7,7 +7,7 @@ # Macro to define and start the quality agent. # Long term goal is to improve the commited code. -MACRO_QUALITY_AGENT = /usr/lib/pakfire/quality-agent +MACRO_QUALITY_AGENT = BUILDROOT=%{BUILDROOT} /usr/lib/pakfire/quality-agent # XXX to be moved to some place else #export QUALITY_AGENT_NO_DIRECTORY_CHECK diff --git a/pakfire/base.py b/pakfire/base.py index 3753477cb..b2c2fed39 100644 --- a/pakfire/base.py +++ b/pakfire/base.py @@ -452,8 +452,9 @@ class Pakfire(object): b.build() except Error: raise BuildError, _("Build command has failed.") - finally: - b.cleanup() + + # If the build was successful, cleanup all temporary files. + b.cleanup() @staticmethod def shell(pkg, **kwargs): diff --git a/pakfire/builder.py b/pakfire/builder.py index 3acfe64e1..0633cf8cb 100644 --- a/pakfire/builder.py +++ b/pakfire/builder.py @@ -132,8 +132,6 @@ class BuildEnviron(object): } #self.settings.update(settings) - self.buildroot = "/buildroot" - # Lock the buildroot self._lock = None self.lock() @@ -436,7 +434,7 @@ class BuildEnviron(object): logging.debug("Cleaning environemnt.") # Remove the build directory and buildroot. - dirs = ("build", self.buildroot, "result") + dirs = ("build", "result") for d in dirs: d = self.chrootPath(d) @@ -519,9 +517,6 @@ class BuildEnviron(object): "TERM" : os.environ.get("TERM", "dumb"), "PS1" : "\u:\w\$ ", - "BUILDROOT" : self.buildroot, - "PARALLELISMFLAGS" : "-j%s" % util.calc_parallelism(), - # Set the container that we can detect, if we are inside a # chroot. "container" : "pakfire-builder", @@ -644,14 +639,15 @@ class Builder(object): # Open package file. self.pkg = packages.Makefile(self.pakfire, self.filename) - #self.buildroot = "/tmp/pakfire_buildroot/%s" % util.random_string(20) - self.buildroot = "/buildroot" - self._environ = { - "BUILDROOT" : self.buildroot, - "LANG" : "C", + "LANG" : "C", + "PARALLELISMFLAGS" : "-j%s" % util.calc_parallelism(), } + @property + def buildroot(self): + return self.pkg.buildroot + @property def distro(self): return self.pakfire.distro diff --git a/pakfire/packages/make.py b/pakfire/packages/make.py index 66cc0bf02..e422b2168 100644 --- a/pakfire/packages/make.py +++ b/pakfire/packages/make.py @@ -80,7 +80,6 @@ class MakefileBase(Package): self.filename = os.path.abspath(filename) # Open and parse the makefile. - # XXX pass environment to lexer self.lexer = lexer.RootLexer.open(self.filename, environ=self.pakfire.environ) @@ -171,6 +170,10 @@ class MakefileBase(Package): def vendor(self): return self.lexer.get_var("DISTRO_VENDOR") + @property + def buildroot(self): + return self.lexer.get_var("BUILDROOT") + @property def build_host(self): return socket.gethostname() -- 2.39.5