diff options
| -rw-r--r-- | Makefile.am | 1 | ||||
| -rw-r--r-- | doc/guix.texi | 7 | ||||
| -rw-r--r-- | guix/scripts/pack.scm | 20 | ||||
| -rw-r--r-- | tests/guix-pack-localstatedir.sh | 69 |
4 files changed, 94 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am index eda87f3124e..70ec2e52ef2 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -410,6 +410,7 @@ SH_TESTS = \ | |||
| 410 | tests/guix-gc.sh \ | 410 | tests/guix-gc.sh \ |
| 411 | tests/guix-hash.sh \ | 411 | tests/guix-hash.sh \ |
| 412 | tests/guix-pack.sh \ | 412 | tests/guix-pack.sh \ |
| 413 | tests/guix-pack-localstatedir.sh \ | ||
| 413 | tests/guix-pack-relocatable.sh \ | 414 | tests/guix-pack-relocatable.sh \ |
| 414 | tests/guix-package.sh \ | 415 | tests/guix-package.sh \ |
| 415 | tests/guix-package-net.sh \ | 416 | tests/guix-package-net.sh \ |
diff --git a/doc/guix.texi b/doc/guix.texi index 648f3e50bd8..594aca731a7 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} | |||
| 3488 | symlink pointing to the @file{bin} sub-directory of the profile. | 3488 | symlink pointing to the @file{bin} sub-directory of the profile. |
| 3489 | 3489 | ||
| 3490 | @item --localstatedir | 3490 | @item --localstatedir |
| 3491 | Include the ``local state directory'', @file{/var/guix}, in the | 3491 | @itemx --profile-name=@var{name} |
| 3492 | resulting pack. | 3492 | Include the ``local state directory'', @file{/var/guix}, in the resulting |
| 3493 | pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}} | ||
| 3494 | profile---by default @var{name} is @code{guix-profile}, which corresponds to | ||
| 3495 | @file{~root/.guix-profile}. | ||
| 3493 | 3496 | ||
| 3494 | @file{/var/guix} contains the store database (@pxref{The Store}) as well | 3497 | @file{/var/guix} contains the store database (@pxref{The Store}) as well |
| 3495 | as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in | 3498 | as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in |
diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index a86b95dd38a..ce46f549cc8 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm | |||
| @@ -149,6 +149,7 @@ dependencies are registered." | |||
| 149 | 149 | ||
| 150 | (define* (self-contained-tarball name profile | 150 | (define* (self-contained-tarball name profile |
| 151 | #:key target | 151 | #:key target |
| 152 | (profile-name "guix-profile") | ||
| 152 | deduplicate? | 153 | deduplicate? |
| 153 | (compressor (first %compressors)) | 154 | (compressor (first %compressors)) |
| 154 | localstatedir? | 155 | localstatedir? |
| @@ -221,6 +222,7 @@ added to the pack." | |||
| 221 | ;; <http://lists.gnu.org/archive/html/bug-tar/2017-11/msg00009.html>. | 222 | ;; <http://lists.gnu.org/archive/html/bug-tar/2017-11/msg00009.html>. |
| 222 | (populate-single-profile-directory %root | 223 | (populate-single-profile-directory %root |
| 223 | #:profile #$profile | 224 | #:profile #$profile |
| 225 | #:profile-name #$profile-name | ||
| 224 | #:closure "profile" | 226 | #:closure "profile" |
| 225 | #:database #+database) | 227 | #:database #+database) |
| 226 | 228 | ||
| @@ -279,6 +281,7 @@ added to the pack." | |||
| 279 | 281 | ||
| 280 | (define* (squashfs-image name profile | 282 | (define* (squashfs-image name profile |
| 281 | #:key target | 283 | #:key target |
| 284 | (profile-name "guix-profile") | ||
| 282 | (compressor (first %compressors)) | 285 | (compressor (first %compressors)) |
| 283 | localstatedir? | 286 | localstatedir? |
| 284 | (symlinks '()) | 287 | (symlinks '()) |
| @@ -377,6 +380,7 @@ added to the pack." | |||
| 377 | 380 | ||
| 378 | (define* (docker-image name profile | 381 | (define* (docker-image name profile |
| 379 | #:key target | 382 | #:key target |
| 383 | (profile-name "guix-profile") | ||
| 380 | (compressor (first %compressors)) | 384 | (compressor (first %compressors)) |
| 381 | localstatedir? | 385 | localstatedir? |
| 382 | (symlinks '()) | 386 | (symlinks '()) |
| @@ -587,6 +591,7 @@ please email '~a'~%") | |||
| 587 | (define %default-options | 591 | (define %default-options |
| 588 | ;; Alist of default option values. | 592 | ;; Alist of default option values. |
| 589 | `((format . tarball) | 593 | `((format . tarball) |
| 594 | (profile-name . "guix-profile") | ||
| 590 | (system . ,(%current-system)) | 595 | (system . ,(%current-system)) |
| 591 | (substitutes? . #t) | 596 | (substitutes? . #t) |
| 592 | (build-hook? . #t) | 597 | (build-hook? . #t) |
| @@ -658,6 +663,13 @@ please email '~a'~%") | |||
| 658 | (option '("localstatedir") #f #f | 663 | (option '("localstatedir") #f #f |
| 659 | (lambda (opt name arg result) | 664 | (lambda (opt name arg result) |
| 660 | (alist-cons 'localstatedir? #t result))) | 665 | (alist-cons 'localstatedir? #t result))) |
| 666 | (option '("profile-name") #t #f | ||
| 667 | (lambda (opt name arg result) | ||
| 668 | (match arg | ||
| 669 | ((or "guix-profile" "current-guix") | ||
| 670 | (alist-cons 'profile-name arg result)) | ||
| 671 | (_ | ||
| 672 | (leave (G_ "~a: unsupported profile name~%") arg))))) | ||
| 661 | (option '("bootstrap") #f #f | 673 | (option '("bootstrap") #f #f |
| 662 | (lambda (opt name arg result) | 674 | (lambda (opt name arg result) |
| 663 | (alist-cons 'bootstrap? #t result))) | 675 | (alist-cons 'bootstrap? #t result))) |
| @@ -691,6 +703,9 @@ Create a bundle of PACKAGE.\n")) | |||
| 691 | (display (G_ " | 703 | (display (G_ " |
| 692 | --localstatedir include /var/guix in the resulting pack")) | 704 | --localstatedir include /var/guix in the resulting pack")) |
| 693 | (display (G_ " | 705 | (display (G_ " |
| 706 | --profile-name=NAME | ||
| 707 | populate /var/guix/profiles/.../NAME")) | ||
| 708 | (display (G_ " | ||
| 694 | --bootstrap use the bootstrap binaries to build the pack")) | 709 | --bootstrap use the bootstrap binaries to build the pack")) |
| 695 | (newline) | 710 | (newline) |
| 696 | (display (G_ " | 711 | (display (G_ " |
| @@ -779,7 +794,8 @@ Create a bundle of PACKAGE.\n")) | |||
| 779 | (#f | 794 | (#f |
| 780 | (leave (G_ "~a: unknown pack format~%") | 795 | (leave (G_ "~a: unknown pack format~%") |
| 781 | pack-format)))) | 796 | pack-format)))) |
| 782 | (localstatedir? (assoc-ref opts 'localstatedir?))) | 797 | (localstatedir? (assoc-ref opts 'localstatedir?)) |
| 798 | (profile-name (assoc-ref opts 'profile-name))) | ||
| 783 | (run-with-store store | 799 | (run-with-store store |
| 784 | (mlet* %store-monad ((profile (profile-derivation | 800 | (mlet* %store-monad ((profile (profile-derivation |
| 785 | manifest | 801 | manifest |
| @@ -798,6 +814,8 @@ Create a bundle of PACKAGE.\n")) | |||
| 798 | symlinks | 814 | symlinks |
| 799 | #:localstatedir? | 815 | #:localstatedir? |
| 800 | localstatedir? | 816 | localstatedir? |
| 817 | #:profile-name | ||
| 818 | profile-name | ||
| 801 | #:archiver | 819 | #:archiver |
| 802 | archiver))) | 820 | archiver))) |
| 803 | (mbegin %store-monad | 821 | (mbegin %store-monad |
diff --git a/tests/guix-pack-localstatedir.sh b/tests/guix-pack-localstatedir.sh new file mode 100644 index 00000000000..b734b0f7e3a --- /dev/null +++ b/tests/guix-pack-localstatedir.sh | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | # GNU Guix --- Functional package management for GNU | ||
| 2 | # Copyright © 2018 Ludovic Courtès <ludo@gnu.org> | ||
| 3 | # | ||
| 4 | # This file is part of GNU Guix. | ||
| 5 | # | ||
| 6 | # GNU Guix is free software; you can redistribute it and/or modify it | ||
| 7 | # under the terms of the GNU General Public License as published by | ||
| 8 | # the Free Software Foundation; either version 3 of the License, or (at | ||
| 9 | # your option) any later version. | ||
| 10 | # | ||
| 11 | # GNU Guix is distributed in the hope that it will be useful, but | ||
| 12 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | # GNU General Public License for more details. | ||
| 15 | # | ||
| 16 | # You should have received a copy of the GNU General Public License | ||
| 17 | # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | # | ||
| 20 | # Test the 'guix pack --localstatedir' command-line utility. | ||
| 21 | # | ||
| 22 | |||
| 23 | guix pack --version | ||
| 24 | |||
| 25 | # 'guix pack --localstatedir' produces derivations that depend on | ||
| 26 | # guile-sqlite3 and guile-gcrypt. To make that relatively inexpensive, run | ||
| 27 | # the test in the user's global store if possible, on the grounds that | ||
| 28 | # binaries may already be there or can be built or downloaded inexpensively. | ||
| 29 | |||
| 30 | NIX_STORE_DIR="`guile -c '(use-modules (guix config))(display %storedir)'`" | ||
| 31 | localstatedir="`guile -c '(use-modules (guix config))(display %localstatedir)'`" | ||
| 32 | GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket" | ||
| 33 | export NIX_STORE_DIR GUIX_DAEMON_SOCKET | ||
| 34 | |||
| 35 | if ! guile -c '(use-modules (guix)) (exit (false-if-exception (open-connection)))' | ||
| 36 | then | ||
| 37 | exit 77 | ||
| 38 | fi | ||
| 39 | |||
| 40 | # Build a tarball with '--localstatedir' | ||
| 41 | the_pack="`guix pack -C none --localstatedir --profile-name=current-guix \ | ||
| 42 | guile-bootstrap`" | ||
| 43 | test_directory="`mktemp -d`" | ||
| 44 | trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT | ||
| 45 | |||
| 46 | cd "$test_directory" | ||
| 47 | tar -xf "$the_pack" | ||
| 48 | |||
| 49 | profile="`find -name current-guix`" | ||
| 50 | test "`readlink $profile`" = "current-guix-1-link" | ||
| 51 | test -s "`dirname $profile`/../../../db/db.sqlite" | ||
| 52 | test -x ".`guix build guile-bootstrap`/bin/guile" | ||
| 53 | cd - | ||
| 54 | |||
| 55 | # Make sure the store database is not completely bogus. | ||
| 56 | guile -c "(use-modules (sqlite3) (guix config) (ice-9 match)) | ||
| 57 | |||
| 58 | (define db | ||
| 59 | (sqlite-open (string-append \"$test_directory\" | ||
| 60 | %localstatedir | ||
| 61 | \"/guix/db/db.sqlite\") | ||
| 62 | SQLITE_OPEN_READONLY)) | ||
| 63 | |||
| 64 | (define stmt | ||
| 65 | (sqlite-prepare db \"SELECT * FROM ValidPaths;\")) | ||
| 66 | |||
| 67 | (match (sqlite-fold cons '() stmt) | ||
| 68 | ((#(ids paths hashes times derivers sizes) ...) | ||
| 69 | (exit (member \"`guix build guile-bootstrap`\" paths))))" | ||
