From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:41185) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7BCR-0008V0-VA for guix-patches@gnu.org; Wed, 26 Feb 2020 23:55:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7BCQ-0007EN-Lx for guix-patches@gnu.org; Wed, 26 Feb 2020 23:55:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:52626) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7BCQ-0007EF-Ja for guix-patches@gnu.org; Wed, 26 Feb 2020 23:55:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j7BCQ-000260-He for guix-patches@gnu.org; Wed, 26 Feb 2020 23:55:02 -0500 Subject: [bug#39807] [PATCH] guix: pack: Only wrap executable files. Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:33586) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7Arj-0005mL-KC for guix-patches@gnu.org; Wed, 26 Feb 2020 23:33:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7Ari-0007Za-4A for guix-patches@gnu.org; Wed, 26 Feb 2020 23:33:39 -0500 Received: from mout02.posteo.de ([185.67.36.66]:41839) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7Arh-0007X4-Hd for guix-patches@gnu.org; Wed, 26 Feb 2020 23:33:38 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 0FABA2400FB for ; Thu, 27 Feb 2020 05:33:33 +0100 (CET) From: Eric Bavier Date: Wed, 26 Feb 2020 22:36:04 -0600 Message-Id: <20200227043604.13102-1-bavier@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 39807@debbugs.gnu.org Cc: Eric Bavier From: Eric Bavier Hello Guix, This patch fixes some uses of relocatable git (e.g. octopus merge).=20 Previously, guix pack would wrap all files in "bin", "sbin", and "libexec= ", even non-executable files. This would cause issues for git when its shel= l scripts in libexec would try to source other shell files that had been wrapped and were no longer a valid shell file. I feel like a test should be added to tests/guix-pack-relocatable.sh, but I'm not sure how to do that while keeping the test lightweight. Suggesti= ons welcome. Cheers, `~Eric * guix/scripts/pack.scm (wrapped-package): Build wrappers for executable files and symlink others. --- guix/scripts/pack.scm | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index c8d8546e29..3634326102 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -4,6 +4,7 @@ ;;; Copyright =C2=A9 2018 Konrad Hinsen ;;; Copyright =C2=A9 2018 Chris Marusich ;;; Copyright =C2=A9 2018 Efraim Flashner +;;; Copyright =C2=A9 2020 Eric Bavier ;;; ;;; This file is part of GNU Guix. ;;; @@ -673,9 +674,11 @@ last resort for relocation." (guix build union))) #~(begin (use-modules (guix build utils) - ((guix build union) #:select (relative-file-name)= ) + ((guix build union) #:select (symlink-relative)) + (srfi srfi-1) (ice-9 ftw) - (ice-9 match)) + (ice-9 match) + (ice-9 receive)) =20 (define input ;; The OUTPUT* output of PACKAGE. @@ -726,15 +729,26 @@ last resort for relocation." (mkdir target) (for-each (lambda (file) (unless (member file '("." ".." "bin" "sbin" "libe= xec")) - (let ((file* (string-append input "/" file))) - (symlink (relative-file-name target file*) - (string-append target "/" file))))) + (symlink-relative (string-append input "/" file= ) + (string-append target "/" file= )))) (scandir input)) =20 - (for-each build-wrapper - (append (find-files (string-append input "/bin")) - (find-files (string-append input "/sbin")) - (find-files (string-append input "/libexec")= )))))) + (receive (executables others) + (partition executable-file? + (append (find-files (string-append input "/bin"= )) + (find-files (string-append input "/sbin= ")) + (find-files (string-append input "/libe= xec")))) + ;; Wrap only executables, since the wrapper will eventually = need + ;; to execve them. E.g. git's "libexec" directory contains = many + ;; shell scripts that are source'd from elsewhere, which fai= ls if + ;; they are wrapped. + (for-each build-wrapper executables) + ;; Link any other non-executable files + (for-each (lambda (old) + (let ((new (string-append target (strip-store-pr= efix old)))) + (mkdir-p (dirname new)) + (symlink-relative old new))) + others))))) =20 (computed-file (string-append (cond ((package? package) --=20 2.25.1