From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 17 05:44:48 2020 Received: (at 39970) by debbugs.gnu.org; 17 Mar 2020 09:44:48 +0000 Received: from localhost ([127.0.0.1]:38190 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jE8mF-000712-Lx for submit@debbugs.gnu.org; Tue, 17 Mar 2020 05:44:47 -0400 Received: from pelzflorian.de ([5.45.111.108]:48028 helo=mail.pelzflorian.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jE8mD-00070u-T4 for 39970@debbugs.gnu.org; Tue, 17 Mar 2020 05:44:46 -0400 Received: from pelzflorian.localdomain (unknown [5.45.111.108]) by mail.pelzflorian.de (Postfix) with ESMTPSA id A8BA93604F7; Tue, 17 Mar 2020 10:44:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=pelzflorian.de; s=mail; t=1584438284; bh=FViUB2onlkxlPJz3sgsG6UPdaGGq0G4v3H7AS4KvKyE=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=jyJPlRWCiRjQWeh4WnD5jE61H6owflDzHayCPGP3TubmHm36cPtBU78kT6zhnLC1p 1hBxMFeK1iS1eUKKhNmJxlumMSEBQeU8Q7gpsZCt3A9oOcxSv+OT1ot28ZMj8bnbOI 8Ix8siXRlGRJ521x+9OrbwbnkYHsu5NBCbvvzMXM= Date: Tue, 17 Mar 2020 10:44:43 +0100 From: "pelzflorian (Florian Pelz)" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#39970: guix commands broken on Azerbaijani 'az_AZ' and Turkish 'tr_TR' locales Message-ID: <20200317094443.cnajoi4yuzvxaafe@pelzflorian.localdomain> References: <20200307120052.ocwzphlvemvmb2ts@pelzflorian.localdomain> <20200307152003.myj7jkjthokbmark@pelzflorian.localdomain> <20200308070804.ylpb5yrwpgbc3p3w@pelzflorian.localdomain> <8736ah1mxb.fsf@gnu.org> <20200312110206.2hsinzejnmcefmot@pelzflorian.localdomain> <874kutsgmx.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2sl72hxfrvw7sfvd" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <874kutsgmx.fsf@gnu.org> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 39970 Cc: 39970@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --2sl72hxfrvw7sfvd Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Thu, Mar 12, 2020 at 05:05:26PM +0100, Ludovic Court�s wrote: > "pelzflorian (Florian Pelz)" skribis: > > Why would not using a regexp be better? > > It reduces reliance on libc, reduces complexity, and performs better as > noted in the commit log of 35eb77b09d957019b2437e7681bd88013d67d3cd. Thank you for your wisdom. I hope the attached patch is OK. `LC_ALL=en_US.utf8 make check` is mostly fine (except tests/pack.scm, which also failed before). Manual testing of `./pre-inst-env guix environment` works. `LC_ALL=tr_TR.utf8 make check` is still very unhappy though. There are many failures. I will continue to investigate later today. Regards, Florian --2sl72hxfrvw7sfvd Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: attachment; filename="0001-store-Fix-many-guix-commands-failing-on-some-locales.patch" Content-Transfer-Encoding: 8bit From: Florian Pelz Date: Thu, 12 Mar 2020 11:08:16 +0100 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [PATCH] store: Fix many guix commands failing on some locales. Partly fixes bug #39970 (see: https://bugs.gnu.org/39970). At least 'guix environment', 'guix install' and 'guix pull' on 'az_AZ.utf8' and 'tr_TR.utf8' were affected. * guix/store.scm (store-path-hash-part): Move base path detection to ... (store-path-base): ... this new exported procedure. (store-path-package-name): Use it instead of locale-dependent regexps. (store-regexp*): Remove. --- guix/store.scm | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/guix/store.scm b/guix/store.scm index f99fa581a8..5465204f5f 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -2,6 +2,7 @@ ;;; Copyright � 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Court�s ;;; Copyright � 2018 Jan Nieuwenhuizen ;;; Copyright � 2019 Mathieu Othacehe +;;; Copyright � 2020 Florian Pelz ;;; ;;; This file is part of GNU Guix. ;;; @@ -43,7 +44,6 @@ #:use-module (srfi srfi-35) #:use-module (srfi srfi-39) #:use-module (ice-9 match) - #:use-module (ice-9 regex) #:use-module (ice-9 vlist) #:use-module (ice-9 popen) #:use-module (ice-9 threads) @@ -172,6 +172,7 @@ store-path? direct-store-path? derivation-path? + store-path-base store-path-package-name store-path-hash-part direct-store-path @@ -1943,29 +1944,26 @@ valid inputs." "Return #t if PATH is a derivation path." (and (store-path? path) (string-suffix? ".drv" path))) -(define store-regexp* - ;; The substituter makes repeated calls to 'store-path-hash-part', hence - ;; this optimization. - (mlambda (store) - "Return a regexp matching a file in STORE." - (make-regexp (string-append "^" (regexp-quote store) - "/([0-9a-df-np-sv-z]{32})-([^/]+)$")))) +(define (store-path-base path) + "Return the base path of a path in the store." + (and (string-prefix? (%store-prefix) path) + (let ((base (string-drop path (+ 1 (string-length (%store-prefix)))))) + (and (> (string-length base) 33) + (not (string-index base #\/)) + base)))) (define (store-path-package-name path) "Return the package name part of PATH, a file name in the store." - (let ((path-rx (store-regexp* (%store-prefix)))) - (and=> (regexp-exec path-rx path) - (cut match:substring <> 2)))) + (let ((base (store-path-base path))) + (string-drop base (+ 32 1)))) ;32 hash part + 1 hyphen (define (store-path-hash-part path) "Return the hash part of PATH as a base32 string, or #f if PATH is not a syntactically valid store path." - (and (string-prefix? (%store-prefix) path) - (let ((base (string-drop path (+ 1 (string-length (%store-prefix)))))) - (and (> (string-length base) 33) - (let ((hash (string-take base 32))) - (and (string-every %nix-base32-charset hash) - hash)))))) + (let* ((base (store-path-base path)) + (hash (string-take base 32))) + (and (string-every %nix-base32-charset hash) + hash))) (define (derivation-log-file drv) "Return the build log file for DRV, a derivation file name, or #f if it -- 2.25.1 --2sl72hxfrvw7sfvd--