Merge from trunk

This commit is contained in:
Stefano Rivera 2011-09-03 21:08:52 +02:00
commit c994254e4b
20 changed files with 56 additions and 1008 deletions

18
debian/NEWS vendored
View File

@ -1,3 +1,21 @@
ubuntu-dev-tools (0.129) unstable; urgency=low
Several tools that worked against Launchpad but were not specific to Ubuntu
have been migrated to the "lptools" project.
The following tools have moved:
- get-branches (renamed to lp-get-branches)
- grab-attachments (renamed to lp-grab-attachments)
- lp-project-upload
- lp-list-bugs
- lp-set-dup
- lp-shell
They can now be found in the lptools package (version 0.0.1~bzr28-1 or
later).
-- Jelmer Vernooij <jelmer@debian.org> Fri, 02 Sep 2011 13:43:34 +0200
ubuntu-dev-tools (0.119) unstable; urgency=low
launchpadlib 1.9 will cause some issues, as it uses the GNOME Keyring / KDE

12
debian/changelog vendored
View File

@ -5,12 +5,22 @@ ubuntu-dev-tools (0.129) oneiric; urgency=low
style of operation.
* syncpackage: Require -f/--force option to overwrite Ubuntu changes.
[ Jelmer Vernooij ]
* Remove several tools not specific to Ubuntu that have been migrated to
lptools (LP: #708886):
- get-branches (renamed to lp-get-branches)
- grab-attachments (renamed to lp-grab-attachments)
- lp-project-upload
- lp-list-bugs
- lp-set-dup
- lp-shell
[ Stefano Rivera ]
* syncpackage: Show changes to be synced when performing native syncs.
* syncpackage: Support --bug (extra bugs to be closed by the sync) with
native syncs. (Bugs are closed one individually, via the API, post-sync)
-- Stefano Rivera <stefanor@ubuntu.com> Sat, 03 Sep 2011 21:04:38 +0200
-- Stefano Rivera <stefanor@debian.org> Sat, 03 Sep 2011 21:04:38 +0200
ubuntu-dev-tools (0.128) unstable; urgency=low

7
debian/control vendored
View File

@ -75,21 +75,14 @@ Description: useful tools for Ubuntu developers
- debian-distro-info - provides information about Debian's distributions.
- dgetlp - download a source package from the Launchpad library.
- distro-info - provides information about the distributions' releases.
- get-branches - used to branch/checkout all the bzr branches in a Launchpad
team.
- get-build-deps - install the build dependencies needed for a package
reading debian/control.
- grab-attachments - download all bug attachments from a Launchpad bug
report.
- grab-merge - grabs a merge from merges.ubuntu.com easily.
- grep-merges - search for pending merges from Debian.
- harvest - grabs information about development opportunities from
http://harvest.ubuntu.com
- hugdaylist - compile HugDay lists from bug list URLs.
- import-bug-from-debian - copy a bug from the Debian BTS to Launchpad
- lp-list-bugs - briefly list status of Launchpad bugs.
- lp-project-upload - upload a release tarball to a Launchpad project
- lp-set-dup - sets the "duplicate of" bug of a bug and its dups.
- massfile - fill multiple bugs using a template.
- merge-changelog - manually merges two Debian changelogs with the same base
version.

14
debian/copyright vendored
View File

@ -11,7 +11,6 @@ Files: *
doc/check-symbols.1
doc/requestsync.1
doc/ubuntu-iso.1
lp-shell
requestsync
setup.py
ubuntu-iso
@ -22,7 +21,6 @@ Copyright: 2007, Albert Damen <albrt@gmx.net>
2010, Benjamin Drung <bdrung@ubuntu.com>
2007-2010, Canonical Ltd.
2006-2007, Daniel Holbach <daniel.holbach@ubuntu.com>
2010, Dustin Kirkland <kirkland@ubuntu.com>
2010, Evan Broder <evan@ebroder.net>
2006-2007, Luke Yelavich <themuso@ubuntu.com>
2009-2010, Michael Bienia <geser@ubuntu.com>
@ -47,16 +45,11 @@ Files: 404main
doc/404main.1
doc/dgetlp.1
doc/import-bug-from-debian.1
doc/lp-project-upload.1
doc/lp-set-dup.1
doc/lp-shell.1
doc/pbuilder-dist-simple.1
doc/pbuilder-dist.1
doc/reverse-build-depends.1
doc/submittodebian.1
import-bug-from-debian
lp-project-upload
lp-set-dup
pbuilder-dist
pbuilder-dist-simple
reverse-build-depends
@ -87,8 +80,6 @@ License: GPL-2+
Files: ack-sync
doc/bitesize.1
doc/get-branches.1
doc/grab-attachments.1
doc/grab-merge.1
doc/harvest.1
doc/hugdaylist.1
@ -97,8 +88,6 @@ Files: ack-sync
doc/setup-packaging-environment.1
doc/syncpackage.1
bitesize
get-branches
grab-attachments
grab-merge
harvest
hugdaylist
@ -108,7 +97,6 @@ Files: ack-sync
syncpackage
Copyright: 2010, Benjamin Drung <bdrung@ubuntu.com>
2007-2011, Canonical Ltd.
2010, Dustin Kirkland <kirkland@ubuntu.com>
2008, Jonathan Patrick Davies <jpds@ubuntu.com>
2008-2010, Martin Pitt <martin.pitt@canonical.com>
2009, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
@ -130,14 +118,12 @@ Files: dch-repeat
doc/dch-repeat.1
doc/get-build-deps.1
doc/grep-merges.1
doc/lp-list-bugs.1
doc/mk-sbuild.1
doc/pull-lp-source.1
doc/pull-revu-source.1
doc/ubuntu-build.1
get-build-deps
grep-merges
lp-list-bugs
mk-sbuild
pull-lp-source
pull-revu-source

View File

@ -1,47 +0,0 @@
.TH get\-branches "1" "11 August 2008" "ubuntu-dev-tools"
.SH NAME
get\-branches - downloads all branches related to a Launchpad team or person
.SH SYNOPSIS
.B get\-branches
.RB [ \-d
.IR directory ]
.RB [ \-o
.BR branch | checkout ]
.B \-t
.I team
.br
.B get\-branches
.I team
.br
.B get\-branches \-\-help
.SH DESCRIPTION
\fBget\-branches\fR uses the LP API to get a list of branches for a person or
team and calls Bazaar to download all branches.
.SH OPTIONS
Listed below are the command line options for \fBget\-branches\fR:
.TP
.BR \-h ", " \-\-help
Display a help message and exit.
.TP
.BR \-d ", " \-\-directory
Download branches to a directory other than the current directory.
.TP
.BR \-o ", " \-\-operation
Specifies which Bazaar operation to use when downloading the branches; may be
either \fIbranch\fR or \fIcheckout\fR.
.TP
.BR \-t ", " \-\-team
Specifies which Launchpad team/person to download branches from.
This option is required.
.SH AUTHORS
\fBget\-branches\fR was written by Daniel Holbach <daniel.holbach@ubuntu.com>,
and this manual page was written by Jonathan Patrick Davies <jpds@ubuntu.com>.
.PP
Both are released under the terms of the GNU General Public License, version 3.
.SH SEE ALSO
.B bzr(1)

View File

@ -1,57 +0,0 @@
.TH GRAB\-ATTACHMENTS "1" "10 August 2008" "ubuntu-dev-tools"
.SH NAME
grab\-attachments \- downloads attachments from a Launchpad bug
.SH SYNOPSIS
.B grab\-attachments\fR [\fIoptions\fR] \fIbug-number\fR...
.br
.B grab\-attachments \-h
.SH DESCRIPTION
\fBgrab\-attachments\fR is a script to download all attachments from a
Launchpad bug report or bug reports with a source package task into
a directory named after the bug e.g. bug-1.
.SH OPTIONS
Listed below are the command line options for grab\-attachments:
.TP
.I bug-number
Specifies the Launchpad bug number that the script should download
attachments from.
.TP
.BR \-h ", " \-\-help
Display a help message and exit.
.TP
.B \-l \fIINSTANCE\fR, \fB\-\-lpinstance\fR=\fIINSTANCE\fR
Use the specified instance of Launchpad (e.g. "staging"), instead of
the default of "production".
.TP
.B \-\-no\-conf
Do not read any configuration files, or configuration from environment
variables.
.TP
.BR \-d ", " \-\-duplicates
Download attachments from duplicates too.
.TP
.B \-p \fISRCPACKAGE\fR, \fB\-\-package\fR=\fISRCPACKAGE\fR
Download attachments from all bugs with a task for this source
package.
.SH ENVIRONMENT
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)
configuration files.
In each case, the script\-specific variable takes precedence over the
package\-wide variable.
.TP
.BR GRAB_ATTACHMENTS_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE
The default value for \fB--lpinstance\fR.
.SH SEE ALSO
.BR ubuntu\-dev\-tools (5)
.SH AUTHOR
\fBgrab\-attachments\fR was written by Daniel Holbach and this manual page
was written by Jonathan Patrick Davies.
.PP
Both are released under the GNU General Public License, version 2.

