public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* calm (mksetupini): Allow a missing curr version
@ 2016-07-16 16:48 Ken Brown
  2016-07-18 16:22 ` Jon Turney
  0 siblings, 1 reply; 2+ messages in thread
From: Ken Brown @ 2016-07-16 16:48 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 1092 bytes --]

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.

[-- Attachment #2: 0001-Don-t-fail-if-a-package-has-no-curr-version.patch --]
[-- Type: text/plain, Size: 833 bytes --]

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


[-- Attachment #3: 0002-Add-option-okmissing-curr-to-mksetupini.patch --]
[-- Type: text/plain, Size: 2329 bytes --]

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: calm (mksetupini): Allow a missing curr version
  2016-07-16 16:48 calm (mksetupini): Allow a missing curr version Ken Brown
@ 2016-07-18 16:22 ` Jon Turney
  0 siblings, 0 replies; 2+ messages in thread
From: Jon Turney @ 2016-07-18 16:22 UTC (permalink / raw)
  To: cygwin-apps

On 16/07/2016 17:48, Ken Brown wrote:
> 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
[...]
>
> 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.

Thanks for the patches.

I'd been wondering if a package with no curr, only test versions made 
any sense at all, but I guess this example makes it clear while it's 
probably not very useful in calm, it could be useful in the mksetupini, 
where the output is an overlay setup.ini which is going to be merged by 
setup with a setup.ini which does have a curr version...

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-18 16:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-16 16:48 calm (mksetupini): Allow a missing curr version Ken Brown
2016-07-18 16:22 ` Jon Turney

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).