From f8f26457d1092ac1d75f8692208a9d21d99b5df0 Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Tue, 30 Aug 2022 12:52:26 -0400 Subject: [PATCH] Allow passing macros to SRPM build Signed-off-by: Eric D. Helms --- .pylintrc | 2 +- obal/data/modules/srpm.py | 10 ++++++++-- obal/data/roles/build_package/tasks/koji_build.yml | 1 + obal/data/roles/build_srpm/tasks/main.yaml | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.pylintrc b/.pylintrc index b14a4ac8..48107986 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,7 +1,7 @@ [MASTER] ignore=docs,tests # Disable useless-object-inheritance because we still support py2 -disable=R0205,C0209,W1514,R1735 +disable=R0205,C0209,W1514,R1735,R0913,R0917 min-similarity-lines=10 max-line-length=120 max-locals=20 diff --git a/obal/data/modules/srpm.py b/obal/data/modules/srpm.py index 54ffd34c..25b6af7c 100644 --- a/obal/data/modules/srpm.py +++ b/obal/data/modules/srpm.py @@ -83,7 +83,7 @@ def fetch_remote_sources(source_location, source_system, sources_dir): zip_file.extract(zip_info, sources_dir) -def build_srpm(module, package, base_dir, sources_dir, scl=None): +def build_srpm(module, package, base_dir, sources_dir, scl=None, macros=None): """ Build the SRPM and return the path to the result """ @@ -101,6 +101,10 @@ def build_srpm(module, package, base_dir, sources_dir, scl=None): if scl: command += ['--define', 'scl %s' % scl] + if macros is not None: + for (macro, value) in macros.items(): + command += ['--define', '%s %s' % (macro, value)] + command += [os.path.join(base_dir, '%s.spec' % os.path.basename(package))] try: @@ -128,6 +132,7 @@ def main(): argument_spec=dict( package=dict(type='str', required=False), scl=dict(type='str', required=False), + macros=dict(type='dict', required=False), output=dict(type='path', required=False), source_location=dict(type='str', required=False), source_system=dict(type='str', required=False), @@ -137,6 +142,7 @@ def main(): package = module.params['package'] output = module.params['output'] scl = module.params['scl'] + macros = module.params['macros'] source_location = module.params['source_location'] source_system = module.params['source_system'] @@ -158,7 +164,7 @@ def main(): copy_sources(spec_file, package, sources_dir) shutil.copy(spec_file, base_dir) - result = build_srpm(module, package, base_dir, sources_dir, scl) + result = build_srpm(module, package, base_dir, sources_dir, scl, macros) if not os.path.exists(output): os.mkdir(output) diff --git a/obal/data/roles/build_package/tasks/koji_build.yml b/obal/data/roles/build_package/tasks/koji_build.yml index aff429d0..35af9c33 100644 --- a/obal/data/roles/build_package/tasks/koji_build.yml +++ b/obal/data/roles/build_package/tasks/koji_build.yml @@ -44,6 +44,7 @@ package: "{{ inventory_dir }}/{{ package_base_dir }}/{{ inventory_hostname }}" output: "{{ build_package_srpm_directory | default(srpm_directory.path) }}" scl: "{{ scl | default(omit) }}" + macros: "{{ tag.macros | default(omit) }}" source_location: "{{ source_location | default(omit) }}" source_system: "{{ source_system | default(omit) }}" register: srpm_build diff --git a/obal/data/roles/build_srpm/tasks/main.yaml b/obal/data/roles/build_srpm/tasks/main.yaml index 89d94faa..630e5406 100644 --- a/obal/data/roles/build_srpm/tasks/main.yaml +++ b/obal/data/roles/build_srpm/tasks/main.yaml @@ -4,6 +4,7 @@ package: "{{ inventory_dir }}/{{ package_base_dir }}/{{ inventory_hostname }}" output: "{{ build_srpm_output_dir }}" scl: "{{ build_srpm_scl | default(omit) }}" + macros: "{{ macros | default(omit) }}" source_location: "{{ source_location | default(omit) }}" source_system: "{{ source_system | default(omit) }}" register: srpm_build