add treeinfo refresh

This commit is contained in:
Louis Abel 2023-05-12 00:27:48 -07:00
parent bd67c4d9fa
commit cb5ee4bf3b
Signed by untrusted user: label
GPG Key ID: B37E62D143879B36
3 changed files with 56 additions and 15 deletions

View File

@ -0,0 +1,33 @@
# This script can be called to do single syncs or full on syncs.
import argparse
from empanadas.common import *
from empanadas.util import Checks
from empanadas.util import RepoSync
# Start up the parser baby
parser = argparse.ArgumentParser(description="Peridot Sync and Compose")
# All of our options
parser.add_argument('--release', type=str, help="Major Release Version or major-type (eg 9-beta)", required=True)
parser.add_argument('--logger', type=str)
# Parse them
results = parser.parse_args()
rlvars = rldict[results.release]
major = rlvars['major']
r = Checks(rlvars, config['arch'])
r.check_validity()
# Send them and do whatever I guess
a = RepoSync(
rlvars,
config,
major=major,
logger=results.logger,
)
def run():
a.refresh_compose_treeinfo()

View File

@ -303,7 +303,7 @@ class RepoSync:
# tweak_treeinfo calls out to a method that does. This should not # tweak_treeinfo calls out to a method that does. This should not
# cause issues as the method is fairly static in nature. # cause issues as the method is fairly static in nature.
if self.refresh_treeinfo and not self.fullrun: if self.refresh_treeinfo and not self.fullrun:
self.deploy_treeinfo(self.repo, sync_root, self.arch) self.deploy_treeinfo(self.repo, sync_root, self.arch, refresh=True)
self.tweak_treeinfo(self.repo, sync_root, self.arch) self.tweak_treeinfo(self.repo, sync_root, self.arch)
self.deploy_metadata(sync_root) self.deploy_metadata(sync_root)
@ -927,7 +927,7 @@ class RepoSync:
readme_file.close() readme_file.close()
def deploy_treeinfo(self, repo, sync_root, arch): def deploy_treeinfo(self, repo, sync_root, arch, refresh=False):
""" """
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. If there is a treeinfo overwritten by our ISO process, which is fine. If there is a treeinfo
@ -1003,8 +1003,7 @@ class RepoSync:
'kickstart/media.repo' 'kickstart/media.repo'
) )
if not os.path.exists(os_tree_path) or (os.path.exists(os_tree_path) and refresh):
if not os.path.exists(os_tree_path):
try: try:
Shared.treeinfo_new_write( Shared.treeinfo_new_write(
os_tree_path, os_tree_path,
@ -1023,7 +1022,7 @@ class RepoSync:
else: else:
self.log.warn(Color.WARN + repo_name + ' ' + a + ' os .treeinfo already exists') self.log.warn(Color.WARN + repo_name + ' ' + a + ' os .treeinfo already exists')
if not os.path.exists(os_disc_path): if not os.path.exists(os_disc_path) or (os.path.exists(os_disc_path) and refresh):
try: try:
Shared.discinfo_write( Shared.discinfo_write(
self.timestamp, self.timestamp,
@ -1041,7 +1040,7 @@ class RepoSync:
' os .discinfo already exists' ' os .discinfo already exists'
) )
if not os.path.exists(os_media_path): if not os.path.exists(os_media_path) or (os.path.exists(os_media_path) and refresh):
try: try:
Shared.media_repo_write( Shared.media_repo_write(
self.timestamp, self.timestamp,
@ -1059,7 +1058,7 @@ class RepoSync:
) )
# Kickstart part of the repos # Kickstart part of the repos
if not os.path.exists(ks_tree_path): if not os.path.exists(ks_tree_path) or (os.path.exists(ks_tree_path) and refresh):
try: try:
Shared.treeinfo_new_write( Shared.treeinfo_new_write(
ks_tree_path, ks_tree_path,
@ -1080,7 +1079,7 @@ class RepoSync:
' kickstart .treeinfo already exists' ' kickstart .treeinfo already exists'
) )
if not os.path.exists(ks_disc_path): if not os.path.exists(ks_disc_path) or (os.path.exists(ks_disc_path) and refresh):
try: try:
Shared.discinfo_write( Shared.discinfo_write(
self.timestamp, self.timestamp,
@ -1098,7 +1097,7 @@ class RepoSync:
' kickstart .discinfo already exists' ' kickstart .discinfo already exists'
) )
if not os.path.exists(ks_media_path): if not os.path.exists(ks_media_path) or (os.path.exists(ks_media_path) and refresh):
try: try:
Shared.media_repo_write( Shared.media_repo_write(
self.timestamp, self.timestamp,
@ -1137,7 +1136,7 @@ class RepoSync:
'debug/tree/media.repo' 'debug/tree/media.repo'
) )
if not os.path.exists(debug_tree_path): if not os.path.exists(debug_tree_path) or (os.path.exists(debug_tree_path) and refresh):
try: try:
Shared.treeinfo_new_write( Shared.treeinfo_new_write(
debug_tree_path, debug_tree_path,
@ -1158,7 +1157,7 @@ class RepoSync:
' debug .treeinfo already exists' ' debug .treeinfo already exists'
) )
if not os.path.exists(debug_disc_path): if not os.path.exists(debug_disc_path) or (os.path.exists(debug_disc_path) and refresh):
try: try:
Shared.discinfo_write( Shared.discinfo_write(
self.timestamp, self.timestamp,
@ -1176,7 +1175,7 @@ class RepoSync:
' debug .discinfo already exists' ' debug .discinfo already exists'
) )
if not os.path.exists(debug_media_path): if not os.path.exists(debug_media_path) or (os.path.exists(debug_media_path) and refresh):
try: try:
Shared.media_repo_write( Shared.media_repo_write(
self.timestamp, self.timestamp,
@ -1213,7 +1212,7 @@ class RepoSync:
'source/tree/media.repo' 'source/tree/media.repo'
) )
if not os.path.exists(source_tree_path): if not os.path.exists(source_tree_path) or (os.path.exists(source_tree_path) and refresh):
try: try:
Shared.treeinfo_new_write( Shared.treeinfo_new_write(
source_tree_path, source_tree_path,
@ -1230,7 +1229,7 @@ class RepoSync:
else: else:
self.log.warn(Color.WARN + repo_name + ' source os .treeinfo already exists') self.log.warn(Color.WARN + repo_name + ' source os .treeinfo already exists')
if not os.path.exists(source_disc_path): if not os.path.exists(source_disc_path) or (os.path.exists(source_disc_path) and refresh):
try: try:
Shared.discinfo_write( Shared.discinfo_write(
self.timestamp, self.timestamp,
@ -1244,7 +1243,7 @@ class RepoSync:
else: else:
self.log.warn(Color.WARN + repo_name + ' source .discinfo already exists') self.log.warn(Color.WARN + repo_name + ' source .discinfo already exists')
if not os.path.exists(source_media_path): if not os.path.exists(source_media_path) or (os.path.exists(source_media_path) and refresh):
try: try:
Shared.media_repo_write( Shared.media_repo_write(
self.timestamp, self.timestamp,
@ -1327,6 +1326,14 @@ class RepoSync:
self.log.error(Color.FAIL + 'There was an error writing kickstart treeinfo.') self.log.error(Color.FAIL + 'There was an error writing kickstart treeinfo.')
self.log.error(e) self.log.error(e)
def refresh_compose_treeinfo(self):
"""
It is rare that this should be called.
"""
sync_root = self.compose_latest_sync
self.deploy_treeinfo(self.repo, sync_root, self.arch, refresh=True)
self.tweak_treeinfo(self.repo, sync_root, self.arch)
def run_compose_closeout(self): def run_compose_closeout(self):
""" """
Closes out a compose. This ensures the ISO's are synced from work/isos Closes out a compose. This ensures the ISO's are synced from work/isos

View File

@ -36,6 +36,7 @@ finalize_compose = "empanadas.scripts.finalize_compose:run"
pull-cloud-image = "empanadas.scripts.pull_cloud_image:run" pull-cloud-image = "empanadas.scripts.pull_cloud_image:run"
generate_compose = "empanadas.scripts.generate_compose:run" generate_compose = "empanadas.scripts.generate_compose:run"
peridot_repoclosure = "empanadas.scripts.peridot_repoclosure:run" peridot_repoclosure = "empanadas.scripts.peridot_repoclosure:run"
refresh_all_treeinfo = "empanadas.scripts.refresh_all_treeinfo:run"
[build-system] [build-system]
requires = ["poetry-core>=1.0.0"] requires = ["poetry-core>=1.0.0"]