[1/2] guix: ruby-build-system: Extract gemspec during 'configure'.

Message ID 1463872621-17738-2-git-send-email-donttrustben@gmail.com
State New
Headers

Commit Message

Ben Woodcroft May 21, 2016, 11:17 p.m. UTC
  * guix/build/ruby-build-system.scm [build]: Move extraction from here ...
[configure]: ... to here.  New variable.
[first-gemspec]: New variable.
[standard-phases]: Add 'configure'.
---
 guix/build/ruby-build-system.scm | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
  

Comments

Ricardo Wurmus May 24, 2016, 12:14 p.m. UTC | #1
Hi Ben,

I’m in favour of this change.  I agree with Dave that the name of this
phase should not be “configure”.

> * guix/build/ruby-build-system.scm [build]: Move extraction from here ...
> [configure]: ... to here.  New variable.
> [first-gemspec]: New variable.
> [standard-phases]: Add 'configure'.

I think these should be round parentheses.  Also “standard-phases”
should really be “%standard-phases”.

~~ Ricardo
  
Ben Woodcroft May 25, 2016, 12:42 p.m. UTC | #2
On 24/05/16 22:14, Ricardo Wurmus wrote:
> Hi Ben,
>
> I’m in favour of this change.  I agree with Dave that the name of this
> phase should not be “configure”.
>
>> * guix/build/ruby-build-system.scm [build]: Move extraction from here ...
>> [configure]: ... to here.  New variable.
>> [first-gemspec]: New variable.
>> [standard-phases]: Add 'configure'.
> I think these should be round parentheses.  Also “standard-phases”
> should really be “%standard-phases”.

Thanks, all pushed.
ben
  

Patch

diff --git a/guix/build/ruby-build-system.scm b/guix/build/ruby-build-system.scm
index a4ac3b3..1861010 100644
--- a/guix/build/ruby-build-system.scm
+++ b/guix/build/ruby-build-system.scm
@@ -66,14 +66,13 @@  directory."
       ;; Use GNU unpack strategy for things that aren't gem archives.
       (gnu:unpack #:source source)))
 
-(define* (build #:key source #:allow-other-keys)
-  "Build a new gem using the gemspec from the SOURCE gem."
-  (define (first-gemspec)
-    (first-matching-file "\\.gemspec$"))
+(define (first-gemspec)
+  (first-matching-file "\\.gemspec$"))
 
-  ;; Remove the original gemspec, if present, and replace it with a new one.
-  ;; This avoids issues with upstream gemspecs requiring tools such as git to
-  ;; generate the files list.
+(define* (configure #:key source #:allow-other-keys)
+  "Remove the original gemspec, if present, and replace it with a new one.
+This avoids issues with upstream gemspecs requiring tools such as git to
+generate the files list."
   (when (gem-archive? source)
     (let ((gemspec (or (false-if-exception (first-gemspec))
                        ;; Make new gemspec if one wasn't shipped.
@@ -94,7 +93,10 @@  directory."
                   (write-char (read-char pipe) out))))
             #t)
           (lambda ()
-            (close-pipe pipe))))))
+            (close-pipe pipe)))))))
+
+(define* (build #:key source #:allow-other-keys)
+  "Build a new gem using the gemspec from the SOURCE gem."
 
   ;; Build a new gem from the current working directory.  This also allows any
   ;; dynamic patching done in previous phases to be present in the installed
@@ -133,7 +135,7 @@  GEM-FLAGS are passed to the 'gem' invokation, if present."
 
 (define %standard-phases
   (modify-phases gnu:%standard-phases
-    (delete 'configure)
+    (replace 'configure configure)
     (replace 'build build)
     (replace 'unpack unpack)
     (replace 'install install)