[calm - Cygwin server-side packaging maintenance script] branch master, updated. 20230209-92-g872e4b1

Jon Turney jturney@sourceware.org
Wed Apr 17 12:51:13 GMT 2024




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

commit 872e4b144d9bdc74f08f086a091937b10758977c
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Thu Apr 11 16:10:26 2024 +0100

    Drop age threshold for 'upgrade old-style obsoletes'

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

commit 20ed63de168ccc3e9b8cf4871269c3a8598b0a02
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Fri Apr 12 14:00:38 2024 +0100

    Make formatting of 'conflicts:' lines in setup.ini consistent
    
    Make formatting of 'conflicts:' lines in setup.ini consistent with
    everything else.

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

commit 522d329dcbd9500af424d442278ae69a3c7e76f1
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Thu Apr 11 16:05:17 2024 +0100

    Utility function to drop version constraints from a package list
    
    Factor out "strip out version constraints from a package list" into a
    utility function.


Diff:
---
 calm/package.py | 40 +++++++++++++---------------------------
 calm/reports.py |  6 +++---
 calm/utils.py   |  8 --------
 3 files changed, 16 insertions(+), 38 deletions(-)

diff --git a/calm/package.py b/calm/package.py
index abaec1b..6220191 100755
--- a/calm/package.py
+++ b/calm/package.py
@@ -613,14 +613,7 @@ def sort_key(k):
 #
 # generate a record to add an obsoletes: header to the replacement package.
 #
-
-OBSOLETE_CONVERT_THRESHOLD_YEARS = 2
-
-
 def upgrade_oldstyle_obsoletes(packages, missing_obsolete):
-    certain_age = time.time() - (OBSOLETE_CONVERT_THRESHOLD_YEARS * 365.25 * 24 * 60 * 60)
-    logging.debug("cut-off date for _obsolete package to be considered for conversion is %s" % (time.strftime("%F %T %Z", time.localtime(certain_age))))
-
     for p in sorted(packages):
         if packages[p].kind == Kind.binary:
             for vr in sorted(packages[p].versions(), key=lambda v: SetupVersion(v), reverse=True):
@@ -637,15 +630,8 @@ def upgrade_oldstyle_obsoletes(packages, missing_obsolete):
                         '_obsolete' in packages[p].version_hints[vr]['category']):
                     break
 
-                # initially apply to a subset over a certain age, to gradually
-                # introduce this change
-                mtime = packages[p].tar(vr).mtime
-                if mtime > certain_age:
-                    continue
-                logging.debug("_obsolete package '%s' version '%s' mtime '%s' is over cut-off age" % (p, vr, time.strftime("%F %T %Z", time.localtime(mtime))))
-
                 requires = packages[p].version_hints[vr].get('depends', [])
-                requires = [re.sub(r'(.*) +\(.*\)', r'\1', r) for r in requires]
+                requires = deplist_without_versions(requires)
 
                 o = None
                 for oso_re, oso_o in past_mistakes.old_style_obsolete_by.items():
@@ -692,6 +678,13 @@ def upgrade_oldstyle_obsoletes(packages, missing_obsolete):
     return missing_obsolete
 
 
+#
+# drop version constraints from a list of dependencies
+#
+def deplist_without_versions(dpl):
+    return [re.sub(r'(.*)\s+\(.*\)', r'\1', dp) for dp in dpl]
+
+
 #
 # validate the package database
 #
@@ -735,11 +728,7 @@ def validate_packages(args, packages, valid_provides_extra=None, missing_obsolet
             ]:
                 # if c is in hints, and not the empty string
                 if hints.get(c, ''):
-                    for r in hints[c]:
-                        # strip off any version relation enclosed in '()'
-                        # following the package name
-                        r = re.sub(r'(.*) +\(.*\)', r'\1', r)
-
+                    for r in deplist_without_versions(hints[c]):
                         if c == 'depends':
                             # don't count cygwin-debuginfo for the purpose of
                             # checking if this package has any requires, as
