From patchwork Fri Mar 27 02:53:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Bavier X-Patchwork-Id: 20903 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 6EB5027BBE4; Fri, 27 Mar 2020 02:54:12 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID,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 ESMTP id 99C6627BBEA for ; Fri, 27 Mar 2020 02:54:11 +0000 (GMT) Received: from localhost ([::1]:36366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHf8N-00073m-5s for patchwork@mira.cbaines.net; Thu, 26 Mar 2020 22:54:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33412) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHf8F-00070q-Sr for guix-patches@gnu.org; Thu, 26 Mar 2020 22:54:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHf8E-0006AD-DZ for guix-patches@gnu.org; Thu, 26 Mar 2020 22:54:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:54455) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jHf8D-00069j-Vn for guix-patches@gnu.org; Thu, 26 Mar 2020 22:54:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jHf8D-0003mq-T6 for guix-patches@gnu.org; Thu, 26 Mar 2020 22:54:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#39807] [PATCH] guix: pack: Only wrap executable files. Resent-From: Eric Bavier Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 27 Mar 2020 02:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39807 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 39807 <39807@debbugs.gnu.org> Received: via spool by 39807-submit@debbugs.gnu.org id=B39807.158527761714514 (code B ref 39807); Fri, 27 Mar 2020 02:54:01 +0000 Received: (at 39807) by debbugs.gnu.org; 27 Mar 2020 02:53:37 +0000 Received: from localhost ([127.0.0.1]:60428 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jHf7h-0003lk-VQ for submit@debbugs.gnu.org; Thu, 26 Mar 2020 22:53:37 -0400 Received: from mout01.posteo.de ([185.67.36.65]:53421) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jHf7e-0003lS-JO for 39807@debbugs.gnu.org; Thu, 26 Mar 2020 22:53:27 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 9FB2E16005C for <39807@debbugs.gnu.org>; Fri, 27 Mar 2020 03:53:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1585277599; bh=Oxh0KUm3tGUsBCRL6c4eUM1jZtHu7r227HpOdSNVxmc=; h=Date:From:To:Subject:From; b=BikptcPR1cJg6EDoMkJeowxo/DsF5PGuO5u37iOpgKdsKyKp11Iefps0sGQXkYRx5 QCMuU2YvBxjIYHbeZsExJpnOXQTU/r7G1FDJsMh7DJU249QjzyZBrQqmo/yEe8HRoS XMIAgIbXP7g2F/hRszDFWB0kdVoyatJTH3gTWlUCqf/lCK7ZJm+9X3f664f8wAiMUU /gAqhKqH1cvphj76k8YeBXkqA8FIxrEOXnfp5BuV6Vpi9RwQb5NjV+glkZO4hSynAc AQjy5/oc8dI2rblT3uhEmExl+zPyoeIl13KbzWdaFe60+GdeKKbHfVTUdXL73vl/Rx 0RnBp2SJkwNWw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 48pRHg0V03z6tmD for <39807@debbugs.gnu.org>; Fri, 27 Mar 2020 03:53:18 +0100 (CET) MIME-Version: 1.0 Date: Thu, 26 Mar 2020 21:53:18 -0500 From: Eric Bavier In-Reply-To: <87h7ydljyv.fsf@gnu.org> References: <20200227043604.13102-1-bavier@posteo.net> <87d09pohrj.fsf@gnu.org> <87h7ydljyv.fsf@gnu.org> Message-ID: <9929712b169123d7f35169919dfaaa9c@posteo.net> X-Sender: bavier@posteo.net User-Agent: Posteo Webmail X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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 Latest patch attached. From 5b9c0a140837138740b2b4f07338901948f08515 Mon Sep 17 00:00:00 2001 From: Eric Bavier Date: Mon, 24 Feb 2020 23:47:02 -0600 Subject: [PATCH] wip: guix: pack: Only wrap executable files. * guix/scripts/pack.scm (wrapped-package): Build wrappers for executable files and symlink others. * tests/guix-pack-relocatable.sh: Test relocatable git-minimal's "merge-octopus". --- guix/scripts/pack.scm | 32 ++++++++++++++++++++--------- tests/guix-pack-relocatable.sh | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 9 deletions(-) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index b6fb73838d..55ed0958ad 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2018 Konrad Hinsen ;;; Copyright © 2018 Chris Marusich ;;; Copyright © 2018 Efraim Flashner +;;; Copyright © 2020 Eric Bavier ;;; ;;; This file is part of GNU Guix. ;;; @@ -690,9 +691,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)) (define input ;; The OUTPUT* output of PACKAGE. @@ -743,15 +746,26 @@ last resort for relocation." (mkdir target) (for-each (lambda (file) (unless (member file '("." ".." "bin" "sbin" "libexec")) - (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)) - (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 "/libexec")))) + ;; 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 fails 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-prefix old)))) + (mkdir-p (dirname new)) + (symlink-relative old new))) + others))))) (computed-file (string-append (cond ((package? package) diff --git a/tests/guix-pack-relocatable.sh b/tests/guix-pack-relocatable.sh index e93610eedc..a3d9013133 100644 --- a/tests/guix-pack-relocatable.sh +++ b/tests/guix-pack-relocatable.sh @@ -1,5 +1,6 @@ # GNU Guix --- Functional package management for GNU # Copyright © 2018, 2019 Ludovic Courtès +# Copyright © 2020 Eric Bavier # # This file is part of GNU Guix. # @@ -84,3 +85,39 @@ chmod -Rf +w "$test_directory"; rm -rf "$test_directory"/* tarball="`guix pack -R -S /share=share groff:doc`" (cd "$test_directory"; tar xvf "$tarball") test -d "$test_directory/share/doc/groff/html" +chmod -Rf +w "$test_directory"; rm -rf "$test_directory"/* + +# Check that packages that mix executable and support files (e.g. git) in the +# "binary" directories still work after wrapped. +tarball="`guix pack $relocatable_option -S /opt= git-minimal`" +(cd "$test_directory"; tar xvf "$tarball" + mkdir foo; cd foo; touch .gitignore bar.txt bif.txt) +do_test=' + export GUIX_PROFILE="$test_directory/opt" + . $GUIX_PROFILE/etc/profile + cd "$test_directory/foo" + git config --global user.email "gnu@example.com" + git config --global user.name "Gnu Hacker" + git --version >"$test_directory/output" + git init; git add .gitignore; git commit -m "Initial" + git branch a; git branch b + git checkout a + git add bar.txt; git commit -m "Add bar" + git checkout b + git add bif.txt; git commit -m "Add bif" + git checkout master + # Check merge-octopus script which sources libexec/git-core/git-sh-setup + git merge a b -m "merge" >>"$test_directory/output" +' +if unshare -r true # Are user namespaces supported? +then + unshare -mrf \ + sh -c 'mount -t tmpfs none "$HOME"; # Forbid git to read user configs + mount -t tmpfs none "$STORE_PARENT"; \ + '"$do_test" + cd - +else + ( $do_test ) +fi +grep 'git version' "$test_directory/output" +grep 'octopus' "$test_directory/output" -- 2.25.2