From ac2641445913aedda8c5fb6726d131f9d41d0a75 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Fri, 2 Jan 2009 00:17:49 +0000 Subject: [PATCH 1/9] * requestsync: - Use optparse instead of getopt for option parsing. - Skip existing bug report check if python-launchpad-bugs is not installed. --- debian/changelog | 4 ++ requestsync | 108 +++++++++++++++++++++++++++-------------------- 2 files changed, 66 insertions(+), 46 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3b7dd48..eb32110 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,10 @@ ubuntu-dev-tools (0.51) UNRELEASED; urgency=low * buildd: Added checks for arch-indep packages and packages which have no builds in a release. * hugdaylist: String improvements. + * requestsync: + - Use optparse instead of getopt for option parsing. + - Skip existing bug report check if python-launchpad-bugs is not + installed. -- Jonathan Davies Tue, 30 Dec 2008 15:51:55 +0000 diff --git a/requestsync b/requestsync index 07ed972..6340976 100755 --- a/requestsync +++ b/requestsync @@ -25,7 +25,7 @@ # # ################################################################## -import getopt +#import getopt import os import subprocess import sys @@ -33,6 +33,8 @@ import urllib import urllib2 from debian_bundle.changelog import Version +from optparse import OptionParser + # Use functions from ubuntu-dev-tools to create Launchpad cookie file. sys.path.append('/usr/share/ubuntu-dev-tools/') import common @@ -76,6 +78,8 @@ def checkNeedsSponsorship(component): print "If the above is correct please press Enter, otherwise please " \ "press Ctrl-C to stop this script now\nand check the cookie file " \ "at:", launchpad_cookiefile + print "Logging into Launchpad, deleting the above and rerunning this " \ + "script should be enough to generate the cookie." raw_input_exit_on_ctrlc() # Abort if necessary. return True # Sponsorship required. @@ -87,7 +91,15 @@ def checkExistingReports(package): If found ask for confirmation on filing a request. """ - import launchpadbugs.connector as Connector + try: + import launchpadbugs.connector as Connector + except: + print >> sys.stderr, "Unable to import launchpadbugs. Is " \ + "python-launchpad-bugs installed?" + print >> sys.stderr, "Skipping existing report check, you should "\ + "manually check at:" + print "- https://bugs.launchpad.net/ubuntu/+source/%s" % package + return # Connect to the bug list. bugList = Connector.ConnectBugList() @@ -211,23 +223,6 @@ def raw_input_exit_on_ctrlc(*args, **kwargs): print 'Abort requested. No sync request filed.' sys.exit(1) -def usage(): - print '''Usage: requestsync [-d distro|-h|-n|-s|-k |--lp] [basever] - -In some cases, the base version (fork point from Debian) cannot be determined -automatically, and you'll get a complete Debian changelog. Specify the correct -base version of the package in Ubuntu. - -Options: - -d distro Override Debian distribution to sync from [unstable]. - -h Print this help. - -n New source package (doesn't exist yet in Ubuntu). - -s Specify that you require sponsorship. - -k Sign email with (only used when submitting per email). - --lp Use python-launchpad-bugs instead of email for bug submitting. -''' - sys.exit(1) - def get_email_address(): '''Get the DEBEMAIL environment variable or give an error.''' myemailaddr = os.getenv('DEBEMAIL') @@ -446,52 +441,73 @@ def edit_report(subject, body, changes_required=False): # if __name__ == '__main__': - newsource = False - sponsorship = False - keyid = None - use_lp_bugs = False - need_interaction = False - distro = 'unstable' + # Our usage options. + usage = "Usage: %prog [-d distro] [-k keyid] [-n] [--lp] [-s] Date: Fri, 2 Jan 2009 00:29:19 +0000 Subject: [PATCH 2/9] * requestsync: Remove commented out getopt import. --- requestsync | 2 -- 1 file changed, 2 deletions(-) diff --git a/requestsync b/requestsync index 6340976..5a799cd 100755 --- a/requestsync +++ b/requestsync @@ -25,14 +25,12 @@ # # ################################################################## -#import getopt import os import subprocess import sys import urllib import urllib2 from debian_bundle.changelog import Version - from optparse import OptionParser # Use functions from ubuntu-dev-tools to create Launchpad cookie file. From eee4c697d51a9bee3dac45235a8e6819a34ca9f9 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Fri, 2 Jan 2009 13:18:53 +0000 Subject: [PATCH 3/9] * requestsync: Implemented sleeps to --lp bug reporting in case of a slow Launchpad to stop mass bug filing (LP: #311289). --- debian/changelog | 2 ++ requestsync | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index eb32110..8959ba2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,8 @@ ubuntu-dev-tools (0.51) UNRELEASED; urgency=low - Use optparse instead of getopt for option parsing. - Skip existing bug report check if python-launchpad-bugs is not installed. + - 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 diff --git a/requestsync b/requestsync index 5a799cd..e24a2bb 100755 --- a/requestsync +++ b/requestsync @@ -32,6 +32,7 @@ import urllib import urllib2 from debian_bundle.changelog import Version from optparse import OptionParser +from time import sleep # Use functions from ubuntu-dev-tools to create Launchpad cookie file. sys.path.append('/usr/share/ubuntu-dev-tools/') @@ -339,12 +340,11 @@ def post_bug(source_package, subscribe, status, bugtitle, bugtext): try: import launchpadbugs.connector + from launchpadbugs.lpconstants import HTTPCONNECTION except ImportError: print >> sys.stderr, 'Importing launchpadbugs failed. Is python-launchpad-bugs installed?' return False - print "Using cookie file at", launchpad_cookiefile - if source_package: product = {'name': source_package, 'target': 'ubuntu'} else: @@ -366,20 +366,32 @@ def post_bug(source_package, subscribe, status, bugtitle, bugtext): in_confirm_loop = False break else: - print "Invalid answer" + print "Invalid answer." # Create bug Bug = launchpadbugs.connector.ConnectBug() - Bug.authentication = launchpad_cookiefile + # Force the usage of stable Launchpad. + Bug.set_connection_mode(HTTPCONNECTION.MODE.STABLE) + # Use our cookie file for authentication. + Bug.authentication = launchpad_cookiefile + print "Using LP cookie at: %s for authentication." % launchpad_cookiefile + + # Submit bug report. bug = Bug.New(product = product, summary = bugtitle, description = bugtext) + sleep(2) # Wait in case of slow Launchpad. + try: bug.importance = 'Wishlist' except IOError, s: print "Warning: setting importance failed: %s" % s + bug.status = status bug.subscriptions.add(subscribe) + sleep(1) # Wait. + bug.commit() + sleep(1) # Wait. print 'Sync request filed as bug #%i: https://launchpad.net/bugs/%i' % (bug.bugnumber, bug.bugnumber) 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 4/9] * 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 5/9] .. --- 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__': From b2c631d62126caa4255f5c657599f53446389bb3 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Fri, 2 Jan 2009 14:18:09 +0000 Subject: [PATCH 6/9] 0.50 upload. --- debian/changelog | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 8959ba2..2544ff5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,11 @@ -ubuntu-dev-tools (0.51) UNRELEASED; urgency=low +ubuntu-dev-tools (0.52) UNRELEASED; urgency=low + + * Changes go here. + + -- Jonathan Davies Fri, 02 Jan 2009 14:17:40 +0000 + +ubuntu-dev-tools (0.51) jaunty; urgency=low - [ Jonathan Davies ] * buildd: Added checks for arch-indep packages and packages which have no builds in a release. * hugdaylist: String improvements. From bd824b90722f17907108e27cc857204034e43bda Mon Sep 17 00:00:00 2001 From: Nathan Handler Date: Fri, 2 Jan 2009 10:37:12 -0600 Subject: [PATCH 7/9] pull-debian-source: Pass -xu arguments to dget to be consistant with pull-lp-source --- debian/changelog | 7 ++++++- pull-debian-source | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 19001fe..1190da0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,15 @@ ubuntu-dev-tools (0.52) UNRELEASED; urgency=low + [ 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 + [ Nathan Handler ] + * pull-debian-source: Pass -xu arguments to dget to be consistant with + pull-lp-source + + -- Nathan Handler Fri, 02 Jan 2009 10:35:27 -0600 ubuntu-dev-tools (0.51) jaunty; urgency=low diff --git a/pull-debian-source b/pull-debian-source index c0a6c4d..161af5a 100755 --- a/pull-debian-source +++ b/pull-debian-source @@ -28,7 +28,7 @@ my($release)=$ARGV[1] || 'unstable'; &checkRelease($release); my($dsc)=&getDSC(&getMadison(&getURL($package,$release))); print "$dsc\n"; -exec("dget $dsc"); +exec("dget -xu $dsc"); sub checkRelease { my($release)=shift || die("No Release Passed To checkRelease!\n"); chomp $release; From d91f26495beeb8eedbdca26eab81efc4d95f1e73 Mon Sep 17 00:00:00 2001 From: Nathan Handler Date: Fri, 2 Jan 2009 11:36:39 -0600 Subject: [PATCH 8/9] Add support for packages with a name beginning with lib --- debian/changelog | 7 ++++--- pull-debian-source | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1190da0..01ef5dc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,10 +6,11 @@ ubuntu-dev-tools (0.52) UNRELEASED; urgency=low pbuilder-dist, we will also create a cowbuilder-dist symlink to it. [ Nathan Handler ] - * pull-debian-source: Pass -xu arguments to dget to be consistant with - pull-lp-source + * pull-debian-source: + - Pass -xu arguments to dget to be consistant with pull-lp-source + - Add support for packages with a name beginning with "lib" - -- Nathan Handler Fri, 02 Jan 2009 10:35:27 -0600 + -- Nathan Handler Fri, 02 Jan 2009 11:35:36 -0600 ubuntu-dev-tools (0.51) jaunty; urgency=low diff --git a/pull-debian-source b/pull-debian-source index 161af5a..6946380 100755 --- a/pull-debian-source +++ b/pull-debian-source @@ -78,7 +78,13 @@ sub getDSC { $version=~s/^.*?\://; if($archs=~m/source/) { print "Package: $package\nVersion: $version\nRelease: $release\nArchitectures: $archs\n"; - my($firstLetter)=substr($package,0,1); + my($firstLetter); + if($package=~m/^lib/) { + $firstLetter="lib" . substr($package,3,1); + } + else { + $firstLetter=substr($package,0,1); + } my($url)=$baseURL . $firstLetter . '/' . $package . '/' . $package . '_' . $version . '.dsc'; return $url; } From 8583d8bf15878165fea6ad0a4b24864485909615 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Sat, 3 Jan 2009 10:50:53 -0800 Subject: [PATCH 9/9] mk-sbuild-lv: add --skip-updates to allow building security-only chroots. --- debian/changelog | 5 ++++- doc/mk-sbuild-lv.1 | 23 ++++++++++++++++------- mk-sbuild-lv | 14 +++++++++++++- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/debian/changelog b/debian/changelog index 01ef5dc..69cc96a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,7 +10,10 @@ ubuntu-dev-tools (0.52) UNRELEASED; urgency=low - Pass -xu arguments to dget to be consistant with pull-lp-source - Add support for packages with a name beginning with "lib" - -- Nathan Handler Fri, 02 Jan 2009 11:35:36 -0600 + [ Kees Cook ] + * mk-sbuild-lv: add --skip-updates to allow building security-only chroots. + + -- Kees Cook Sat, 03 Jan 2009 10:44:02 -0800 ubuntu-dev-tools (0.51) jaunty; urgency=low diff --git a/doc/mk-sbuild-lv.1 b/doc/mk-sbuild-lv.1 index 4eaf6e7..59ddddc 100644 --- a/doc/mk-sbuild-lv.1 +++ b/doc/mk-sbuild-lv.1 @@ -18,16 +18,19 @@ Listed below are the command line options for mk\-sbuild\-lv: What architecture to select (defaults to the native architecture). .TP .B \-\-name=NAME -Base name for the schroot (arch is appended) +Base name for the schroot (arch is appended). .TP .B \-\-personality=PERSONALITY -What personality to use (defaults to match \-\-arch) +What personality to use (defaults to match \-\-arch). .TP .B \-\-debug -Turn on script debugging +Turn on script debugging. +.TP +.B \-\-skip\-updates +Do not include the -updates pocket in the installed sources.list. .TP .B \-\-source\-template=FILE -Use FILE as the sources.list template (defaults to $HOME/.mk\-sbuild\-lv.sources) +Use FILE as the sources.list template (defaults to $HOME/.mk\-sbuild\-lv.sources). .TP .B \-\-debootstrap\-mirror=URL Use URL as the debootstrap source (defaults to http://ports.ubuntu.com for lpia, @@ -36,16 +39,22 @@ official Ubuntu repositories for the supported architectures). .SH ENVIRONMENT VARIABLES .TP .B LV_SIZE -Size of source LVs (defaults to 5G) +Size of source LVs (defaults to 5G). .TP .B SNAPSHOT_SIZE -Size of snapshot LVs (defaults to 4G) +Size of snapshot LVs (defaults to 4G). .TP .B SCHROOT_CONF_SUFFIX -Lines to append to schroot entries +Lines to append to schroot entries. +.TP +.B SKIP_UPDATES +Do not include the -updates pocket in the installed sources.list. .SH FILES .TP +.B $HOME/.mk\-sbuild\-lv.rc +Sourced for environment variables (defined above). +.TP .B $HOME/.mk\-sbuild\-lv.sources Can contain a customized sources.list. It will be read when creating the schroot. diff --git a/mk-sbuild-lv b/mk-sbuild-lv index ea771d9..501cd4c 100755 --- a/mk-sbuild-lv +++ b/mk-sbuild-lv @@ -107,6 +107,7 @@ function usage() echo " --name=NAME Base name for the schroot (arch is appended)" echo " --personality=PERSONALITY What personality to use (defaults to match --arch)" echo " --debug Turn on script debugging" + echo " --skip-updates Do not include -updates pocket in sources.list" echo " --source-template=FILE Use FILE as the sources.list template" echo " --debootstrap-mirror=URL Use URL as the debootstrap source" echo "" @@ -114,6 +115,7 @@ function usage() echo " LV_SIZE Size of source LVs (default ${LV_SIZE})" echo " SNAPSHOT_SIZE Size of snapshot LVs (default ${SNAPSHOT_SIZE})" echo " SCHROOT_CONF_SUFFIX Lines to append to schroot.conf entries" + echo " SKIP_UPDATES Enable --skip-updates" exit 1 } @@ -121,7 +123,7 @@ function usage() if [ -z "$1" ]; then usage fi -OPTS=`getopt -o '' --long "help,debug,arch:,name:,source-template:,debootstrap-mirror:,personality:" -- "$@"` +OPTS=`getopt -o '' --long "help,debug,skip-updates,arch:,name:,source-template:,debootstrap-mirror:,personality:" -- "$@"` eval set -- "$OPTS" name="" @@ -145,6 +147,10 @@ while :; do personality="$2" shift 2 ;; + --skip-updates) + SKIP_UPDATES="1" + shift + ;; --name) name="$2" shift 2 @@ -231,8 +237,14 @@ else cat > "$TEMP_SOURCES" <> "$TEMP_SOURCES" <> "$TEMP_SOURCES" <