#341 Always generate rpms.json file
Merged 8 years ago by ausil. Opened 8 years ago by lsedlar.
lsedlar/pungi always-make-rpms  into  master

file modified
+4 -2
@@ -244,7 +244,8 @@ 

      ti.variants.add(var)

  

      repomd_path = os.path.join(var.repository, "repodata", "repomd.xml")

-     ti.checksums.add(repomd_path, "sha256", root_dir=os_tree)

+     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):

          addon = productmd.treeinfo.Variant(ti)
@@ -259,7 +260,8 @@ 

          var.add(addon)

  

          repomd_path = os.path.join(addon.repository, "repodata", "repomd.xml")

-         ti.checksums.add(repomd_path, "sha256", root_dir=os_tree)

+         if os.path.isfile(repomd_path):

+             ti.checksums.add(repomd_path, "sha256", root_dir=os_tree)

  

      class LoraxProduct(productmd.treeinfo.Release):

          def _check_short(self):

file modified
+1 -1
@@ -155,7 +155,7 @@ 

      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():

file modified
+21 -12
@@ -114,6 +114,13 @@ 

          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 @@ 

          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)

- 

-         self.compose.log_info("Writing RPM manifest: %s" % manifest_file)

-         manifest.dump(manifest_file)

+                 link_files(self.compose, arch, variant,

+                            pkg_map[arch][variant.uid],

+                            self.pkgset_phase.package_sets,

+                            manifest=self.manifest)

+ 

+     def stop(self):

+         self._write_manifest()

+         super(GatherPhase, self).stop()

  

  

  def get_parent_pkgs(arch, variant, result_dict):

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.

Pull-Request has been merged by ausil

8 years ago