🔒 Repository is read-only – file editing is disabled.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
#!/usr/bin/env python3
"""core/glib: poprawne sumy + wirtualna nazwa glib2.
Stan wyjsciowy: 3 zrodla, ale 4 wpisy sha256sums (wszystkie SKIP) - nadmiarowy
wpis + brak jakiejkolwiek weryfikacji pobieranych zrodel.
Zmiany:
1. sha256sums = 3 oficjalne sumy w kolejnosci source (glib/GI z
download.gnome.org *.sha256sum, patch policzony lokalnie),
2. provides: [glib2] - konwencja Arch/NuTyX; w repo pakiet nazywa sie `glib`
(103 receptury), a czesc receptur (np. libgsystemservice) wola `glib2`,
3. pkgrel 1 -> 2.
"""
import sys
import yaml
P = "/var/lib/pagan-sync/recipes/core/glib/PAGBUILD.yaml"
APPLY = "--apply" in sys.argv
SUMS = [
"920d1a3fcedeadc32acff95c2e203b319039dd4b4a08dd1a2dfd283d19c0b9ae", # gobject-introspection-1.86.0.tar.xz
"ab24d24e698dfa1e408b7bcdb508f4aafc906185a8b8ce72fdf79bbbdc9b383b", # glib-2.88.3.tar.xz
"8f9ee9f4a6a08c49c9c912241c63d55b969950c49f4d40337c6fd9557b9daa1b", # glib-skip_warnings-1.patch
]
COMMENT = """depends: []
# Wirtualna nazwa `glib2` (konwencja Arch/NuTyX). W repozytorium pakiet nazywa sie
# `glib` i 103 receptury deklaruja zaleznosc `glib`. Czesc receptur (np.
# libgsystemservice) deklaruje jednak `glib2`; bez tego `pag install glib2`
# i rozwiazywanie zaleznosci nie znajduja pakietu. pagbuild zapisuje to do
# metadata.json (pole `provides`), a repo.json i klient `pag` rozwiazuja przez nie.
provides:
- glib2
"""
text = open(P, newline="", encoding="utf-8").read()
before = yaml.safe_load(text)
assert before["sha256sums"] == ["SKIP"] * 4, f"inny stan sum: {before['sha256sums']}"
assert len(before["source"]) == 3, f"inna liczba zrodel: {len(before['source'])}"
assert before.get("pkgrel") == "1"
old_sums = "sha256sums:\n" + "- SKIP\n" * 4
assert old_sums in text, "nie znalazlem bloku 4x SKIP"
new = text.replace(old_sums, "sha256sums:\n" + "".join(f"- {s}\n" for s in SUMS), 1)
assert text.count("depends: []") == 1, "niejednoznaczne depends: []"
new = new.replace("depends: []", COMMENT, 1)
assert "pkgrel: '1'" in new
new = new.replace("pkgrel: '1'", "pkgrel: '2'", 1)
after = yaml.safe_load(new)
print("pkgname :", after["pkgname"], after["pkgver"], "pkgrel", after["pkgrel"])
print("provides:", after["provides"])
print("depends :", after["depends"])
print(f"source/sums: {len(after['source'])}/{len(after['sha256sums'])}")
for s, h in zip(after["source"], after["sha256sums"]):
print(f" {h[:16]}... {s}")
ok = (after["sha256sums"] == SUMS
and after["provides"] == ["glib2"]
and after["pkgrel"] == "2"
and len(after["source"]) == len(after["sha256sums"]) == 3)
changed = sorted(k for k in set(before) | set(after) if before.get(k) != after.get(k))
print("zmienione klucze:", changed)
ok = ok and set(changed) == {"sha256sums", "provides", "pkgrel"}
print("walidacja:", "OK" if ok else "BLAD")
if not ok:
sys.exit(1)
if APPLY:
with open(P, "w", newline="", encoding="utf-8") as f:
f.write(new)
print("ZAPISANO")
else:
print("DRY-RUN")