@@ -808,9 +797,7 @@ def validate_packages(args, packages, valid_provides_extra=None, missing_obsolet
         for hints in packages[p].version_hints.values():
             obsoletes = hints.get('obsoletes', [])
             if obsoletes:
-                for o in obsoletes:
-                    o = re.sub(r'(.*) +\(.*\)', r'\1', o)
-
+                for o in deplist_without_versions(obsoletes):
                     if o in packages:
                         packages[o].obsolete = True
 
@@ -961,8 +948,7 @@ def validate_packages(args, packages, valid_provides_extra=None, missing_obsolet
                     ('obsoletes', 'obsoleted_by'),
             ]:
                 if k in hints:
-                    for dp in hints[k]:
-                        dp = re.sub(r'(.*)\s+\(.*\)', r'\1', dp)
+                    for dp in deplist_without_versions(hints[k]):
                         if dp in packages:
                             getattr(packages[dp], a).add(p)
 
@@ -1114,7 +1100,7 @@ def assign_importance(packages):
     def recursive_basedep(p):
         bv = p.best_version
         requires = p.version_hints[bv].get('depends', [])
-        requires = [re.sub(r'(.*) +\(.*\)', r'\1', r) for r in requires]
+        requires = deplist_without_versions(requires)
         for r in requires:
             if r in packages:
                 if packages[r].importance == Importance.other:
@@ -1372,7 +1358,7 @@ def write_setup_ini(args, packages, arch):
                         print("provides: %s" % ', '.join(hints['provides']), file=f)
 
                     if hints.get('conflicts', ''):
-                        print("conflicts: %s" % ','.join(hints['conflicts']), file=f)
+                        print("conflicts: %s" % ', '.join(hints['conflicts']), file=f)
 
                 if s:
                     src_hints = packages[s].version_hints.get(version, {})
diff --git a/calm/reports.py b/calm/reports.py
index 0ff0b11..d85b2dd 100644
--- a/calm/reports.py
+++ b/calm/reports.py
@@ -184,7 +184,7 @@ def deprecated(args, packages, reportlist):
                 continue
 
             # current version has the dependency of interest
-            dpl = utils.deplist_without_verrel(packages[arch][d].version_hints[bv]['depends'])
+            dpl = package.deplist_without_versions(packages[arch][d].version_hints[bv]['depends'])
             if p not in dpl:
                 continue
 
@@ -303,7 +303,7 @@ def provides_rebuild(args, packages, fn, provide_package, reportlist):
             bv = po.best_version
 
             depends = packages[arch][p].version_hints[bv]['depends']
-            depends = utils.deplist_without_verrel(depends)
+            depends = packages.deplist_without_versions(depends)
 
             for d in depends:
                 if not d.startswith(pp_provide_base):
@@ -367,7 +367,7 @@ def python_rebuild(args, packages, fn, reportlist):
             continue
 
         depends = packages[arch][p].version_hints[bv]['depends']
-        depends = utils.deplist_without_verrel(depends)
+        depends = package.deplist_without_versions(depends)
 
         for d in depends:
             # scan for a 'pythonnn' dependency
diff --git a/calm/utils.py b/calm/utils.py
index af2f5cb..26e3655 100644
--- a/calm/utils.py
+++ b/calm/utils.py
@@ -30,7 +30,6 @@ import email.utils
 import filecmp
 import logging
 import os
-import re
 import subprocess
 from contextlib import contextmanager
 
@@ -199,10 +198,3 @@ def sendmail(hdr, msg):
             logging.debug('sendmail: msgid %s, exit status %d' % (m['Message-Id'], p.returncode))
 
     return m['Message-Id']
-
-
-#
-# remove version-constrains from a list of dependencies
-#
-def deplist_without_verrel(dpl):
-    return [re.sub(r'(.*)\s+\(.*\)', r'\1', dp) for dp in dpl]



More information about the Cygwin-apps-cvs mailing list