britney: Make read_binaries read all binaries for a suite

Signed-off-by: Niels Thykier <niels@thykier.net>
master
Niels Thykier 8 years ago
parent ea166f5bd3
commit f414b12130

@ -313,19 +313,19 @@ class Britney(object):
self.binaries['tpu'] = {} self.binaries['tpu'] = {}
self.binaries['pu'] = {} self.binaries['pu'] = {}
for arch in self.options.architectures: self.binaries['unstable'] = self.read_binaries(self.options.unstable, "unstable", self.options.architectures)
self.binaries['unstable'][arch] = self.read_binaries(self.options.unstable, "unstable", arch) for suite in ('tpu', 'pu'):
for suite in ('tpu', 'pu'): if hasattr(self.options, suite):
if hasattr(self.options, suite): self.binaries[suite] = self.read_binaries(getattr(self.options, suite), suite, self.options.architectures)
self.binaries[suite][arch] = self.read_binaries(getattr(self.options, suite), suite, arch) else:
else: # _build_installability_tester relies on this being
# _build_installability_tester relies on this being # properly initialised, so insert two empty dicts
# properly initialised, so insert two empty dicts # here.
# here. for arch in self.options.architectures:
self.binaries[suite][arch] = ({}, {}) self.binaries[suite][arch] = ({}, {})
# Load testing last as some live-data tests have more complete information in # Load testing last as some live-data tests have more complete information in
# unstable # unstable
self.binaries['testing'][arch] = self.read_binaries(self.options.testing, "testing", arch) self.binaries['testing'] = self.read_binaries(self.options.testing, "testing", self.options.architectures)
try: try:
constraints_file = os.path.join(self.options.static_input_dir, 'constraints') constraints_file = os.path.join(self.options.static_input_dir, 'constraints')
@ -953,73 +953,78 @@ class Britney(object):
return packages return packages
def read_binaries(self, basedir, distribution, arch): def read_binaries(self, basedir, distribution, architectures):
"""Read the list of binary packages from the specified directory """Read the list of binary packages from the specified directory
The binary packages are read from the `Packages' files for `arch'. This method reads all the binary packages for a given distribution,
which is expected to be in the directory denoted by the "base_dir"
If components are specified, the files parameter.
for each component are loaded according to the usual Debian mirror
layout.
If no components are specified, a single file named If the "components" config parameter is set, the directory should
`Packages_${arch}' is expected to be within the directory be the "suite" directory of a local mirror (i.e. the one containing
specified as `basedir' parameter, replacing ${arch} with the the "InRelease" file). Otherwise, Britney will read the packages
value of the arch parameter. information from all the "Packages_${arch}" files referenced by
the "architectures" parameter.
Considering the Considering the
large amount of memory needed, not all the fields are loaded large amount of memory needed, not all the fields are loaded
in memory. The available fields are Version, Source, Multi-Arch, in memory. The available fields are Version, Source, Multi-Arch,
Depends, Conflicts, Provides and Architecture. Depends, Conflicts, Provides and Architecture.
After reading the packages, reverse dependencies are computed The `Provides' field is used to populate the virtual packages list.
and saved in the `rdepends' keys, and the `Provides' field is
used to populate the virtual packages list.
The dependencies are parsed with the apt_pkg.parse_depends method, The method returns a dict mapping an architecture name to a 2-element
and they are stored both as the format of its return value and tuple. The first element in the tuple is a map from binary package
text. names to "BinaryPackage" objects; the second element is a dictionary
which maps virtual packages to real packages that provide them.
The method returns a tuple. The first element is a list where
every item represents a binary package as a dictionary; the second
element is a dictionary which maps virtual packages to real
packages that provide them.
""" """
arch2packages = {}
if self.options.components: if self.options.components:
packages = {} for arch in architectures:
for component in self.options.components: packages = {}
binary_dir = "binary-%s" % arch for component in self.options.components:
filename = os.path.join(basedir, binary_dir = "binary-%s" % arch
component, binary_dir, 'Packages') filename = os.path.join(basedir,
try: component,
filename = possibly_compressed(filename) binary_dir,
except FileNotFoundError as e: 'Packages')
if arch not in self.options.new_arches: try:
raise filename = possibly_compressed(filename)
self.log("Ignoring missing file for new arch %s: %s" % (arch, filename)) except FileNotFoundError:
continue if arch not in self.options.new_arches:
udeb_filename = os.path.join(basedir, raise
component, "debian-installer", self.log("Ignoring missing file for new arch %s: %s" % (arch, filename))
binary_dir, "Packages") continue
# We assume the udeb Packages file is present if the udeb_filename = os.path.join(basedir,
# regular one is present component,
udeb_filename = possibly_compressed(udeb_filename) "debian-installer",
self._read_packages_file(filename, arch, binary_dir,
self.sources[distribution], packages) "Packages")
self._read_packages_file(udeb_filename, arch, # We assume the udeb Packages file is present if the
self.sources[distribution], packages) # regular one is present
udeb_filename = possibly_compressed(udeb_filename)
self._read_packages_file(filename,
arch,
self.sources[distribution],
packages)
self._read_packages_file(udeb_filename,
arch,
self.sources[distribution],
packages)
# create provides
provides = create_provides_map(packages)
arch2packages[arch] = (packages, provides)
else: else:
filename = os.path.join(basedir, "Packages_%s" % arch) for arch in architectures:
packages = self._read_packages_file(filename, arch, filename = os.path.join(basedir, "Packages_%s" % arch)
self.sources[distribution]) packages = self._read_packages_file(filename,
arch,
# create provides self.sources[distribution])
provides = create_provides_map(packages) provides = create_provides_map(packages)
arch2packages[arch] = (packages, provides)
# return a tuple with the list of real and virtual packages
return (packages, provides) return arch2packages
def read_hints(self, hintsdir): def read_hints(self, hintsdir):
"""Read the hint commands from the specified directory """Read the hint commands from the specified directory

Loading…
Cancel
Save