From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Woodcroft Subject: [PATCH 1/3] guix: ruby-build-system: Build compiled gems reproducibly. Date: Wed, 10 Aug 2016 13:33:23 +1000 Message-ID: <20160810033325.3880-2-donttrustben@gmail.com> References: <20160810033325.3880-1-donttrustben@gmail.com> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXKH5-0005SY-Pt for guix-devel@gnu.org; Tue, 09 Aug 2016 23:33:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXKH4-00084D-Rt for guix-devel@gnu.org; Tue, 09 Aug 2016 23:33:47 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:33406) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXKH4-000847-Kz for guix-devel@gnu.org; Tue, 09 Aug 2016 23:33:46 -0400 Received: by mail-pf0-x243.google.com with SMTP id i6so1993469pfe.0 for ; Tue, 09 Aug 2016 20:33:46 -0700 (PDT) Received: from localhost.localdomain ([103.25.181.216]) by smtp.googlemail.com with ESMTPSA id r2sm28730731pal.14.2016.08.09.20.33.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Aug 2016 20:33:44 -0700 (PDT) In-Reply-To: <20160810033325.3880-1-donttrustben@gmail.com> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * guix/build/ruby-build-system.scm (log-file-deletion): New procedure. (install): Remove files containing non-reproducible elements. Print when each file is deleted. --- guix/build/ruby-build-system.scm | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/guix/build/ruby-build-system.scm b/guix/build/ruby-build-system.scm index 79ac380..95793f7 100644 --- a/guix/build/ruby-build-system.scm +++ b/guix/build/ruby-build-system.scm @@ -120,18 +120,44 @@ GEM-FLAGS are passed to the 'gem' invokation, if present." 1)) (out (assoc-ref outputs "out")) (gem-home (string-append out "/lib/ruby/gems/" ruby-version ".0")) - (gem-name (first-matching-file "\\.gem$"))) + (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-name + (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) - ;; Remove the cached gem file as this is unnecessary and contains - ;; timestamped files rendering builds not reproducible. - (begin (delete-file (string-append gem-home "/cache/" gem-name)) - #t)))) + (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))) + (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")) + (begin + (for-each (lambda (file) + (log-file-deletion file) + (delete-file file)) + (append + (find-files (string-append gem-home "/doc") + "page-Makefile.ri") + (find-files (string-append gem-home "/extensions") + "gem_make.out") + (find-files (string-append gem-directory "/ext") + "Makefile"))))) + #t)))) + +(define (log-file-deletion file) + (display (string-append "deleting '" file "' for reproducibility\n"))) (define %standard-phases (modify-phases gnu:%standard-phases -- 2.9.1