Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/cygwin-apps/calm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2021-02-07 19:24:30 +0300
committerJon Turney <jon.turney@dronecode.org.uk>2021-02-09 22:39:07 +0300
commited5a8f814447f0b2e7c12f9582d67546e871ffc0 (patch)
treeb7a8ef35432b473b98753cb62669e32eb9423b52
parentc7759627578cc49d007f47982646b7e24a37ce95 (diff)
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.
-rw-r--r--calm/fix-annotate-perl-hint.py82
1 files changed, 67 insertions, 15 deletions
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)
#
#