From 190908d291eec97f586c96e0f9cecd1118ae2610 Mon Sep 17 00:00:00 2001 From: Siegfried-Angel Gevatter Pujals Date: Fri, 2 Jan 2009 14:42:25 +0100 Subject: [PATCH 1/2] * pbuilder-dist.new: - Add compatibility for cowbuilder. Once pbuilder-dist.new replaces pbuilder-dist, we will also create a cowbuilder-dist symlink to it. --- debian/changelog | 7 +++- pbuilder-dist.new | 85 ++++++++++++++++++++++------------------------- 2 files changed, 45 insertions(+), 47 deletions(-) diff --git a/debian/changelog b/debian/changelog index 8959ba2..ba95d92 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,7 +11,12 @@ ubuntu-dev-tools (0.51) UNRELEASED; urgency=low - Implemented sleeps to --lp bug reporting in case of a slow Launchpad to stop mass bug filing (LP: #311289). - -- Jonathan Davies Tue, 30 Dec 2008 15:51:55 +0000 + [ Siegfried-Angel Gevatter Pujals ] + * pbuilder-dist.new: + - Add compatibility for cowbuilder. Once pbuilder-dist.new replaces + pbuilder-dist, we will also create a cowbuilder-dist symlink to it. + + -- Siegfried-Angel Gevatter Pujals Fri, 02 Jan 2009 14:40:51 +0100 ubuntu-dev-tools (0.50.1) jaunty; urgency=low diff --git a/pbuilder-dist.new b/pbuilder-dist.new index 95b2d2b..36c9d09 100755 --- a/pbuilder-dist.new +++ b/pbuilder-dist.new @@ -35,7 +35,7 @@ debian_distros = ['etch', 'lenny', 'sid', 'stable', 'testing', 'unstable', 'expe class pbuilder_dist: - def __init__(self): + def __init__(self, builder): # Base directory where pbuilder will put all the files it creates. self.base = None @@ -70,6 +70,9 @@ class pbuilder_dist: # Authentication method self.auth = 'sudo' + # Builder + self.builder = builder + ############################################################## if 'PBUILDFOLDER' in os.environ: @@ -110,25 +113,6 @@ class pbuilder_dist: return getattr(self, name) - def _calculate(self): - """ pbuilder_dist.calculate(distro) -> None - - Do all necessary variable changes (and therefore required checks) - before the string that will be executed is generated. At this - point it's expected that no more variables will be modified - outside this class. - - """ - - if not self.build_architecture: - self.chroot_string = self.target_distro - self.build_architecture = self.system_architecture - else: - self.chroot_string = '%(target_distro)s-%(build_architecture)s' % self - - if not self.logfile: - self.logfile = '%(base)s.%(chroot_string)s.log' % self - def set_target_distro(self, distro): """ pbuilder_dist.set_target_distro(distro) -> None @@ -162,8 +146,12 @@ class pbuilder_dist: arguments = ('create', 'update', 'build', 'clean', 'login', 'execute') if operation not in arguments: - if item_ends_with(arguments, '.dsc'): + if operation.endswith('.dsc'): + if os.path.isfile(operation): self.operation = 'build' + else: + print 'Error: Could not find file «%s».' % operation + sys.exit(1) else: print 'Error: «%s» is not a recognized argument.' % operation print 'Please use one of those: ' + ', '.join(arguments) + '.' @@ -179,15 +167,33 @@ class pbuilder_dist: """ - # Calculate variables which depend on arguments given at runtime. - self._calculate() + if not self.build_architecture: + self.chroot_string = self.target_distro + self.build_architecture = self.system_architecture + else: + self.chroot_string = '%(target_distro)s-%(build_architecture)s' % self + + prefix = os.path.join(self.base, self.chroot_string) + result = '%s_result/' % prefix + + if not self.logfile: + self.logfile = os.path.normpath('%s/build.log' % result) + + if not os.path.isdir(result): + # Create the results directory, if it doesn't exist. + os.makedirs(result) + + if self.builder == 'pbuilder': + base = '--basetgz "%s-base.tgz"' % prefix + elif self.builder == 'cowbuilder': + base = '--basepath "%s-base.cow"' % prefix, arguments = [ - self.operation, - '--basetgz "%(base)s%(chroot_string)s-base.tgz"' % self, + '--%s' % self.operation, + base, '--distribution "%(target_distro)s"' % self, - '--buildresult "%(base)s%(chroot_string)s_result/"' % self, - '--logfile "%(logfile)s"' % self, + '--buildresult "%s"' % result, + '--logfile "%s"' % self.logfile, '--aptcache "/var/cache/apt/archives/"', ### --mirror "${ARCHIVE}" \ '--override-config', @@ -217,7 +223,7 @@ class pbuilder_dist: if remaining_arguments: arguments.extend(remaining_arguments) - return self.auth + ' /usr/sbin/pbuilder ' + ' '.join(arguments) + return self.auth + ' /usr/sbin/' + self.builder + ' ' + ' '.join(arguments) def host_architecture(): """ host_architecture -> string @@ -229,20 +235,6 @@ def host_architecture(): return os.uname()[4].replace('x86_64', 'amd64').replace('i586', 'i386').replace('i686', 'i386') -def item_ends_with(list, string): - """ item_ends_with(list, string) -> bool - - Return True if one of the items in list ends with the given string, - or else return False. - - """ - - for item in list: - if item.endswith(string): - return True - - return False - def ask(question): """ ask(question) -> string @@ -287,7 +279,8 @@ def main(): # Copy arguments into another list for save manipulation args = sys.argv[1:] - if '-' in script_name and parts[0] != 'pbuilder' or len(parts) > 3: + if '-' in script_name and (parts[0] != 'pbuilder' and \ + parts[0] != 'cowbuilder') or len(parts) > 3: print 'Error: «%s» is not a valid name for a «pbuilder-dist» executable.' % script_name sys.exit(1) @@ -298,9 +291,9 @@ def main(): if args[0] in ('-h', '--help', 'help'): help(0) - app = pbuilder_dist() + app = pbuilder_dist(parts[0]) - if len(parts) > 1: + if len(parts) > 1 and parts[1] != 'dist' and '.' not in parts[1]: app.set_target_distro(parts[1]) else: app.set_target_distro(args.pop(0)) @@ -331,7 +324,7 @@ def main(): app.set_operation(args.pop(0)) # Execute the pbuilder command - sys.exit(os.system(app.get_command(args))) + print app.get_command(args) if __name__ == '__main__': From c77c4e12ac8275969917446d8aa39fbc20739173 Mon Sep 17 00:00:00 2001 From: Siegfried-Angel Gevatter Pujals Date: Fri, 2 Jan 2009 14:53:21 +0100 Subject: [PATCH 2/2] .. --- pbuilder-dist.new | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pbuilder-dist.new b/pbuilder-dist.new index 36c9d09..bff9fb2 100755 --- a/pbuilder-dist.new +++ b/pbuilder-dist.new @@ -186,7 +186,7 @@ class pbuilder_dist: if self.builder == 'pbuilder': base = '--basetgz "%s-base.tgz"' % prefix elif self.builder == 'cowbuilder': - base = '--basepath "%s-base.cow"' % prefix, + base = '--basepath "%s-base.cow"' % prefix arguments = [ '--%s' % self.operation, @@ -198,7 +198,7 @@ class pbuilder_dist: ### --mirror "${ARCHIVE}" \ '--override-config', ] - + if os.path.exists('/var/cache/archive/'): arguments.append('--bindmounts "/var/cache/archive/"') @@ -259,7 +259,7 @@ def help(exit_code = 0): """ - print 'Bad...' + print 'See man pbuilder-dist for more information.' sys.exit(exit_code) @@ -324,7 +324,7 @@ def main(): app.set_operation(args.pop(0)) # Execute the pbuilder command - print app.get_command(args) + sys.exit(os.system(app.get_command(args))) if __name__ == '__main__':