summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-03-14 15:11:03 +0100
committerLudovic Courtès <ludo@gnu.org>2017-03-14 17:57:27 +0100
commit6b63c43e0661406bf9e8c4c54f517744fc2ffdb3 (patch)
tree5589fbfa37c20e5210a2ee6921b2ff32b653cb7c
parent9b05ccfedd9945ca09103e1e9557d5988b4815d5 (diff)
downloadpatches-6b63c43e0661406bf9e8c4c54f517744fc2ffdb3.tar
patches-6b63c43e0661406bf9e8c4c54f517744fc2ffdb3.tar.gz
pack: Add '--localstatedir' option.
* guix/scripts/pack.scm (self-contained-tarball): Add #:localstatedir? parameter and honor it. (%options, show-help): Add '--localstatedir'. (guix-pack): Honor it. * gnu/build/install.scm (populate-single-profile-directory): Add #:register? parameter and honor it. * doc/guix.texi (Binary Installation): Use '--localstatedir' in example. (Invoking guix pack): Document it.
-rw-r--r--Makefile.am2
-rw-r--r--doc/guix.texi15
-rw-r--r--gnu/build/install.scm29
-rw-r--r--guix/scripts/pack.scm33
4 files changed, 57 insertions, 22 deletions
diff --git a/Makefile.am b/Makefile.am
index 2684d66bf1..23171ae837 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -488,7 +488,7 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \
guix-binary.%.tar.xz:
$(AM_V_GEN)GUIX_PACKAGE_PATH= \
tarball=`$(top_builddir)/pre-inst-env guix pack -C xz \
- -s "$*" guix` ; \
+ -s "$*" --localstatedir guix` ; \
cp "$$tarball" "$@.tmp" ; mv "$@.tmp" "$@"
diff --git a/doc/guix.texi b/doc/guix.texi
index f4cc207e7b..86fc86da61 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -535,7 +535,7 @@ make guix-binary.@var{system}.tar.xz
... which, in turn, runs:
@example
-guix pack -s @var{system} guix
+guix pack -s @var{system} --localstatedir guix
@end example
@xref{Invoking guix pack}, for more info on this handy tool.
@@ -2434,6 +2434,19 @@ the system type of the build host.
@itemx -C @var{tool}
Compress the resulting tarball using @var{tool}---one of @code{gzip},
@code{bzip2}, @code{xz}, or @code{lzip}.
+
+@item --localstatedir
+Include the ``local state directory'', @file{/var/guix}, in the
+resulting pack.
+
+@file{/var/guix} contains the store database (@pxref{The Store}) as well
+as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
+the pack means that the store is ``complete'' and manageable by Guix;
+not providing it pack means that the store is ``dead'': items cannot be
+added to it or removed from it after extraction of the pack.
+
+One use case for this is the Guix self-contained binary tarball
+(@pxref{Binary Installation}).
@end table
In addition, @command{guix pack} supports all the common build options
diff --git a/gnu/build/install.scm b/gnu/build/install.scm
index 5c2b35632d..11f107d63c 100644
--- a/gnu/build/install.scm
+++ b/gnu/build/install.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
;;;
;;; This file is part of GNU Guix.
@@ -192,13 +192,16 @@ rest of STORE."
(define* (populate-single-profile-directory directory
#:key profile closure
- deduplicate?)
+ deduplicate?
+ register?)
"Populate DIRECTORY with a store containing PROFILE, whose closure is given
in the file called CLOSURE (as generated by #:references-graphs.) DIRECTORY
is initialized to contain a single profile under /root pointing to PROFILE.
-DEDUPLICATE? determines whether to deduplicate files in the store.
+When REGISTER? is true, initialize DIRECTORY/var/guix/db to reflect the
+contents of the store; DEDUPLICATE? determines whether to deduplicate files in
+the store.
-This is used to create the self-contained Guix tarball."
+This is used to create the self-contained tarballs with 'guix pack'."
(define (scope file)
(string-append directory "/" file))
@@ -213,14 +216,16 @@ This is used to create the self-contained Guix tarball."
;; Populate the store.
(populate-store (list closure) directory)
- (register-closure (canonicalize-path directory) closure
- #:deduplicate? deduplicate?)
-
- ;; XXX: 'guix-register' registers profiles as GC roots but the symlink
- ;; target uses $TMPDIR. Fix that.
- (delete-file (scope "/var/guix/gcroots/profiles"))
- (symlink* "/var/guix/profiles"
- "/var/guix/gcroots/profiles")
+
+ (when register?
+ (register-closure (canonicalize-path directory) closure
+ #:deduplicate? deduplicate?)
+
+ ;; XXX: 'guix-register' registers profiles as GC roots but the symlink
+ ;; target uses $TMPDIR. Fix that.
+ (delete-file (scope "/var/guix/gcroots/profiles"))
+ (symlink* "/var/guix/profiles"
+ "/var/guix/gcroots/profiles"))
;; Make root's profile, which makes it a GC root.
(mkdir-p* %root-profile)
diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index e8f3d800a8..138e2c5b77 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -69,10 +69,12 @@ found."
(define* (self-contained-tarball name profile
#:key deduplicate?
- (compressor (first %compressors)))
+ (compressor (first %compressors))
+ localstatedir?)
"Return a self-contained tarball containing a store initialized with the
-closure of PROFILE, a derivation. The tarball contains /gnu/store, /var/guix,
-and PROFILE is available as /root/.guix-profile."
+closure of PROFILE, a derivation. The tarball contains /gnu/store; if
+LOCALSTATEDIR? is true, it also contains /var/guix, including /var/guix/db
+with a properly initialized store database."
(define build
(with-imported-modules '((guix build utils)
(guix build store-copy)
@@ -85,7 +87,10 @@ and PROFILE is available as /root/.guix-profile."
;; We need Guix here for 'guix-register'.
(setenv "PATH"
- (string-append #$guix "/sbin:" #$tar "/bin:"
+ (string-append #$(if localstatedir?
+ (file-append guix "/sbin:")
+ "")
+ #$tar "/bin:"
#$(compressor-package compressor) "/bin"))
;; Note: there is not much to gain here with deduplication and
@@ -94,7 +99,8 @@ and PROFILE is available as /root/.guix-profile."
(populate-single-profile-directory %root
#:profile #$profile
#:closure "profile"
- #:deduplicate? #f)
+ #:deduplicate? #f
+ #:register? #$localstatedir?)
;; Create the tarball. Use GNU format so there's no file name
;; length limitation.
@@ -119,7 +125,10 @@ and PROFILE is available as /root/.guix-profile."
;; extracting the archive. Do not include /root
;; because the root account might have a
;; different home directory.
- "./var/guix"
+ #$@(if localstatedir?
+ '("./var/guix")
+ '())
+
(string-append "." (%store-directory))))))))
(gexp->derivation (string-append name ".tar."
@@ -163,6 +172,9 @@ and PROFILE is available as /root/.guix-profile."
(lambda (opt name arg result)
(alist-cons 'compressor (lookup-compressor arg)
result)))
+ (option '("localstatedir") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'localstatedir? #t result)))
(append %transformation-options
%standard-build-options)))
@@ -178,6 +190,8 @@ Create a bundle of PACKAGE.\n"))
-s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
(display (_ "
-C, --compression=TOOL compress using TOOL--e.g., \"lzip\""))
+ (display (_ "
+ --localstatedir include /var/guix in the resulting pack"))
(newline)
(display (_ "
-h, --help display this help and exit"))
@@ -209,14 +223,17 @@ Create a bundle of PACKAGE.\n"))
(specification->package+output spec))
list))
specs))
- (compressor (assoc-ref opts 'compressor)))
+ (compressor (assoc-ref opts 'compressor))
+ (localstatedir? (assoc-ref opts 'localstatedir?)))
(with-store store
(run-with-store store
(mlet* %store-monad ((profile (profile-derivation
(packages->manifest packages)))
(drv (self-contained-tarball "pack" profile
#:compressor
- compressor)))
+ compressor
+ #:localstatedir?
+ localstatedir?)))
(mbegin %store-monad
(show-what-to-build* (list drv)
#:use-substitutes?