~ubuntu-branches/ubuntu/wily/linux-ti-omap4/wily

« back to all changes in this revision

Viewing changes to tmp/ubuntu-quantal-signed/download-signed

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2013-07-11 18:35:20 UTC
  • Revision ID: package-import@ubuntu.com-20130711183520-htnf1x4y5r11hndr
Tags: 3.5.0-229.42
* Release Tracking Bug
  - LP: #1199276

[ Paolo Pisati ]

* [Config] CONFIG_ATH9K_LEGACY_RATE_CONTROL is not set

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/python3
 
2
 
 
3
import sys
 
4
import re
 
5
import shutil
 
6
from urllib.parse import urlparse, urlunparse
 
7
from urllib.request import urlopen
 
8
from urllib.error import HTTPError
 
9
 
 
10
import apt
 
11
from aptsources.distro import get_distro
 
12
 
 
13
(package_name, package_version, src_package) = sys.argv[1:]
 
14
 
 
15
# Find the package in the available archive repositories.  Use a _binary_
 
16
# package name and version to locate the appropriate archive.  Then use the
 
17
# URI there to look for and find the appropriate binary.
 
18
cache = apt.Cache()
 
19
 
 
20
package = None
 
21
for version in cache[package_name].versions:
 
22
    if version.version == package_version:
 
23
        package = version
 
24
        break
 
25
 
 
26
if not package:
 
27
    raise KeyError("{0}: package version not found".format(package_name))
 
28
 
 
29
 
 
30
pool_parsed = urlparse(package.uri)
 
31
distro = get_distro().codename
 
32
#distro = 'quantal'
 
33
package_dir = "/main/uefi/%s-%s/%s/" % (
 
34
    src_package, package.architecture, package_version)
 
35
 
 
36
def download(base):
 
37
    for pocket in ('-proposed', '-updates', '-security', '', '-backports'):
 
38
        dists_parsed = list(pool_parsed)
 
39
        dists_parsed[2] = re.sub(r"/pool/.*", "/dists/" + distro + \
 
40
            pocket + package_dir + base, dists_parsed[2])
 
41
        dists_uri = urlunparse(dists_parsed)
 
42
 
 
43
        print("Downloading %s ... " % dists_uri, end='')
 
44
        try:
 
45
            with urlopen(dists_uri) as dists, open(base, "wb") as out:
 
46
                shutil.copyfileobj(dists, out)
 
47
        except HTTPError as e:
 
48
            if e.code == 404:
 
49
                print("not found")
 
50
                continue
 
51
            raise
 
52
        else:
 
53
            print("found")
 
54
            return True
 
55
    return False
 
56
    
 
57
for base in "flavours", "version":
 
58
    if not download(base):
 
59
        print('download-signed: {0}: not found'.format(base))
 
60
        sys.exit(1)
 
61
 
 
62
with open("flavours") as fd:
 
63
    for line in fd:
 
64
        filename = line.rstrip()
 
65
        filename += '.signed'
 
66
        if not download(filename):
 
67
            print('download-signed: {0}: not found'.format(filename))
 
68
            sys.exit(1)