-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrun-distrepos.py
More file actions
executable file
·211 lines (188 loc) · 8.73 KB
/
run-distrepos.py
File metadata and controls
executable file
·211 lines (188 loc) · 8.73 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/usr/bin/env python3
"""
run-distrepos
Run osg-koji dist-repo tasks with the correct arguments against a subset of
Koji tags. Note that this uses pre-defined tag data (in the TAGDATA var).
"""
import pprint
import re
import subprocess as sp
import sys
from argparse import ArgumentParser
def ask_yn(prompt: str):
if not sys.stdin.isatty():
return False
reply = ""
while not (reply.startswith("y") or reply.startswith("n")):
print(prompt, "(y/n)", end=" ")
try:
reply = input()
except EOFError:
return False
return reply.startswith("y")
def filter_tags(pattern):
matching = [tag for tag in TAGDATA if pattern.search(tag[0])]
matching_names = [tag[0] for tag in matching]
print("Matching tags: ")
pprint.pprint(matching_names)
return matching
def run_distrepo(tag: str, key: str, non_latest: bool):
sp.run(
"osg-koji dist-repo --wait --with-src "
" --split-debuginfo --write-signed-rpms "
+ ("--non-latest " if non_latest else " ")
+ tag
+ " "
+ key,
shell=True,
)
def get_parser():
"""
Return an argument parser.
"""
parser = ArgumentParser()
parser.add_argument(
"regex",
default="",
nargs="?",
help="Regex to match the tags to regen against (not anchored). "
"Will prompt interactively if not specified.",
)
parser.add_argument(
"-y",
"--noconfirm",
action="store_true",
help="Do not ask for confirmation.",
)
return parser
def run_distrepo_on_matching(matching):
for tag in matching:
name = tag[0]
key = tag[1]
latest = tag[2] == "latest"
run_distrepo(name, key, non_latest=not latest)
def main(argv=None):
parser = get_parser()
args = parser.parse_args((argv or sys.argv)[1:])
if args.regex:
pattern = re.compile(args.regex)
matching = filter_tags(pattern)
if not matching:
print("no tags match")
return 1
if args.noconfirm or ask_yn("Run distrepo on the above tags?"):
run_distrepo_on_matching(matching)
else:
if args.noconfirm:
parser.error("You must specify a regex if you use -y")
if not sys.stdin.isatty():
parser.error("You must specify a pattern if not on a tty")
while True:
try:
regex = input("Enter regex: ").strip()
except EOFError:
print("EOF, exiting")
return 1
except KeyboardInterrupt:
print("Interrupted, exiting")
return 3
if not regex:
print("Empty pattern, exiting")
return 1
try:
pattern = re.compile(regex)
except ValueError:
print("invalid regex, try again")
continue
matching = filter_tags(pattern)
if ask_yn("Run distrepo on the above tags?"):
run_distrepo_on_matching(matching)
break
return 0
# fmt: off
# TAGDATA fields are: tag, GPG key hash, whether to also include non-latest RPMs
TAGDATA = [
("osg-23-el8-contrib" , "92897c00" , "latest") ,
("osg-23-el8-empty" , "92897c00" , "latest") ,
("osg-23-el9-contrib" , "92897c00" , "latest") ,
("osg-23-el9-empty" , "92897c00" , "latest") ,
("osg-23-internal-el8-development" , "4d4384d0" , "latest") ,
("osg-23-internal-el8-release" , "92897c00" , "non-latest"),
("osg-23-internal-el9-development" , "4d4384d0" , "latest") ,
("osg-23-internal-el9-release" , "92897c00" , "non-latest"),
("osg-23-main-el8-development" , "4d4384d0" , "latest") ,
("osg-23-main-el8-release" , "92897c00" , "non-latest"),
("osg-23-main-el8-testing" , "92897c00" , "non-latest"),
("osg-23-main-el9-development" , "4d4384d0" , "latest") ,
("osg-23-main-el9-release" , "92897c00" , "non-latest"),
("osg-23-main-el9-testing" , "92897c00" , "non-latest"),
("osg-23-upcoming-el8-development" , "4d4384d0" , "latest") ,
("osg-23-upcoming-el8-release" , "92897c00" , "non-latest"),
("osg-23-upcoming-el8-testing" , "92897c00" , "non-latest"),
("osg-23-upcoming-el9-development" , "4d4384d0" , "latest") ,
("osg-23-upcoming-el9-release" , "92897c00" , "non-latest"),
("osg-23-upcoming-el9-testing" , "92897c00" , "non-latest"),
("osg-24-contrib-el8" , "effc3be6" , "latest") ,
("osg-24-empty-el8" , "effc3be6" , "latest") ,
("osg-24-contrib-el9" , "effc3be6" , "latest") ,
("osg-24-empty-el9" , "effc3be6" , "latest") ,
("osg-24-contrib-el10" , "effc3be6" , "latest") ,
("osg-24-empty-el10" , "effc3be6" , "latest") ,
("osg-24-internal-el8-development" , "34e958b3" , "latest") ,
("osg-24-internal-el8-release" , "effc3be6" , "non-latest"),
("osg-24-internal-el9-development" , "34e958b3" , "latest") ,
("osg-24-internal-el9-release" , "effc3be6" , "non-latest"),
("osg-24-internal-el10-development" , "34e958b3" , "latest") ,
("osg-24-internal-el10-release" , "effc3be6" , "non-latest"),
("osg-24-main-el8-development" , "34e958b3" , "latest") ,
("osg-24-main-el8-release" , "effc3be6" , "non-latest"),
("osg-24-main-el8-testing" , "effc3be6" , "non-latest"),
("osg-24-main-el9-development" , "34e958b3" , "latest") ,
("osg-24-main-el9-release" , "effc3be6" , "non-latest"),
("osg-24-main-el9-testing" , "effc3be6" , "non-latest"),
("osg-24-main-el10-development" , "34e958b3" , "latest") ,
("osg-24-main-el10-release" , "effc3be6" , "non-latest"),
("osg-24-main-el10-testing" , "effc3be6" , "non-latest"),
("osg-24-upcoming-el8-development" , "34e958b3" , "latest") ,
("osg-24-upcoming-el8-release" , "effc3be6" , "non-latest"),
("osg-24-upcoming-el8-testing" , "effc3be6" , "non-latest"),
("osg-24-upcoming-el9-development" , "34e958b3" , "latest") ,
("osg-24-upcoming-el9-release" , "effc3be6" , "non-latest"),
("osg-24-upcoming-el9-testing" , "effc3be6" , "non-latest"),
("osg-24-upcoming-el10-development" , "34e958b3" , "latest") ,
("osg-24-upcoming-el10-release" , "effc3be6" , "non-latest"),
("osg-24-upcoming-el10-testing" , "effc3be6" , "non-latest"),
("osg-25-contrib-el8" , "d4e9b1fc" , "non-latest"),
("osg-25-contrib-el9" , "d4e9b1fc" , "non-latest"),
("osg-25-contrib-el10" , "d4e9b1fc" , "non-latest"),
("osg-25-empty-el8" , "d4e9b1fc" , "non-latest"),
("osg-25-empty-el9" , "d4e9b1fc" , "non-latest"),
("osg-25-empty-el10" , "d4e9b1fc" , "non-latest"),
("osg-25-internal-el8-development" , "222c5d49" , "latest") ,
("osg-25-internal-el8-release" , "d4e9b1fc" , "non-latest"),
("osg-25-internal-el9-development" , "222c5d49" , "latest") ,
("osg-25-internal-el9-release" , "d4e9b1fc" , "non-latest"),
("osg-25-internal-el10-development" , "222c5d49" , "latest") ,
("osg-25-internal-el10-release" , "d4e9b1fc" , "non-latest"),
("osg-25-main-el8-development" , "222c5d49" , "latest") ,
("osg-25-main-el8-release" , "d4e9b1fc" , "non-latest"),
("osg-25-main-el8-testing" , "d4e9b1fc" , "non-latest"),
("osg-25-main-el9-development" , "222c5d49" , "latest") ,
("osg-25-main-el9-release" , "d4e9b1fc" , "non-latest"),
("osg-25-main-el9-testing" , "d4e9b1fc" , "non-latest"),
("osg-25-main-el10-development" , "222c5d49" , "latest") ,
("osg-25-main-el10-release" , "d4e9b1fc" , "non-latest"),
("osg-25-main-el10-testing" , "d4e9b1fc" , "non-latest"),
("osg-25-upcoming-el8-development" , "222c5d49" , "latest") ,
("osg-25-upcoming-el8-release" , "d4e9b1fc" , "non-latest"),
("osg-25-upcoming-el8-testing" , "d4e9b1fc" , "non-latest"),
("osg-25-upcoming-el9-development" , "222c5d49" , "latest") ,
("osg-25-upcoming-el9-release" , "d4e9b1fc" , "non-latest"),
("osg-25-upcoming-el9-testing" , "d4e9b1fc" , "non-latest"),
("osg-25-upcoming-el10-development" , "222c5d49" , "latest") ,
("osg-25-upcoming-el10-release" , "d4e9b1fc" , "non-latest"),
("osg-25-upcoming-el10-testing" , "d4e9b1fc" , "non-latest"),
]
# fmt: on
if __name__ == "__main__":
sys.exit(main())