# SPDX-FileCopyrightText: Defame1297 and contributors # SPDX-License-Identifier: GPL-3.0-or-later """Run `reuse lint`, tolerating only unused licence texts. LICENSES/ carries licence texts (GPL-3.0-only, Apache-2.0, MIT, EUPL-1.2) before the roles that use them exist; reuse >= 6 reports those as non-compliant. Every other finding still fails. Once the extraction waves have brought in files for all of them, delete UNUSED_ALLOWED and call `reuse lint` directly. """ import json import subprocess import sys UNUSED_ALLOWED = {"GPL-3.0-only", "Apache-2.0", "MIT", "EUPL-1.2"} def main() -> int: proc = subprocess.run( ["reuse", "lint", "--json"], capture_output=True, text=True, check=False ) try: report = json.loads(proc.stdout) except json.JSONDecodeError: sys.stderr.write(proc.stdout + proc.stderr) return 1 problems = {} for key, value in report["non_compliant"].items(): if key == "unused_licenses": value = [name for name in value if name not in UNUSED_ALLOWED] if value: problems[key] = value if problems: sys.stderr.write( "reuse lint found problems:\n" + json.dumps(problems, indent=2) + "\n" ) return 1 print( "reuse lint: compliant (unused licence texts tolerated: " + ", ".join(sorted(UNUSED_ALLOWED)) + ")" ) return 0 if __name__ == "__main__": sys.exit(main())