obs-build
obs-build copied to clipboard
Possible way to implement %bcond_default_foo for older distributions
While writing my blog post about %bcond_default_foo (which was implemented in 885878c5fd21e0c2a5a24a10ec2322080bc0beb8 for newer distributions)
I was wondering if we could not just do something like (pseudo code)
bcond_defaults = {}
if mo=/^%bcond_default_(?<with_variable>\S+)\s+(?<with_value>\S+\s*$)/.match(line)
collected_project_configs.gsub(/^%_with(|out)_#{mo['with_variable']}\s+\S+\s*$/, '')
bcond_defaults[mo['with_variable']] = mo['with_value']
end
[snip]
# at the end of the parsing
if len(bcond_defaults) > 0
collected_project_configs << "Macros:\n"
for key, val in bcond_defaults
with_prefix = val == 1 ? '%_with_' : '%_without_'
collect_project_configs << "#{with_prefix}#{key} #{val}\n"
end
collected_project_configs << ":Macros\n"
end