From 7f6f7babf5e66211885e353e68659b39663278c4 Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Thu, 30 Jun 2022 13:14:27 -0700 Subject: [PATCH] Attempt to resolve RLBT#0000133 --- iso/empanadas/empanadas/util/__init__.py | 1 + iso/empanadas/empanadas/util/iso_utils.py | 44 ++++++++++++++++++++++- iso/empanadas/empanadas/util/shared.py | 23 ++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/iso/empanadas/empanadas/util/__init__.py b/iso/empanadas/empanadas/util/__init__.py index f107a54..828e595 100644 --- a/iso/empanadas/empanadas/util/__init__.py +++ b/iso/empanadas/empanadas/util/__init__.py @@ -8,6 +8,7 @@ from empanadas.util.check import ( from empanadas.util.shared import ( Shared, + ArchCheck, ) from empanadas.util.dnf_utils import ( diff --git a/iso/empanadas/empanadas/util/iso_utils.py b/iso/empanadas/empanadas/util/iso_utils.py index de93dac..ef1e283 100644 --- a/iso/empanadas/empanadas/util/iso_utils.py +++ b/iso/empanadas/empanadas/util/iso_utils.py @@ -35,7 +35,7 @@ import productmd.treeinfo from jinja2 import Environment, FileSystemLoader from empanadas.common import Color, _rootdir -from empanadas.util import Shared +from empanadas.util import Shared, ArchCheck class IsoBuild: """ @@ -710,6 +710,48 @@ class IsoBuild: Syncs data from a non-disc set of images to the appropriate repo. Repo and image MUST match names for this to work. """ + pathway = os.path.join( + self.compose_latest_sync, + repo, + arch, + 'os' + ) + + src_to_image = os.path.join( + self.lorax_work_dir, + arch, + repo + ) + + if not force_unpack: + found_files = [] + for y in ArchCheck.archfile[arch]: + imgpath = os.path.join( + pathway, + y + ) + if os.path.exists(imgpath): + found_files.append(y) + + if os.path.exists(pathway + '/images/boot.iso'): + found_files.append('/images/boot.iso') + + if len(found_files) > 0: + self.log.warn( + '[' + Color.BOLD + Color.YELLOW + 'WARN' + Color.END + '] ' + + 'Images and data for ' + repo + ' and ' + arch + ' already exists.' + ) + return + + self.log.info( + '[' + Color.BOLD + Color.GREEN + 'INFO' + Color.END + '] ' + + 'Copying images and data for ' + repo + ' ' + arch + ) + try: + shutil.copytree(src_to_image, pathway, copy_function=shutil.copy2, dirs_exist_ok=True) + except: + self.log.error('%s already exists??' % repo) + def run_boot_sync(self): """ diff --git a/iso/empanadas/empanadas/util/shared.py b/iso/empanadas/empanadas/util/shared.py index 2661356..7524c2f 100644 --- a/iso/empanadas/empanadas/util/shared.py +++ b/iso/empanadas/empanadas/util/shared.py @@ -4,6 +4,29 @@ import os import hashlib import productmd.treeinfo +class ArchCheck: + """ + Arches and their files + """ + archfile = { + 'x86_64': [ + 'isolinux/vmlinuz', + 'images/grub.conf', + 'EFI/BOOT/BOOTX64.EFI' + ], + 'aarch64': [ + 'EFI/BOOT/BOOTAA64.EFI' + ], + 'ppc64le': [ + 'ppc/bootinfo.txt', + 'ppc/ppc64/vmlinuz' + ], + 's390x': [ + 'generic.ins', + 'images/generic.prm' + ] + } + class Shared: """ Quick utilities that may be commonly used