~ubuntu-branches/ubuntu/natty/ubuntu-dev-tools/natty

« back to all changes in this revision

Viewing changes to pull-debian-source

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Rivera, Felix Geyer, Stefano Rivera, Julian Taylor, Benjamin Drung
  • Date: 2011-03-12 22:07:47 UTC
  • Revision ID: james.westby@ubuntu.com-20110312220747-3047m3rilq3jva3y
Tags: 0.120
[ Felix Geyer ]
* pull-lp-source.1: Document -d option.

[ Stefano Rivera ]
* ubuntutools.archive: Filter rmadison results. (LP: #710579)
  - Canonicalise suites (use code-names) before passing them to rmadison.
* pull-{lp,debian}-source: Download requested versions, as well as simply
  the latest version in a release.
* pull-{lp,debian}-source, pull-debian-debdiff: Catch KeyboardInterrupt.
  (LP: #713845)
* pull-debian-source: Handle -p-u and -security suites.
* Bump X-Python-Version to >= 2.6, now that python-launchpadlib no longer
  supports Python 2.5.

[ Julian Taylor ]
* add support for cowbuilder and cowbuilder-dist in builder.py
  - allows use in sponsor-patch and backportpackage (LP: #728751)

[ Benjamin Drung ]
* data/ubuntu.csv: Add Oneiric Ocelot to the list of know releases.
* ubuntutools.distro_info: Fix TypeError crash and add a test case to
  catch regressions (LP: #731398).

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from ubuntutools.archive import DebianSourcePackage, DownloadError, rmadison
23
23
from ubuntutools.config import UDTConfig
 
24
from ubuntutools.distro_info import DebianDistroInfo
24
25
from ubuntutools.logger import Logger
25
26
 
 
27
def is_suite(version):
 
28
    """If version could be considered to be a Debian suite, return the
 
29
    canonical suite name. Otherwise None
 
30
    """
 
31
    debian_info = DebianDistroInfo()
 
32
    debian_releases = debian_info.all + ['experimental']
 
33
 
 
34
    if '-' in version:
 
35
        release, pocket = version.split('-', 1)
 
36
        release = debian_info.codename(release, default=release)
 
37
        if release in debian_releases:
 
38
            if pocket in ('proposed-updates', 'p-u'):
 
39
                return (release + '-proposed-updates')
 
40
            elif pocket == 'security':
 
41
                return (release + '-security')
 
42
    else:
 
43
        release = debian_info.codename(version, default=version)
 
44
        if release in debian_releases:
 
45
            return release
 
46
    return None
 
47
 
26
48
def main():
27
 
    usage = 'Usage: %prog <package> [release]'
 
49
    usage = 'Usage: %prog <package> [release|version]'
28
50
    parser = optparse.OptionParser(usage)
29
51
    parser.add_option('-d', '--download-only',
30
52
                      dest='download_only', default=False, action='store_true',
31
53
                      help='Do not extract the source package')
32
 
    parser.add_option('-m', '--mirror', metavar='UBUNTU_MIRROR',
 
54
    parser.add_option('-m', '--mirror', metavar='DEBIAN_MIRROR',
33
55
                      dest='debian_mirror',
34
56
                      help='Preferred Debian mirror (default: %s)'
35
57
                           % UDTConfig.defaults['DEBIAN_MIRROR'])
55
77
 
56
78
    package = args[0].lower()
57
79
 
58
 
    if len(args) > 1:
59
 
        suite = args[1].lower()
60
 
    else:
61
 
        suite = 'unstable'
62
 
 
63
 
    line = list(rmadison('debian', package, suite, 'source'))
64
 
    if not line:
65
 
        Logger.error('Unable to find %s in %s.', package, suite)
66
 
        sys.exit(1)
67
 
 
68
 
    line = line[-1]
69
 
    srcpkg = DebianSourcePackage(package, line['version'],
70
 
                                 component=line['component'],
 
80
    version = args[1] if len(args) > 1 else 'unstable'
 
81
    component = None
 
82
 
 
83
    suite = is_suite(version)
 
84
    if suite is not None:
 
85
        line = list(rmadison('debian', package, suite, 'source'))
 
86
        if not line:
 
87
            Logger.error('Unable to find %s in Debian suite "%s".', package,
 
88
                         suite)
 
89
            sys.exit(1)
 
90
        line = line[-1]
 
91
        version = line['version']
 
92
        component = line['component']
 
93
 
 
94
    Logger.normal('Downloading %s version %s', package, version)
 
95
    srcpkg = DebianSourcePackage(package, version, component=component,
71
96
                                 mirrors=[options.debian_mirror,
72
97
                                          options.debsec_mirror])
73
98
    try:
79
104
        srcpkg.unpack()
80
105
 
81
106
if __name__ == '__main__':
82
 
    main()
 
107
    try:
 
108
        main()
 
109
    except KeyboardInterrupt:
 
110
        Logger.normal('User abort.')