File: min-base-version

package info (click to toggle)
cockpit 239-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 67,268 kB
  • sloc: javascript: 245,474; ansic: 72,273; python: 23,634; xml: 6,155; sh: 2,919; makefile: 923; sed: 5
file content (52 lines) | stat: -rwxr-xr-x 1,871 bytes parent folder | download
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python3
# Compute the maximum required "cockpit" version from all pkg/*/manifest.json
# for computing rpm/deb package dependencies. This is a bit stricter than
# absolutely required, as only some subpackages might require a newer cockpit
# version, but doing this precisely would be much more complicated and error
# prone.
#
# Copyright (C) 2017 Red Hat, Inc.
#
# Cockpit is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Cockpit is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Cockpit; If not, see <http://www.gnu.org/licenses/>.

import sys
import os
import json
from glob import glob

proj_dir = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0])))

max_version = ''

for manifest in glob('pkg/*/manifest.json'):
    # if pkg names are given on the command line, then only look at those,
    # otherwise on all of them
    if len(sys.argv) > 1:
        pkg = os.path.basename(os.path.dirname(manifest))
        if pkg not in sys.argv[1:]:
            continue
    with open(manifest, encoding='UTF-8') as f:
        requires = json.load(f).get('requires', {})
    try:
        v = requires['cockpit']
        if v > max_version:
            max_version = v
    except KeyError:
        sys.stderr.write('WARNING: %s lacks cockpit dependency\n' % manifest)

if not max_version:
    sys.stderr.write('ERROR: Could not determine version\n')
    sys.exit(1)

print(max_version)