Merge branch 'core-updates'.
[jackhill/guix/guix.git] / guix / build / ruby-build-system.scm
index 40aa974..1310c4a 100644 (file)
@@ -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$")))))
@@ -53,17 +61,19 @@ directory."
           (match:substring (string-match "ruby-(.*)$"
                                          (assoc-ref inputs "ruby"))
                            1))
-         (gem-home (string-append (assoc-ref outputs "out")
-                                  "/lib/ruby/gems/"
-                                  ruby-version)))
+         (out (assoc-ref outputs "out"))
+         (gem-home (string-append out "/lib/ruby/gems/" ruby-version)))
     (setenv "GEM_HOME" gem-home)
     (mkdir-p gem-home)
     (zero? (system* "gem" "install" "--local"
-                    (first-matching-file "\\.gem$")))))
+                    (first-matching-file "\\.gem$")
+                    ;; Executables should go into /bin, not /lib/ruby/gems.
+                    "--bindir" (string-append out "/bin")))))
 
 (define %standard-phases
   (modify-phases gnu:%standard-phases
     (delete configure)
+    (add-after unpack gitify gitify)
     (replace build build)
     (replace install install)
     (replace check check)))