Debian Codegraph @

scripts/dist-common-files.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 #
3 # Copyright (C) 2023-2026 Tim-Philipp Müller <tim centricular net>
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Library General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later version.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Library General Public License for more details.
14 #
15 # You should have received a copy of the GNU Library General Public
16 # License along with this library; if not, write to the
17 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 # Boston, MA 02110-1301, USA.
19
20 import os
21 import subprocess
22 import shutil
23 import tempfile
24 import sys
25
26 if __name__ == "__main__":
27 dist_root = os.environ['MESON_DIST_ROOT']
28 build_root = os.environ['MESON_BUILD_ROOT']
29 source_root = os.environ['MESON_SOURCE_ROOT']
30 project_version = sys.argv[1]
31 pwd = os.environ['PWD']
32 tmpdir = tempfile.gettempdir()
33
34 ver_array = project_version.split('.')
35 major_minor = '{}.{}'.format(ver_array[0], ver_array[1])
36
37 module = os.path.basename(os.path.normpath(source_root))
38
39 print('Copying README.md into dist staging directory ..')
40 readme_src = os.path.join(source_root, '..', '..', 'README.md')
41 shutil.copy2(readme_src, dist_root)
42
43 # Release notes (instead of NEWS) - could also write it out as NEWS.md
44 print('Copying release notes into dist staging directory ..')
45 relnotes_src = os.path.join(source_root, '..', '..', 'release-notes', major_minor, f'release-notes-{major_minor}.md')
46 with open(relnotes_src, 'r') as f:
47 lines = f.readlines()
48 if not f'### {project_version}\n' in lines:
49 sys.exit(f'Update {relnotes_src} first, must contain a section for {project_version}')
50 if not project_version.endswith('.0'):
51 found = False
52 for line in lines:
53 if line.startswith('The latest') and project_version in line:
54 found = True
55 if not found:
56 sys.exit(f'Update {relnotes_src} first, header should say latest version is {project_version}.')
57 shutil.copy2(relnotes_src, dist_root)
58
59 # RELEASE
60 print('Copying RELEASE into dist staging directory ..')
61 rel_src = os.path.join(source_root, '..', '..', 'release-notes', major_minor, f'RELEASE-{major_minor}.template')
62 with open(rel_src, 'r') as f:
63 lines = f.readlines()
64
65 assert (lines[0].startswith('This is GStreamer'))
66
67 if module == 'gstreamer':
68 lines[0] = f'This is GStreamer core {project_version}\n'
69 else:
70 lines[0] = f'This is GStreamer {module} {project_version}\n'
71
72 with open(os.path.join(dist_root, 'RELEASE'), 'w') as f:
73 f.writelines(lines)