summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--guix/build-system/ruby.scm32
-rw-r--r--guix/build/ruby-build-system.scm21
2 files changed, 33 insertions, 20 deletions
diff --git a/guix/build-system/ruby.scm b/guix/build-system/ruby.scm
index d2dd6a48cc..08301ec609 100644
--- a/guix/build-system/ruby.scm
+++ b/guix/build-system/ruby.scm
@@ -43,22 +43,24 @@
   (define private-keywords
     '(#:source #:target #:ruby #:inputs #:native-inputs))
 
-  (and (not target)                               ;XXX: no cross-compilation
-       (bag
-         (name name)
-         (system system)
-         (host-inputs `(,@(if source
-                              `(("source" ,source))
-                              '())
-                        ,@inputs
+  (let ((version-control (resolve-interface '(gnu packages version-control))))
+    (and (not target)                    ;XXX: no cross-compilation
+         (bag
+           (name name)
+           (system system)
+           (host-inputs `(,@(if source
+                                `(("source" ,source))
+                                '())
+                          ,@inputs
 
-                        ;; Keep the standard inputs of 'gnu-build-system'.
-                        ,@(standard-packages)))
-         (build-inputs `(("ruby" ,ruby)
-                         ,@native-inputs))
-         (outputs outputs)
-         (build ruby-build)
-         (arguments (strip-keyword-arguments private-keywords arguments)))))
+                          ;; Keep the standard inputs of 'gnu-build-system'.
+                          ,@(standard-packages)))
+           (build-inputs `(("ruby" ,ruby)
+                           ("git" ,(module-ref version-control 'git))
+                           ,@native-inputs))
+           (outputs outputs)
+           (build ruby-build)
+           (arguments (strip-keyword-arguments private-keywords arguments))))))
 
 (define* (ruby-build store name inputs
                      #:key
diff --git a/guix/build/ruby-build-system.scm b/guix/build/ruby-build-system.scm
index 2b3ba7c8cd..933788cf90 100644
--- a/guix/build/ruby-build-system.scm
+++ b/guix/build/ruby-build-system.scm
@@ -39,6 +39,14 @@ directory."
     ((file-name . _) file-name)
     (() (error "No files matching pattern: " pattern))))
 
+;; Most gemspecs assume that builds are taking place within a git repository
+;; by include calls to 'git ls-files'.  In order for these gemspecs to work
+;; as-is, every file in the source tree is added to the staging area.
+(define gitify
+  (lambda _
+    (and (zero? (system* "git" "init"))
+         (zero? (system* "git" "add" ".")))))
+
 (define build
   (lambda _
     (zero? (system* "gem" "build" (first-matching-file "\\.gemspec$")))))
@@ -62,13 +70,16 @@ directory."
                     (first-matching-file "\\.gem$")))))
 
 (define %standard-phases
-  (alist-replace
-   'build build
+  (alist-cons-after
+   'unpack 'gitify gitify
    (alist-replace
-    'install install
+    'build build
     (alist-replace
-     'check check
-     (alist-delete 'configure gnu:%standard-phases)))))
+     'install install
+     (alist-replace
+      'check check
+      (alist-delete
+       'configure gnu:%standard-phases))))))
 
 (define* (ruby-build #:key inputs (phases %standard-phases)
                      #:allow-other-keys #:rest args)