Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit 8e8f82e

Browse files
committed
Add a script for filter packages by sst
It is also possible to use it for finding differences between the compose content and the content definition config (see the comment in the script).
1 parent 00fffda commit 8e8f82e

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

get_pkgs_sst.py

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/env python3
2+
3+
"""
4+
Author: Honza Horak <[email protected]>
5+
Copyright 2021 Red Hat, Inc.
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.
24+
25+
26+
A tool to filter packages from the definition files
27+
===================================================
28+
An example of the usage for a useful report of what is specified in the config
29+
but not available in the compose:
30+
31+
./get_pkgs_sst.py --filter-sst=sst_cs_apps configs/*.yaml 2>/dev/null >/tmp/sst
32+
for r in BaseOS AppStream ; do
33+
dnf repoquery --refresh --available --repofrompath="a,https://odcs.stream.centos.org/test/latest-CentOS-Stream/compose/$r/x86_64/os/" \
34+
--disablerepo=\* --enablerepo=a --qf '%{name}'
35+
done | sort -u >/tmp/supported
36+
37+
for r in BaseOS AppStream CRB ; do
38+
dnf repoquery --refresh --available --repofrompath="a,https://odcs.stream.centos.org/test/latest-CentOS-Stream/compose/$r/x86_64/os/" \
39+
--disablerepo=\* --enablerepo=a --qf '%{name}'
40+
done | sort -u >/tmp/shipped
41+
42+
cat /tmp/sst | while read -r c ; do
43+
if ! grep -q -e "^$c$" /tmp/supported ; then
44+
if ! grep -q -e "^$c$" /tmp/shipped ; then
45+
echo "$c not shipped at all"
46+
else
47+
echo "$c not fully supported (CRB only)"
48+
fi
49+
fi
50+
done
51+
"""
52+
53+
import yaml
54+
import argparse
55+
import sys
56+
57+
def main():
58+
parser = argparse.ArgumentParser(description='Filter packages from the content resolver input.')
59+
parser.add_argument('input_files', metavar='FILE', type=str, nargs='+',
60+
help='input files')
61+
parser.add_argument('--filter-sst', dest='filter_sst', default=None,
62+
help='Filter data only for a specific sst (e.g.: sst_cs_apps)')
63+
64+
args = parser.parse_args()
65+
66+
for f in args.input_files:
67+
with open(f, 'r') as stream:
68+
try:
69+
data = yaml.safe_load(stream)
70+
try:
71+
if args.filter_sst:
72+
if data['data']['maintainer'] != args.filter_sst:
73+
continue
74+
print('\n'.join(data['data']['packages']))
75+
except KeyError as exc:
76+
print('Wrong format in {}'.format(f), file=sys.stderr)
77+
print(exc, file=sys.stderr)
78+
continue
79+
80+
except yaml.YAMLError as exc:
81+
print(exc)
82+
exit(1)
83+
84+
if __name__ == "__main__":
85+
main()
86+
87+
# vim :set ts=4 sw=4 sts=4 et :

0 commit comments

Comments
 (0)