View File

@ -1,27 +0,0 @@
.TH lp\-list\-bugs 1 2010-09-17 ubuntu-dev-tools
.SH NAME
lp\-list\-bugs \- briefly list status of Launchpad bugs
.SH DESCRIPTION
.B lp\-list\-bugs
takes one or more Launchpad bug numbers, and lists the status of each bug in a
concise format.
For example:
.PP
.RS
.nf
$ lp\-list\-bugs 3
Bug 3: Custom information for each translation team
rosetta: Fix Released
ubuntu: Invalid
mono (Ubuntu): Invalid
.fi
.RE
.SH OPTIONS
.TP
.BR \-h ", " \-\-help
Display a help message and exit.
.SH AUTHORS
.B lp\-list\-bugs
and this manual page were written by Colin Watson <cjwatson@ubuntu.com>.
Both are released under the terms of the GNU General Public License, version
3 or later.

View File

@ -1,24 +0,0 @@
.TH lp-project-upload "1" "05 September 2009" "ubuntu-dev-tools"
.SH NAME
lp\-project\-upload \- Upload a release tarball to a Launchpad project.
.SH SYNOPSIS
.B lp\-project\-upload
.I <project name> <version> <tarball> [new milestone] [changelog file] [releasenotes file]
.SH DESCRIPTION
\fBlp\-project\-upload\fR uploads a tarball release of a project to Launchpad.
It can create milestones and releases on the fly after confirmation.
If there is a file \fItarball\fB.asc\fR, it is uploaded as the signature of the
tarball.
You can optionally provide the name of the next milestone, which will be created if specified.
You can optionally provide filename(s) specifying the changelog and release notes entries for this release. Note that these might be /dev/null, if you do not want to provide changelog or release notes information. If these are not specified, an interactive editor will allow you to compose these.
.SH AUTHORS
\fBlp\-project\-upload\fR was written by Martin Pitt <martin.pitt@ubuntu.com> and enhanced by Dustin Kirkland <kirkland@ubuntu.com>.
.PP
It is released under the terms of the GNU General Public License, version 2
or (at your option) any later version.

