Skip to content

Commit

Permalink
Improve generate_package_release_notes.py
Browse files Browse the repository at this point in the history
Now we pass in the old and new GAP version in as argument (instead of
hardcoding them). This is then used to download the appropriate package
infos.

Also fix a recently introduce bug in the script (were I accidentally
copy & pasted the variable name `new` instead of `pkg`), and fix an
older bug in `verify_via_checksumfile` (it was broken after a refactoring,
and nobody noticed because it only matters if SHA-256 validation fails...)
  • Loading branch information
fingolfin committed Dec 18, 2022
1 parent 5eaada6 commit 049f6b3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
31 changes: 24 additions & 7 deletions dev/releases/generate_package_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,37 @@
# TODO: integrate this script into generate_release_notes.py

import sys
import os
import json
import gzip

from utils import *

def usage():
print("Usage: `./generate_package_release_notes.py old-package-infos.json new-package-infos.json`")
print("Usage: `./generate_package_release_notes.py OLD_GAP_VERSION NEW_GAP_VERSION`")
sys.exit(1)

def main(old_json_file, new_json_file):
old_gap_version = "4.11.1" # TODO/FIXME: pass this as an argument?
new_gap_version = "4.12.0" # TODO/FIXME: pass this as an argument?
def main(old_gap_version, new_gap_version):

# create tmp directory
tmpdir = os.getcwd() + "/tmp"
notice(f"Files will be put in {tmpdir}")
try:
os.mkdir(tmpdir)
except FileExistsError:
pass

with open(old_json_file, "r") as f:
# download package metadata
old_json_file = f"{tmpdir}/package-infos-{old_gap_version}.json.gz"
download_with_sha256(f"https://github.com/gap-system/PackageDistro/releases/download/v{old_gap_version}/package-infos.json.gz", old_json_file)
new_json_file = f"{tmpdir}/package-infos-{new_gap_version}.json.gz"
download_with_sha256(f"https://github.com/gap-system/PackageDistro/releases/download/v{new_gap_version}/package-infos.json.gz", new_json_file)

# parse package metadata
with gzip.open(old_json_file, "r") as f:
old_json = json.load(f)

with open(new_json_file, "r") as f:
with gzip.open(new_json_file, "r") as f:
new_json = json.load(f)

print("### Package distribution")
Expand All @@ -47,7 +64,7 @@ def main(old_json_file, new_json_file):
for p in sorted(added):
pkg = new_json[p]
name = pkg["PackageName"]
home = new["PackageWWWHome"]
home = pkg["PackageWWWHome"]
desc = pkg["Subtitle"]
vers = pkg["Version"]
authors = [x["FirstNames"]+" "+x["LastName"] for x in pkg["Persons"] if x["IsAuthor"]]
Expand Down
5 changes: 4 additions & 1 deletion dev/releases/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ def file_matches_checksumfile(filename):
return expected_checksum == sha256file(filename)

def verify_via_checksumfile(filename):
if not file_matches_checksumfile(filename):
actual_checksum = sha256file(filename)
with open(filename + ".sha256", "r") as f:
expected_checksum = f.read().strip()
if expected_checksum != actual_checksum:
error(f"checksum for '{filename}' expected to be {expected_checksum} but got {actual_checksum}")

# Download file at the given URL to path `dst`, unless we detect that a file
Expand Down

0 comments on commit 049f6b3

Please sign in to comment.