-
Notifications
You must be signed in to change notification settings - Fork 16
/
list_unsigned_rpms
executable file
·56 lines (39 loc) · 1.23 KB
/
list_unsigned_rpms
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
#!/usr/bin/env python3
from subprocess import check_output, STDOUT, CalledProcessError
import argparse
import glob
def find_unsigned_packages(target_dir, gpgkey):
packages = glob.glob(f"{target_dir}/*.rpm")
for package in packages:
cmd = [
'rpm',
'--query',
'--queryformat',
'%{SIGPGP:pgpsig}',
package
]
output = check_output(cmd, universal_newlines=True, stderr=STDOUT)
if gpgkey.lower() not in output:
yield package
def handle_args():
parser = argparse.ArgumentParser(description='Sign unsigned RPMs in local stage repository')
parser.add_argument(
'repository_path',
help='Path to repository to sign unsigned RPMs'
)
parser.add_argument(
'gpgkey',
help='Short form gpgkey for the version being generated'
)
args = parser.parse_args()
if len(args.gpgkey) != 16:
raise SystemExit("GPG key must be the last 16 characters")
return args
def main():
args = handle_args()
repository_path = args.repository_path
gpgkey = args.gpgkey
for rpm in find_unsigned_packages(repository_path, gpgkey):
print(rpm)
if __name__ == '__main__':
main()