calm (mksetupini): Allow a missing curr version

Ken Brown kbrown@cornell.edu
Sat Jul 16 16:48:00 GMT 2016


If a package has no curr version, mksetupini will emit a warning and later fail, as in the following example[*]:

mksetupini.py: package 'perl' doesn't have a curr version
Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/kbrown/src/calm/calm/mksetupini.py", line 126, in <module>
    sys.exit(main())
  File "/home/kbrown/src/calm/calm/mksetupini.py", line 118, in main
    do_main(args)
  File "/home/kbrown/src/calm/calm/mksetupini.py", line 61, in do_main
    if not package.validate_packages(args, packages):
  File "/home/kbrown/src/calm/calm/package.py", line 498, in validate_packages
    versions[packages[install_p].stability['curr']].append(install_p)
KeyError: 'curr'

The first of the two attached patches prevents the failure.  The second provides a user option to suppress the warning.

Ken

[*] Here I had built perl-5.24.0 for my own use and put it in my local repository as a test version.
-------------- next part --------------
From 3ceaa9e5887e3403eabf700890cb663078f2714d Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Sat, 16 Jul 2016 12:06:51 -0400
Subject: [PATCH 1/2] Don't fail if a package has no curr version

---
 calm/package.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/calm/package.py b/calm/package.py
index d1e79dd..338ecc1 100755
--- a/calm/package.py
+++ b/calm/package.py
@@ -495,7 +495,8 @@ def validate_packages(args, packages):
             if re.match(r'^lib.*\d', install_p):
                 continue
 
-            versions[packages[install_p].stability['curr']].append(install_p)
+            if 'curr' in packages[install_p].stability:
+                versions[packages[install_p].stability['curr']].append(install_p)
 
         if len(versions) > 1:
             out = []
-- 
2.8.3

-------------- next part --------------
From 17ae1f75043536c64b798d81c53266191f1b08b3 Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Sat, 16 Jul 2016 12:25:01 -0400
Subject: [PATCH 2/2] Add option 'okmissing=curr' to mksetupini
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If this option is specified, suppress warning that a package doesn’t
have a current version.
---
 calm/mksetupini.py | 2 +-
 calm/package.py    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/calm/mksetupini.py b/calm/mksetupini.py
index 6add377..609d1c3 100755
--- a/calm/mksetupini.py
+++ b/calm/mksetupini.py
@@ -100,7 +100,7 @@ def main():
     parser = argparse.ArgumentParser(description='Make setup.ini')
     parser.add_argument('--arch', action='store', required=True, choices=common_constants.ARCHES)
     parser.add_argument('--inifile', '-u', action='store', help='output filename', required=True)
-    parser.add_argument('--okmissing', action='append', help='missing things are ok', choices=['required-package'])
+    parser.add_argument('--okmissing', action='append', help='missing things are ok', choices=['curr', 'required-package'])
     parser.add_argument('--pkglist', action='store', nargs='?', metavar='FILE', help="package maintainer list (default: " + pkglist_default + ")", const=pkglist_default)
     parser.add_argument('--release', action='store', help='value for setup-release key (default: cygwin)', default='cygwin')
     parser.add_argument('--releasearea', action='store', metavar='DIR', help="release directory (default: " + relarea_default + ")", default=relarea_default, dest='rel_area')
diff --git a/calm/package.py b/calm/package.py
index 338ecc1..4cd7065 100755
--- a/calm/package.py
+++ b/calm/package.py
@@ -411,7 +411,7 @@ def validate_packages(args, packages):
             logging.error("package '%s' doesn't have any versions" % (p))
             error = True
         # it's also probably a really good idea if a curr version exists
-        elif 'curr' not in packages[p].stability:
+        elif 'curr' not in packages[p].stability and 'curr' not in getattr(args, 'okmissing', []):
             logging.warning("package '%s' doesn't have a curr version" % (p))
 
         # If, for every stability level, the install tarball is empty and there
-- 
2.8.3



More information about the Cygwin-apps mailing list