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
View File

@ -5,8 +5,10 @@ ubuntu-dev-tools (0.120) UNRELEASED; urgency=low
[ Stefano Rivera ]
* 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

View File

@ -17,11 +17,17 @@
pull\-debian\-source \- download and extract a source package from Debian
.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
\fBpull\-debian\-source\fR downloads and extracts the current version of
\fIsource package\fR in the specified Debian \fIrelease\fR.
\fBpull\-debian\-source\fR downloads and extracts the specified
\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
.TP
@ -32,6 +38,9 @@ The source package to download from Debian.
The release to download the source package from. Defaults to
\fBunstable\fR.
.TP
.I version
The specific version of the package to download.
.TP
.BR \-d ", " \-\-download\-only
Do not extract the source package.
.TP

View File

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

View File

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

View File

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