From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95385 invoked by alias); 16 Feb 2020 18:19:13 -0000 Mailing-List: contact cygwin-apps-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-apps-cvs-owner@sourceware.org Received: (qmail 95338 invoked by uid 9795); 16 Feb 2020 18:19:13 -0000 Date: Sun, 16 Feb 2020 18:19:00 -0000 Message-ID: <20200216181913.95326.qmail@sourceware.org> From: jturney@sourceware.org To: cygwin-apps-cvs@sourceware.org Subject: [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20200129-3-ga51a0f9 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: a56dc7c1e10f84c33795f1c873046b04562c0834 X-Git-Newrev: a51a0f91f9203faaeb5015d92abf8593cfafa823 X-SW-Source: 2020-q1/txt/msg00012.txt https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=a51a0f91f9203faaeb5015d92abf8593cfafa823 commit a51a0f91f9203faaeb5015d92abf8593cfafa823 Author: Jon Turney Date: Sun Feb 16 17:23:43 2020 +0000 Add a tool for annotating existing perl hints https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=2561af30026554830521662513db8e0a113a22f1 commit 2561af30026554830521662513db8e0a113a22f1 Author: Jon Turney Date: Sun Feb 9 16:07:30 2020 +0000 Fix dryrun in listings https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=17775b37f6af508335f0ce74758da0263c1e05f8 commit 17775b37f6af508335f0ce74758da0263c1e05f8 Author: Jon Turney Date: Sun Feb 2 14:48:43 2020 +0000 Avoid KeyError exception if obsoleted package isn't present Diff: --- calm/fix-annotate-perl-hint.py | 90 ++++++++++++++++++++++++++++++++++++++++++ calm/package.py | 16 +++++--- calm/pkg2html.py | 7 +++- 3 files changed, 105 insertions(+), 8 deletions(-) diff --git a/calm/fix-annotate-perl-hint.py b/calm/fix-annotate-perl-hint.py new file mode 100644 index 0000000..59ee570 --- /dev/null +++ b/calm/fix-annotate-perl-hint.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2020 Jon Turney +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +# +# Annotate existing hints with requires: perl with a comment noting these +# require perl5.26 (or possibly earlier), before we deploy perl5.30. Later +# these comments can be transformed into an requires: on an additional provides: +# in perl_base package. +# + +import argparse +import logging +import os +import re +import shutil +import sys + +from . import common_constants +from . import hint + +# +# +# + +def fix_one_hint(dirpath, hintfile): + pn = os.path.join(dirpath, hintfile) + + with open(pn, 'r') as f: + for l in f: + if 'perl5_26' in l: + logging.info("%s already annotated" % (hintfile)) + return + + hints = hint.hint_file_parse(pn, hint.pvr) + + requires = hints.get('requires', '').split() + if requires: + if ('perl_base' in requires) or ('perl' in requires): + logging.info("%s has perl in requires" % (hintfile)) + + shutil.copy2(pn, pn + '.bak') + with open(pn, 'a') as f: + print("# perl5_26", file=f) + + +def fix_hints(relarea): + for (dirpath, subdirs, files) in os.walk(relarea): + for f in files: + match = re.match(r'^.*\.hint$', f) + if match: + fix_one_hint(dirpath, f) + +# +# +# + +if __name__ == "__main__": + relarea_default = common_constants.FTP + + parser = argparse.ArgumentParser(description='perl requires annotater') + parser.add_argument('-v', '--verbose', action='count', dest='verbose', help='verbose output', default=0) + parser.add_argument('--releasearea', action='store', metavar='DIR', help="release directory (default: " + relarea_default + ")", default=relarea_default, dest='relarea') + (args) = parser.parse_args() + + if args.verbose: + logging.getLogger().setLevel(logging.INFO) + + logging.basicConfig(format=os.path.basename(sys.argv[0]) + ': %(message)s') + + fix_hints(args.relarea) diff --git a/calm/package.py b/calm/package.py index d100044..a3bf328 100755 --- a/calm/package.py +++ b/calm/package.py @@ -540,12 +540,16 @@ def validate_packages(args, packages): o = o.strip() o = re.sub(r'(.*) +\(.*\)', r'\1', o) - for (ov, ohints) in packages[o].version_hints.items(): - if 'depends' in ohints: - depends = ohints['depends'].split(',') - depends = [d for d in depends if d != p] - packages[o].version_hints[ov]['depends'] = ','.join(depends) - logging.debug("removed obsoleting '%s' from the depends: of package '%s'" % (p, o)) + if o in packages: + for (ov, ohints) in packages[o].version_hints.items(): + if 'depends' in ohints: + depends = ohints['depends'].split(',') + if p in depends: + depends = [d for d in depends if d != p] + packages[o].version_hints[ov]['depends'] = ','.join(depends) + logging.debug("removed obsoleting '%s' from the depends: of package '%s'" % (p, o)) + else: + logging.debug("can't ensure package '%s' doesn't depends: on obsoleting '%s'" % (o, p)) packages[p].vermap = {} is_empty = {} diff --git a/calm/pkg2html.py b/calm/pkg2html.py index 21256ae..110f03a 100755 --- a/calm/pkg2html.py +++ b/calm/pkg2html.py @@ -434,8 +434,11 @@ def write_arch_listing(args, packages, arch): # # for each tarfile, write tarfile listing # - listings = os.listdir(dir) - listings.remove('.htaccess') + if os.path.exists(dir): + listings = os.listdir(dir) + listings.remove('.htaccess') + else: + listings = [] for tn, to in itertools.chain.from_iterable([packages[p].tars[vr].items() for vr in packages[p].tars]): fver = re.sub(r'\.tar.*$', '', tn)