Ubuntu Pastebin

Paste from cyphermox at Wed, 17 Feb 2016 13:54:38 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/python
#
# lp-binary-url -- finds the binary package URL from Launchpad
#
# Copyright (C) 2010 Philippe Gauthier <philippe.gauthier@deuxpi.ca>
#
# Based un pull-lp-source
# Copyright (C) 2008 Iain Lane <iain@orangesquash.org.uk>
#
# 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.
# 
# See file /usr/share/common-licenses/GPL for more details.

import commands
import os
import sys

try:
    from ubuntutools.lp.lpapicache import Distribution, Launchpad
    from ubuntutools.lp.udtexceptions import (SeriesNotFoundException,
        PackageNotFoundException, PocketDoesNotExistError)
    from ubuntutools.misc import split_release_pocket, host_architecture
except ImportError:
    print "E: Please install the 'ubuntu-dev-tools' package and rerun this" \
        " script again."
    sys.exit(1)

if len(sys.argv) < 2:
    print "Usage: %s package [release] [arch]" % sys.argv[0]
    sys.exit(1)

Launchpad.login_anonymously()

package = sys.argv[1].lower()
source = commands.getoutput("apt-cache show %s | grep Source:" % package)
if source.startswith("Source:"):
    source = source.split()[1]
    print "W: Source package for '%s' is '%s'." % (package, source)
    package = source

if len(sys.argv) >= 3: # Custom distribution specified.
    release = sys.argv[2].lower()
else:
    release = os.getenv('DIST') or Distribution('ubuntu').getDevelopmentSeries().name

if len(sys.argv) >= 4:
    arch = sys.argv[3]
else:
    arch = host_architecture()

try:
    (release, pocket) = split_release_pocket(release)
except PocketDoesNotExistError, e:
    print 'E: %s' % e
    sys.exit(1)

try:
    spph = Distribution('ubuntu').getArchive().getSourcePackage(package, release, pocket)
except (SeriesNotFoundException, PackageNotFoundException), e:
    print 'E: %s' % e
    sys.exit(1)

for url in spph.binaryFileUrls():
    if url.endswith("_%s.deb" % arch):
        print url
Download as text