guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

04/05: pack: Add '--profile-name'.


From: guix-commits
Subject: 04/05: pack: Add '--profile-name'.
Date: Fri, 23 Nov 2018 09:42:19 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 08f410834bffbe1e55633a0a4c87caba69d7fa92
Author: Ludovic Courtès <address@hidden>
Date:   Sat Oct 20 19:28:05 2018 +0200

    pack: Add '--profile-name'.
    
    * 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-localstatedir.sh: New file.
    * Makefile.am (SH_TESTS): Add it.
    * doc/guix.texi (Invoking guix pack): Document "--profile-name".
---
 Makefile.am                      |  1 +
 doc/guix.texi                    |  7 ++--
 guix/scripts/pack.scm            | 20 +++++++++++-
 tests/guix-pack-localstatedir.sh | 69 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 94 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index eda87f3..70ec2e5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -410,6 +410,7 @@ SH_TESTS =                                  \
   tests/guix-gc.sh                             \
   tests/guix-hash.sh                           \
   tests/guix-pack.sh                           \
+  tests/guix-pack-localstatedir.sh             \
   tests/guix-pack-relocatable.sh               \
   tests/guix-package.sh                                \
   tests/guix-package-net.sh                    \
diff --git a/doc/guix.texi b/doc/guix.texi
index 648f3e5..594aca7 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -3488,8 +3488,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.
address@hidden address@hidden
+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
address@hidden/.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 a86b95d..ce46f54 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -149,6 +149,7 @@ dependencies are registered."
 
 (define* (self-contained-tarball name profile
                                  #:key target
+                                 (profile-name "guix-profile")
                                  deduplicate?
                                  (compressor (first %compressors))
                                  localstatedir?
@@ -221,6 +222,7 @@ added to the pack."
           ;; <http://lists.gnu.org/archive/html/bug-tar/2017-11/msg00009.html>.
           (populate-single-profile-directory %root
                                              #:profile #$profile
+                                             #:profile-name #$profile-name
                                              #:closure "profile"
                                              #:database #+database)
 
@@ -279,6 +281,7 @@ added to the pack."
 
 (define* (squashfs-image name profile
                          #:key target
+                         (profile-name "guix-profile")
                          (compressor (first %compressors))
                          localstatedir?
                          (symlinks '())
@@ -377,6 +380,7 @@ added to the pack."
 
 (define* (docker-image name profile
                        #:key target
+                       (profile-name "guix-profile")
                        (compressor (first %compressors))
                        localstatedir?
                        (symlinks '())
@@ -587,6 +591,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)
@@ -658,6 +663,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)))
@@ -691,6 +703,9 @@ Create a bundle of PACKAGE.\n"))
   (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)
   (display (G_ "
@@ -779,7 +794,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
@@ -798,6 +814,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-localstatedir.sh b/tests/guix-pack-localstatedir.sh
new file mode 100644
index 0000000..b734b0f
--- /dev/null
+++ b/tests/guix-pack-localstatedir.sh
@@ -0,0 +1,69 @@
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2018 Ludovic Courtès <address@hidden>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+#
+# Test the 'guix pack --localstatedir' command-line utility.
+#
+
+guix pack --version
+
+# 'guix pack --localstatedir' produces derivations that depend on
+# guile-sqlite3 and guile-gcrypt.  To make that relatively inexpensive, run
+# the test in the user's global store if possible, on the grounds that
+# binaries may already be there or can be built or downloaded inexpensively.
+
+NIX_STORE_DIR="`guile -c '(use-modules (guix config))(display %storedir)'`"
+localstatedir="`guile -c '(use-modules (guix config))(display 
%localstatedir)'`"
+GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket"
+export NIX_STORE_DIR GUIX_DAEMON_SOCKET
+
+if ! guile -c '(use-modules (guix)) (exit (false-if-exception 
(open-connection)))'
+then
+    exit 77
+fi
+
+# Build a tarball with '--localstatedir'
+the_pack="`guix pack -C none --localstatedir --profile-name=current-guix \
+            guile-bootstrap`"
+test_directory="`mktemp -d`"
+trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT
+
+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"
+cd -
+
+# Make sure the store database is not completely bogus.
+guile -c "(use-modules (sqlite3) (guix config) (ice-9 match))
+
+  (define db
+    (sqlite-open (string-append \"$test_directory\"
+                                %localstatedir
+                               \"/guix/db/db.sqlite\")
+                 SQLITE_OPEN_READONLY))
+
+  (define stmt
+    (sqlite-prepare db \"SELECT * FROM ValidPaths;\"))
+
+  (match (sqlite-fold cons '() stmt)
+    ((#(ids paths hashes times derivers sizes) ...)
+     (exit (member \"`guix build guile-bootstrap`\" paths))))"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]