View File

@ -1,56 +0,0 @@
.TH lp\-set\-dup "1" "March 6 2010" "ubuntu-dev-tools"
.SH NAME
lp\-set\-dup \- mark one or more bugs as duplicate of another bug
.SH SYNOPSIS
.B lp\-set\-dup \fR[\fB\-f\fR] <\fImain bug\fR> <\fIduplicate bug\fR>
[<\fIduplicate bug\fR> ...]
.br
.B lp\-set\-dup \-\-help
.SH DESCRIPTION
\fBlp\-set\-dup\fR allow to easily mark one or more bug as duplicate of
another bug. It checks for permission to operate on a given bug first,
then perform required tasks on Launchpad.
.SH OPTIONS
Listed below are the command line options for \fBlp\-set\-dup\fR:
.TP
.BR \-h ", " \-\-help
Display a help message and exit.
.TP
.B \-f
Skip confirmation prompt.
.TP
.B \-l \fIINSTANCE\fR, \fB\-\-lpinstance\fR=\fIINSTANCE\fR
Use the specified instance of Launchpad (e.g. "staging"), instead of
the default of "production".
.TP
.B \-\-no\-conf
Do not read any configuration files, or configuration from environment
variables.
.SH ENVIRONMENT
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)
configuration files.
In each case, the script\-specific variable takes precedence over the
package\-wide variable.
.TP
.BR LP_SET_DUP_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE
The default value for \fB--lpinstance\fR.
.SH SEE ALSO
.BR ubuntu\-dev\-tools (5)
.SH AUTHORS
\fBlp\-set\-dup\fR was written by Loïc Minier <lool@dooz.org>,
and this manual page was written by Luca Falavigna <dktrkranz@debian.org>.
.PP
Both are released under the terms of the GNU General Public License, version 2.

View File

@ -1,52 +0,0 @@
.TH lp-shell "1" "27 March 2010" "ubuntu-dev-tools"
.SH NAME
lp\-shell \- Open an interactive launchpadlib shell.
.SH SYNOPSIS
.B lp\-shell
.RB [ \-a ]
.RB [ \-\-python ]
.RB [ \-\-ipython ]
.RI [ service ]
.RI [ "LP API version" ]
.SH DESCRIPTION
.B lp\-shell
opens an interactive Python shell with a launchpadlib.Launchpad object "lp"
which is ready for use.
It authenticates against Launchpad with the consumer name "udt-lp-shell". When
using \fBlp\-shell\fR with the \fB\-a\fR option it will use the anonymous login
from launchpadlib.Launchpad.
By default \fBlp\-shell\fR connects to the "\fIproduction\fR" Launchpad service
using the "\fI1.0\fR" LP API version.
If you want to connect to another Launchpad service, call \fBlp\-shell\fR with
the service name as the second argument. \fBlp\-shell\fR supports all services
known by launchpadlib Python module.
Currently known are (list can be incomplete or outdated): "production",
"staging", "dogfood".
A different LP API version can be selected by passing the API version to use as
the third argument. Current supported are: "beta", "1.0" and "devel".
.SH OPTIONS
.TP
.B \-a
Login anonymously into Launchpad.
.TP
.B \-\-ipython
Use an ipython shell if available (default).
.TP
.B \-\-python
Use a regular python shell.
.SH AUTHORS
.B lp\-shell
was written by Martin Pitt <martin.pitt@ubuntu.com>.
.PP
It is released under the terms of the GNU General Public License, version 2
or (at your option) any later version.

