Always generate rpms.json file

Even if gather phase is skipped, it will still generate a rpms.json
metadata file. It will have no payload, but the header structure is
there.

Createrepo phase had to be updated to ignore variants that have no RPMs
listed in metadata.

There is one more fix for writing treeinfo files: if repomd.xml files
are not generated, it will no longer crash.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-06-27 08:47:26 +02:00
parent 00e11b2f51
commit 8323a735e7
3 changed files with 25 additions and 14 deletions

View File

@ -244,6 +244,7 @@ def write_tree_info(compose, arch, variant, timestamp=None):
ti.variants.add(var)
repomd_path = os.path.join(var.repository, "repodata", "repomd.xml")
if os.path.isfile(repomd_path):
ti.checksums.add(repomd_path, "sha256", root_dir=os_tree)
for i in variant.get_variants(types=["addon"], arch=arch):
@ -259,6 +260,7 @@ def write_tree_info(compose, arch, variant, timestamp=None):
var.add(addon)
repomd_path = os.path.join(addon.repository, "repodata", "repomd.xml")
if os.path.isfile(repomd_path):
ti.checksums.add(repomd_path, "sha256", root_dir=os_tree)
class LoraxProduct(productmd.treeinfo.Release):

View File

@ -155,7 +155,7 @@ def create_variant_repo(compose, arch, variant, pkg_type):
manifest = productmd.rpms.Rpms()
manifest.load(manifest_file)
for rpms_arch, data in manifest.rpms[variant.uid].iteritems():
for rpms_arch, data in manifest.rpms.get(variant.uid, {}).iteritems():
if arch is not None and arch != rpms_arch:
continue
for srpm_data in data.itervalues():

View File

@ -114,6 +114,13 @@ class GatherPhase(PhaseBase):
PhaseBase.__init__(self, compose)
# pkgset_phase provides package_sets and path_prefix
self.pkgset_phase = pkgset_phase
# Prepare empty manifest
self.manifest_file = self.compose.paths.compose.metadata("rpms.json")
self.manifest = Rpms()
self.manifest.compose.id = self.compose.compose_id
self.manifest.compose.type = self.compose.compose_type
self.manifest.compose.date = self.compose.compose_date
self.manifest.compose.respin = self.compose.compose_respin
@staticmethod
def check_deps():
@ -124,22 +131,24 @@ class GatherPhase(PhaseBase):
for i in ["release_name", "release_short", "release_version"]:
errors.append(self.conf_assert_str(i))
def run(self):
pkg_map = gather_wrapper(self.compose, self.pkgset_phase.package_sets, self.pkgset_phase.path_prefix)
def _write_manifest(self):
self.compose.log_info("Writing RPM manifest: %s" % self.manifest_file)
self.manifest.dump(self.manifest_file)
manifest_file = self.compose.paths.compose.metadata("rpms.json")
manifest = Rpms()
manifest.compose.id = self.compose.compose_id
manifest.compose.type = self.compose.compose_type
manifest.compose.date = self.compose.compose_date
manifest.compose.respin = self.compose.compose_respin
def run(self):
pkg_map = gather_wrapper(self.compose, self.pkgset_phase.package_sets,
self.pkgset_phase.path_prefix)
for arch in self.compose.get_arches():
for variant in self.compose.get_variants(arch=arch):
link_files(self.compose, arch, variant, pkg_map[arch][variant.uid], self.pkgset_phase.package_sets, manifest=manifest)
link_files(self.compose, arch, variant,
pkg_map[arch][variant.uid],
self.pkgset_phase.package_sets,
manifest=self.manifest)
self.compose.log_info("Writing RPM manifest: %s" % manifest_file)
manifest.dump(manifest_file)
def stop(self):
self._write_manifest()
super(GatherPhase, self).stop()
def get_parent_pkgs(arch, variant, result_dict):