From 1d4ab335b22a93e01c2eb1eb3e93fc6534157040 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 30 Sep 2020 22:40:59 +0200 Subject: self: Use a 'guile' that doesn't complain about locales. Since commit ba48895899a117d6ace2209c3f54411a4a989133, selected UTF-8 locales are bundled. However, because 'guix-command' is itself a Guile script, users would still see Guile's warning, particularly on foreign distros: $ LC_ALL=sdf guix foo guile: warning: failed to install locale hint: Consider installing the `glibc-utf8-locales' [...] User commands would print that warning, but more importantly, each invocation of 'guix substitute' would print it, even though 'guix-daemon.service' explicitly chooses "en_US.utf8", which is in 'glibc-utf8-locales'. This leads to confusion since users would keep seeing this message unless/until they realize they also need to install 'glibc-utf8-locales' in root's profile. This patch gets rid of "guile: warning: ..." for a guix-pulled 'guix' command. * guix/self.scm (specification->package): Add "gcc-toolchain". (quiet-guile): New procedure. (guix-command): Use it. * gnu/packages/aux-files/guile-launcher.c: New file. * Makefile.am (AUX_FILES): Add it. --- guix/self.scm | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'guix/self.scm') diff --git a/guix/self.scm b/guix/self.scm index 5eb80f42fe..bbfd2f1b95 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -27,6 +27,7 @@ #:use-module (guix packages) #:use-module (guix sets) #:use-module (guix modules) + #:use-module ((guix utils) #:select (version-major+minor)) #:use-module ((guix build utils) #:select (find-files)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) @@ -62,6 +63,7 @@ ("xz" (ref '(gnu packages compression) 'xz)) ("po4a" (ref '(gnu packages gettext) 'po4a)) ("gettext" (ref '(gnu packages gettext) 'gettext-minimal)) + ("gcc-toolchain" (ref '(gnu packages commencement) 'gcc-toolchain)) (_ #f)))) ;no such package @@ -580,6 +582,48 @@ that provide Guile modules." (computed-file name build)) +(define (quiet-guile guile) + "Return a wrapper that does the same as the 'guile' executable of GUILE, +except that it does not complain about locales and falls back to 'en_US.utf8' +instead of 'C'." + (define gcc + (specification->package "gcc-toolchain")) + + (define source + (search-path %load-path + "gnu/packages/aux-files/guile-launcher.c")) + + (define effective + (version-major+minor (package-version guile))) + + (define build + ;; XXX: Reuse from (guix scripts pack) instead? + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils) + (srfi srfi-26)) + + (mkdir-p (string-append #$output "/bin")) + + (setenv "PATH" #$(file-append gcc "/bin")) + (setenv "C_INCLUDE_PATH" + (string-join + (map (cut string-append <> "/include") + '#$(match (bag-transitive-build-inputs + (package->bag guile)) + (((labels packages . _) ...) + (filter package? packages)))) + ":")) + (setenv "LIBRARY_PATH" #$(file-append gcc "/lib")) + + (invoke "gcc" #$(local-file source) "-Wall" "-g0" "-O2" + "-I" #$(file-append guile "/include/guile/" effective) + "-L" #$(file-append guile "/lib") + #$(string-append "-lguile-" effective) + "-o" (string-append #$output "/bin/guile"))))) + + (computed-file "guile-wrapper" build)) + (define* (guix-command modules #:key source (dependencies '()) guile (guile-version (effective-version))) @@ -634,7 +678,9 @@ load path." ;; XXX: It would be more convenient to change it to: ;; (exit (apply guix-main (command-line))) (apply guix-main (command-line)))) - #:guile guile)) + + ;; Use a 'guile' variant that doesn't complain about locales. + #:guile (quiet-guile guile))) (define (miscellaneous-files source) "Return data files taken from SOURCE." -- cgit v1.2.3