From 7d7163a1567f06a40034075c361be0b1eaed2d29 Mon Sep 17 00:00:00 2001 From: nazunalika Date: Tue, 28 Jun 2022 07:49:23 -0700 Subject: [PATCH] prepping treeinfo outside --- iso/empanadas/empanadas/util/dnf_utils.py | 4 ++- iso/empanadas/empanadas/util/iso_utils.py | 15 ++++++--- iso/empanadas/empanadas/util/shared.py | 41 +++++++++++++++++++++++ 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/iso/empanadas/empanadas/util/dnf_utils.py b/iso/empanadas/empanadas/util/dnf_utils.py index a54b4ee..8291a8f 100644 --- a/iso/empanadas/empanadas/util/dnf_utils.py +++ b/iso/empanadas/empanadas/util/dnf_utils.py @@ -78,6 +78,7 @@ class RepoSync: self.compose_root = config['compose_root'] self.compose_base = config['compose_root'] + "/" + major self.profile = rlvars['profile'] + self.iso_map = rlvars['iso_map'] # Relevant major version items self.shortname = config['shortname'] @@ -935,7 +936,8 @@ class RepoSync: def deploy_treeinfo(self, repo, sync_root, arch): """ Deploys initial treeinfo files. These have the potential of being - overwritten by our ISO process, which is fine. + overwritten by our ISO process, which is fine. If there is a treeinfo + found, it will be skipped. """ arches_to_tree = self.arches if arch: diff --git a/iso/empanadas/empanadas/util/iso_utils.py b/iso/empanadas/empanadas/util/iso_utils.py index 5921df9..de93dac 100644 --- a/iso/empanadas/empanadas/util/iso_utils.py +++ b/iso/empanadas/empanadas/util/iso_utils.py @@ -450,7 +450,7 @@ class IsoBuild: for arch in arches_to_unpack: for variant in self.iso_map['images']: self.log.info( - 'Configuring treeinfo for %s%s %s%s' % (Color.BOLD, arch, variant, Color.END) + 'Configuring treeinfo and discinfo for %s%s %s%s' % (Color.BOLD, arch, variant, Color.END) ) self._treeinfo_wrapper(arch, variant) @@ -741,12 +741,15 @@ class IsoBuild: def _treeinfo_wrapper(self, arch, variant): """ - Ensure treeinfo is written correctly based on the variant passed. Each - .treeinfo file should be configured similarly but also differently from - the next. + Ensure treeinfo and discinfo is written correctly based on the variant + passed. Each file should be configured similarly but also differently + from the next. The Shared module does have a .treeinfo writer, but it + is for basic use. Eventually it'll be expanded to handle this scenario. """ image = os.path.join(self.lorax_work_dir, arch, variant) treeinfo = os.path.join(image, '.treeinfo') + discinfo = os.path.join(image, '.discinfo') + mediarepo = os.path.join(image, 'media.repo') imagemap = self.iso_map['images'][variant] primary = imagemap['variant'] repos = imagemap['repos'] @@ -827,6 +830,10 @@ class IsoBuild: # Set default variant ti.dump(treeinfo, main_variant=primary) + # Set discinfo + Shared.discinfo_write(self.timestamp, self.fullname, arch, discinfo) + # Set media.repo + Shared.media_repo_write(self.timestamp, self.fullname, mediarepo) # Next set of functions are loosely borrowed (in concept) from pungi. Some # stuff may be combined/mixed together, other things may be simplified or diff --git a/iso/empanadas/empanadas/util/shared.py b/iso/empanadas/empanadas/util/shared.py index d9bb357..e3b08c5 100644 --- a/iso/empanadas/empanadas/util/shared.py +++ b/iso/empanadas/empanadas/util/shared.py @@ -2,6 +2,7 @@ import os import hashlib +import productmd.treeinfo class Shared: """ @@ -44,6 +45,46 @@ class Shared: checksum.hexdigest() ) + @staticmethod + def treeinfo_new_write( + file_path, + distname, + shortname, + release, + arch, + time, + repo + ): + """ + Writes really basic treeinfo, this is for single repository treeinfo + data. This is usually called in the case of a fresh run and each repo + needs one. + """ + ti = productmd.treeinfo.TreeInfo() + ti.release.name = distname + ti.release.short = shortname + ti.release.version = release + ti.tree.arch = arch + ti.tree.build_timestamp = time + # Variants (aka repos) + variant = productmd.treeinfo.Variant(ti) + variant.id = repo + variant.uid = repo + variant.name = repo + variant.type = "variant" + variant.repository = "." + variant.packages = "Packages" + ti.variants.add(variant) + ti.dump(file_path) + + @staticmethod + def treeinfo_modify_write(): + """ + Modifies a specific treeinfo with already available data. This is in + the case of modifying treeinfo for primary repos or images. + """ + + @staticmethod def discinfo_write(timestamp, fullname, arch, file_path): """