Files
gnome-shell-extensions/meson/check-version.py
Florian Müllner b7f285d733 Make project compatible with Reuse Software spec
Provide all licenses used in the project in a LICENSES folder and
add SPDX license and copyright information for all files in
accordance with the Reuse Software[0] specification.

The copyright information is based on the file's git history,
using a fairly generous definition of "non-trivial".

As of the spec recommendation, the information is generally added
as comments in the files themselves, except for

 - NEWS, README and similar top-level standard files, so that
   a SPDX code isn't the first thing people encounter
 - files that don't support comments (json) or where they'd
   be a bit awkward (.desktop, .service)
 - anything under po/, to not interfere with translation teams

Those are covered by a .reuse/dep5 files, except for image assets,
where separate .license files are used (It would be possible to
add comments to SVG files, but I don't trust image editors to
preserve them).

[0] https://reuse.software/

Part-of:
<https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/224>
2023-08-17 11:51:48 +00:00

37 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2021 Florian Müllner <fmuellner@gnome.org>
#
# SPDX-License-Identifier: GPL-2.0-or-later
import os, sys
from pathlib import Path
import argparse, subprocess
def check_version(version, file, type='news'):
if type == 'news':
line = file.open().readline()
ok = line.startswith(version)
print("{}: {}".format(file, "OK" if ok else "FAILED"))
if not ok:
raise Exception("{} does not start with {}".format(file, version))
elif type == 'metainfo':
subprocess.run(['appstream-util', 'validate-version', file, version],
check=True)
else:
raise Exception('Not implemented')
parser = argparse.ArgumentParser(description='Check release version information.')
parser.add_argument('--type', choices=['metainfo','news'], default='news')
parser.add_argument('version', help='the version to check for')
parser.add_argument('files', nargs='+', help='files to check')
args = parser.parse_args()
distroot = os.environ.get('MESON_DIST_ROOT', './')
try:
for file in args.files:
check_version(args.version, Path(distroot, file), args.type)
except:
sys.exit(1)