From fbf0dcb259e865e7ef1b742d546186a0232a9c0f Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Tue, 15 Apr 2014 13:06:55 +0200 Subject: [PATCH] pbuilder-dist: Store build logs in __.build instead of last_operation.log This avoids overwriting build logs. --- debian/changelog | 2 ++ pbuilder-dist | 26 ++++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 5100de9..4dc1eb5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,8 @@ ubuntu-dev-tools (0.153) UNRELEASED; urgency=medium [ Benjamin Drung ] * pbuilder-dist: - Set different aptcache directories for Debian and Ubuntu. + - Store build logs in __.build instead of + last_operation.log (to avoid overwriting build logs). -- Stefano Rivera Tue, 25 Feb 2014 22:45:05 +0200 diff --git a/pbuilder-dist b/pbuilder-dist index b4c861f..f64b312 100755 --- a/pbuilder-dist +++ b/pbuilder-dist @@ -32,9 +32,11 @@ import os import sys +import debian.deb822 from distro_info import DebianDistroInfo, UbuntuDistroInfo, DistroDataOutdated import ubuntutools.misc +import ubuntutools.version from ubuntutools.config import UDTConfig from ubuntutools.logger import Logger from ubuntutools.question import YesNoQuestion @@ -196,15 +198,25 @@ class PbuilderDist(object): prefix = os.path.join(self.base, self.chroot_string) if '--buildresult' not in remaining_arguments: - result = '%s_result/' % prefix + result = os.path.normpath('%s_result/' % prefix) else: location_of_arg = remaining_arguments.index('--buildresult') - result = remaining_arguments[location_of_arg+1] + result = os.path.normpath(remaining_arguments[location_of_arg+1]) remaining_arguments.pop(location_of_arg+1) remaining_arguments.pop(location_of_arg) if not self.logfile and self.operation != 'login': - self.logfile = os.path.normpath('%s/last_operation.log' % result) + if self.operation == 'build': + dsc_files = [a for a in remaining_arguments + if a.strip().endswith('.dsc')] + assert len(dsc_files) == 1 + dsc = debian.deb822.Dsc(open(dsc_files[0])) + version = ubuntutools.version.Version(dsc['Version']) + name = (dsc['Source'] + '_' + version.strip_epoch() + '_' + + self.build_architecture + '.build') + self.logfile = os.path.join(result, name) + else: + self.logfile = os.path.join(result, 'last_operation.log') if not os.path.isdir(result): try: @@ -471,9 +483,11 @@ def main(): # Parse the operation args = app.set_operation(args.pop(0)) + args - if app.operation == 'build' and '.dsc' not in ' '.join(args): - Logger.error('You have to specify a .dsc file if you want to build.') - sys.exit(1) + if app.operation == 'build': + if len([a for a in args if a.strip().endswith('.dsc')]) != 1: + msg = 'You have to specify one .dsc file if you want to build.' + Logger.error(msg) + sys.exit(1) # Execute the pbuilder command if not '--debug-echo' in args: