|
| 1 | +URL = "https://api.github.com/repos/hhd-dev/linux-bazzite/releases" |
| 2 | + |
| 3 | +import requests |
| 4 | +import sys |
| 5 | +import datetime |
| 6 | + |
| 7 | +contributors = { "antheas": "Antheas Kapenekakis <[email protected]>"} |
| 8 | + |
| 9 | +# * Wed Aug 28 2024 Fedora Kernel Team <[email protected]> [6.11.0-0.rc5.86987d84b968.45] |
| 10 | +# - redhat: include resolve_btfids in kernel-devel (Jan Stancek) |
| 11 | +# - redhat: workaround CKI cross compilation for scripts (Jan Stancek) |
| 12 | +# - spec: fix "unexpected argument to non-parametric macro" warnings (Jan Stancek) |
| 13 | +# - Linux v6.11.0-0.rc5.86987d84b968 |
| 14 | + |
| 15 | + |
| 16 | +def main(): |
| 17 | + res = requests.get(URL) |
| 18 | + data = res.json() |
| 19 | + |
| 20 | + out = "" |
| 21 | + |
| 22 | + for release in data: |
| 23 | + # Wed Aug 28 2024 |
| 24 | + date = datetime.datetime.strptime( |
| 25 | + release["published_at"], "%Y-%m-%dT%H:%M:%SZ" |
| 26 | + ).strftime("%a %b %d %Y") |
| 27 | + author = release["author"]["login"] |
| 28 | + rel = release["tag_name"] |
| 29 | + |
| 30 | + out += f"* {date} {contributors.get(author, author)} [{rel}]\n" |
| 31 | + out += f"- {release['name'].replace(rel + ": ", '')}\n" |
| 32 | + |
| 33 | + body_lines = release["body"].split("\n") |
| 34 | + for line in body_lines: |
| 35 | + parts = line.split(" ") |
| 36 | + buf = "" |
| 37 | + for part in parts: |
| 38 | + if len(buf) + len(part) + 1 > 80 and not part.startswith("http"): |
| 39 | + out += f" {buf}\n" |
| 40 | + buf = part |
| 41 | + else: |
| 42 | + buf += f" {part}" |
| 43 | + if buf: |
| 44 | + out += f" {buf}\n" |
| 45 | + out += "\n" |
| 46 | + |
| 47 | + with open("kernel.spec", "r") as f: |
| 48 | + spec = f.read() |
| 49 | + |
| 50 | + spec = spec.replace("%changelog", "%changelog\n" + out) |
| 51 | + |
| 52 | + with open("kernel.spec", "w") as f: |
| 53 | + f.write(spec) |
| 54 | + |
| 55 | + print(f"Wrote changelog:\n{out}") |
| 56 | + |
| 57 | + |
| 58 | +if __name__ == "__main__": |
| 59 | + for i in range(3): |
| 60 | + try: |
| 61 | + main() |
| 62 | + break |
| 63 | + except Exception as e: |
| 64 | + print(f"Error:\n{e}. Retrying...", file=sys.stderr) |
0 commit comments