-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathgenerate-licenses-for-rpmlint.py
executable file
·30 lines (25 loc) · 1.26 KB
/
generate-licenses-for-rpmlint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3
import argparse
import os
parser = argparse.ArgumentParser(description='Generate TOML configuration file with valid licenses.')
parser.add_argument('output', help='Output file')
parser.add_argument('-s', '--suse', action='store_true', help='Add SUSE exceptions')
args = parser.parse_args()
SUSE_EXCEPTIONS = """
AGPL-3.0 AGPL-3.0+ GFDL-1.1 GFDL-1.1+ GFDL-1.2 GFDL-1.2+ GFDL-1.3 GFDL-1.3+ GPL-3.0-with-GCC-exception \
GPL-2.0-with-classpath-exception GPL-2.0-with-font-exception SUSE-LGPL-2.1+-with-GCC-exception SUSE-NonFree \
GPL-1.0+ GPL-1.0 GPL-2.0+ GPL-2.0 GPL-3.0+ GPL-3.0 LGPL-2.0 LGPL-2.0+ LGPL-2.1+ LGPL-2.1 LGPL-3.0+ LGPL-3.0
"""
with open(args.output, 'w') as wfile:
script_name = os.path.basename(__file__)
wfile.write('# Generated with %s script from spec-cleaner:\n' % script_name)
wfile.write('# URL: https://github.com/rpm-software-management/spec-cleaner\n\n')
wfile.write('ValidLicenses = [\n')
for line in open('data/licenses_changes.txt').readlines():
name = line.strip().split('\t')[0]
wfile.write(f' "{name}",\n')
if args.suse:
wfile.write(' # SUSE EXCEPTIONS\n')
for name in SUSE_EXCEPTIONS.strip().split(' '):
wfile.write(f' "{name}",\n')
wfile.write(']\n')