]> git.ipfire.org Git - pakfire.git/commitdiff
builder: Enable logging when doing a build for the server and upload the file afterwards.
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 25 Apr 2011 17:14:47 +0000 (19:14 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 25 Apr 2011 17:14:47 +0000 (19:14 +0200)
pakfire/server/base.py
pakfire/server/slave.py

index 9490dce18c5e8442c61026d1b007466f049f2aa8..626c1bb26433b7cdf4860b7fa0c6502e915a84cd 100644 (file)
@@ -83,8 +83,10 @@ class MasterSlave(object):
 
                return self.conn.package_add_file(pkg_id, file_id, info)
 
-       def upload_log_file(self):
-               pass # XXX TO BE DONE
+       def upload_log_file(self, build_id, logfile):
+               file_id = self._chunked_upload(logfile)
+
+               return self.conn.build_add_log(build_id, file_id)
 
        def package_add(self, source, pkg):
                logging.info("Adding package: %s" % pkg.friendly_name)
index 8fde679e09a0fdc3a22132b9af0e0f0ddaa82513..e26e5da3a71799fa76b7ce612f85745f41eb44a5 100644 (file)
@@ -82,6 +82,7 @@ class Slave(MasterSlave):
                        self.update_build_status(build_id, "finished")
 
        def build_binary_job(self, build_id, build):
+               arch     = build["arch"]
                filename = build["name"]
                download = build["download"]
                hash1    = build["hash1"]
@@ -89,6 +90,7 @@ class Slave(MasterSlave):
                # Create a temporary file and a directory for the resulting files.
                tmpdir = tempfile.mkdtemp()
                tmpfile = os.path.join(tmpdir, filename)
+               logfile = os.path.join(tmpdir, "build.log")
 
                # Get a package grabber and add mirror download capabilities to it.
                grabber = pakfire.downloader.PackageDownloader()
@@ -108,14 +110,14 @@ class Slave(MasterSlave):
 
                        # Run the build.
                        pakfire.api.build(tmpfile, build_id=build_id,
-                               resultdirs=[tmpdir,])
+                               resultdirs=[tmpdir,], logfile=logfile)
 
                        self.update_build_status(build_id, "uploading")
 
                        for dir, subdirs, files in os.walk(tmpdir):
                                for file in files:
                                        file = os.path.join(dir, file)
-                                       if file == tmpfile:
+                                       if file in (logfile, tmpfile,):
                                                continue
 
                                        pkg = pakfire.packages.open(self.pakfire, None, file)
@@ -127,6 +129,10 @@ class Slave(MasterSlave):
                        self.update_build_status(build_id, "dependency_error", message)
 
                finally:
+                       # Upload the logfile in any case and if it exists.
+                       if os.path.exists(logfile):
+                               self.upload_log_file(build_id, logfile)
+
                        # Cleanup the files we created.
                        pakfire.util.rm(tmpdir)