public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jon TURNEY <jturney@sourceware.org>
To: cygwin-apps-cvs@sourceware.org
Subject: [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20210626-17-g40a756a
Date: Sun,  6 Feb 2022 13:04:11 +0000 (GMT)	[thread overview]
Message-ID: <20220206130411.794D53858D1E@sourceware.org> (raw)




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=40a756adfaffae36e136b5ed384fdb3ff98fe6a4

commit 40a756adfaffae36e136b5ed384fdb3ff98fe6a4
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Fri Feb 4 14:58:51 2022 +0000

    Correctly identify upstream version for legacy packages

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=599f5f12038fe9a8a7383e6f62ae6d4e7465df82

commit 599f5f12038fe9a8a7383e6f62ae6d4e7465df82
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Thu Feb 3 20:17:09 2022 +0000

    Always apply upstream_version annotations
    
    process_relarea() constructs the package state ab inito, so we must
    retain the fetched data and reapply the package annotations on every
    call to annotate_packages().

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=98956d34dc33d048b988faef8d3ae87520e2af7b

commit 98956d34dc33d048b988faef8d3ae87520e2af7b
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Mon Jan 31 18:59:52 2022 +0000

    Include upstream version in 'unmaintained packages' report
    
    Fetch the upstream version from repology, and in include it in the
    'unmaintained packages' report.
    
    v2:
    Annotate packages in daemonized mode as well
    
    v3:
    Use bare version, not V-R for current version in report


Diff:
---
 calm/repology.py | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
 calm/reports.py  |  2 +-
 calm/version.py  |  1 +
 3 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/calm/repology.py b/calm/repology.py
index c4aa0a5..16d285b 100644
--- a/calm/repology.py
+++ b/calm/repology.py
@@ -26,15 +26,26 @@
 # may not exist for some packages, e.g. where upstream doesn't do releases)
 #
 
+from collections import namedtuple
+
 import json
 import logging
 import time
 import urllib.request
 
+from .version import SetupVersion
+
 REPOLOGY_API_URL = 'https://repology.org/api/v1/projects/'
 last_check = 0
 last_data = {}
 
+LegacyData = namedtuple('LegacyData', ['version', 'ignores'])
+use_legacy = {'qt': [LegacyData('5', []),
+                     LegacyData('4', []),
+                     LegacyData('3', [])],
+              'gtk': [LegacyData('3', ['3.9', '+']),
+                      LegacyData('2', [])]}
+
 
 def repology_fetch_versions():
     upstream_versions = {}
@@ -52,13 +63,37 @@ def repology_fetch_versions():
         for pn in sorted(j.keys()):
             p = j[pn]
 
-            # first, pick out the version which repology has called newest
+            # first, pick out the version which repology has called newest, and
+            # if needed, also pick out latest version for legacy packages
             newest_version = None
+            legacy_versions = {}
+
             for i in p:
+                v = i['version']
                 if i['status'] == 'newest':
-                    newest_version = i['version']
-                    break
-            else:
+                    newest_version = v
+
+                if (pn in use_legacy) and (i['status'] in ['legacy', 'outdated']):
+                    prefix = None
+                    for ld in use_legacy[pn]:
+                        if v.startswith(ld.version):
+                            prefix = ld.version
+                            break
+
+                    if not prefix:
+                        continue
+
+                    # blacklist versions containing substrings (pre-release
+                    # versions etc.)
+                    if any(ignore in v for ignore in ld.ignores):
+                        continue
+
+                    # repology doesn't identify the highest legacy version, so
+                    # we have to that ourselves
+                    if SetupVersion(v) > SetupVersion(legacy_versions.get(prefix, '0')):
+                        legacy_versions[prefix] = v
+
+            if not newest_version:
                 continue
 
             # next, assign that version to all the corresponding cygwin source
@@ -69,6 +104,19 @@ def repology_fetch_versions():
             for i in p:
                 if i['repo'] == "cygwin":
                     source_pn = i['srcname']
+
+                    # if package name contains legacy version
+                    if pn in use_legacy:
+                        prefix = None
+                        for ld in use_legacy[pn]:
+                            if (pn + ld.version) in source_pn:
+                                prefix = ld.version
+
+                        if prefix and prefix in legacy_versions:
+                            upstream_versions[source_pn] = legacy_versions[prefix]
+                            continue
+
+                    # otherwise, just use the newest version
                     upstream_versions[source_pn] = newest_version
 
         if pn == last_pn:
@@ -80,8 +128,10 @@ def repology_fetch_versions():
 
 
 def annotate_packages(args, packages):
-    # rate limit to daily
     global last_check
+    global last_data
+
+    # rate limit to daily
     if (time.time() - last_check) < (24 * 60 * 60):
         logging.info("not consulting %s due to ratelimit" % (REPOLOGY_API_URL))
     else:
diff --git a/calm/reports.py b/calm/reports.py
index 2cd2308..5d18cdd 100644
--- a/calm/reports.py
+++ b/calm/reports.py
@@ -97,7 +97,7 @@ def unmaintained(args, packages, reportsdir):
         up = types.SimpleNamespace()
         up.pn = p
         up.po = po
-        up.v = v
+        up.v = SetupVersion(v).V
         up.upstream_v = getattr(po, 'upstream_version', 'unknown')
         up.ts = po.tar(v).mtime
         up.rdepends = len(rdepends)
diff --git a/calm/version.py b/calm/version.py
index 17f8d0e..c61e8fc 100644
--- a/calm/version.py
+++ b/calm/version.py
@@ -55,6 +55,7 @@ class SetupVersion:
         # non-alphanumeric separators are discarded
         # numeric sequences have leading zeroes discarded
         for j, i in enumerate(['E', 'V', 'R']):
+            setattr(self, i, split[j])
             sequences = re.finditer(r'(\d+|[a-zA-Z]+|[^a-zA-Z\d]+)', split[j])
             sequences = [m for m in sequences if not re.match(r'[^a-zA-Z\d]+', m.group(1))]
             sequences = [re.sub(r'^0+(\d)', r'\1', m.group(1), 1) for m in sequences]



                 reply	other threads:[~2022-02-06 13:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220206130411.794D53858D1E@sourceware.org \
    --to=jturney@sourceware.org \
    --cc=cygwin-apps-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).