View File

@ -72,6 +72,9 @@ 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.
If a sync is blacklisted because of a source tarball mismatch,
\fB\-\-force\fR can be used to override the blacklist, when doing a
local sync (\fB\-\-no\-lp\fR).
.TP
.B \-d \fIDEBIAN_MIRROR\fR, \fB\-\-debian\-mirror\fR=\fIDEBIAN_MIRROR\fR
Use the specified mirror.

View File

@ -1,118 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Canonical Ltd.
# Created by Daniel Holbach <daniel.holbach@ubuntu.com>
# Modified by Jonathan Patrick Davies <jpds@ubuntu.com>
#
# ##################################################################
#
# 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; version 3.
#
# 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.
#
# See file /usr/share/common-licenses/GPL-3 for more details.
#
# ##################################################################
#
# This script is used to checkout or branch all the Bazaar branches
# of a Launchpad team.
#
import os
import sys
from optparse import OptionParser
from ubuntutools.lp.lpapicache import PersonTeam
from ubuntutools import subprocess
def main():
usage = "Usage: %prog [-d <directory>] -t <team> [-o <operation>]"
usage += "\nUsage: %prog <team>"
opt_parser = OptionParser(usage)
# Our options.
opt_parser.add_option("-d", "--directory", action="store", type="string",
dest="directory", default=os.getcwd(),
help="Directory to download branches to.")
opt_parser.add_option("-t", "--team", action="store", type="string",
dest="lpteam",
help="Launchpad team to download branches from.")
opt_parser.add_option("-o", "--operation", action="store", type="string",
dest="operation", default="branch",
help="Whether to branch or checkout the Bazaar "
"branches. May be either 'branch' or "
"'checkout'.")
(options, args) = opt_parser.parse_args()
# Fetch our current directory to return to later.
pwd = os.getcwd()
# Parse our options.
if len(args) != 1 and options.lpteam == None:
opt_parser.error("No team has been specified.")
# Dictionary settings.
directory = options.directory
if not os.path.isdir(directory): # Check that it is a directory.
opt_parser.error("%s is not a valid directory." % directory)
os.chdir(directory)
# Type of Bazaar operation to perform.
operation_type = options.operation.lower()
if operation_type not in ("branch", "checkout"):
opt_parser.error("Invalid operation '%s' for '-o' flag." % \
operation_type)
# Launchpad team setting.
if options.lpteam:
team = options.lpteam.lower()
if args:
team = args[0].lower()
try:
team = PersonTeam(team)
except KeyError:
print >> sys.stderr, "E: The team '%s' doesn't exist." % team
# Get a list of branches
branches = team.getBranches()
print "Downloading all branches for the '%s' team. This may take some " \
"time." % team.display_name
try:
os.makedirs(team.name)
except:
pass
os.chdir(team.name)
for branch in branches:
project_name = branch.project.name
if not os.path.exists(project_name):
os.makedirs(project_name)
os.chdir(project_name)
if not os.path.exists(branch.name):
print "Branching %s ..." % branch.display_name
cmd = ["bzr", operation_type, branch.bzr_identity, branch.name]
subprocess.call(cmd)
else:
print "Merging %s ..." % branch.display_name
os.chdir(branch.name)
subprocess.call(["bzr", "merge", "--pull", "--remember"])
os.chdir(os.path.join(directory, team.name))
os.chdir(pwd)
sys.exit(0)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print "Operation was interrupted by user."

View File

