changeset 462:058856954e2d

Make the compress_all_logs call builder independent and also compress if an error occurs before the builders are executed.
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 31 Aug 2010 15:56:46 +0000
parents 454967511f5c
children 52f841330c16
files treepkg/builder.py treepkg/packager.py treepkg/sbuilder.py treepkg/util.py
diffstat 4 files changed, 23 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/treepkg/builder.py	Mon Aug 30 13:32:31 2010 +0000
+++ b/treepkg/builder.py	Tue Aug 31 15:56:46 2010 +0000
@@ -206,20 +206,14 @@
             args.extend(["--bindmounts", mount])
         for pkg in extra_packages:
             args.extend(["--extrapackages", pkg])
-        try:
-            run.call(cmdexpand("@rootcmd /usr/sbin/pbuilder build"
-                               " --configfile $pbuilderrc @args"
-                               " --debbuildopts -b $dsc",
-                               rootcmd=self.root_cmd, pbuilderrc=self.pbuilderrc,
-                               dsc=dsc_file, args=args),
-                     suppress_output=True,
-                     extra_env=extra_env)
-        except:
-            util.compress_all_logs(logfile)
-            raise
+        run.call(cmdexpand("@rootcmd /usr/sbin/pbuilder build"
+                           " --configfile $pbuilderrc @args"
+                           " --debbuildopts -b $dsc",
+                           rootcmd=self.root_cmd, pbuilderrc=self.pbuilderrc,
+                           dsc=dsc_file, args=args),
+                 suppress_output=True,
+                 extra_env=extra_env)
 
-        util.compress_all_logs(logfile)
- 
         # remove the source package files put into the binary directory
         # by pbuilder
         if binary_dir is not None:
--- a/treepkg/packager.py	Mon Aug 30 13:32:31 2010 +0000
+++ b/treepkg/packager.py	Tue Aug 31 15:56:46 2010 +0000
@@ -372,18 +372,21 @@
 
     def package(self):
         try:
-            util.ensure_directory(self.work_dir)
-            self.status.start = datetime.datetime.utcnow()
-            src_packager = self.source_packager_cls(self)
-            src_packager.package()
+            try:
+                util.ensure_directory(self.work_dir)
+                self.status.start = datetime.datetime.utcnow()
+                src_packager = self.source_packager_cls(self)
+                src_packager.package()
 
-            dsc_file = self.find_dsc_file()
-            if dsc_file is None:
-                raise RuntimeError("Cannot find dsc File in %r" % self.src_dir)
+                dsc_file = self.find_dsc_file()
+                if dsc_file is None:
+                    raise RuntimeError("Cannot find dsc File in %r" % self.src_dir)
 
-            bin_packager = self.binary_packager_cls(self, dsc_file, self.build_log)
-            bin_packager.package()
-            self.status.stop = datetime.datetime.utcnow()
+                bin_packager = self.binary_packager_cls(self, dsc_file, self.build_log)
+                bin_packager.package()
+                self.status.stop = datetime.datetime.utcnow()
+            finally:
+                util.compress_all_logs(self.log_dir)
         except:
             self.status.error()
             self.status.stop = datetime.datetime.utcnow()
--- a/treepkg/sbuilder.py	Mon Aug 30 13:32:31 2010 +0000
+++ b/treepkg/sbuilder.py	Tue Aug 31 15:56:46 2010 +0000
@@ -139,8 +139,6 @@
                     if os.path.splitext(filename)[1] not in (".deb", ".changes"):
                         os.remove(os.path.join(binary_dir, filename))
         finally:
-            # compress logfiles
-            util.compress_all_logs(logfile)
             # remove all mounted directories
             self.umount_all()
 
--- a/treepkg/util.py	Mon Aug 30 13:32:31 2010 +0000
+++ b/treepkg/util.py	Tue Aug 31 15:56:46 2010 +0000
@@ -196,8 +196,9 @@
     files in same folder with the cmd command.
     """
     if reference_log and os.path.exists(reference_log):
-        log_dir = os.path.dirname(reference_log)
-        for log_file in [os.path.join(log_dir, f) 
+        log_dir = os.path.isdir(reference_log) and \
+            reference_log or os.path.dirname(reference_log)
+        for log_file in [os.path.join(log_dir, f)
                          for f in os.listdir(log_dir)]:
             if os.path.isfile(log_file):
                 run.call(cmdexpand(cmd, logfile=log_file))
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)