-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
…of Copr When the version is nightly, this will not pull from production but instead treat what is in Copr as the source of truth. At the end, the output for a versioned repository is a list of unsigned packages.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from subprocess import check_output, STDOUT, CalledProcessError | ||
import argparse | ||
import glob | ||
|
||
|
||
def find_unsigned_packages(target_dir, gpgkey): | ||
unsigned = [] | ||
packages = glob.glob(f"{target_dir}/*.rpm") | ||
|
||
for package in packages: | ||
cmd = [ | ||
'rpm', | ||
'-qpi', | ||
package | ||
] | ||
|
||
output = check_output(cmd, universal_newlines=True, stderr=STDOUT) | ||
|
||
if gpgkey.lower() not in output: | ||
unsigned.append(package) | ||
|
||
return unsigned | ||
|
||
|
||
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, does not apply to nightly' | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
if args.gpgkey: | ||
if len(args.gpgkey) != 8: | ||
raise SystemExit("GPG key must be in short form and 8 characters long") | ||
|
||
return args | ||
|
||
|
||
def main(): | ||
args = handle_args() | ||
|
||
repository_path = args.repository_path | ||
gpgkey = args.gpgkey | ||
|
||
unsigned_rpms = find_unsigned_packages(f"{repository_path}/x86_64", gpgkey) | ||
unsigned_srpms = find_unsigned_packages(f"{repository_path}/source", gpgkey) | ||
|
||
for rpm in unsigned_rpms: | ||
print(rpm) | ||
for srpm in unsigned_srpms: | ||
print(srpm) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash -e | ||
|
||
. settings | ||
|
||
echo "./list_unsigned_rpms $1 $GPGKEY" | ||
UNSIGNED_RPMS=(`./list_unsigned_rpms $1 $GPGKEY`) | ||
Check warning Code scanning / shellcheck Prefer mapfile or read -a to split command output (or quote to avoid splitting). Warning
Prefer mapfile or read -a to split command output (or quote to avoid splitting).
Check notice Code scanning / shellcheck Use $(...) notation instead of legacy backticks .... Note
Use $(...) notation instead of legacy backticks ....
Check notice Code scanning / shellcheck Double quote to prevent globbing and word splitting. Note
Double quote to prevent globbing and word splitting.
Check notice Code scanning / shellcheck Double quote to prevent globbing and word splitting. Note
Double quote to prevent globbing and word splitting.
|
||
|
||
for rpm_path in "${UNSIGNED_RPMS[@]}" | ||
do | ||
echo "Signing $rpm_path" | ||
./sign_rpms $rpm_path | ||
Check notice Code scanning / shellcheck Double quote to prevent globbing and word splitting. Note
Double quote to prevent globbing and word splitting.
|
||
done |