@ -1,107 +0,0 @@
#!/usr/bin/python
#
# Copyright (C) 2007, Canonical Ltd.
# Written by Daniel Holbach,
# Stefano Rivera,
# Brian Murray
#
# ##################################################################
#
# 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; version 3.
#
# 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.
#
# See file /usr/share/common-licenses/GPL-3 for more details.
#
# ##################################################################
from optparse import OptionParser
import errno
import os
import sys
from launchpadlib.launchpad import Launchpad
from ubuntutools.config import UDTConfig
USAGE = "grab-attachments <bug numbers>"
def download_attachments(bug):
bug_folder_name = 'bug-%s' % bug.id
try:
os.mkdir(bug_folder_name)
except OSError, error:
if error.errno == errno.EEXIST:
return
for attachment in bug.attachments:
f = attachment.data.open()
filename = os.path.join(os.getcwd(), bug_folder_name, f.filename)
local_file = open(filename, "w")
local_file.write(f.read())
f.close()
local_file.close()
def main():
parser = OptionParser('Usage: %prog [options] <bug numbers>')
parser.add_option('-l', '--lpinstance', metavar='INSTANCE',
dest='lpinstance', default=None,
help='Launchpad instance to connect to '
'(default: production)')
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('-d', '--duplicates', default=False,
action='store_true',
help='Download attachments from duplicates too')
parser.add_option('-p', '--package',
help='Download attachments from all bugs with a '
'task for this source package')
opts, args = parser.parse_args()
if len(args) < 1 and not opts.package:
parser.error('No bug numbers provided')
config = UDTConfig(opts.no_conf)
if opts.lpinstance is None:
opts.lpinstance = config.get_value('LPINSTANCE')
try:
launchpad = Launchpad.login_with("ubuntu-dev-tools", opts.lpinstance)
if opts.package:
ubuntu = launchpad.projects['ubuntu']
src_package = ubuntu.getSourcePackage(name=opts.package)
if src_package is None:
parser.error('Unable to find package %s' % opts.package)
for task in src_package.searchTasks():
args.append(task.bug.id)
for arg in args:
try:
bug_number = int(arg)
except ValueError:
parser.error("'%s' is not a valid bug number." % arg)
bug = launchpad.bugs[bug_number]
download_attachments(bug)
if opts.duplicates is True:
for bug in bug.duplicates:
download_attachments(bug)
# no LP credentials
except IOError, error:
print error
sys.exit(1)
if __name__ == '__main__':
main()

View File

@ -1,63 +0,0 @@
#! /usr/bin/python
# -*- coding: UTF-8 -*-
"""Briefly list status of Launchpad bugs."""
# Copyright (c) 2010 Canonical Ltd.
#
# lp-set-dup 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, or (at your option) any
# later version.
#
# lp-set-dup 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 lp-set-dup; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# Authors:
# Colin Watson <cjwatson@ubuntu.com>
import sys
from optparse import OptionParser
from launchpadlib.launchpad import Launchpad
from launchpadlib.errors import HTTPError
def main():
usage = "Usage: %prog <bug> [...]"
parser = OptionParser(usage)
args = parser.parse_args()[1]
if len(args) < 1:
parser.error("Need at least one bug number")
try:
launchpad = Launchpad.login_with('ubuntu-dev-tools', 'production')
except Exception, error:
print >> sys.stderr, 'Could not connect to Launchpad:', str(error)
sys.exit(2)
for bugnum in args:
try:
bug = launchpad.bugs[bugnum]
print "Bug %s: %s" % (bugnum, bug.title)
for task in bug.bug_tasks:
print " %s: %s" % (task.bug_target_name, task.status)
except HTTPError, error:
if error.response.status == 401:
print >> sys.stderr, \
("E: Don't have enough permissions to access bug %s" %
bugnum)
print >> sys.stderr, error.content
continue
elif error.response.status == 404:
print >> sys.stderr, "E: Bug %s not found" % bugnum
else:
raise
if __name__ == '__main__':
main()

View File

