Unverified Commit f8f7fbf3 authored by intrigeri's avatar intrigeri
Browse files

Lint

parent bbc87dd5
...@@ -17,17 +17,26 @@ log = logging.getLogger() ...@@ -17,17 +17,26 @@ log = logging.getLogger()
def main(): def main():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="Copy IUKs from Jenkins to our rsync server \ description="Copy IUKs from Jenkins to our rsync server \
and verify that they match those built locally" and verify that they match those built locally")
) parser.add_argument("--hashes-file",
parser.add_argument("--hashes-file", type=str, action="store", required=True) type=str,
parser.add_argument("--jenkins-build-id", type=int, action="store", required=True) action="store",
required=True)
parser.add_argument("--jenkins-build-id",
type=int,
action="store",
required=True)
parser.add_argument("--work-dir", type=str, action="store", default=".") parser.add_argument("--work-dir", type=str, action="store", default=".")
parser.add_argument("-q", "--quiet", action="store_true", parser.add_argument("-q",
"--quiet",
action="store_true",
help="quiet output") help="quiet output")
parser.add_argument("--debug", action="store_true", help="debug output") parser.add_argument("--debug", action="store_true", help="debug output")
parser.add_argument("--skip-sending-hashes-file", action="store_true", parser.add_argument("--skip-sending-hashes-file",
action="store_true",
help="Assume the hashes file was uploaded already") help="Assume the hashes file was uploaded already")
parser.add_argument("--skip-downloading-iuks", action="store_true", parser.add_argument("--skip-downloading-iuks",
action="store_true",
help="Assume the IUKs were already downloaded") help="Assume the IUKs were already downloaded")
args = parser.parse_args() args = parser.parse_args()
...@@ -65,19 +74,14 @@ def main(): ...@@ -65,19 +74,14 @@ def main():
) )
def send_hashes_file( def send_hashes_file(hashes_file: str, desthost: str, destdir: str) -> None:
hashes_file: str,
desthost: str,
destdir: str) -> None:
log.info("Sending %(f)s to %(d)s on %(h)s…" % { log.info("Sending %(f)s to %(d)s on %(h)s…" % {
"f": hashes_file, "f": hashes_file,
"d": destdir, "d": destdir,
"h": desthost, "h": desthost,
}) })
subprocess.run( subprocess.run(
["scp", hashes_file, "%s:%s" % (desthost, destdir)], ["scp", hashes_file, "%s:%s" % (desthost, destdir)], check=True)
check=True
)
def iuks_listed_in(hashes_file: str) -> List[str]: def iuks_listed_in(hashes_file: str) -> List[str]:
...@@ -86,12 +90,9 @@ def iuks_listed_in(hashes_file: str) -> List[str]: ...@@ -86,12 +90,9 @@ def iuks_listed_in(hashes_file: str) -> List[str]:
return [l.split(' ')[-1].rstrip() for l in lines] return [l.split(' ')[-1].rstrip() for l in lines]
def download_iuks_from_jenkins( def download_iuks_from_jenkins(hashes_file: str, desthost: str, destdir: str,
hashes_file: str, jenkins_iuks_base_url: str,
desthost: str, jenkins_build_id: int) -> None:
destdir: str,
jenkins_iuks_base_url: str,
jenkins_build_id: int) -> None:
log.info("Downloading IUKs from Jenkins to %s…" % (desthost)) log.info("Downloading IUKs from Jenkins to %s…" % (desthost))
iuks = iuks_listed_in(hashes_file) iuks = iuks_listed_in(hashes_file)
log.debug("IUKS: %s" % ', '.join(iuks)) log.debug("IUKS: %s" % ', '.join(iuks))
...@@ -112,14 +113,14 @@ def download_iuks_from_jenkins( ...@@ -112,14 +113,14 @@ def download_iuks_from_jenkins(
def verify_iuks(desthost: str, iuks_dir: str, hashes_file: str) -> None: def verify_iuks(desthost: str, iuks_dir: str, hashes_file: str) -> None:
log.info("Verifying that IUKs built on Jenkins match those you've built…") log.info("Verifying that IUKs built on Jenkins match those you've built…")
try: try:
subprocess.run( subprocess.run([
["ssh", desthost, "ssh", desthost,
"cd '%(d)s' && sha256sum --check --strict '%(f)s'" % { "cd '%(d)s' && sha256sum --check --strict '%(f)s'" % {
"d": iuks_dir, "d": iuks_dir,
"f": Path(hashes_file).name, "f": Path(hashes_file).name,
}], }
check=True ],
) check=True)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
print("\nERROR: IUKs built on Jenkins don't match yours\n", print("\nERROR: IUKs built on Jenkins don't match yours\n",
file=sys.stderr) file=sys.stderr)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment