From 37714cabd61fa287e5784f55397e7f63c4b202cb Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Tue, 12 Jul 2022 18:30:59 -0700 Subject: [PATCH] force selinux for the temporary repo file --- .../empanadas/templates/reposync.tmpl | 7 +++++++ iso/empanadas/empanadas/util/dnf_utils.py | 19 ++++++++++++++----- iso/empanadas/empanadas/util/shared.py | 2 ++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/iso/empanadas/empanadas/templates/reposync.tmpl b/iso/empanadas/empanadas/templates/reposync.tmpl index d2bf35e..0709b6f 100644 --- a/iso/empanadas/empanadas/templates/reposync.tmpl +++ b/iso/empanadas/empanadas/templates/reposync.tmpl @@ -19,8 +19,15 @@ if [ "$ret_val" -eq 0 ]; then echo "SOME PACKAGES DID NOT DOWNLOAD" | tee -a {{ sync_log }} exit 1 else + # This is kind of a hack too. + #FOUND=$(grep -A20 'git\.rockylinux\.org' {{ sync_log }} | egrep -c '^\([0-9]+\/[0-9]+\)|\[SKIPPED\]|\.rpm') + #if [ "$FOUND" -eq "0" ]; then + # echo "Repository is empty." | tee -a {{ sync_log }} + # rm -rf {{ download_path }} + #fi exit 0 fi fi + # {{ check_cmd }} | tee -a {{ sync_log }} diff --git a/iso/empanadas/empanadas/util/dnf_utils.py b/iso/empanadas/empanadas/util/dnf_utils.py index 096a691..820f6db 100644 --- a/iso/empanadas/empanadas/util/dnf_utils.py +++ b/iso/empanadas/empanadas/util/dnf_utils.py @@ -164,7 +164,6 @@ class RepoSync: self.log.info('reposync init') self.log.info(self.revision) - self.dnf_config = self.generate_conf() # The repo name should be valid if self.repo is not None: @@ -235,6 +234,9 @@ class RepoSync: "global", ) + #self.dnf_config = self.generate_conf(dest_path=global_work_root) + self.dnf_config = self.generate_conf() + if self.dryrun: self.log.error('Dry Runs are not supported just yet. Sorry!') raise SystemExit() @@ -436,7 +438,8 @@ class RepoSync: arch_force_cp=arch_force_cp, dnf_plugin_cmd=dnf_plugin_cmd, sync_cmd=sync_cmd, - sync_log=sync_log + sync_log=sync_log, + download_path=os_sync_path ) debug_sync_template = self.tmplenv.get_template('reposync.tmpl') @@ -445,7 +448,8 @@ class RepoSync: arch_force_cp=arch_force_cp, dnf_plugin_cmd=dnf_plugin_cmd, sync_cmd=debug_sync_cmd, - sync_log=debug_sync_log + sync_log=debug_sync_log, + download_path=debug_sync_path ) entry_point_open = open(entry_point_sh, "w+") @@ -555,7 +559,7 @@ class RepoSync: #print(entry_name_list) for pod in entry_name_list: - podman_cmd_entry = '{} run -d -it -v "{}:{}" -v "{}:{}" -v "{}:{}" --name {} --entrypoint {}/{} {}'.format( + podman_cmd_entry = '{} run -d -it -v "{}:{}" -v "{}:{}:z" -v "{}:{}" --name {} --entrypoint {}/{} {}'.format( cmd, self.compose_root, self.compose_root, @@ -668,6 +672,10 @@ class RepoSync: dest_path, "{}-{}-config.repo".format(self.shortname, self.major_version) ) + pname = os.path.join( + '/var/tmp', + "{}-{}-config.repo".format(self.shortname, self.major_version) + ) self.log.info('Generating the repo configuration: %s' % fname) if self.repo_base_url.startswith("/"): @@ -711,6 +719,7 @@ class RepoSync: config_file.write(output) config_file.close() + #return (fname, pname) return fname def repoclosure_work(self, sync_root, work_root, log_root): @@ -795,7 +804,7 @@ class RepoSync: self.log.info('Spawning pods for %s' % repo) for pod in repoclosure_entry_name_list: - podman_cmd_entry = '{} run -d -it -v "{}:{}" -v "{}:{}" -v "{}:{}" --name {} --entrypoint {}/{} {}'.format( + podman_cmd_entry = '{} run -d -it -v "{}:{}" -v "{}:{}:z" -v "{}:{}" --name {} --entrypoint {}/{} {}'.format( cmd, self.compose_root, self.compose_root, diff --git a/iso/empanadas/empanadas/util/shared.py b/iso/empanadas/empanadas/util/shared.py index d82d3d9..8155090 100644 --- a/iso/empanadas/empanadas/util/shared.py +++ b/iso/empanadas/empanadas/util/shared.py @@ -518,6 +518,8 @@ class Shared: message = 'Path synced does not seem to exist for some reason.' retval = 1 + #shutil.rmtree(tmp_dir) + return message, retval @staticmethod