@ -1,178 +0,0 @@
#!/usr/bin/python
# Copyright (c) 2009 Canonical Ltd.
#
# 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 2, or (at your option) any
# later version.
#
# lp-project-upload 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.
# Authors:
# Martin Pitt <martin.pitt@ubuntu.com>, based on
# http://blog.launchpad.net/api/recipe-for-uploading-files-via-the-api
# Dustin Kirkland <kirkland@ubuntu.com>
# - support files for changelog and release notes
'''Upload a release tarball to a Launchpad project.'''
import datetime
import os
import sys
import tempfile
from launchpadlib.launchpad import Launchpad
from launchpadlib.errors import HTTPError
from ubuntutools import subprocess
def create_release(project, version):
'''Create new release and milestone for LP project.'''
print 'Release %s could not be found for project. Create it? (Y/n)' % \
version
answer = sys.stdin.readline().strip()
if answer.startswith('n'):
sys.exit(0)
n_series = len(project.series)
if n_series == 1:
series = project.series[0]
elif n_series > 1:
msg = 'More than one series exist. Which one would you like to ' \
'upload to? Possible series are (listed as index, name):'
print msg
for idx, serie in enumerate(project.series):
print '\t%i - %s' % (idx, serie.name)
print 'Enter series index: '
answer = sys.stdin.readline().strip()
try:
series = project.series[int(answer)]
except (ValueError, IndexError):
print >> sys.stderr, 'The series index is invalid (%s).' % answer
sys.exit(3)
else:
print "Using series named '%s'" % series.name
else:
print >> sys.stderr, ('Does not support creating releases if no '
'series exists.')
sys.exit(3)
release_date = datetime.date.today().strftime('%Y-%m-%d')
milestone = series.newMilestone(name=version,
date_targeted=release_date)
return milestone.createProductRelease(date_released=release_date)
def edit_file(prefix, description):
(fd, f) = tempfile.mkstemp(prefix=prefix+'.')
os.write(fd, '\n\n#------\n# Please enter the %s here. '
'Lines which start with "#" are ignored.\n' % description)
os.close(fd)
subprocess.call(['sensible-editor', f])
return cat_file(f)
def cat_file(f):
content = ''
for line in open(f):
if line.startswith('#'):
continue
content += line
return content.strip()
def main():
if len(sys.argv) < 4 or len(sys.argv) > 7:
print >> sys.stderr, '''Upload a release tarball to a Launchpad project.
Usage: %s <project name> <version> <tarball> [new milestone] [changelog file] [releasenotes file]''' % sys.argv[0]
sys.exit(1)
new_milestone = None
changelog_file = None
releasenotes_file = None
if len(sys.argv) == 4:
(project, version, tarball) = sys.argv[1:]
elif len(sys.argv) == 5:
(project, version, tarball, new_milestone) = sys.argv[1:]
elif len(sys.argv) == 6:
(project, version, tarball, new_milestone, changelog_file) = sys.argv[1:]
elif len(sys.argv) == 7:
(project, version, tarball, new_milestone, changelog_file, releasenotes_file) = sys.argv[1:]
try:
launchpad = Launchpad.login_with('ubuntu-dev-tools', 'production')
except Exception, error:
print >> sys.stderr, 'Could not connect to Launchpad:', str(error)
sys.exit(2)
try:
# Look up the project using the Launchpad instance.
proj = launchpad.projects[project]
# Find the release in the project's releases collection.
release = None
for rel in proj.releases:
if rel.version == version:
release = rel
break
if not release:
for milestone in proj.all_milestones:
if milestone.name == version:
today = datetime.date.today().strftime('%Y-%m-%d')
release = milestone.createProductRelease(date_released=today)
if not release:
release = create_release(proj, version)
# Get the file contents.
file_content = open(tarball, 'r').read()
# Get the signature, if available.
signature = tarball + '.asc'
if not os.path.exists(signature):
print 'Calling GPG to create tarball signature...'
cmd = ['gpg', '--armor', '--sign', '--detach-sig', tarball]
if subprocess.call(cmd) != 0:
print >> sys.stderr, 'gpg failed, aborting'
if os.path.exists(signature):
signature_content = open(signature, 'r').read()
else:
signature_content = None
# Create a new product release file.
filename = os.path.basename(tarball)
release.add_file(filename=filename, description='release tarball',
file_content=file_content, content_type='appplication/x-gzip',
file_type='Code Release Tarball', signature_filename=signature,
signature_content=signature_content)
if changelog_file is not None:
changelog = cat_file(changelog_file)
else:
changelog = edit_file('changelog', 'changelog')
if changelog:
release.changelog = changelog
if releasenotes_file is not None:
release_notes = cat_file(releasenotes_file)
else:
release_notes = edit_file('releasenotes', 'release notes')
if release_notes:
release.release_notes = release_notes
release.lp_save()
# Create a new milestone if requested
if new_milestone is not None:
mil = release.milestone
for series in proj.series:
if mil.name in [milestone.name for milestone in series.all_milestones]:
series.newMilestone(name=new_milestone)
except HTTPError, error:
print 'An error happened in the upload:', error.content
sys.exit(1)
if __name__ == '__main__':
main()

View File

