From 60e197c9e172429c1ec56ab46576cb6938a5934b Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Wed, 28 Jun 2023 14:43:14 -0700 Subject: [PATCH] add modularitylabel support --- importer/operation.py | 9 ++++++++- util/rpmutil.py | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/importer/operation.py b/importer/operation.py index 39117d9..28a4086 100644 --- a/importer/operation.py +++ b/importer/operation.py @@ -114,7 +114,7 @@ class Import: else: shutil.move(src=source_path, dst=dest_path) if os.path.exists('/usr/sbin/restorecon'): - processor.run_proc_foreground_shell('/usr/sbin/restorecon {dest_path}') + processor.run_proc_foreground_shell(f'/usr/sbin/restorecon {dest_path}') class SrpmImport(Import): """ @@ -178,6 +178,13 @@ class SrpmImport(Import): git_repo_path = f'/var/tmp/{self.rpm_name}' branch = self.__branch repo_tags = [] + + # We need to determine if this package has a modularity label. If it + # does, we need to augment the branch name. + if len(self.__srpm_metadata['modularitylabel']) > 0: + stream_version = self.__srpm_metadata['modularitylabel'].split(':')[1] + branch = f'{self.__branch}-stream-{stream_version}' + # If we return None, we need to assume that this is a brand new repo, # so we will try to set it up accordingly. If we return refs, we'll see # if the branch we want to work with exists. If it does not exist, diff --git a/util/rpmutil.py b/util/rpmutil.py index a08179e..5598de7 100644 --- a/util/rpmutil.py +++ b/util/rpmutil.py @@ -184,6 +184,11 @@ def get_rpm_metadata_from_hdr(hdr) -> dict: if not found_epoch: found_epoch = '' + # This avoids the modularity label being None or 'None' in the dict. + found_modularitylabel = header_data[rpm.RPMTAG_MODULARITYLABEL] + if not found_modularitylabel: + found_modularitylabel = '' + metadata = { 'changelog_xml': changelog_result, 'files': file_stuff['file'], @@ -205,6 +210,7 @@ def get_rpm_metadata_from_hdr(hdr) -> dict: 'release': generic.to_unicode(header_data[rpm.RPMTAG_RELEASE]), 'epoch': found_epoch, 'arch': pkg_arch, + 'modularitylabel': found_modularitylabel, 'signature': header_data[rpm.RPMTAG_RSAHEADER], } for key, rpmkey, in (('archivesize', rpm.RPMTAG_ARCHIVESIZE),