4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
22 p = argparse.ArgumentParser(
23 description='Parse RPM macro definitions from mock '
24 'config and write a file for "rpmbuild" to process')
25 p.add_argument('--mock-config', required=True)
26 p.add_argument('--output-file-path', required=True)
27 args = p.parse_args(args)
32 args = parse(input_args)
33 with open(args.mock_config, 'r') as f:
35 with open(args.output_file_path, 'w') as f:
36 for macro, expr in re.findall(
37 r'^\s*config_opts\[[\'"]macros[\'"]\]\[[\'"](.*)[\'"]\]\s*=\s*[\'"](.*)[\'"]\s*$',
39 f.write('{} {}\n'.format(macro, expr))
40 print('Wrote ' + args.output_file_path)
43 if __name__ == "__main__":