chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] Show foreign dependencies with chicken-install


From: Christian Kellermann
Subject: [Chicken-hackers] Show foreign dependencies with chicken-install
Date: Sat, 3 Sep 2011 23:14:59 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

as I've promised a patch to chicken-install to enable egg authors to
hint foreign dependencies to chicken-install in the .meta file I am
delivering the patch for it here. Please find it attached to this mail.

If you want to accept this patch apply it to your git repo with

git apply 0001-Add-show-foreign-depends-option-to-chicken-install.patch

For this to work egg authors need to add a (foreign-depends ) clause
to the egg's .meta files. The clause is free form and will get printed
with each element on one line.

The new option '-show-foreign-depends' fetches and displays the
foreign-depends clause from meta files. When invoked in combination
with -r only the retrieved egg's clause will be displayed. 

I will disect the patch now for the interested reader, not so much for
showing off smug lisp skills (far from it) but to seek advice. I am
willing to reiterate this process until we do have a satisfactory
result. Also to revive this list for patch reviews.

The patch:

---
 chicken-install.scm |   35 ++++++++++++++++++++++++++++++-----
 1 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/chicken-install.scm b/chicken-install.scm
index a4d175e..e635705 100644
--- a/chicken-install.scm
+++ b/chicken-install.scm
@@ -107,6 +107,7 @@
   (define *keep-going* #f)
   (define *override* '())
   (define *reinstall* #f)
+  (define *show-foreign-depends* #f)
 
Trivial flag whether we have seen the option on the command line.

   (define (repo-path)
     (if (and *cross-chicken* (not *host-extension*))
@@ -391,6 +392,22 @@
            ((pair? egg) (cdr egg))
            (else #f))))
 
+  (define (show-foreign-depends eggs)
+    (print "fetching meta information...")
+    (retrieve eggs)
+    (print "Foreign dependencies as reported in .meta:")
+    (for-each
+     (lambda (egg)
+       (and-let* ((meta-file (make-pathname (cadr egg) (car egg) "meta"))
+                  (m (and (file-exists? meta-file) (with-input-from-file 
meta-file read)))
+                  (ds (deps 'foreign-depends m)))
+         (unless (null? ds)
+           (print (car egg) ": ")
+           (for-each (cut print "\t" <>) (deps 'foreign-depends m)))))
+     *eggs+dirs+vers*)
+    (cleanup)
+    (exit 0))
+

This uses the retreive procedure for getting the meta data and
resolving dependencies for us. The result is stored in the global
*eggs+dirs+vers* variable which we iterate through and check for the
foreign-depends clause. If found print it.

Afterwards call cleanup to delete the temporary directories and exit.


   (define (retrieve eggs)
     (print "retrieving ...")
     (for-each
@@ -816,11 +834,15 @@ EOF
                          (unless *default-location*
                            (error
                             "no default location defined - please use 
`-location' option")))
-                       (if listeggs
-                           (display
-                            (list-available-extensions
-                             *default-transport* *default-location*))
-                           (install (apply-mappings (reverse eggs))))))))
+                        (cond (listeggs
+                               (display
+                                (list-available-extensions
+                                 *default-transport* *default-location*)))
+                              (*show-foreign-depends*
+                               (show-foreign-depends eggs))
+                              (else
+                               (install (apply-mappings (reverse eggs)))))
+                        ))))

This is code is reached when all args are parsed and we now have a
list of eggs to process. Inserted show-foreign-depends as a third code
branch hence reworded as a cond statement. 

               (else
                (let ((arg (car args)))
                  (cond ((or (string=? arg "-help")
@@ -937,6 +959,9 @@ EOF
                         (unless (pair? (cdr args)) (usage 1))
                         (set! *password* (cadr args))
                         (loop (cddr args) eggs))
+                       ((string=? "-show-foreign-depends" arg)
+                        (set! *show-foreign-depends* #t)
+                        (loop (cdr args) eggs))
                        ((and (positive? (string-length arg))
                              (char=? #\- (string-ref arg 0)))
                         (if (> (string-length arg) 2)
-- 
1.7.3.5

Just checks the presence of the command line option and sets the flag.
Because of this giving also -r on the command line will stop at
retreiving only the listed egg, thus our EDV list will only contain
those eggs.

The reuse of retrieve will also generate quite noisy output. Would it
be worthwhile to refactor chicken-install to quiet it down? 

That's all for now!

Suggestions, criticism and your thoughts are welcome.

Kind regards,

Christian


-- 
Who can (make) the muddy water (clear)? Let it be still, and it will
gradually become clear. Who can secure the condition of rest? Let
movement go on, and the condition of rest will gradually arise.
 -- Lao Tse. 

Attachment: 0001-Add-show-foreign-depends-option-to-chicken-install.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]