Skip to content

Instantly share code, notes, and snippets.

@paride
Created March 26, 2024 17:51
Show Gist options
  • Save paride/48a8d68f0c99e1da79fe10f01fc65483 to your computer and use it in GitHub Desktop.
Save paride/48a8d68f0c99e1da79fe10f01fc65483 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import sys
import yaml
# Use LibYAML is available, otherwise this is going to be super slow
try:
from yaml import CSafeLoader as SafeLoader
except ImportError:
print("Expect slowness!")
from yaml import SafeLoader
def parse_excuses(excuses_file):
regressed_packages = set()
with open(excuses_file, "r", encoding="UTF-8") as f:
excuses = yaml.load(f, Loader=SafeLoader)["sources"]
for excuse in excuses:
# We only want packages blocked *only* by tests
if excuse["reason"] != ["autopkgtest"]:
continue
# Among blocked-by-tests packages, look regressions in testing,
# to exclude packages with tests in RUNNING state.
verdict = excuse["policy_info"]["autopkgtest"]["verdict"]
if verdict != "REJECTED_PERMANENTLY":
continue
# Ok, we found a package blocked only by tests.
# Now let's find the blocking packages
autopkgtest = excuse["policy_info"]["autopkgtest"]
for entry in autopkgtest:
if "/" not in entry:
# It's the "verdict", not a package/version entry
continue
for arch in excuse["policy_info"]["autopkgtest"][entry]:
result = excuse["policy_info"]["autopkgtest"][entry][arch][0]
if result == "REGRESSION":
bad = f"{entry}/{arch}"
regressed_packages.add(bad)
print(*regressed_packages, sep="\n")
if __name__ == "__main__":
if len(sys.argv) != 2:
print(f"Usage: {sys.argv[0]} /path/to/update_excuses.yaml")
print(
f"Or: {sys.argv[0]} <(curl -sS https://ubuntu-archive-team.ubuntu.com/proposed-migration/noble/update_excuses.yaml.xz | xzcat)"
)
sys.exit(1)
parse_excuses(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment