Merge ~ximion/germinate:wip/split-arch-all into germinate:master

Proposed by Matthias Klumpp
Status: Needs review
Proposed branch: ~ximion/germinate:wip/split-arch-all
Merge into: germinate:master
Diff against target: 88 lines (+59/-0)
1 file modified
germinate/archive.py (+59/-0)
Reviewer Review Type Date Requested Status
Colin Watson Pending
Review via email: mp+444522@code.launchpad.net

Description of the change

Hi!

In PureOS we are using the "modern" split-arch:all archive layout, where arch:all packages are not duplicated in each arch:any Packages file, but are downloaded separately. (see https://repo.pureos.net/pureos/dists/ )
This layout is described in https://wiki.debian.org/DebianRepository/Format and may, in the far future, be also used exclusively by Debian.

Anything using APT directory supports it, but unfortunately Germinator did not. This patch changes that.
I hope it is acceptable, the code stripping the PGP signature from the InRelease file does not make me happy, but we need to read that file in order to make sure we get compatibility with split-arch:all and non-split-arch:all repositories.

Thank you for considering this change!
Cheers,
    Matthias

To post a comment you must log in.

Unmerged commits

b711d73... by Matthias Klumpp

Implement support for repositories using split arch:all

This change implements support for modern APT repository layouts that
have arch:all packages split into a separate Packages file, and not
merged with the arch:any Packages file.

This is described in
https://wiki.debian.org/DebianRepository/Format#No-Support-for-Architecture-all

Failed
[FAILED] test:0 (build)
11 of 1 result

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/germinate/archive.py b/germinate/archive.py
2index efb5e72..e45f79c 100644
3--- a/germinate/archive.py
4+++ b/germinate/archive.py
5@@ -108,6 +108,51 @@ class TagFile(Archive):
6 self._source_mirrors = mirrors
7 self._cleanup = cleanup
8
9+ def _uses_split_arch_all(self, dist):
10+ """Check if the archive supports & defaults to split arch:all.
11+
12+ See https://wiki.debian.org/DebianRepository/Format
13+ for details."""
14+
15+ for mirror in self._mirrors:
16+ url = (mirror + "dists/" + dist + "/InRelease")
17+ req = Request(url)
18+
19+ if get_request_type(req) == "file":
20+ if not os.path.exists(url):
21+ # no Inrelease file found, assume split arch:all
22+ # is not supported.
23+ return False
24+
25+ with closing(urlopen(req)) as url_f:
26+ text_lines = []
27+ parse_state = -1
28+ for line in url_f:
29+ if parse_state == -1:
30+ if line.startswith(b"-----"):
31+ parse_state = 0
32+ continue
33+ else:
34+ parse_state = 1
35+ if parse_state < 1 and not line.strip():
36+ parse_state = 1
37+ continue
38+ if line.startswith(b"-----"):
39+ break
40+ if parse_state == 1:
41+ text_lines.append(str(line, "utf-8"))
42+
43+ section = apt_pkg.TagSection(''.join(text_lines))
44+ if "all" in section["Architectures"].split(" "):
45+ no_archall_support = section.get(
46+ "No-Support-for-Architecture-all", "").split(" ")
47+ if "Packages" in no_archall_support:
48+ return False
49+ else:
50+ return True
51+ return False
52+ return False
53+
54 def _open_tag_files(self, mirrors, dirname, tagfile_type,
55 dist, component, ftppath):
56 def _open_tag_file(mirror, suffix):
57@@ -220,10 +265,18 @@ class TagFile(Archive):
58
59 try:
60 for dist in self._dists:
61+ uses_split_arch_all = self._uses_split_arch_all(dist)
62+ if uses_split_arch_all:
63+ print("[note] Suite %s uses split arch:all layout." % dist)
64+
65 for component in self._components:
66 packages = self._open_tag_files(
67 self._mirrors, dirname, "Packages", dist, component,
68 "binary-" + self._arch + "/Packages")
69+ if uses_split_arch_all:
70+ packages.extend(self._open_tag_files(
71+ self._mirrors, dirname, "Packages_all", dist,
72+ component, "binary-all" + "/Packages"))
73 for tag_file in packages:
74 try:
75 for section in apt_pkg.TagFile(tag_file):
76@@ -249,6 +302,12 @@ class TagFile(Archive):
77 dist, component,
78 "debian-installer/binary-" + self._arch +
79 "/Packages")
80+ if uses_split_arch_all:
81+ instpackages.extend(self._open_tag_files(
82+ self._mirrors, dirname,
83+ "InstallerPackages_all", dist, component,
84+ "debian-installer/binary-all" +
85+ "/Packages"))
86 except IOError:
87 # can live without these
88 _progress("Missing installer Packages file for %s "

Subscribers

People subscribed via source and target branches

to all changes: