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. 20210110-2-ged5a8f8
Date: Wed, 10 Feb 2021 15:14:06 +0000 (GMT)	[thread overview]
Message-ID: <20210210151407.13F7A398E476@sourceware.org> (raw)




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

commit ed5a8f814447f0b2e7c12f9582d67546e871ffc0
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sun Feb 7 16:24:30 2021 +0000

    Update perl annotation tool
    
    Update perl annotation tool to update requires: with the appropriate
    provide name stored in an annotation, where it looks like it should be
    needed, now we actually have them.

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

commit c7759627578cc49d007f47982646b7e24a37ce95
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sun Jan 10 19:38:25 2021 +0000

    Ignore B902 flake
    
    Ignore 'B902 blind except Exception: statement' flake.
    
    This isn't ideal. Three of these places are where we would otherwise
    have to enumerate all possible exceptions which could be raised during
    reading a compressed archive.
    
    The final place is were we are catching any possible exception to log
    before terminating, so really needs to be blind.


Diff:
---
 .flake8                        |  2 +-
 calm/fix-annotate-perl-hint.py | 82 ++++++++++++++++++++++++++++++++++--------
 2 files changed, 68 insertions(+), 16 deletions(-)

diff --git a/.flake8 b/.flake8
index 81548f7..0baa6cd 100644
--- a/.flake8
+++ b/.flake8
@@ -1,3 +1,3 @@
 [flake8]
-ignore=E741,E129,W504,A003
+ignore=E741,E129,W504,A003,B902
 max-line-length=240
diff --git a/calm/fix-annotate-perl-hint.py b/calm/fix-annotate-perl-hint.py
index 0f2679a..41ab770 100644
--- a/calm/fix-annotate-perl-hint.py
+++ b/calm/fix-annotate-perl-hint.py
@@ -24,31 +24,36 @@
 import argparse
 import logging
 import os
+import re
 import shutil
 import sys
+import tarfile
+import xtarfile
 
 from . import common_constants
 from . import hint
 
+# packages which are known to embed a perl interpreter or contain perl extension
+# dlls (i.e. link with libperl)
+known_packages = [
+    'perl-gdal',
+    'hexchat-perl',
+    'irssi',
+    'postgresql-contrib',
+    'postgresql-plperl',
+    'rxvt-unicode',
+    'weechat-perl',
+    'znc-perl',
+]
+
 #
 #
 #
 
 
-def fix_one_hint(dirpath, hintfile):
+def fix_one_hint(dirpath, hintfile, tf):
     pn = os.path.join(dirpath, hintfile)
 
-    annotation = False
-    with open(pn, 'r') as f:
-        for l in f:
-            if '# perl5_26' in l:
-                logging.info("%s has annotation comment" % (hintfile))
-                annotation = True
-                break
-
-    if not annotation:
-        return
-
     hints = hint.hint_file_parse(pn, hint.pvr)
 
     hints.pop('parse-warnings', None)
@@ -56,18 +61,65 @@ def fix_one_hint(dirpath, hintfile):
         logging.error('invalid hints %s' % hintfile)
         return
 
-    hints['notes'] = 'perl5_26'
+    modified = False
+
+    # if no annotation yet, add a perl annotation
+    if 'notes' not in hints:
+        requires = hints.get('requires', '').split()
+        if requires:
+            if ('perl_base' in requires) or ('perl' in requires):
+                logging.info("%s has perl in requires and no annotations" % (hintfile))
+                hints['notes'] = 'perl5_030'
+                modified = True
+
+    # if annotated, check if this package installs into vendor_perl, and if so,
+    # add the annotate perl version to requires, if not already present
+    if hints.get('notes', '').startswith('perl5_0'):
+        ivp = False
+        exe = False
+
+        try:
+            with xtarfile.open(os.path.join(dirpath, tf), mode='r') as a:
+                ivp = any(re.match(r'usr/(lib|share)/perl5/vendor_perl/', m) for m in a.getnames())
+                exe = any(re.search(r'\.(exe|dll)$', m) for m in a.getnames())
+        except tarfile.ReadError:
+            pass
+
+        knwn = any(hintfile.startswith(k) for k in known_packages)
+
+        if ivp or knwn:
+            requires = hints.get('requires', '').split()
+            if hints['notes'] not in requires:
+                requires.append(hints['notes'])
+                requires = sorted(requires)
+                modified = True
+                logging.warning("adding perl provide to requires in %s" % (hintfile))
+            hints['requires'] = ' '.join(requires)
+        else:
+            if exe:
+                logging.info("%s has perl in requires, and might have content linked to libperl" % (hintfile))
+            else:
+                logging.info("%s has perl in requires, assuming that's for a perl script" % (hintfile))
+
+    if not modified:
+        return
 
     # write updated hints
     shutil.copy2(pn, pn + '.bak')
     hint.hint_file_write(pn, hints)
+    # os.system('/usr/bin/diff -uBZ %s %s' % (pn + '.bak', pn))
 
 
 def fix_hints(relarea):
     for (dirpath, _subdirs, files) in os.walk(relarea):
         for f in files:
-            if f.endswith('.hint'):
-                fix_one_hint(dirpath, f)
+            match = re.match(r'^([^-].*?)\.tar' + common_constants.PACKAGE_COMPRESSIONS_RE + r'$', f)
+            if match:
+                root = match.group(1)
+                if root.endswith('-src'):
+                    continue
+
+                fix_one_hint(dirpath, root + '.hint', f)
 
 #
 #



                 reply	other threads:[~2021-02-10 15:14 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=20210210151407.13F7A398E476@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).