From 86ba4c99ca0529d143d1bee0d40150227e172af2 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Tue, 6 Dec 2011 23:37:25 +0200 Subject: [PATCH 01/15] move --no-lp options into their own group --- syncpackage | 83 ++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/syncpackage b/syncpackage index 51d7b77..f4f4175 100755 --- a/syncpackage +++ b/syncpackage @@ -494,6 +494,10 @@ def parse(): parser.add_option("-c", "--component", dest="component", default=None, help="Specify the Debian component to sync from.") + parser.add_option("-b", "--bug", metavar="BUG", + dest="bugs", action="append", default=list(), + help="Mark Launchpad bug BUG as being fixed by this " + "upload.") parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False, help="Display more progress information.") @@ -501,54 +505,55 @@ def parse(): dest="fakesync", action="store_true", default=False, help="Perform a fakesync (a sync where Debian and Ubuntu " "have a .orig.tar mismatch).") - parser.add_option("--no-lp", - dest="lp", action="store_false", default=True, - help="Construct sync locally rather than letting " - "Launchpad copy the package directly (not " - "recommended).") + parser.add_option("-f", "--force", + dest="force", action="store_true", default=False, + help="Force sync over the top of Ubuntu changes.") + parser.add_option('--no-conf', + dest='no_conf', default=False, action='store_true', + help="Don't read config files or environment variables.") parser.add_option('-l', '--lpinstance', metavar='INSTANCE', dest='lpinstance', default=None, help='Launchpad instance to connect to ' '(default: production).') - parser.add_option("-n", "--uploader-name", - dest="uploader_name", default=None, - help="Use UPLOADER_NAME as the name of the maintainer " - "for this upload.") - parser.add_option("-e", "--uploader-email", - dest="uploader_email", default=None, - help="Use UPLOADER_EMAIL as email address of the " - "maintainer for this upload.") - parser.add_option("-k", "--key", - dest="keyid", default=None, - help="Specify the key ID to be used for signing.") - parser.add_option('--dont-sign', - dest='keyid', action='store_false', - help='Do not sign the upload.') - parser.add_option("-b", "--bug", metavar="BUG", - dest="bugs", action="append", default=list(), - help="Mark Launchpad bug BUG as being fixed by this " - "upload.") - parser.add_option("-f", "--force", - dest="force", action="store_true", default=False, - help="Force sync over the top of Ubuntu changes.") - parser.add_option('-D', '--debian-mirror', metavar='DEBIAN_MIRROR', - dest='debian_mirror', - help='Preferred Debian mirror ' - '(default: %s)' - % UDTConfig.defaults['DEBIAN_MIRROR']) - parser.add_option('-U', '--ubuntu-mirror', metavar='UBUNTU_MIRROR', - dest='ubuntu_mirror', - help='Preferred Ubuntu mirror ' - '(default: %s)' - % UDTConfig.defaults['UBUNTU_MIRROR']) - parser.add_option('--no-conf', - dest='no_conf', default=False, action='store_true', - help="Don't read config files or environment variables.") parser.add_option('--simulate', dest='simulate', default=False, action='store_true', help="Show what would be done, but don't actually do " "it.") + no_lp = optparse.OptionGroup(parser, "Local sync preperation options", + "Options that only apply when using --no-lp. " + "WARNING: The use of --no-lp is not recommended for uploads " + "targetted at Ubuntu. The archive-admins discourage its use.") + no_lp.add_option("--no-lp", + dest="lp", action="store_false", default=True, + help="Construct sync locally rather than letting " + "Launchpad copy the package directly") + no_lp.add_option("-n", "--uploader-name", + dest="uploader_name", default=None, + help="Use UPLOADER_NAME as the name of the maintainer " + "for this upload.") + no_lp.add_option("-e", "--uploader-email", + dest="uploader_email", default=None, + help="Use UPLOADER_EMAIL as email address of the " + "maintainer for this upload.") + no_lp.add_option("-k", "--key", + dest="keyid", default=None, + help="Specify the key ID to be used for signing.") + no_lp.add_option('--dont-sign', + dest='keyid', action='store_false', + help='Do not sign the upload.') + no_lp.add_option('-D', '--debian-mirror', metavar='DEBIAN_MIRROR', + dest='debian_mirror', + help='Preferred Debian mirror ' + '(default: %s)' + % UDTConfig.defaults['DEBIAN_MIRROR']) + no_lp.add_option('-U', '--ubuntu-mirror', metavar='UBUNTU_MIRROR', + dest='ubuntu_mirror', + help='Preferred Ubuntu mirror ' + '(default: %s)' + % UDTConfig.defaults['UBUNTU_MIRROR']) + parser.add_option_group(no_lp) + (options, args) = parser.parse_args() if options.fakesync: From 857778b922b4330fa5a9481fad59a9b8e8c66218 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 00:01:08 +0200 Subject: [PATCH 02/15] Remove unecessary optparse clutter --- syncpackage | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/syncpackage b/syncpackage index f4f4175..8703d07 100755 --- a/syncpackage +++ b/syncpackage @@ -483,40 +483,35 @@ def parse(): parser = optparse.OptionParser(usage=usage, epilog=epilog) parser.add_option("-d", "--distribution", - dest="dist", default=None, help="Debian distribution to sync from.") parser.add_option("-r", "--release", - dest="release", default=None, help="Specify target Ubuntu release.") parser.add_option("-V", "--debian-version", - dest="debversion", default=None, help="Specify the version to sync from.") parser.add_option("-c", "--component", - dest="component", default=None, help="Specify the Debian component to sync from.") parser.add_option("-b", "--bug", metavar="BUG", dest="bugs", action="append", default=list(), help="Mark Launchpad bug BUG as being fixed by this " "upload.") parser.add_option("-v", "--verbose", - dest="verbose", action="store_true", default=False, + action="store_true", default=False, help="Display more progress information.") parser.add_option("-F", "--fakesync", - dest="fakesync", action="store_true", default=False, + action="store_true", default=False, help="Perform a fakesync (a sync where Debian and Ubuntu " "have a .orig.tar mismatch).") parser.add_option("-f", "--force", - dest="force", action="store_true", default=False, + action="store_true", default=False, help="Force sync over the top of Ubuntu changes.") parser.add_option('--no-conf', - dest='no_conf', default=False, action='store_true', + default=False, action='store_true', help="Don't read config files or environment variables.") parser.add_option('-l', '--lpinstance', metavar='INSTANCE', - dest='lpinstance', default=None, help='Launchpad instance to connect to ' '(default: production).') parser.add_option('--simulate', - dest='simulate', default=False, action='store_true', + default=False, action='store_true', help="Show what would be done, but don't actually do " "it.") @@ -529,26 +524,22 @@ def parse(): help="Construct sync locally rather than letting " "Launchpad copy the package directly") no_lp.add_option("-n", "--uploader-name", - dest="uploader_name", default=None, help="Use UPLOADER_NAME as the name of the maintainer " "for this upload.") no_lp.add_option("-e", "--uploader-email", - dest="uploader_email", default=None, help="Use UPLOADER_EMAIL as email address of the " "maintainer for this upload.") no_lp.add_option("-k", "--key", - dest="keyid", default=None, + dest="keyid", help="Specify the key ID to be used for signing.") no_lp.add_option('--dont-sign', dest='keyid', action='store_false', help='Do not sign the upload.') no_lp.add_option('-D', '--debian-mirror', metavar='DEBIAN_MIRROR', - dest='debian_mirror', help='Preferred Debian mirror ' '(default: %s)' % UDTConfig.defaults['DEBIAN_MIRROR']) no_lp.add_option('-U', '--ubuntu-mirror', metavar='UBUNTU_MIRROR', - dest='ubuntu_mirror', help='Preferred Ubuntu mirror ' '(default: %s)' % UDTConfig.defaults['UBUNTU_MIRROR']) @@ -616,7 +607,8 @@ def main(): ubuntu = Launchpad.distributions["ubuntu"] options.release = ubuntu.current_series.name - src_pkg = fetch_source_pkg(package, options.dist, options.debversion, + src_pkg = fetch_source_pkg(package, options.distribution, + options.debian_version, options.component, options.release.split("-")[0], options.debian_mirror) @@ -662,7 +654,7 @@ def main(): options.force) else: os.environ['DEB_VENDOR'] = 'Ubuntu' - sync_dsc(src_pkg, options.dist, options.release, options.uploader_name, + sync_dsc(src_pkg, options.distribution, options.release, options.uploader_name, options.uploader_email, options.bugs, options.ubuntu_mirror, options.keyid, options.simulate, options.force, options.fakesync) From 1f2d2e8d62875b6e9571b15db0151d3d41a5f748 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 00:14:00 +0200 Subject: [PATCH 03/15] Pyflakes & PEP-8 fine-tooth comb applied --- syncpackage | 60 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/syncpackage b/syncpackage index 8703d07..d25e4c7 100755 --- a/syncpackage +++ b/syncpackage @@ -37,8 +37,8 @@ from lazr.restfulclient.errors import HTTPError from ubuntutools.archive import (DebianSourcePackage, UbuntuSourcePackage, DownloadError) from ubuntutools.config import UDTConfig, ubu_email -from ubuntutools.requestsync.mail import (get_debian_srcpkg - as requestsync_mail_get_debian_srcpkg) +from ubuntutools.requestsync.mail import ( + get_debian_srcpkg as requestsync_mail_get_debian_srcpkg) from ubuntutools.requestsync.lp import get_debian_srcpkg, get_ubuntu_srcpkg from ubuntutools.lp import udtexceptions from ubuntutools.lp.lpapicache import (Distribution, Launchpad, @@ -52,9 +52,9 @@ class Version(debian.debian_support.Version): def strip_epoch(self): '''Removes the epoch from a Debian version string. - strip_epoch(1:1.52-1) will return "1.52-1" and strip_epoch(1.1.3-1) will - return "1.1.3-1".''' - + strip_epoch(1:1.52-1) will return "1.52-1" and strip_epoch(1.1.3-1) + will return "1.1.3-1". + ''' parts = self.full_version.split(':') if len(parts) > 1: del parts[0] @@ -62,6 +62,7 @@ class Version(debian.debian_support.Version): return version_without_epoch def get_related_debian_version(self): + '''Strip the ubuntu-specific bits off the version''' related_debian_version = self.full_version uidx = related_debian_version.find('ubuntu') if uidx > 0: @@ -72,6 +73,7 @@ class Version(debian.debian_support.Version): return Version(related_debian_version) def is_modified_in_ubuntu(self): + '''Did Ubuntu modify this (and mark the version appropriately?''' return 'ubuntu' in self.full_version @@ -97,6 +99,7 @@ def remove_signature(dscname): dsc_file.writelines(unsigned_file) dsc_file.close() + def add_fixed_bugs(changes, bugs): '''Add additional Launchpad bugs to the list of fixed bugs in changes file.''' @@ -117,15 +120,22 @@ def add_fixed_bugs(changes, bugs): return "\n".join(changes + [""]) + def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror, keyid=None, simulate=False, force=False, fakesync=False): + '''Local sync, trying to emulate sync-source.py + Grabs a source package, replaces the .orig.tar with the one from Ubuntu, + if necessary, writes a sync-appropriate .changes file, and signs it. + ''' + uploader = name + " <" + email + ">" src_pkg.pull_dsc() new_ver = Version(src_pkg.dsc["Version"]) try: - ubuntu_source = get_ubuntu_srcpkg(src_pkg.source, release.split("-")[0]) + ubuntu_source = get_ubuntu_srcpkg(src_pkg.source, + release.split("-")[0]) ubuntu_ver = Version(ubuntu_source.getVersion()) ubu_pkg = UbuntuSourcePackage(src_pkg.source, ubuntu_ver.full_version, ubuntu_source.getComponent(), @@ -206,7 +216,8 @@ def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror, if not Logger.verbose: cmd += ["-q"] Logger.command(cmd + ['>', '../' + changes_filename]) - changes = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] + changes = subprocess.Popen(cmd, stdout=subprocess.PIPE) \ + .communicate()[0] # Add additional bug numbers if len(bugs) > 0: @@ -266,7 +277,9 @@ def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror, 'Please check build log above.') sys.exit(1) -def fetch_source_pkg(package, dist, version, component, ubuntu_release, mirror): + +def fetch_source_pkg(package, dist, version, component, ubuntu_release, + mirror): """Download the specified source package. dist, version, component, mirror can all be None. """ @@ -320,6 +333,7 @@ def fetch_source_pkg(package, dist, version, component, ubuntu_release, mirror): return DebianSourcePackage(package, version.full_version, component, mirrors=mirrors) + def copy(src_pkg, release, bugs, simulate=False, force=False): """Copy a source package from Debian to Ubuntu using the Launchpad API.""" ubuntu = Distribution('ubuntu') @@ -413,6 +427,7 @@ def copy(src_pkg, release, bugs, simulate=False, force=False): close_bugs(bugs, src_pkg.source, src_pkg.version.full_version, changes) + def is_blacklisted(query): """"Determine if package "query" is in the sync blacklist Returns tuple of (blacklisted, comments) @@ -422,8 +437,8 @@ def is_blacklisted(query): lp_comments = series.getDifferenceComments(source_package_name=query) blacklisted = False comments = [u'%s\n -- %s %s' - %(c.body_text, c.comment_author.name, - c.comment_date.strftime('%a, %d %b %Y %H:%M:%S +0000')) + % (c.body_text, c.comment_author.name, + c.comment_date.strftime('%a, %d %b %Y %H:%M:%S +0000')) for c in lp_comments] for diff in series.getDifferencesTo(source_package_name_filter=query): @@ -451,6 +466,7 @@ def is_blacklisted(query): return (blacklisted, comments) + def close_bugs(bugs, package, version, changes): """Close the correct task on all bugs, with changes""" ubuntu = Launchpad.distributions['ubuntu'] @@ -475,6 +491,7 @@ def close_bugs(bugs, package, version, changes): else: Logger.error(u"Cannot find any tasks on LP: #%i to close.", bug.id) + def parse(): """Parse given command-line parameters.""" @@ -499,8 +516,8 @@ def parse(): help="Display more progress information.") parser.add_option("-F", "--fakesync", action="store_true", default=False, - help="Perform a fakesync (a sync where Debian and Ubuntu " - "have a .orig.tar mismatch).") + help="Perform a fakesync (a sync where Debian and " + "Ubuntu have a .orig.tar mismatch).") parser.add_option("-f", "--force", action="store_true", default=False, help="Force sync over the top of Ubuntu changes.") @@ -582,6 +599,7 @@ def parse(): def main(): + '''Handle parameters and get the ball rolling''' (options, package) = parse() Logger.verbose = options.verbose @@ -609,7 +627,8 @@ def main(): src_pkg = fetch_source_pkg(package, options.distribution, options.debian_version, - options.component, options.release.split("-")[0], + options.component, + options.release.split("-")[0], options.debian_mirror) blacklisted, comments = is_blacklisted(src_pkg.source) @@ -619,14 +638,16 @@ def main(): if blacklisted == 'CURRENT': Logger.debug("Source package %s is temporarily blacklisted " - "(blacklisted_current). Ubuntu ignores these for now. " + "(blacklisted_current). " + "Ubuntu ignores these for now. " "See also LP: #841372", src_pkg.source) else: if options.fakesync: messages += ["Doing a fakesync, overriding blacklist."] else: blacklist_fail = True - messages += ["If this package needs a fakesync, use --fakesync", + messages += ["If this package needs a fakesync, " + "use --fakesync", "If you think this package shouldn't be " "blacklisted, please file a bug explaining your " "reasoning and subscribe ~ubuntu-archive."] @@ -654,10 +675,11 @@ def main(): options.force) else: os.environ['DEB_VENDOR'] = 'Ubuntu' - sync_dsc(src_pkg, options.distribution, options.release, options.uploader_name, - options.uploader_email, options.bugs, options.ubuntu_mirror, - options.keyid, options.simulate, options.force, - options.fakesync) + sync_dsc(src_pkg, options.distribution, options.release, + options.uploader_name, options.uploader_email, options.bugs, + options.ubuntu_mirror, options.keyid, options.simulate, + options.force, options.fakesync) + if __name__ == "__main__": try: From dc9d6b5bf3f00decee7ede901f4789570ce5c940 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 00:23:22 +0200 Subject: [PATCH 04/15] Add sponsorship support --- syncpackage | 49 +++++++++++++++++++++++++++++------- ubuntutools/lp/lpapicache.py | 3 ++- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/syncpackage b/syncpackage index d25e4c7..ccf01ec 100755 --- a/syncpackage +++ b/syncpackage @@ -41,7 +41,7 @@ from ubuntutools.requestsync.mail import ( get_debian_srcpkg as requestsync_mail_get_debian_srcpkg) from ubuntutools.requestsync.lp import get_debian_srcpkg, get_ubuntu_srcpkg from ubuntutools.lp import udtexceptions -from ubuntutools.lp.lpapicache import (Distribution, Launchpad, +from ubuntutools.lp.lpapicache import (Distribution, Launchpad, PersonTeam, SourcePackagePublishingHistory) from ubuntutools.misc import split_release_pocket from ubuntutools.question import YesNoQuestion @@ -334,7 +334,7 @@ def fetch_source_pkg(package, dist, version, component, ubuntu_release, mirrors=mirrors) -def copy(src_pkg, release, bugs, simulate=False, force=False): +def copy(src_pkg, release, bugs, sponsoree=None, simulate=False, force=False): """Copy a source package from Debian to Ubuntu using the Launchpad API.""" ubuntu = Distribution('ubuntu') debian_archive = Distribution('debian').getArchive() @@ -396,6 +396,9 @@ def copy(src_pkg, release, bugs, simulate=False, force=False): if simulate: return + if sponsoree: + Logger.normal("Sponsoring this sync for %s (%s)", + sponsoree.display_name, sponsoree.name) answer = YesNoQuestion().ask("Sync this package", "no") if answer != "yes": return @@ -407,7 +410,8 @@ def copy(src_pkg, release, bugs, simulate=False, force=False): from_archive=debian_archive, to_series=ubuntu_series, to_pocket=ubuntu_pocket, - include_binaries=False) + include_binaries=False, + sponsoree=sponsoree) except HTTPError, error: Logger.error("HTTP Error %s: %s", error.response.status, error.response.reason) @@ -511,6 +515,10 @@ def parse(): dest="bugs", action="append", default=list(), help="Mark Launchpad bug BUG as being fixed by this " "upload.") + parser.add_option("-s", "--sponsor", metavar="USERNAME", + dest="sponsoree", default=None, + help="Sponsor the sync for USERNAME (a launchpad " + "username).") parser.add_option("-v", "--verbose", action="store_true", default=False, help="Display more progress information.") @@ -608,10 +616,6 @@ def main(): options.debian_mirror = config.get_value('DEBIAN_MIRROR') if options.ubuntu_mirror is None: options.ubuntu_mirror = config.get_value('UBUNTU_MIRROR') - if options.uploader_name is None: - options.uploader_name = ubu_email(export=False)[0] - if options.uploader_email is None: - options.uploader_email = ubu_email(export=False)[1] if options.lpinstance is None: options.lpinstance = config.get_value('LPINSTANCE') @@ -625,6 +629,33 @@ def main(): ubuntu = Launchpad.distributions["ubuntu"] options.release = ubuntu.current_series.name + sponsoree = None + if options.sponsoree: + try: + sponsoree = PersonTeam(options.sponsoree) + except KeyError: + Logger.error('Cannot find the username "%s" in Launchpad.', + options.sponsoree) + sys.exit(1) + + if sponsoree and options.uploader_name is None: + options.uploader_name = sponsoree.display_name + elif options.uploader_name is None: + options.uploader_name = ubu_email(export=False)[0] + + if sponsoree and options.uploader_email is None: + try: + options.uploader_email = sponsoree.preferred_email_address.email + except ValueError: + if options.lp: + # Not needed + pass + Logger.error("%s doesn't have a publicly visible e-mail address " + "in LP, please provide one --uploader-email option", + sponsoree.display_name) + elif options.uploader_email is None: + options.uploader_email = ubu_email(export=False)[1] + src_pkg = fetch_source_pkg(package, options.distribution, options.debian_version, options.component, @@ -671,8 +702,8 @@ def main(): sys.exit(1) if options.lp: - copy(src_pkg, options.release, options.bugs, options.simulate, - options.force) + copy(src_pkg, options.release, options.bugs, sponsoree, + options.simulate, options.force) else: os.environ['DEB_VENDOR'] = 'Ubuntu' sync_dsc(src_pkg, options.distribution, options.release, diff --git a/ubuntutools/lp/lpapicache.py b/ubuntutools/lp/lpapicache.py index 5906c48..64492d0 100644 --- a/ubuntutools/lp/lpapicache.py +++ b/ubuntutools/lp/lpapicache.py @@ -383,7 +383,7 @@ class Archive(BaseWrapper): return cache[index] def copyPackage(self, source_name, version, from_archive, to_pocket, - to_series=None, include_binaries=False): + to_series=None, sponsored=None, include_binaries=False): '''Copy a single named source into this archive. Asynchronously copy a specific version of a named source to the @@ -398,6 +398,7 @@ class Archive(BaseWrapper): from_archive=from_archive._lpobject, to_pocket=to_pocket, to_series=to_series, + sponsored=sponsored, include_binaries=include_binaries ) From 79e525d26081be33f018eefad0265a372d185cdb Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 00:42:34 +0200 Subject: [PATCH 05/15] Break up some long lines into multiple statements --- syncpackage | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/syncpackage b/syncpackage index ccf01ec..50c3376 100755 --- a/syncpackage +++ b/syncpackage @@ -73,7 +73,7 @@ class Version(debian.debian_support.Version): return Version(related_debian_version) def is_modified_in_ubuntu(self): - '''Did Ubuntu modify this (and mark the version appropriately?''' + '''Did Ubuntu modify this (and mark the version appropriately)?''' return 'ubuntu' in self.full_version @@ -134,8 +134,8 @@ def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror, new_ver = Version(src_pkg.dsc["Version"]) try: - ubuntu_source = get_ubuntu_srcpkg(src_pkg.source, - release.split("-")[0]) + series = release.split("-")[0] + ubuntu_source = get_ubuntu_srcpkg(src_pkg.source, series) ubuntu_ver = Version(ubuntu_source.getVersion()) ubu_pkg = UbuntuSourcePackage(src_pkg.source, ubuntu_ver.full_version, ubuntu_source.getComponent(), @@ -216,8 +216,8 @@ def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror, if not Logger.verbose: cmd += ["-q"] Logger.command(cmd + ['>', '../' + changes_filename]) - changes = subprocess.Popen(cmd, stdout=subprocess.PIPE) \ - .communicate()[0] + process = subprocess.Popen(cmd, stdout=subprocess.PIPE) + changes = process.communicate.communicate()[0] # Add additional bug numbers if len(bugs) > 0: From b771bf89b068249b508bbe0d62c4a0b66adb51b9 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 00:48:13 +0200 Subject: [PATCH 06/15] Clarify --no-lp --- syncpackage | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/syncpackage b/syncpackage index 50c3376..69ec4fb 100755 --- a/syncpackage +++ b/syncpackage @@ -525,7 +525,9 @@ def parse(): parser.add_option("-F", "--fakesync", action="store_true", default=False, help="Perform a fakesync (a sync where Debian and " - "Ubuntu have a .orig.tar mismatch).") + "Ubuntu have a .orig.tar mismatch). " + "This implies --no-lp and will leave a signed " + ".changes file for you to upload.") parser.add_option("-f", "--force", action="store_true", default=False, help="Force sync over the top of Ubuntu changes.") @@ -543,7 +545,8 @@ def parse(): no_lp = optparse.OptionGroup(parser, "Local sync preperation options", "Options that only apply when using --no-lp. " "WARNING: The use of --no-lp is not recommended for uploads " - "targetted at Ubuntu. The archive-admins discourage its use.") + "targetted at Ubuntu. " + "The archive-admins discourage its use, except for fakesyncs.") no_lp.add_option("--no-lp", dest="lp", action="store_false", default=True, help="Construct sync locally rather than letting " From 8ca2144a748443bbf8d4d78e41132669dd1e68c3 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 00:51:48 +0200 Subject: [PATCH 07/15] --no-lp *itself* could get some love, too --- syncpackage | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/syncpackage b/syncpackage index 69ec4fb..9f0b8a5 100755 --- a/syncpackage +++ b/syncpackage @@ -549,8 +549,10 @@ def parse(): "The archive-admins discourage its use, except for fakesyncs.") no_lp.add_option("--no-lp", dest="lp", action="store_false", default=True, - help="Construct sync locally rather than letting " - "Launchpad copy the package directly") + help="Construct sync locally, rather than letting " + "Launchpad copy the package directly. " + "It will leave a signed .changes file for you to " + "upload.") no_lp.add_option("-n", "--uploader-name", help="Use UPLOADER_NAME as the name of the maintainer " "for this upload.") From c289c20b885a3e490fe38d078f7e80baf57b795f Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 01:03:35 +0200 Subject: [PATCH 08/15] Spelling --- syncpackage | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syncpackage b/syncpackage index 9f0b8a5..ca39b16 100755 --- a/syncpackage +++ b/syncpackage @@ -517,7 +517,7 @@ def parse(): "upload.") parser.add_option("-s", "--sponsor", metavar="USERNAME", dest="sponsoree", default=None, - help="Sponsor the sync for USERNAME (a launchpad " + help="Sponsor the sync for USERNAME (a Launchpad " "username).") parser.add_option("-v", "--verbose", action="store_true", default=False, @@ -542,10 +542,10 @@ def parse(): help="Show what would be done, but don't actually do " "it.") - no_lp = optparse.OptionGroup(parser, "Local sync preperation options", + no_lp = optparse.OptionGroup(parser, "Local sync preparation options", "Options that only apply when using --no-lp. " "WARNING: The use of --no-lp is not recommended for uploads " - "targetted at Ubuntu. " + "targeted at Ubuntu. " "The archive-admins discourage its use, except for fakesyncs.") no_lp.add_option("--no-lp", dest="lp", action="store_false", default=True, From bba53d9f7a0e88c5207eab910c55b0862dcc89d1 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 01:07:28 +0200 Subject: [PATCH 09/15] Corrosponding manpage improvements --- doc/syncpackage.1 | 61 +++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/doc/syncpackage.1 b/doc/syncpackage.1 index 729d160..3a3e8e2 100644 --- a/doc/syncpackage.1 +++ b/doc/syncpackage.1 @@ -1,9 +1,11 @@ .TH SYNCPACKAGE "1" "June 2010" "ubuntu-dev-tools" .SH NAME syncpackage \- copy source packages from Debian to Ubuntu +.\" .SH SYNOPSIS .B syncpackage [\fIoptions\fR] \fI<.dsc URL/path or package name>\fR +.\" .SH DESCRIPTION \fBsyncpackage\fR causes a source package to be copied from Debian to Ubuntu. @@ -14,16 +16,19 @@ this way you can preserve source files integrity between the two distributions. .PP \fBsyncpackage\fR will detect source tarballs with mismatching checksums, and can perform fake syncs. +.\" .SH WARNING The use of \fBsyncpackage \-\-no\-lp\fR, which generates a changes file to be directly uploaded to the Ubuntu primary archive or a PPA, is discouraged by the Ubuntu Archive Administrators, as it introduces an unnecessary window for error. -This only exists for backward compatibility, for unusual corner cases, and -for uploads to archives other than the Ubuntu primary archive. +This only exists for backward compatibility, for unusual corner cases +(such as fakesyncs), and for uploads to archives other than the Ubuntu +primary archive. Omitting this option will cause Launchpad to perform the sync request directly, which is the preferred method for uploads to the Ubuntu primary archive. +.\" .SH OPTIONS .TP \fB\-h\fR, \fB\-\-help\fR @@ -42,20 +47,45 @@ Specify the version to sync from. \fB\-c\fI COMPONENT\fR, \fB\-\-component\fR=\fICOMPONENT\fR Specify the component to sync from. .TP +\fB\-b\fI BUG\fR, \fB\-\-bug\fR=\fIBUG\fR +Mark a Launchpad bug as being fixed by this upload. +.TP +\fB\-s\fI USERNAME\fR, \fB\-\-sponsor\fR=\fIUSERNAME\fR +Sponsor the sync for \fIUSERNAME\fR (a Launchpad username). +.TP \fB\-v\fR, \fB\-\-verbose\fR Display more progress information. .TP -.B \-\-no\-lp -Construct sync locally rather than letting Launchpad copy the package -directly (not recommended). -.TP \fB\-F\fR, \fB\-\-fakesync\fR Perform a fakesync, to work around a tarball mismatch between Debian and -Ubuntu. This option ignores blacklisting, and performs a local sync. +Ubuntu. +This option ignores blacklisting, and performs a local sync. +It implies \fB\-\-no\-lp\fR, and will leave a signed \fB.changes\fR file +for you to upload. +.TP +\fB\-f\fR, \fB\-\-force\fR +Force sync over the top of Ubuntu changes. +.TP +.B \-\-no\-conf +Do not read any configuration files, or configuration from environment +variables. .TP \fB\-l\fI INSTANCE\fR, \fB\-\-lpinstance\fR=\fIINSTANCE\fR Launchpad instance to connect to (default: production). .TP +.B \-\-simulate +Show what would be done, but don't actually do it. +.\" +.SH LOCAL SYNC PREPARATION OPTIONS +.TP +Options that only apply when using \fB\-\-no\-lp\fR: +.TP +.B \-\-no\-lp +Construct sync locally, rather than letting Launchpad copy the package +directly. +It will leave a signed \fB.changes\fR file for you to upload. +See the \fBWARNING\fR above. +.TP \fB\-n\fI UPLOADER_NAME\fR, \fB\-\-uploader\-name\fR=\fIUPLOADER_NAME\fR Use UPLOADER_NAME as the name of the maintainer for this upload instead of evaluating DEBFULLNAME and UBUMAIL. @@ -72,12 +102,6 @@ Specify the key ID to be used for signing. \fB\-\-dont-sign\fR Do not sign the upload. .TP -\fB\-b\fI BUG\fR, \fB\-\-bug\fR=\fIBUG\fR -Mark a Launchpad bug as being fixed by this upload. -.TP -\fB\-f\fR, \fB\-\-force\fR -Force sync over the top of Ubuntu changes. -.TP .B \-d \fIDEBIAN_MIRROR\fR, \fB\-\-debian\-mirror\fR=\fIDEBIAN_MIRROR\fR Use the specified mirror. Should be in the form \fBhttp://ftp.debian.org/debian\fR. @@ -89,13 +113,7 @@ Use the specified Debian security mirror. Should be in the form \fBhttp://archive.ubuntu.com/ubuntu\fR. If the package isn't found on this mirror, \fBsyncpackage\fR will fall back to the default mirror. -.TP -.B \-\-no\-conf -Do not read any configuration files, or configuration from environment -variables. -.TP -.B \-\-simulate -Show what would be done, but don't actually do it. +.\" .SH ENVIRONMENT .TP .BR DEBFULLNAME ", " DEBEMAIL ", " UBUMAIL @@ -108,6 +126,7 @@ All of the \fBCONFIGURATION VARIABLES\fR below are also supported as environment variables. Variables in the environment take precedence to those in configuration files. +.\" .SH CONFIGURATION VARIABLES The following variables can be set in the environment or in .BR ubuntu\-dev\-tools (5) @@ -120,9 +139,11 @@ The default value for \fB\-\-debian\-mirror\fR. .TP .BR SYNCPACKAGE_UBUNTU_MIRROR ", " UBUNTUTOOLS_DEBSEC_MIRROR The default value for \fB\-\-ubuntu\-mirror\fR. +.\" .SH SEE ALSO .BR requestsync (1), .BR ubuntu\-dev\-tools (5) +.\" .SH AUTHOR \fBsyncpackage\fR was written by Martin Pitt and Benjamin Drung . .PP From 90628d7ee7b2bd8af2de49330ed7435a876e3eca Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 01:07:58 +0200 Subject: [PATCH 10/15] Changelog entry --- debian/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/changelog b/debian/changelog index d6b53ca..6872b39 100644 --- a/debian/changelog +++ b/debian/changelog @@ -23,6 +23,7 @@ ubuntu-dev-tools (0.137) UNRELEASED; urgency=low that we only edit the report once, after checking for duplicates. - rm the tmpdir with a little more force (shutil.rmtree) (LP: #899399) * New Tool: ubuntu-upload-permission: Query upload permissions (LP: #876554) + * syncpackage: Support sponsorship for native-syncs, now that LP does. [ Andreas Moog ] * sponsor-patch: Check permission to unsubscribe sponsors-team (LP: #896884) From 198d5a872087b667677dadecd385213b68a73879 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 01:18:24 +0200 Subject: [PATCH 11/15] Correct logic for obtaining email address for --no-lp sponsorship syncs --- syncpackage | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/syncpackage b/syncpackage index ca39b16..72b9970 100755 --- a/syncpackage +++ b/syncpackage @@ -652,12 +652,11 @@ def main(): try: options.uploader_email = sponsoree.preferred_email_address.email except ValueError: - if options.lp: - # Not needed - pass - Logger.error("%s doesn't have a publicly visible e-mail address " - "in LP, please provide one --uploader-email option", - sponsoree.display_name) + if not options.lp: + Logger.error("%s doesn't have a publicly visible e-mail " + "address in LP, please provide one " + "--uploader-email option", sponsoree.display_name) + sys.exit(1) elif options.uploader_email is None: options.uploader_email = ubu_email(export=False)[1] From 73f2273d710731836ad69096131b5c2c6da5b9b6 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 01:19:02 +0200 Subject: [PATCH 12/15] Typo --- syncpackage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syncpackage b/syncpackage index 72b9970..24d483a 100755 --- a/syncpackage +++ b/syncpackage @@ -217,7 +217,7 @@ def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror, cmd += ["-q"] Logger.command(cmd + ['>', '../' + changes_filename]) process = subprocess.Popen(cmd, stdout=subprocess.PIPE) - changes = process.communicate.communicate()[0] + changes = process.communicate()[0] # Add additional bug numbers if len(bugs) > 0: From 81783242663a4b23face4c8b99ae70c05ed93624 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 01:23:06 +0200 Subject: [PATCH 13/15] Make syncpackage print a warning when --no-lp is used --- syncpackage | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/syncpackage b/syncpackage index 24d483a..45c34fe 100755 --- a/syncpackage +++ b/syncpackage @@ -634,6 +634,12 @@ def main(): ubuntu = Launchpad.distributions["ubuntu"] options.release = ubuntu.current_series.name + if not options.fakesync and not options.lp: + Logger.warn("The use of --no-lp is not recommended for uploads " + "targeted at Ubuntu. " + "The archive-admins discourage its use, except for " + "fakesyncs.") + sponsoree = None if options.sponsoree: try: From a55229619e75670c99e68f5179a43bb74927dca6 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 15:46:09 +0200 Subject: [PATCH 14/15] Pass the launchpadlib person object to copyPackages --- ubuntutools/lp/lpapicache.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ubuntutools/lp/lpapicache.py b/ubuntutools/lp/lpapicache.py index 64492d0..dc7764a 100644 --- a/ubuntutools/lp/lpapicache.py +++ b/ubuntutools/lp/lpapicache.py @@ -392,6 +392,9 @@ class Archive(BaseWrapper): will happen sometime later with full checking. ''' + if isinstance(sponsored, PersonTeam): + sponsored = sponsored._lpobject + self._lpobject.copyPackage( source_name=source_name, version=version, From 75c139ace8ca4f057955b9ef43c765101b808b56 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 7 Dec 2011 15:46:21 +0200 Subject: [PATCH 15/15] The parameter is sponsored --- syncpackage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syncpackage b/syncpackage index 45c34fe..31701a3 100755 --- a/syncpackage +++ b/syncpackage @@ -411,7 +411,7 @@ def copy(src_pkg, release, bugs, sponsoree=None, simulate=False, force=False): to_series=ubuntu_series, to_pocket=ubuntu_pocket, include_binaries=False, - sponsoree=sponsoree) + sponsored=sponsoree) except HTTPError, error: Logger.error("HTTP Error %s: %s", error.response.status, error.response.reason)