Add support for tag/target macros for Mageia

Discussions with Son_Goku (from Mageia) on IRC revealed that they need
per tag/target macro support in Koji. We store tag macros in 'Extra Options'
and macro has to start with '%'.

Example:

    % koji taginfo f29
    Tag: f29 [11]
    Arches: riscv64
    Groups:
    Required permission: 'admin'
    Tag options:
      %mymacro : 'value123'
      %packager : 'Fedora Project RISC-V'
      mock.package_manager : 'dnf'
    [..]

Tag macros can be added using koji edit-tag.

The tag macros are allowed to overwrite macros set in koji.genMockConfig.
For example, %packager is set in koji.genMockConfig by default. The mock
configuration generated by kojid was:

    [..]
    config_opts['macros']['%_host'] = 'riscv64-koji-linux-gnu'
    config_opts['macros']['%mymacro'] = 'value123'
    config_opts['macros']['%_host_cpu'] = 'riscv64'
    config_opts['macros']['%vendor'] = 'Fedora Project'
    config_opts['macros']['%distribution'] = 'Fedora Project'
    config_opts['macros']['%_topdir'] = '/builddir/build'
    config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
    config_opts['macros']['%packager'] = 'Fedora Project RISC-V'
    [..]

This two-line change was tested on Fedora RISC-V koji instance.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
This commit is contained in:
David Abdurachmanov 2018-04-22 09:19:56 +02:00 committed by Mike McLean
parent cef24b1b50
commit 7e1809bafd
2 changed files with 4 additions and 0 deletions

View file

@ -276,6 +276,7 @@ class BuildRoot(object):
opts['module_hotfixes'] = self.config['extra']['mock.yum.module_hotfixes']
if self.internal_dev_setup is not None:
opts['internal_dev_setup'] = bool(self.internal_dev_setup)
opts['tag_macros'] = dict([ _ for _ in self.config['extra'].items() if _[0].startswith('%') ])
output = koji.genMockConfig(self.name, self.br_arch, managed=True, **opts)
#write config

View file

@ -1559,6 +1559,9 @@ name=build
#TODO - track some of these in the db instead?
}
# Load tag specific macros, which can override macros above
macros.update(opts.get('tag_macros', []))
parts = ["""# Auto-generated by the Koji build system
"""]
if managed: