6
from urllib.parse import urlparse, urlunparse
7
from urllib.request import urlopen
8
from urllib.error import HTTPError
11
from aptsources.distro import get_distro
13
(package_name, package_version, src_package) = sys.argv[1:]
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.
21
for version in cache[package_name].versions:
22
if version.version == package_version:
27
raise KeyError("{0}: package version not found".format(package_name))
30
pool_parsed = urlparse(package.uri)
31
distro = get_distro().codename
33
package_dir = "/main/uefi/%s-%s/%s/" % (
34
src_package, package.architecture, package_version)
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)
43
print("Downloading %s ... " % dists_uri, end='')
45
with urlopen(dists_uri) as dists, open(base, "wb") as out:
46
shutil.copyfileobj(dists, out)
47
except HTTPError as e:
57
for base in "flavours", "version":
58
if not download(base):
59
print('download-signed: {0}: not found'.format(base))
62
with open("flavours") as fd:
64
filename = line.rstrip()
66
if not download(filename):
67
print('download-signed: {0}: not found'.format(filename))