From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWnXW-0005sS-0v for guix-patches@gnu.org; Sun, 16 Jul 2017 13:41:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dWnXS-0003qs-57 for guix-patches@gnu.org; Sun, 16 Jul 2017 13:41:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:40004) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dWnXS-0003qo-0o for guix-patches@gnu.org; Sun, 16 Jul 2017 13:41:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dWnXR-0003Zz-Rk for guix-patches@gnu.org; Sun, 16 Jul 2017 13:41:01 -0400 Subject: [bug#27438] [PATCH] guix: build: ruby-build-system: Install to the vendor directory Resent-Message-ID: From: Christopher Baines Date: Sun, 16 Jul 2017 18:40:14 +0100 Message-Id: <20170716174014.21859-1-mail@cbaines.net> In-Reply-To: <20170716183705.18b5025e@cbaines.net> References: <20170716183705.18b5025e@cbaines.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 27438@debbugs.gnu.org From: Christopher Baines * guix/build/ruby-build-system.scm (install): Install gems to the vendor directory, rather than the GEM_HOME. The vendor directory does not include the version of ruby used to install the gem in the path, which makes it easier to add it to the GEM_PATH for all versions of ruby to use. * gnu/packages/ruby.scm (ruby,ruby-2.1)[native-search-paths]: Switch to lib/ruby/vendor_ruby. --- gnu/packages/ruby.scm | 12 ++---------- guix/build/ruby-build-system.scm | 38 +++++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/gnu/packages/ruby.scm b/gnu/packages/ruby.scm index 7eba68444..f634d5e71 100644 --- a/gnu/packages/ruby.scm +++ b/gnu/packages/ruby.scm @@ -93,9 +93,7 @@ (native-search-paths (list (search-path-specification (variable "GEM_PATH") - (files (list (string-append "lib/ruby/gems/" - (version-major+minor version) - ".0")))))) + (files (list (string-append "lib/ruby/vendor_ruby")))))) (synopsis "Programming language interpreter") (description "Ruby is a dynamic object-oriented programming language with a focus on simplicity and productivity.") @@ -159,13 +157,7 @@ a focus on simplicity and productivity.") "lib/mkmf.rb" "process.c") (("/bin/sh") (which "sh")))) - %standard-phases))) - (native-search-paths - (list (search-path-specification - (variable "GEM_PATH") - (files (list (string-append "lib/ruby/gems/" - (version-major+minor version) - ".0")))))))) + %standard-phases))))) (define-public ruby-1.8 (package (inherit ruby) diff --git a/guix/build/ruby-build-system.scm b/guix/build/ruby-build-system.scm index c2d276627..f4ce2e5d8 100644 --- a/guix/build/ruby-build-system.scm +++ b/guix/build/ruby-build-system.scm @@ -129,40 +129,48 @@ GEM-FLAGS are passed to the 'gem' invokation, if present." (assoc-ref inputs "ruby")) 1)) (out (assoc-ref outputs "out")) - (gem-home (string-append out "/lib/ruby/gems/" ruby-version ".0")) + (vendor-dir (string-append out "/lib/ruby/vendor_ruby")) (gem-file (first-matching-file "\\.gem$")) (gem-file-basename (basename gem-file)) (gem-name (substring gem-file-basename 0 - (- (string-length gem-file-basename) 4))) - (gem-directory (string-append gem-home "/gems/" gem-name))) - (setenv "GEM_HOME" gem-home) - (mkdir-p gem-home) - (and (apply system* "gem" "install" gem-file - "--local" "--ignore-dependencies" - ;; Executables should go into /bin, not /lib/ruby/gems. - "--bindir" (string-append out "/bin") - gem-flags) + (- (string-length gem-file-basename) 4)))) + (setenv "GEM_VENDOR" vendor-dir) + (and (let ((install-succeeded? + (zero? + (apply system* "gem" "install" gem-file + "--local" "--ignore-dependencies" "--vendor" + ;; Executables should go into /bin, not + ;; /lib/ruby/gems. + "--bindir" (string-append out "/bin") + gem-flags)))) + (or install-succeeded? + (begin + (simple-format #t "installation failed\n") + (let ((failed-output-dir (string-append (getcwd) "/out"))) + (mkdir failed-output-dir) + (copy-recursively out failed-output-dir)) + #f))) (begin ;; Remove the cached gem file as this is unnecessary and contains ;; timestamped files rendering builds not reproducible. - (let ((cached-gem (string-append gem-home "/cache/" gem-file))) + (let ((cached-gem (string-append vendor-dir "/cache/" gem-file))) (log-file-deletion cached-gem) (delete-file cached-gem)) ;; For gems with native extensions, several Makefile-related files ;; are created that contain timestamps or other elements making ;; them not reproducible. They are unnecessary so we remove them. - (if (file-exists? (string-append gem-directory "/ext")) + (if (file-exists? (string-append vendor-dir "/ext")) (begin (for-each (lambda (file) (log-file-deletion file) (delete-file file)) (append - (find-files (string-append gem-home "/doc") + (find-files (string-append vendor-dir "/doc") "page-Makefile.ri") - (find-files (string-append gem-home "/extensions") + (find-files (string-append vendor-dir "/extensions") "gem_make.out") - (find-files (string-append gem-directory "/ext") + (find-files (string-append vendor-dir "/ext") "Makefile"))))) #t)))) -- 2.13.1