@ -1,134 +0,0 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""Sets the "duplicate of" bug of a bug and its dups."""
# Copyright (c) 2009 Canonical Ltd.
#
# lp-set-dup 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 2, or (at your option) any
# later version.
#
# lp-set-dup 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 lp-set-dup; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# Authors:
# Loïc Minier <lool@dooz.org>
import sys
from optparse import OptionParser
from launchpadlib.launchpad import Launchpad
from launchpadlib.errors import HTTPError
from ubuntutools.config import UDTConfig
def die(message):
print >> sys.stderr, "Fatal: " + message
sys.exit(1)
def main():
usage = "Usage: %prog [-f] <new main bug> <bug to dup> [<bug to dup>...]"
opt_parser = OptionParser(usage)
opt_parser.add_option("-f",
help="Skip confirmation prompt",
dest="force", default=False, action="store_true")
opt_parser.add_option("-l", "--lpinstance", metavar="INSTANCE",
help="Launchpad instance to connect to "
"(default: production)",
dest="lpinstance", default=None)
opt_parser.add_option("--no-conf",
help="Don't read config files or "
"environment variables.",
dest="no_conf", default=False, action="store_true")
(options, args) = opt_parser.parse_args()
if len(args) < 2:
opt_parser.error("Need at least a new main bug and a bug to dup")
config = UDTConfig(options.no_conf)
if options.lpinstance is None:
options.lpinstance = config.get_value("LPINSTANCE")
launchpad = None
try:
print "Setting up Launchpad"
launchpad = Launchpad.login_with("ubuntu-dev-tools", options.lpinstance)
print "Launchpad setup complete"
except ImportError:
suggestion = "check whether python-launchpadlib is installed"
if launchpad is None:
die("Couldn't setup Launchpad for the ubuntu-dev-tools consumer; %s" % \
(suggestion, ))
# check that the new main bug isn't a duplicate
try:
new_main_bug = launchpad.bugs[args[0]]
except HTTPError, error:
if error.response.status == 401:
print >> sys.stderr, ("E: Don't have enough permissions to access "
"bug %s") % (args[0])
die(error.content)
else:
raise
new_main_dup_of = new_main_bug.duplicate_of
if new_main_dup_of is not None:
answer = None
try:
answer = raw_input("Bug %s is a duplicate of %s; would you like to "
"use %s as the new main bug instead? [y/N]" % \
(new_main_bug.id, new_main_dup_of.id,
new_main_dup_of.id))
except:
die("Aborted")
if answer.lower() not in ("y", "yes"):
die("User aborted")
new_main_bug = new_main_dup_of
# build list of bugs to process, first the dups then the bug
bugs_to_process = []
for bug_number in args[1:]:
print "Processing %s" % (bug_number)
try:
bug = launchpad.bugs[bug_number]
except HTTPError, error:
if error.response.status == 401:
print >> sys.stderr, ("W: Don't have enough permissions to "
"access bug %s") % (bug_number)
print >> sys.stderr, "W: %s" % (error.content)
continue
else:
raise
dups = bug.duplicates
if dups is not None:
bugs_to_process.extend(dups)
print "Found %i dups for %s" % (len(dups), bug_number)
bugs_to_process.append(bug)
# process dups first, then their main bug
print "Would set the following bugs as duplicates of %s: %s" % \
(new_main_bug.id, " ".join([str(b.id) for b in bugs_to_process]))
if not options.force:
answer = None
try:
answer = raw_input("Proceed? [y/N]")
except:
die("Aborted")
if answer.lower() not in ("y", "yes"):
die("User aborted")
for bug in bugs_to_process:
print "Marking bug %s as a duplicate of %s" % (bug.id, new_main_bug.id)
bug.duplicate_of = new_main_bug
bug.lp_save()
if __name__ == '__main__':
main()

112
lp-shell
View File

@ -1,112 +0,0 @@
#!/usr/bin/python
# Open an interactive launchpadlib Python shell.
# It supports all known LP service instances and API versions. The login
# can optionally happen anonymously.
# Author: Martin Pitt <martin.pitt@ubuntu.com>
# Copyright: (C) 2010 Canonical Ltd.
#
# This package 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, at version 2.
#
# This package 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.
import sys
import code
from optparse import OptionParser
from launchpadlib.launchpad import Launchpad
from launchpadlib.uris import lookup_service_root
def main():
instance = 'production'
valid_api_versions = ('beta', '1.0', 'devel')
api_version = '1.0'
usage = 'Usage: %prog [-a] [instance] [LP API version]'
opt_parser = OptionParser(usage)
opt_parser.add_option('-a', action='store_true',
dest='anonymous', default=False,
help='Login anonymously into LP.')
opt_parser.add_option('--ipython', action='store_const',
dest='shell', const='ipython', default="ipython",
help='Use ipython shell (default).')
opt_parser.add_option('--python', action='store_const',
dest='shell', const='python',
help='Use python shell.')
(options, args) = opt_parser.parse_args()
if len(args) >= 1:
try:
instance = lookup_service_root(args[0])
except ValueError, err:
print 'E: %s' % (err)
print 'I: Falling back to "production".'
if len(args) >= 2:
if args[1] in valid_api_versions:
api_version = args[1]
else:
print 'E: "%s" is not a valid LP API version.' % (args[1])
print 'I: Falling back to "1.0".'
if options.anonymous:
launchpad = Launchpad.login_anonymously('udt-lp-shell', instance,
version=api_version)
banner = ('Connected anonymously to LP service "%s" with API version '
'"%s":' % (instance, api_version))
else:
launchpad = Launchpad.login_with('udt-lp-shell', instance,
version=api_version)
banner = 'Connected to LP service "%s" with API version "%s":' % \
(instance, api_version)
banner += '\nNote: LP can be accessed through the "lp" object.'
sh = None
if options.shell == "ipython":
try:
try: # ipython >= 0.11
from IPython.frontend.terminal.embed import InteractiveShellEmbed
sh = InteractiveShellEmbed(banner2=banner, user_ns={'lp': launchpad})
except ImportError: # ipython < 0.11
# pylint does not handle nested try-except, disable import error
# pylint: disable-msg=E0611
from IPython.Shell import IPShellEmbed
sh = IPShellEmbed(argv=[], user_ns={'lp': launchpad})
sh.set_banner(sh.IP.BANNER + '\n' + banner)
sh.excepthook = sys.__excepthook__
except ImportError:
print "E: ipython not available. Using normal python shell."
if sh:
sh()
else:
class CompleterConsole(code.InteractiveConsole):
def __init__(self):
local = {'lp': launchpad}
code.InteractiveConsole.__init__(self, locals=local)
try:
import readline
except ImportError:
print 'I: readline module not available.'
else:
import rlcompleter
readline.parse_and_bind("tab: complete")
# Disable default apport hook, as lp-shell is intended for interactive use
# and thus exceptions often bubble up to the top level.
sys.excepthook = sys.__excepthook__
console = CompleterConsole()
console.interact(banner)
if __name__ == '__main__':
main()

View File

@ -20,18 +20,12 @@ scripts = ['404main',
'check-symbols',
'dch-repeat',
'dgetlp',
'get-branches',
'get-build-deps',
'grab-attachments',
'grab-merge',
'grep-merges',
'harvest',
'hugdaylist',
'import-bug-from-debian',
'lp-list-bugs',
'lp-project-upload',
'lp-set-dup',
'lp-shell',
'massfile',
'merge-changelog',
'mk-sbuild',

View File

@ -28,7 +28,6 @@ import shutil
import sys
import urllib
import debian.deb822
import debian.debian_support
from devscripts.logger import Logger
from lazr.restfulclient.errors import HTTPError
@ -407,6 +406,19 @@ def is_blacklisted(query):
Returns True or a string of all relevant comments if blacklisted,
False if not
"""
# LP:
# TODO: Refactor when LP: #833080 is fixed
series = Launchpad.distributions['ubuntu'].current_series
diffs = series.getDifferencesTo(source_package_name_filter=query,
status='Needs attention')
if len(diffs) == 0:
comments = series.getDifferenceComments(source_package_name=query)
comment = '; '.join(c.body_text for c in comments)
if comment:
return comment
return True
# Old blacklist:
url = 'http://people.canonical.com/~ubuntu-archive/sync-blacklist.txt'
with codecs.EncodedFile(urllib.urlopen(url), 'UTF-8') as f:
applicable_comments = []
@ -500,7 +512,8 @@ def main():
"upload.")
parser.add_option("-f", "--force",
dest="force", action="store_true", default=False,
help="Force sync over the top of Ubuntu changes.")
help="Force sync over the top of Ubuntu changes "
"or a fake-sync when blacklisted.")
parser.add_option('-D', '--debian-mirror', metavar='DEBIAN_MIRROR',
dest='debian_mirror',
help='Preferred Debian mirror '
@ -580,7 +593,15 @@ def main():
Logger.error("Source package is blacklisted")
if isinstance(blacklisted, basestring):
Logger.error(u"Reason: %s", blacklisted)
sys.exit(1)
Logger.error("If you think this package shouldn't be blacklisted, "
"please file a bug explaining your reasoning and "
"subscribe ~ubuntu-archive.")
if options.force and not options.lp:
Logger.warn(u"Forcing fake-sync, overriding blacklist.")
else:
Logger.error("--force and --no-lp are required to override the "
"blacklist, if this package needs a fakesync.")
sys.exit(1)
if options.lp:
copy(src_pkg, options.release, options.bugs, options.simulate,

View File

@ -29,8 +29,6 @@ BLACKLIST = {
'check-symbols': 'No Help',
'get-build-deps': 'No Help, runs sudo',
'grep-merges': 'No Help',
'lp-project-upload': 'Returns non-zero after help. '
'Leaving u-d-t in LP: #524680',
'pbuilder-dist-simple': 'No Help',
'setup-packaging-environment': 'Throws Error',
'submittodebian': 'No Help',