diff options
Diffstat (limited to 'pkg/linux.py')
-rw-r--r-- | pkg/linux.py | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/pkg/linux.py b/pkg/linux.py index 4246286..7be7cb7 100644 --- a/pkg/linux.py +++ b/pkg/linux.py @@ -52,15 +52,54 @@ def _esc_label(s): return s.replace('-', '_') +def rpm_get_config(ctx): + if ctx.env.RPM_CONFIG: + config = pkg.configs.get_config_parser() + try: + config.read(ctx.env.RPM_CONFIG) + except pkg.configs.get_config_error() as ce: + conf.fatal('rpm config parse error: ' + str(ce)) + else: + config = None + return config + + +def rpm_config_parser(bld, build): + config = rpm_get_config(bld) + no_config = '# No user configuration, see ./waf --help and --rpm-config' + if config is None: + return no_config + if not config.has_section(build['buildset']): + return no_config + try: + items = config.items(build['buildset']) + except pkg.configs.get_config_error() as ce: + bld.fatal('rpm config parse error: ' + str(ce)) + user_config = [] + for ci in items: + user_config += ['%%define %s %s' % (ci[0], ci[1])] + return os.linesep.join(user_config) + + def rpm_configure(conf): try: conf.find_program('rpmbuild', var='RPMBUILD', manditory=False) conf.env.PACKAGER = True except: pass + if conf.options.rpm_config is not None: + if not conf.env.PACKAGER: + conf.fatal('RPM config option is invalid without rpmbuild') + if not os.path.isfile(conf.options.rpm_config): + conf.fatal('RPM config does not exist or not a file: ' + + conf.options.rpm_config) + conf.msg('RPM config', conf.options.rpm_config) + conf.env.RPM_CONFIG = conf.options.rpm_config + rpm_get_config(conf) def rpm_build(bld, build): + user_rpm_config = rpm_config_parser(bld, build) bset = pkg.configs.buildset(bld, build, dry_run=False) rpm_name = 'rpmspec/' + bset['name'] spec_file = _esc_name(build['buildset']) @@ -84,7 +123,8 @@ def rpm_build(bld, build): TARFILE=bset['tar'], RSB_SET_BUILDER=bset['cmd'], RSB_SET_BUILDER_ARGS=' '.join(bset['pkg-opts']), - RSB_WORK_PATH=bld.path) + RSB_WORK_PATH=bld.path, + USER_RPM_CONFIG=user_rpm_config) def rpmspec(bld): @@ -97,7 +137,10 @@ def init(ctx): def options(opt): - pass + opt.add_option('--rpm-config', + default=None, + dest='rpm_config', + help='RPM configuration INI file') def configure(conf): |