diff options
author | Simo Fält <simo.falt@qt.io> | 2023-05-25 11:12:40 +0300 |
---|---|---|
committer | Simo Fält <simo.falt@qt.io> | 2023-05-25 11:12:40 +0300 |
commit | ca0519cb3f6b62e3b61ba74f0c60eac891dd3a15 (patch) | |
tree | 46e94d1b9a77648ca080a36b7d266f2322031d67 /tools/license_changer.py | |
parent | 72d32f66685fbb7fefc41eee629e63f4824cb10b (diff) | |
parent | 7c386888b453b7f2ac78ef1da59d077b25e372b3 (diff) |
Merge tag 'v5.15.4-lts' into tqtc/lts-5.15-opensourcev5.15.4-lts-lgpl
Qt For Python Release 5.15.4
Change-Id: I8457501ba90fc481fb9de686eb8a2f880ecc06cd
Diffstat (limited to 'tools/license_changer.py')
-rw-r--r-- | tools/license_changer.py | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/tools/license_changer.py b/tools/license_changer.py new file mode 100644 index 000000000..0c3443b83 --- /dev/null +++ b/tools/license_changer.py @@ -0,0 +1,85 @@ +############################################################################# +## +## Copyright (C) 2021 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the Qt for Python project. +## +## $QT_BEGIN_LICENSE:COMM$ +## +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## $QT_END_LICENSE$ +## +############################################################################# + +from argparse import ArgumentParser, RawTextHelpFormatter +import os +from pathlib import Path +import subprocess +import sys + + +DESC = """ +Tool to adapt licenses to a commercial LTS branch +Requires the qtsdk/tqtc-qtsdk and qtqa repos to be checked out as siblings. +""" + + +REPO_DIR = Path(__file__).resolve().parents[1] + + +EXCLUSIONS = ['/build_scripts/', '/coin/', '/doc/', '/examples/', + '/testing/', '/tests/', + '/coin_build_instructions.py', '/coin_test_instructions.py', + '/ez_setup.py', '/setup.py', '/testrunner.py'] + + +if __name__ == '__main__': + argument_parser = ArgumentParser(description=DESC, + formatter_class=RawTextHelpFormatter) + argument_parser.add_argument('--dry-run', '-d', action='store_true', + help='Dry run, print commands') + options = argument_parser.parse_args() + dry_run = options.dry_run + + license_changer = (REPO_DIR.parent / 'tqtc-qtsdk' / 'packaging-tools' + / 'release_tools' / 'license_changer.pl') + print('Checking ', license_changer) + if not license_changer.is_file: + print('Not found, please clone the qtsdk/tqtc-qtsdk repo') + sys.exit(1) + template = (REPO_DIR.parent / 'qtqa' / 'tests' / 'prebuild' + / 'license' / 'templates' / 'header.COMM') + print('Checking ', template) + if not template.is_file(): + print('Not found, please clone the qtqa repo') + sys.exit(1) + + os.chdir(REPO_DIR) + fixed_cmd = [str(license_changer), '--path', str(REPO_DIR), + '--headerfile', str(template)] + for e in EXCLUSIONS: + fixed_cmd.append('--exclude') + fixed_cmd.append(e) + + for license in ['GPL-EXCEPT', 'GPL', 'LGPL']: + log = f'license_{license.lower()}_log.txt' + cmd = fixed_cmd + cmd.extend(['--replacehdr', license, '--errorlog', log]) + cmds = ' '.join(cmd) + print('Running: ', cmds) + if not dry_run: + ex = subprocess.call(cmd) + if ex != 0: + print('FAIL! ', cmds) + sys.exit(1) + + if not dry_run: + subprocess.call(['git', 'diff']) |