summaryrefslogtreecommitdiffstats
path: root/meson/check-version.py
blob: 81750c990dc1da8706cbeb8a08d9613221193456 (plain)
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
31
32
#!/usr/bin/env python3

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)