* [PATCH] build: ruby: Add support for tarball and directory sources.
@ 2015-09-08 3:01 David Thompson
2015-09-14 8:08 ` Ludovic Courtès
0 siblings, 1 reply; 3+ messages in thread
From: David Thompson @ 2015-09-08 3:01 UTC (permalink / raw
To: guix-devel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-build-ruby-Add-support-for-tarball-and-directory-sou.patch --]
[-- Type: text/x-patch, Size: 5454 bytes --]
From 612a4a692375f241934de03d24064dbef1c7294c Mon Sep 17 00:00:00 2001
From: David Thompson <dthompson2@worcester.edu>
Date: Mon, 7 Sep 2015 22:58:05 -0400
Subject: [PATCH] build: ruby: Add support for tarball and directory sources.
Previously, the Ruby build system only knew how to work with gem archives,
which made it difficult to build unreleased gems from a Git repository or
released gems in tarball form.
* gnu/build/ruby-build-system.scm (gnu:unpack, gem-archive?): New procedures.
(unpack): Use GNU build system unpack phase for non-gem sources.
(build): Rebuild the gemspec iff the source is a gem archive.
---
guix/build/ruby-build-system.scm | 86 ++++++++++++++++++++++------------------
1 file changed, 48 insertions(+), 38 deletions(-)
diff --git a/guix/build/ruby-build-system.scm b/guix/build/ruby-build-system.scm
index 4184ccc..2685da1 100644
--- a/guix/build/ruby-build-system.scm
+++ b/guix/build/ruby-build-system.scm
@@ -41,53 +41,63 @@ directory."
((file-name . _) file-name)
(() (error "No files matching pattern: " pattern))))
+(define gnu:unpack (assq-ref gnu:%standard-phases 'unpack))
+
+(define (gem-archive? file-name)
+ (string-match "^.*\\.gem$" file-name))
+
(define* (unpack #:key source #:allow-other-keys)
"Unpack the gem SOURCE and enter the resulting directory."
- (and (zero? (system* "gem" "unpack" source))
- ;; The unpacked gem directory is named the same as the archive, sans
- ;; the ".gem" extension. It is renamed to simply "gem" in an effort to
- ;; keep file names shorter to avoid UNIX-domain socket file names and
- ;; shebangs that exceed the system's fixed maximum length when running
- ;; test suites.
- (let ((dir (match:substring (string-match "^(.*)\\.gem$"
- (basename source))
- 1)))
- (rename-file dir "gem")
- (chdir "gem")
- #t)))
+ (if (gem-archive? source)
+ (and (zero? (system* "gem" "unpack" source))
+ ;; The unpacked gem directory is named the same as the archive,
+ ;; sans the ".gem" extension. It is renamed to simply "gem" in an
+ ;; effort to keep file names shorter to avoid UNIX-domain socket
+ ;; file names and shebangs that exceed the system's fixed maximum
+ ;; length when running test suites.
+ (let ((dir (match:substring (string-match "^(.*)\\.gem$"
+ (basename source))
+ 1)))
+ (rename-file dir "gem")
+ (chdir "gem")
+ #t))
+ ;; 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$"))
;; 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.
- (let ((gemspec (or (false-if-exception
- (first-matching-file "\\.gemspec$"))
- ;; Make new gemspec if one wasn't shipped.
- ".gemspec")))
-
- (when (file-exists? gemspec) (delete-file gemspec))
-
- ;; Extract gemspec from source gem.
- (let ((pipe (open-pipe* OPEN_READ "gem" "spec" "--ruby" source)))
- (dynamic-wind
- (const #t)
- (lambda ()
- (call-with-output-file gemspec
- (lambda (out)
- ;; 'gem spec' writes to stdout, but 'gem build' only reads
- ;; gemspecs from a file, so we redirect the output to a file.
- (while (not (eof-object? (peek-char pipe)))
- (write-char (read-char pipe) out))))
- #t)
- (lambda ()
- (close-pipe pipe))))
-
- ;; 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
- ;; gem.
- (zero? (system* "gem" "build" gemspec))))
+ (when (gem-archive? source)
+ (let ((gemspec (or (false-if-exception (first-gemspec))
+ ;; Make new gemspec if one wasn't shipped.
+ ".gemspec")))
+
+ (when (file-exists? gemspec) (delete-file gemspec))
+
+ ;; Extract gemspec from source gem.
+ (let ((pipe (open-pipe* OPEN_READ "gem" "spec" "--ruby" source)))
+ (dynamic-wind
+ (const #t)
+ (lambda ()
+ (call-with-output-file gemspec
+ (lambda (out)
+ ;; 'gem spec' writes to stdout, but 'gem build' only reads
+ ;; gemspecs from a file, so we redirect the output to a file.
+ (while (not (eof-object? (peek-char pipe)))
+ (write-char (read-char pipe) out))))
+ #t)
+ (lambda ()
+ (close-pipe pipe))))))
+
+ ;; 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
+ ;; gem.
+ (zero? (system* "gem" "build" (first-gemspec))))
(define* (check #:key tests? test-target #:allow-other-keys)
"Run the gem's test suite rake task TEST-TARGET. Skip the tests if TESTS?
--
2.5.0
[-- Attachment #2: Type: text/plain, Size: 38 bytes --]
--
David Thompson
GPG Key: 0FF1D807
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] build: ruby: Add support for tarball and directory sources.
2015-09-08 3:01 [PATCH] build: ruby: Add support for tarball and directory sources David Thompson
@ 2015-09-14 8:08 ` Ludovic Courtès
2015-09-14 12:23 ` Thompson, David
0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2015-09-14 8:08 UTC (permalink / raw
To: David Thompson; +Cc: guix-devel
David Thompson <dthompson2@worcester.edu> skribis:
> From 612a4a692375f241934de03d24064dbef1c7294c Mon Sep 17 00:00:00 2001
> From: David Thompson <dthompson2@worcester.edu>
> Date: Mon, 7 Sep 2015 22:58:05 -0400
> Subject: [PATCH] build: ruby: Add support for tarball and directory sources.
>
> Previously, the Ruby build system only knew how to work with gem archives,
> which made it difficult to build unreleased gems from a Git repository or
> released gems in tarball form.
>
> * gnu/build/ruby-build-system.scm (gnu:unpack, gem-archive?): New procedures.
> (unpack): Use GNU build system unpack phase for non-gem sources.
> (build): Rebuild the gemspec iff the source is a gem archive.
I trust you for all things Ruby, but it looks good.
Should the manual mention that both Gems and raw checkouts are handled?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] build: ruby: Add support for tarball and directory sources.
2015-09-14 8:08 ` Ludovic Courtès
@ 2015-09-14 12:23 ` Thompson, David
0 siblings, 0 replies; 3+ messages in thread
From: Thompson, David @ 2015-09-14 12:23 UTC (permalink / raw
To: Ludovic Courtès; +Cc: guix-devel
On Mon, Sep 14, 2015 at 4:08 AM, Ludovic Courtès <ludo@gnu.org> wrote:
> David Thompson <dthompson2@worcester.edu> skribis:
>
>> From 612a4a692375f241934de03d24064dbef1c7294c Mon Sep 17 00:00:00 2001
>> From: David Thompson <dthompson2@worcester.edu>
>> Date: Mon, 7 Sep 2015 22:58:05 -0400
>> Subject: [PATCH] build: ruby: Add support for tarball and directory sources.
>>
>> Previously, the Ruby build system only knew how to work with gem archives,
>> which made it difficult to build unreleased gems from a Git repository or
>> released gems in tarball form.
>>
>> * gnu/build/ruby-build-system.scm (gnu:unpack, gem-archive?): New procedures.
>> (unpack): Use GNU build system unpack phase for non-gem sources.
>> (build): Rebuild the gemspec iff the source is a gem archive.
>
> I trust you for all things Ruby, but it looks good.
>
> Should the manual mention that both Gems and raw checkouts are handled?
Yes, I'll mention it and push. Thanks!
- Dave
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-14 12:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-08 3:01 [PATCH] build: ruby: Add support for tarball and directory sources David Thompson
2015-09-14 8:08 ` Ludovic Courtès
2015-09-14 12:23 ` Thompson, David
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.