From bbb3458aad2f1f5c753de887f06d0742bf4ecb1b Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Tue, 24 Jan 2023 19:29:32 +0100 Subject: [PATCH] cygwin: always take the newest version available In case a previous version obsoleted a package that might still stay around and come first in setup.ini, so always take the newest version in case there are multiple entries. --- app/fetch.py | 7 +++++-- tests/test_main.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/fetch.py b/app/fetch.py index 71b18b0..d4288b3 100644 --- a/app/fetch.py +++ b/app/fetch.py @@ -90,8 +90,11 @@ def parse_cygwin_versions(base_url: str, data: bytes) -> CygwinVersions: source_package = fn.rsplit("/")[-1].rsplit("-", 3)[0] src_url = base_url + "/" + fn assert version is not None - if source_package not in versions: - versions[source_package] = (version, "https://cygwin.com/packages/summary/%s-src.html" % source_package, src_url) + if source_package in versions: + existing_version = versions[source_package][0] + if not version_is_newer_than(version, existing_version): + continue + versions[source_package] = (version, "https://cygwin.com/packages/summary/%s-src.html" % source_package, src_url) return versions diff --git a/tests/test_main.py b/tests/test_main.py index 40653f4..36af06c 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -55,6 +55,28 @@ source: x86_64/release/python36/python36-3.6.9-1-src.tar.xz 17223444 ef39d9419"" assert versions["python36"][2] == "https://mirrors.kernel.org/sourceware/cygwin/x86_64/release/python36/python36-3.6.9-1-src.tar.xz" +def test_parse_cygwin_multiple(): + data = b"""\ +@ gcc-cilkplus +version: 10.2.0-1 +install: x86_64/release/gcc/gcc-cilkplus/gcc-cilkplus-10.2.0-1.tar.xz 108 96dd43cf9 +source: x86_64/release/gcc/gcc-10.2.0-1-src.tar.xz 75022528 96dd43cf9 +build-depends: cygport + +@ gcc-core +version: 11.3.0-1 +install: x86_64/release/gcc/gcc-core/gcc-core-11.3.0-1.tar.zst 31476642 96dd43cf9 +source: x86_64/release/gcc/gcc-11.3.0-1-src.tar.zst 81157789 96dd43cf9 +depends2: bash, binutils +obsoletes: gcc-ada, gcc-cilkplus +provides: gcc11 + """ + + setup_ini_url = "https://mirrors.kernel.org/sourceware/cygwin/x86_64/setup.ini" + versions = parse_cygwin_versions(setup_ini_url, data) + assert versions["gcc"][0] == "11.3.0" + + EXAMPLE_SIG = ( "iHUEABEIAB0WIQStNRxQrghXdetZMztfku/BpH1FoQUCXlOY5wAKCRBfku" "/BpH1FodQoAP4nQnPNLnx5MVIJgZgCwW/hplW7Ai9MqkmFBqD8/+EXfAD/"