# HG changeset patch # User Andre Heinecke # Date 1283270206 0 # Node ID 058856954e2d16a36422edf44f5126e0dca5ef6d # Parent 454967511f5ca96aa96798f7f984269b79b506aa Make the compress_all_logs call builder independent and also compress if an error occurs before the builders are executed. diff -r 454967511f5c -r 058856954e2d treepkg/builder.py --- 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: diff -r 454967511f5c -r 058856954e2d treepkg/packager.py --- 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() diff -r 454967511f5c -r 058856954e2d treepkg/sbuilder.py --- 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() diff -r 454967511f5c -r 058856954e2d treepkg/util.py --- 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))