From 45f2d5146c7d6511bb082a6a155d5fb177f29c95 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Thu, 3 Jul 2008 17:37:57 +0100 Subject: [PATCH 1/6] Add simple script pull-lp-source to download and extract a source given source package from LP --- pull-lp-source | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 pull-lp-source diff --git a/pull-lp-source b/pull-lp-source new file mode 100755 index 0000000..2f69f9f --- /dev/null +++ b/pull-lp-source @@ -0,0 +1,76 @@ +#!/usr/bin/python +# pull-lp-source -- pull a source package from Launchpad +# Basic usage: pull-lp-source [] +# +# Copyright (C) 2008 Iain Lane, BackportFromLP class taken from +# prevu tool and: +# Copyright (C) 2006 John Dong +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 3 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# TODO: Determine before going to LP whether a source package and distro exist or not. +# TODO: Determine current development distro programatically + +import sys,os + +class BackportFromLP(): + + def __getitem__(self, name): + return getattr(self, name) + + def __init__(self, package, target_distro): + self.package=package + self.target_distro=target_distro + self.__prepare_sources() + def __prepare_sources(self): + # Scrape from Launchpad the source package :) + import re + + contents = os.popen('wget -q https://launchpad.net/ubuntu/%(target_distro)s/+source/%(package)s -O-' % self).read() + links = re.findall('a href=\"(.*\.dsc)\"', contents) + + if len(links) == 1 and (os.system("dget -xu http://launchpad.net%s" % links[0])) == 0: + print 'Success' + else: + raise ValueError, "Failed to fetch and extract source. Ensure that the package specified is a valid source package name and Launchpad is not down." + +default_distro = 'intrepid' + +def usage(): + print 'Usage: %s [distro]' % sys.argv[0] + +if __name__=='__main__': + + args = sys.argv[1:] or [] + + if len(args) >= 1: + package = args[0] + + if len(args) == 2: + distro = args[1] + elif len(args) == 1: + distro=os.getenv('DIST') or default_distro + else: # incorrect args + usage() + sys.exit(1) + + # Correct-ish args, can proceed + try: + print 'Attempting to get %s from distro %s' % (package, distro) + BackportFromLP(package, distro) + except ValueError, e: + print "Error when downloading package %s from distro %s: %s" % (package, distro, e) + From d89e38e42b40197bd4b2cb693de37bf01d9374de Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Thu, 3 Jul 2008 17:38:30 +0100 Subject: [PATCH 2/6] Fix bug when requesting sync of packages with no ubuntu changes - get rid of bug_text variable and now just use the name report all the time. --- requestsync | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requestsync b/requestsync index 4b9f6a0..41f8ff4 100755 --- a/requestsync +++ b/requestsync @@ -419,21 +419,21 @@ if __name__ == '__main__': report += debian_changelog(srcpkg, debiancomponent, base_ver) + '\n' if need_interaction: - (_, bug_text) = edit_report(title, report, changes_required=True) + (_, report) = edit_report(title, report, changes_required=True) # Post sync request using Launchpad interface: srcpkg = not newsource and srcpkg or None if use_lp_bugs: # Map status to the values expected by lp-bugs mapping = {'new': 'New', 'confirmed': 'Confirmed'} - if post_bug(srcpkg, subscribe, mapping[status], title, bug_text): + if post_bug(srcpkg, subscribe, mapping[status], title, report): sys.exit(0) # Abort on error: print 'Something went wrong. No sync request filed.' sys.exit(1) # Mail sync request: - if mail_bug(srcpkg, subscribe, status, title, bug_text, keyid): + if mail_bug(srcpkg, subscribe, status, title, report, keyid): sys.exit(0) print 'Something went wrong. No sync request filed.' From b9270bfb779256d205eac572058748ba3e545626 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Thu, 3 Jul 2008 17:46:45 +0100 Subject: [PATCH 3/6] Update debian/copyright with my information, debian/changelog with my new changes. --- debian/changelog | 8 +++++++- debian/copyright | 9 ++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 69601a2..26305f4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,14 @@ ubuntu-dev-tools (0.32) UNRELEASED; urgency=low + [ Kees Cook ] * [empty changelog for new bzr commits] - -- Kees Cook Fri, 13 Jun 2008 11:55:24 -0700 + [ Iain Lane ] + * Add pull-lp-source: Get source packages from LP to avoid mirror lag. + * requestsync: Fix bug where requestsync would fall over when requesting + sync for package with no local changes. + + -- Iain Lane Thu, 03 Jul 2008 17:44:19 +0100 ubuntu-dev-tools (0.31) intrepid; urgency=low diff --git a/debian/copyright b/debian/copyright index 57f8f62..46a43c3 100644 --- a/debian/copyright +++ b/debian/copyright @@ -18,6 +18,7 @@ Upstream Authors: Soren Hansen Steve Kowalik Terence Simpson + Iain Lane Copyright: @@ -32,6 +33,7 @@ Copyright: (C) 2006-2007, Pete Savage (C) 2007-2008, Siegfried-A. Gevatter (C) 2007, Terence Simpson + (C) 2008, Iain Lane Licenses: @@ -51,8 +53,8 @@ and what-patch are licensed under GPLv2: On Debian systems, the complete text of the GNU General Public License v2 can be found in `/usr/share/common-licenses/GPL-2'. -get-branches, get-build-deps, debian-pull-debdiff, massfile, ppaput and -suspicious-source are licensed under GPLv3: +get-branches, get-build-deps, debian-pull-debdiff, massfile, ppaput, +suspicious-source and pull-lp-source are licensed under GPLv3: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -68,4 +70,5 @@ can be found in `/usr/share/common-licenses/GPL-3'. The following of the scripts can be used, at your option, regarding any later version of the previously specified license: 404main, pbuilder-dist, -dgetlp, reverse-build-depends, suspicious-source and get-build-deps. +dgetlp, reverse-build-depends, suspicious-source, pull-lp-source and +get-build-deps. From d7d19fd41afb80d9470564c9481ceb8c9ba304e2 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Mon, 4 Aug 2008 17:27:37 +0100 Subject: [PATCH 4/6] Take code from requestsync to make massfile work with Firefox 3 cookies --- massfile | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/massfile b/massfile index e927a82..a835e12 100755 --- a/massfile +++ b/massfile @@ -2,11 +2,15 @@ # -*- coding: utf-8 -*- # # (C) Canonical, 2007, GPL v3 +# Authors: +# Iain Lane , taking some code written by: +# Daniel Hahler import os import sys import email import subprocess +import glob import launchpadbugs.connector as Connector @@ -66,7 +70,7 @@ def check_configfiles(): def file_bug(config): Bug = Connector.ConnectBug() - Bug.authentication = os.path.expanduser("~/.lpcookie") + Bug.authentication = cookie try: summary = config["subject"].replace("$pack", config["sourcepackage"]) @@ -85,6 +89,7 @@ def file_bug(config): if tag.strip("\n").strip(): bug.tags.append(tag.strip("\n").strip()) bug.assignee = config["assignee"] + bug.status = "Confirmed" bug.commit() except: "Bug for '%s' was not filed." % config["sourcepackage"] @@ -100,16 +105,38 @@ def read_buglist(url): return packages +def lp_cookie(): + global cookie + cookie = None + + # Search cookiefile (for authentication to lp) + if cookie == None: + try_globs = ('~/.lpcookie.txt', '~/.mozilla/*/*/cookies.sqlite', '~/.mozilla/*/*/cookies.txt') + for try_glob in try_globs: + try: + cookiefile = glob.glob(os.path.expanduser(try_glob))[0] + except IndexError: + continue + # Found: + print "Using cookie file at «%s».\n" % cookiefile + cookie = cookiefile + break + + if cookie == None: + raise RuntimeError('''Could not find cookie file for Launchpad (looked in %s) + You should be able to create a valid file by logging into Launchpad with Firefox''') % ", ".join(try_globs) + def main(): if not check_configfiles(): sys.exit(1) - if not os.path.exists(os.path.expanduser("~/.lpcookie")): - print >> sys.stderr, \ - "Launchpad cookie not found in ~/.lpcookie." + try: + lp_cookie() + except RuntimeError, e: + print e sys.exit(1) - + config = read_config() pack_list = read_list() buglist = read_buglist(config["buglist-url"]) From fe8087a169e8e35d6ccbbe46ed4b1d704a7592fa Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Mon, 4 Aug 2008 18:04:07 +0100 Subject: [PATCH 5/6] Two changes to pbuilder-dist. 1) Use /var/cache/archive/$distro as an apt source if it exists. Useful for making locally-built packages available. 2) Set mirror and components correctly for debian distros. --- pbuilder-dist.new | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pbuilder-dist.new b/pbuilder-dist.new index 0710d95..12fe499 100755 --- a/pbuilder-dist.new +++ b/pbuilder-dist.new @@ -17,6 +17,8 @@ import sys import os +debian_distros = ["etch", "lenny", "sid", "stable", "testing", "unstable"] + class pbuilder_dist: def __init__(self): @@ -182,8 +184,18 @@ class pbuilder_dist: '--logfile "%(logfile)s"' % self, '--aptcache "/var/cache/apt/archives/"', ### --mirror "${ARCHIVE}" \ + '--bindmounts /var/cache/archive/ --override-config' ] + localrepo = '/var/cache/archive/%(target_distro)s' % self + + if os.path.exists(localrepo): + arguments.append('--othermirror "deb file:///var/cache/archive/ %(target_distro)s/"' % self) + + if self.target_distro in debian_distros: + arguments.append('--mirror "ftp://ftp.debian.org/debian"') + arguments.append('--components "main contrib non-free"') + if self.build_architecture != self.system_architecture: arguments.append('--debootstrapopts --arch') arguments.append('--debootstrapopts "%(build_architecture)s"' % self) From 35392e884dbce285d9f625df6f69094f9d703813 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Mon, 4 Aug 2008 18:23:13 +0100 Subject: [PATCH 6/6] Add -h, --help to pull-lp-source. Add pull-lp-source manpage. --- doc/pull-lp-source.1 | 29 +++++++++++++++++++++++++++++ pull-lp-source | 4 ++++ 2 files changed, 33 insertions(+) create mode 100644 doc/pull-lp-source.1 diff --git a/doc/pull-lp-source.1 b/doc/pull-lp-source.1 new file mode 100644 index 0000000..4595486 --- /dev/null +++ b/doc/pull-lp-source.1 @@ -0,0 +1,29 @@ +.TH PULL-LP-SOURCE "1" "4 August 2008" "ubuntu-dev-tools" +.SH NAME +pull-lp-source \- Download a source package from Launchpad +.SH SYNOPSIS +.B pull-lp-source <\fBsource package\fR> [\fItarget release\fR] + +.B pull-lp-source -h +.SH DESCRIPTION +.PP +\fBpull-lp-source\fR downloads and extracts the latest version of +<\fBsource package\fR> from Launchpad. If the optional parameter +[\fItarget release\fR] is specified, the latest version in that release +will be downloaded instead. +.SH OPTIONS +.PP +Listed below are the command line options for requestsync: +.TP +.B \-h, --help +Display a help message and exit. +.TP +.B +This is the source package that you would like to be downloaded from Launchpad. +.TP +.B [target release] +This is the release that you would like the source package to be downloaded from. +This value defaults to the current development release. +.SH AUTHOR +.PP +This manual page was written by Iain Lane diff --git a/pull-lp-source b/pull-lp-source index 2f69f9f..66abad0 100755 --- a/pull-lp-source +++ b/pull-lp-source @@ -56,6 +56,10 @@ if __name__=='__main__': args = sys.argv[1:] or [] + if args == [] or args[0] in ['-h', '--help']: + usage() + sys.exit(0) + if len(args) >= 1: package = args[0]