prepping treeinfo outside

This commit is contained in:
Louis Abel 2022-06-28 07:49:23 -07:00
parent 760967211b
commit 7d7163a156
Signed by: label
GPG Key ID: B37E62D143879B36
3 changed files with 55 additions and 5 deletions

View File

@ -78,6 +78,7 @@ class RepoSync:
self.compose_root = config['compose_root'] self.compose_root = config['compose_root']
self.compose_base = config['compose_root'] + "/" + major self.compose_base = config['compose_root'] + "/" + major
self.profile = rlvars['profile'] self.profile = rlvars['profile']
self.iso_map = rlvars['iso_map']
# Relevant major version items # Relevant major version items
self.shortname = config['shortname'] self.shortname = config['shortname']
@ -935,7 +936,8 @@ class RepoSync:
def deploy_treeinfo(self, repo, sync_root, arch): def deploy_treeinfo(self, repo, sync_root, arch):
""" """
Deploys initial treeinfo files. These have the potential of being 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 arches_to_tree = self.arches
if arch: if arch:

View File

@ -450,7 +450,7 @@ class IsoBuild:
for arch in arches_to_unpack: for arch in arches_to_unpack:
for variant in self.iso_map['images']: for variant in self.iso_map['images']:
self.log.info( 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) self._treeinfo_wrapper(arch, variant)
@ -741,12 +741,15 @@ class IsoBuild:
def _treeinfo_wrapper(self, arch, variant): def _treeinfo_wrapper(self, arch, variant):
""" """
Ensure treeinfo is written correctly based on the variant passed. Each Ensure treeinfo and discinfo is written correctly based on the variant
.treeinfo file should be configured similarly but also differently from passed. Each file should be configured similarly but also differently
the next. 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) image = os.path.join(self.lorax_work_dir, arch, variant)
treeinfo = os.path.join(image, '.treeinfo') 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] imagemap = self.iso_map['images'][variant]
primary = imagemap['variant'] primary = imagemap['variant']
repos = imagemap['repos'] repos = imagemap['repos']
@ -827,6 +830,10 @@ class IsoBuild:
# Set default variant # Set default variant
ti.dump(treeinfo, main_variant=primary) 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 # Next set of functions are loosely borrowed (in concept) from pungi. Some
# stuff may be combined/mixed together, other things may be simplified or # stuff may be combined/mixed together, other things may be simplified or

View File

@ -2,6 +2,7 @@
import os import os
import hashlib import hashlib
import productmd.treeinfo
class Shared: class Shared:
""" """
@ -44,6 +45,46 @@ class Shared:
checksum.hexdigest() 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 @staticmethod
def discinfo_write(timestamp, fullname, arch, file_path): def discinfo_write(timestamp, fullname, arch, file_path):
""" """