Skip to content

Commit

Permalink
Allow passing macros to SRPM build
Browse files Browse the repository at this point in the history
Signed-off-by: Eric D. Helms <[email protected]>
  • Loading branch information
ehelms authored and evgeni committed Oct 23, 2024
1 parent fce83e6 commit f8f2645
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -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
10 changes: 8 additions & 2 deletions obal/data/modules/srpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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:
Expand Down Expand Up @@ -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),
Expand All @@ -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']

Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions obal/data/roles/build_package/tasks/koji_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions obal/data/roles/build_srpm/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f8f2645

Please sign in to comment.