From patchwork Sun Oct 21 20:49:42 2018 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: 1596 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 B14561672F; Sun, 21 Oct 2018 21:51:13 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id 4351116724 for ; Sun, 21 Oct 2018 21:51:13 +0100 (BST) Received: from localhost ([::1]:60182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEKgq-0001VH-LX for patchwork@mira.cbaines.net; Sun, 21 Oct 2018 16:51:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEKgi-0001S4-K6 for guix-patches@gnu.org; Sun, 21 Oct 2018 16:51:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEKgg-0005qS-Fp for guix-patches@gnu.org; Sun, 21 Oct 2018 16:51:04 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:58646) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEKgg-0005ph-AP for guix-patches@gnu.org; Sun, 21 Oct 2018 16:51:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gEKgg-0008VB-7s for guix-patches@gnu.org; Sun, 21 Oct 2018 16:51:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#33111] [PATCH 2/3] pack: Add '--profile-name'. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 21 Oct 2018 20:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33111 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 33111@debbugs.gnu.org Received: via spool by 33111-submit@debbugs.gnu.org id=B33111.154015501432603 (code B ref 33111); Sun, 21 Oct 2018 20:51:02 +0000 Received: (at 33111) by debbugs.gnu.org; 21 Oct 2018 20:50:14 +0000 Received: from localhost ([127.0.0.1]:34668 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEKft-0008Tm-Mq for submit@debbugs.gnu.org; Sun, 21 Oct 2018 16:50:14 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35549) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEKfs-0008TL-9f for 33111@debbugs.gnu.org; Sun, 21 Oct 2018 16:50:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEKfk-0005CZ-Na for 33111@debbugs.gnu.org; Sun, 21 Oct 2018 16:50:07 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:35990) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEKfd-00058m-HH; Sun, 21 Oct 2018 16:49:59 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=33222 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gEKfb-0003ed-SC; Sun, 21 Oct 2018 16:49:57 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sun, 21 Oct 2018 22:49:42 +0200 Message-Id: <20181021204943.2142-2-ludo@gnu.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181021204943.2142-1-ludo@gnu.org> References: <20181021204943.2142-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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: 208.118.235.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 * guix/scripts/pack.scm (self-contained-tarball): Add #:profile-name and honor it. (squashfs-image, docker-image): Add #:profile-name. (%default-options): Add 'profile-name'. (%options, show-help): Add "--profile-name". (guix-pack): Honor it. * tests/guix-pack.sh: Add test for '--localstatedir --profile-name=current-guix'. * doc/guix.texi (Invoking guix pack): Document "--profile-name". --- doc/guix.texi | 7 +++++-- guix/scripts/pack.scm | 20 +++++++++++++++++++- tests/guix-pack.sh | 17 +++++++++++++++-- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 12346c4b8..7265eed91 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3459,8 +3459,11 @@ For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin} symlink pointing to the @file{bin} sub-directory of the profile. @item --localstatedir -Include the ``local state directory'', @file{/var/guix}, in the -resulting pack. +@itemx --profile-name=@var{name} +Include the ``local state directory'', @file{/var/guix}, in the resulting +pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}} +profile---by default @var{name} is @code{guix-profile}, which corresponds to +@file{~root/.guix-profile}. @file{/var/guix} contains the store database (@pxref{The Store}) as well as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index b7b4e22bb..a87a96115 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -105,6 +105,7 @@ found." (define* (self-contained-tarball name profile #:key target + (profile-name "guix-profile") deduplicate? (compressor (first %compressors)) localstatedir? @@ -184,6 +185,7 @@ added to the pack." ;; . (populate-single-profile-directory %root #:profile #$profile + #:profile-name #$profile-name #:closure "profile" #:deduplicate? #f #:register? #$localstatedir? @@ -244,6 +246,7 @@ added to the pack." (define* (squashfs-image name profile #:key target + (profile-name "guix-profile") deduplicate? (compressor (first %compressors)) localstatedir? @@ -333,6 +336,7 @@ added to the pack." (define* (docker-image name profile #:key target + (profile-name "guix-profile") deduplicate? (compressor (first %compressors)) localstatedir? @@ -538,6 +542,7 @@ please email '~a'~%") (define %default-options ;; Alist of default option values. `((format . tarball) + (profile-name . "guix-profile") (system . ,(%current-system)) (substitutes? . #t) (build-hook? . #t) @@ -609,6 +614,13 @@ please email '~a'~%") (option '("localstatedir") #f #f (lambda (opt name arg result) (alist-cons 'localstatedir? #t result))) + (option '("profile-name") #t #f + (lambda (opt name arg result) + (match arg + ((or "guix-profile" "current-guix") + (alist-cons 'profile-name arg result)) + (_ + (leave (G_ "~a: unsupported profile name~%") arg))))) (option '("bootstrap") #f #f (lambda (opt name arg result) (alist-cons 'bootstrap? #t result))) @@ -641,6 +653,9 @@ Create a bundle of PACKAGE.\n")) -m, --manifest=FILE create a pack with the manifest from FILE")) (display (G_ " --localstatedir include /var/guix in the resulting pack")) + (display (G_ " + --profile-name=NAME + populate /var/guix/profiles/.../NAME")) (display (G_ " --bootstrap use the bootstrap binaries to build the pack")) (newline) @@ -730,7 +745,8 @@ Create a bundle of PACKAGE.\n")) (#f (leave (G_ "~a: unknown pack format~%") pack-format)))) - (localstatedir? (assoc-ref opts 'localstatedir?))) + (localstatedir? (assoc-ref opts 'localstatedir?)) + (profile-name (assoc-ref opts 'profile-name))) (run-with-store store (mlet* %store-monad ((profile (profile-derivation manifest @@ -749,6 +765,8 @@ Create a bundle of PACKAGE.\n")) symlinks #:localstatedir? localstatedir? + #:profile-name + profile-name #:archiver archiver))) (mbegin %store-monad diff --git a/tests/guix-pack.sh b/tests/guix-pack.sh index cd721a60e..c55fe6c9a 100644 --- a/tests/guix-pack.sh +++ b/tests/guix-pack.sh @@ -61,7 +61,7 @@ the_pack="`guix pack -S /opt/gnu/bin=bin guile-bootstrap`" # exists because /opt/gnu/bin may be an absolute symlink to a store item that # has been GC'd. test_directory="`mktemp -d`" -trap 'rm -rf "$test_directory"' EXIT +trap 'find "$test_directory" -type d -exec chmod +w {} \; ;rm -rf "$test_directory"' EXIT cd "$test_directory" tar -xf "$the_pack" test -L opt/gnu/bin @@ -74,10 +74,23 @@ is_available () { if is_available chroot && is_available unshare; then # Verify we can use what we built. unshare -r chroot . /opt/gnu/bin/guile --version - cd - else echo "warning: skipped some verification because chroot or unshare is unavailable" >&2 fi +cd - +rm -rf "$test_directory" + +# Build a tarball with '--localstatedir' +the_pack="`guix pack -C none --localstatedir --profile-name=current-guix \ + guile-bootstrap`" +test_directory="`mktemp -d`" +cd "$test_directory" +tar -xf "$the_pack" + +profile="`find -name current-guix`" +test "`readlink $profile`" = "current-guix-1-link" +test -s "`dirname $profile`/../../../db/db.sqlite" +test -x ".`guix build guile-bootstrap`/bin/guile" # For the tests that build Docker images below, we currently have to use # --dry-run because if we don't, there are only two possible cases: