From patchwork Thu Oct 1 08:38:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 24395 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DECC627BBE9; Thu, 1 Oct 2020 09:40:09 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4D74627BBE8 for ; Thu, 1 Oct 2020 09:40:09 +0100 (BST) Received: from localhost ([::1]:51388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNu8G-0008BH-GL for patchwork@mira.cbaines.net; Thu, 01 Oct 2020 04:40:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNu8B-0008B2-3g for guix-patches@gnu.org; Thu, 01 Oct 2020 04:40:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kNu8A-0003bE-Qm for guix-patches@gnu.org; Thu, 01 Oct 2020 04:40:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kNu8A-0008Ci-OR for guix-patches@gnu.org; Thu, 01 Oct 2020 04:40:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#43737] [PATCH 1/2] self: Use a 'guile' that doesn't complain about locales. References: <20201001083507.27246-1-ludo@gnu.org> In-Reply-To: <20201001083507.27246-1-ludo@gnu.org> Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 01 Oct 2020 08:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43737 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 43737@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 43737-submit@debbugs.gnu.org id=B43737.160154154131422 (code B ref 43737); Thu, 01 Oct 2020 08:40:02 +0000 Received: (at 43737) by debbugs.gnu.org; 1 Oct 2020 08:39:01 +0000 Received: from localhost ([127.0.0.1]:33985 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNu7B-0008Af-7U for submit@debbugs.gnu.org; Thu, 01 Oct 2020 04:39:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57262) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNu79-0008AK-5K for 43737@debbugs.gnu.org; Thu, 01 Oct 2020 04:38:59 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50875) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNu73-0003Sj-Rw; Thu, 01 Oct 2020 04:38:53 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=33392 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kNu73-0000y1-6T; Thu, 01 Oct 2020 04:38:53 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Thu, 1 Oct 2020 10:38:47 +0200 Message-Id: <20201001083848.27390-1-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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. --- Makefile.am | 1 + gnu/packages/aux-files/guile-launcher.c | 46 ++++++++++++++++++++++++ guix/self.scm | 48 ++++++++++++++++++++++++- 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/aux-files/guile-launcher.c diff --git a/Makefile.am b/Makefile.am index 8e91e1e558..bc3efd2b6f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -330,6 +330,7 @@ dist_noinst_DATA = \ # Auxiliary files for packages. AUX_FILES = \ + gnu/packages/aux-files/guile-launcher.c \ gnu/packages/aux-files/chromium/master-preferences.json \ gnu/packages/aux-files/emacs/guix-emacs.el \ gnu/packages/aux-files/linux-libre/5.8-arm.conf \ diff --git a/gnu/packages/aux-files/guile-launcher.c b/gnu/packages/aux-files/guile-launcher.c new file mode 100644 index 0000000000..886ede2846 --- /dev/null +++ b/gnu/packages/aux-files/guile-launcher.c @@ -0,0 +1,46 @@ +/* GNU Guix --- Functional package management for GNU + Copyright 1996-1997,2000-2001,2006,2008,2011,2013,2018 + Free Software Foundation, Inc. + Copyright (C) 2020 Ludovic Courtès + + This file is part of GNU Guix. + + GNU Guix is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or (at + your option) any later version. + + GNU Guix is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Guix. If not, see . */ + +/* This file implements a variant of the 'guile' executable that does not + complain about locale issues. */ + +#include +#include + +static void +inner_main (void *unused, int argc, char **argv) +{ + scm_shell (argc, argv); +} + +int +main (int argc, char **argv) +{ + /* Try to install the current locale; remain silent if it fails. */ + if (setlocale (LC_ALL, "") == NULL) + /* The 'guix pull'-provided 'guix' includes at least en_US.utf8 so use + that. That gives us UTF-8 support for 'scm_to_locale_string', etc., + which is always preferable over the C locale. */ + setlocale (LC_ALL, "en_US.utf8"); + + scm_install_gmp_memory_functions = 1; + scm_boot_guile (argc, argv, inner_main, 0); + return 0; /* never reached */ +} 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." From patchwork Thu Oct 1 08:38:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 24396 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 483CA27BBE9; Thu, 1 Oct 2020 09:40:12 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id DEFFA27BBE8 for ; Thu, 1 Oct 2020 09:40:11 +0100 (BST) Received: from localhost ([::1]:51492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNu8J-0008EV-3v for patchwork@mira.cbaines.net; Thu, 01 Oct 2020 04:40:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNu8B-0008B8-Gy for guix-patches@gnu.org; Thu, 01 Oct 2020 04:40:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kNu8B-0003bM-7H for guix-patches@gnu.org; Thu, 01 Oct 2020 04:40:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kNu8B-0008Cp-5N for guix-patches@gnu.org; Thu, 01 Oct 2020 04:40:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#43737] [PATCH 2/2] build: Use a 'guile' executable that doesn't warn about locales. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 01 Oct 2020 08:40:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43737 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 43737@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 43737-submit@debbugs.gnu.org id=B43737.160154154231432 (code B ref 43737); Thu, 01 Oct 2020 08:40:03 +0000 Received: (at 43737) by debbugs.gnu.org; 1 Oct 2020 08:39:02 +0000 Received: from localhost ([127.0.0.1]:33987 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNu7B-0008Al-OD for submit@debbugs.gnu.org; Thu, 01 Oct 2020 04:39:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57266) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNu79-0008AL-Tt for 43737@debbugs.gnu.org; Thu, 01 Oct 2020 04:39:00 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50876) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNu74-0003So-Lm; Thu, 01 Oct 2020 04:38:54 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=33392 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kNu74-0000y1-60; Thu, 01 Oct 2020 04:38:54 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Thu, 1 Oct 2020 10:38:48 +0200 Message-Id: <20201001083848.27390-2-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001083848.27390-1-ludo@gnu.org> References: <20201001083848.27390-1-ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches This gets rid of: guile: warning: failed to install locale when running the 'guix' command on a foreign distro where 'GUIX_LOCPATH' isn't set. * Makefile.am (pkglibexec_PROGRAMS, guile_SOURCES, guile_LDADD) (guile_CFLAGS): New variables. (install-exec-hook): New target. (AUX_FILES): Remove 'guile-launcher.c'. * configure.ac: Use 'GUILE_FLAGS'. --- Makefile.am | 13 ++++++++++++- configure.ac | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index bc3efd2b6f..7aaf15cf8a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,6 +47,18 @@ scripts/guix: scripts/guix.in Makefile $(AM_V_GEN)$(do_subst) < "$(srcdir)/$@.in" > "$@-t" $(AM_V_at)chmod a+x,a-w "$@-t" && mv -f "$@-t" "$@" +# This is our variant of the 'guile' executable, one that doesn't complain +# about locales. +pkglibexec_PROGRAMS = guile +guile_SOURCES = gnu/packages/aux-files/guile-launcher.c +guile_LDADD = $(GUILE_LIBS) +guile_CFLAGS = $(GUILE_CFLAGS) + +# Have the 'guix' command refer to our 'guile'. +install-exec-hook: + $(SED) -i "$(DESTDIR)$(bindir)/guix" \ + -e 's,^#![[:graph:]]\+,#!$(pkglibexecdir)/guile,g' + nodist_noinst_SCRIPTS = \ pre-inst-env \ test-env @@ -330,7 +342,6 @@ dist_noinst_DATA = \ # Auxiliary files for packages. AUX_FILES = \ - gnu/packages/aux-files/guile-launcher.c \ gnu/packages/aux-files/chromium/master-preferences.json \ gnu/packages/aux-files/emacs/guix-emacs.el \ gnu/packages/aux-files/linux-libre/5.8-arm.conf \ diff --git a/configure.ac b/configure.ac index adca374619..6861112eaf 100644 --- a/configure.ac +++ b/configure.ac @@ -105,6 +105,9 @@ if test "x$GUILE_EFFECTIVE_VERSION" = "x2.2"; then PKG_CHECK_MODULES([GUILE], [guile-2.2 >= 2.2.3]) fi +dnl Get CFLAGS and LDFLAGS for libguile. +GUILE_FLAGS + dnl Installation directories for .scm and .go files. guilemoduledir="${datarootdir}/guile/site/$GUILE_EFFECTIVE_VERSION" guileobjectdir="${libdir}/guile/$GUILE_EFFECTIVE_VERSION/site-ccache"