Skip to content

Commit

Permalink
src/download-overrides: Fix flake8 CI errors
Browse files Browse the repository at this point in the history
  • Loading branch information
c4rt0 authored and dustymabe committed Jun 14, 2023
1 parent 2f2fec6 commit 453afe6
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/download-overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import os
import yaml
import subprocess
import sys

arch = os.uname().machine

# this was partially copied from coreos-koji-tagger


def get_rpminfo(string: str) -> str:
form = hawkey.FORM_NEVRA

Expand All @@ -23,20 +24,23 @@ def get_rpminfo(string: str) -> str:
rpminfo = nevras[0]
return rpminfo


def is_override_lockfile(filename: str) -> bool:
return (filename == "manifest-lock.overrides.yaml" or
filename == f'manifest-lock.overrides.{arch}.yaml')


def assert_epochs_match(overrides_epoch: int, rpmfile_epoch: str):
# normalize the input into a string
if overrides_epoch is None:
normalized_overrides_epoch = '(none)' # matches rpm -qp --queryformat='%{E}'
normalized_overrides_epoch = '(none)' # matches rpm -qp --queryformat='%{E}'
else:
normalized_overrides_epoch = str(overrides_epoch)
if normalized_overrides_epoch != rpmfile_epoch:
normalized_overrides_epoch = str(overrides_epoch)
if normalized_overrides_epoch != rpmfile_epoch:
raise Exception(f"Epoch mismatch between downloaded rpm ({rpmfile_epoch})"
f" and overrides file entry ({overrides_epoch})")


assert os.path.isdir("builds"), "Missing builds/ dir; is this a cosa workdir?"

rpms = set()
Expand All @@ -58,9 +62,9 @@ def assert_epochs_match(overrides_epoch: int, rpmfile_epoch: str):
# Make sure the epoch matches what was in the overrides file
# otherwise we can get errors: https://github.com/coreos/fedora-coreos-config/pull/293
cp = subprocess.run(['rpm', '-qp', '--queryformat', '%{E}', f'{rpmnvra}.rpm'],
check=True,
capture_output=True,
cwd='overrides/rpm')
check=True,
capture_output=True,
cwd='overrides/rpm')
rpmfile_epoch = cp.stdout.decode('utf-8')
assert_epochs_match(rpminfo.epoch, rpmfile_epoch)

Expand Down

0 comments on commit 453afe6

Please sign in to comment.