Hi all,

As I was trying to install spiffy on Haiku, I noticed that the
posix-groups egg (a dependency) refused to install because haiku
is not unix, and posix-groups.egg has a (platform unix) clause.

So I changed it to (platform (or unix haiku)) and it still failed.
If I swapped the two it would succeed.  It turns out that the
check-platform procedure in chicken-install.scm was written with
the idea that fail was a continuation, or something.  But it
isn't, so it would just raise an early error when it encountered
"unix" on the haiku platform, where that feature is not defined.

I also noticed that "and" will always fail, even if you do just
(platform (and unix)), which should be equivalent to (platform unix).

Attached is a relatively straightforward patch that simply allows
the loop to finish and return #t or #f, and if #f it will error.

Cheers,
Peter
From bad328ab90cc9b871f1f77bb56b052d0769dee81 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Sun, 12 Aug 2018 20:17:31 +0200
Subject: [PATCH] Fix behaviour of complex (platform) clauses in .egg files

Something like (platform (and unix)) would always fail even on UNIX,
as would (platform (or haiku unix)), and (platform (or (unix haiku)))
would succeed on UNIX but fail on Haiku.
---
 chicken-install.scm | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/chicken-install.scm b/chicken-install.scm
index a282f791..3a44f2f4 100644
--- a/chicken-install.scm
+++ b/chicken-install.scm
@@ -716,22 +716,21 @@
         (else #f)))
 
 (define (check-platform name info)
-  (define (fail)
-    (error "extension is not targeted for this system" name))
   (unless cross-chicken
     (and-let* ((platform (get-egg-property info 'platform)))
-      (let loop ((p platform))
-        (cond ((symbol? p) 
-               (or (feature? p) (fail)))
-              ((not (list? p))
-               (error "invalid `platform' property" name platform))
-              ((and (eq? 'not (car p)) (pair? (cdr p)))
-               (and (not (loop (cadr p))) (fail)))
-              ((eq? 'and (car p))
-               (and (every loop (cdr p)) (fail)))
-              ((eq? 'or (car p))
-               (and (not (any loop (cdr p))) (fail)))
-              (else (error "invalid `platform' property" name platform)))))))
+      (or (let loop ((p platform))
+	    (cond ((symbol? p)
+		   (feature? p))
+		  ((not (list? p))
+		   (error "invalid `platform' property" name platform))
+		  ((and (eq? 'not (car p)) (pair? (cdr p)))
+		   (not (loop (cadr p))))
+		  ((eq? 'and (car p))
+		   (every loop (cdr p)))
+		  ((eq? 'or (car p))
+		   (any loop (cdr p)))
+		  (else (error "invalid `platform' property" name platform))))
+	  (error "extension is not targeted for this system" name)))))
 
 (define (replace-extension-question e+d+v upgrade)
   (print (string-intersperse
-- 
2.11.0

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to