3
0
mirror of https://git.launchpad.net/ubuntu-dev-tools synced 2025-03-13 08:01:09 +00:00

pull-{lp,debian}-source: Download requested versions, as well as simply

the latest version in a release.
This commit is contained in:
Stefano Rivera 2011-03-05 00:48:58 +02:00
parent a93078cb32
commit c8a854cc4a
5 changed files with 69 additions and 43 deletions

4
debian/changelog vendored

@ -5,8 +5,10 @@ ubuntu-dev-tools (0.120) UNRELEASED; urgency=low
[ Stefano Rivera ] [ Stefano Rivera ]
* ubuntutools.archive: Filter rmadison results. (LP: #710579) * ubuntutools.archive: Filter rmadison results. (LP: #710579)
* pull-{lp,debian}-source: Download requested versions, as well as simply
the latest version in a release.
-- Stefano Rivera <stefanor@debian.org> Wed, 02 Mar 2011 12:34:04 +0200 -- Stefano Rivera <stefanor@debian.org> Sat, 05 Mar 2011 00:47:57 +0200
ubuntu-dev-tools (0.119) unstable; urgency=low ubuntu-dev-tools (0.119) unstable; urgency=low

@ -17,11 +17,17 @@
pull\-debian\-source \- download and extract a source package from Debian pull\-debian\-source \- download and extract a source package from Debian
.SH SYNOPSIS .SH SYNOPSIS
.B pull\-debian\-source \fR[\fIoptions\fR] <\fIsource package\fR> [\fIrelease\fR] .B pull\-debian\-source \fR[\fIoptions\fR] <\fIsource package\fR>
[\fIrelease\fR|\fIversion\fR]
.SH DESCRIPTION .SH DESCRIPTION
\fBpull\-debian\-source\fR downloads and extracts the current version of \fBpull\-debian\-source\fR downloads and extracts the specified
\fIsource package\fR in the specified Debian \fIrelease\fR. \fIversion\fR of \fIsource package\fR, or the latest version in the
specified Debian \fIrelease\fR.
.P
\fBpull\-debian\-source\fR will try the preferred mirror, default
mirror, security mirror, and fall back to \fBLaunchpad\fR or
\fBsnapshot.debian.org\fR, in search of the requested version.
.SH OPTIONS .SH OPTIONS
.TP .TP
@ -32,6 +38,9 @@ The source package to download from Debian.
The release to download the source package from. Defaults to The release to download the source package from. Defaults to
\fBunstable\fR. \fBunstable\fR.
.TP .TP
.I version
The specific version of the package to download.
.TP
.BR \-d ", " \-\-download\-only .BR \-d ", " \-\-download\-only
Do not extract the source package. Do not extract the source package.
.TP .TP

@ -4,21 +4,26 @@
pull\-lp\-source \- download a source package from Launchpad pull\-lp\-source \- download a source package from Launchpad
.SH SYNOPSIS .SH SYNOPSIS
.B pull\-lp\-source \fR[\fIoptions\fR]\fB <\fBsource package\fR> [\fItarget release\fR] .B pull\-lp\-source \fR[\fIoptions\fR]\fB \fBsource package\fR
[\fIrelease\fR|\fIversion\fR]
.SH DESCRIPTION .SH DESCRIPTION
\fBpull\-lp\-source\fR downloads and extracts the latest version of \fBpull\-lp\-source\fR downloads and extracts the specified
<\fBsource package\fR> from Launchpad. \fIversion\fR of <\fBsource package\fR> from Launchpad, or the latest
If the optional parameter [\fItarget release\fR] is specified, the latest version of the specified \fIrelease\fR.
version in that release will be downloaded instead. If no \fIversion\fR or \fIrelease\fR is specified, the latest version in
the development release will be downloaded.
.SH OPTIONS .SH OPTIONS
Listed below are the command line options for pull\-lp\-source: Listed below are the command line options for pull\-lp\-source:
.TP .TP
.B <source package> .B source package
This is the source package that you would like to be downloaded from Launchpad. This is the source package that you would like to be downloaded from Launchpad.
.TP .TP
.B [target release] .B version
This is the version of the source package to be downloaded.
.TP
.B release
This is the release that you would like the source package to be downloaded from. This is the release that you would like the source package to be downloaded from.
This value defaults to the current development release. This value defaults to the current development release.
.TP .TP

@ -21,10 +21,11 @@ import sys
from ubuntutools.archive import DebianSourcePackage, DownloadError, rmadison from ubuntutools.archive import DebianSourcePackage, DownloadError, rmadison
from ubuntutools.config import UDTConfig from ubuntutools.config import UDTConfig
from ubuntutools.distro_info import DebianDistroInfo
from ubuntutools.logger import Logger from ubuntutools.logger import Logger
def main(): def main():
usage = 'Usage: %prog <package> [release]' usage = 'Usage: %prog <package> [release|version]'
parser = optparse.OptionParser(usage) parser = optparse.OptionParser(usage)
parser.add_option('-d', '--download-only', parser.add_option('-d', '--download-only',
dest='download_only', default=False, action='store_true', dest='download_only', default=False, action='store_true',
@ -55,19 +56,22 @@ def main():
package = args[0].lower() package = args[0].lower()
if len(args) > 1: version = args[1] if len(args) > 1 else 'unstable'
suite = args[1].lower() component = None
else:
suite = 'unstable'
line = list(rmadison('debian', package, suite, 'source')) debian_info = DebianDistroInfo()
if not line: if version in debian_info.all or debian_info.codename(version) is not None:
Logger.error('Unable to find %s in %s.', package, suite) suite = version
sys.exit(1) line = list(rmadison('debian', package, suite, 'source'))
if not line:
Logger.error('Unable to find %s in Debian suite "%s".', package, suite)
sys.exit(1)
line = line[-1]
version = line['version']
component = line['component']
line = line[-1] Logger.normal('Downloading %s version %s', package, version)
srcpkg = DebianSourcePackage(package, line['version'], srcpkg = DebianSourcePackage(package, version, component=component,
component=line['component'],
mirrors=[options.debian_mirror, mirrors=[options.debian_mirror,
options.debsec_mirror]) options.debsec_mirror])
try: try:

@ -29,6 +29,7 @@ from optparse import OptionParser
from ubuntutools.archive import UbuntuSourcePackage, DownloadError from ubuntutools.archive import UbuntuSourcePackage, DownloadError
from ubuntutools.config import UDTConfig from ubuntutools.config import UDTConfig
from ubuntutools.distro_info import UbuntuDistroInfo
from ubuntutools.logger import Logger from ubuntutools.logger import Logger
from ubuntutools.lp.lpapicache import Distribution, Launchpad from ubuntutools.lp.lpapicache import Distribution, Launchpad
from ubuntutools.lp.udtexceptions import (SeriesNotFoundException, from ubuntutools.lp.udtexceptions import (SeriesNotFoundException,
@ -37,7 +38,7 @@ from ubuntutools.lp.udtexceptions import (SeriesNotFoundException,
from ubuntutools.misc import split_release_pocket from ubuntutools.misc import split_release_pocket
def main(): def main():
usage = "Usage: %prog <package> [release]" usage = "Usage: %prog <package> [release|version]"
opt_parser = OptionParser(usage) opt_parser = OptionParser(usage)
opt_parser.add_option('-d', '--download-only', opt_parser.add_option('-d', '--download-only',
dest='download_only', default=False, dest='download_only', default=False,
@ -63,28 +64,33 @@ def main():
package = str(args[0]).lower() package = str(args[0]).lower()
if len(args) >= 2: # Custom distribution specified. ubuntu_info = UbuntuDistroInfo()
release = str(args[1]).lower() if len(args) > 1: # Custom distribution specified.
version = str(args[1])
else: else:
release = os.getenv('DIST') or (Distribution('ubuntu') version = os.getenv('DIST') or ubuntu_info.devel()
.getDevelopmentSeries().name) component = None
try: # Release, not package version number:
(release, pocket) = split_release_pocket(release) if version.split('-', 1)[0] in ubuntu_info.all:
except PocketDoesNotExistError, e: release = version
Logger.error(str(e)) try:
sys.exit(1) (release, pocket) = split_release_pocket(release)
except PocketDoesNotExistError, e:
Logger.error(str(e))
sys.exit(1)
try:
spph = Distribution('ubuntu').getArchive().getSourcePackage(package,
release,
pocket)
except (SeriesNotFoundException, PackageNotFoundException), e:
Logger.error(str(e))
sys.exit(1)
version = spph.getVersion()
component = spph.getComponent()
try: Logger.normal('Downloading %s version %s', package, version)
spph = Distribution('ubuntu').getArchive().getSourcePackage(package, srcpkg = UbuntuSourcePackage(package, version, component=component,
release,
pocket)
except (SeriesNotFoundException, PackageNotFoundException), e:
Logger.error(str(e))
sys.exit(1)
srcpkg = UbuntuSourcePackage(package, spph.getVersion(),
component=spph.getComponent(),
mirrors=[options.ubuntu_mirror]) mirrors=[options.ubuntu_mirror])
try: try:
srcpkg.pull() srcpkg.pull()