summaryrefslogtreecommitdiff
path: root/guix/scripts/pack.scm
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 /guix/scripts/pack.scm
parent9b05ccfedd9945ca09103e1e9557d5988b4815d5 (diff)
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.
Diffstat (limited to 'guix/scripts/pack.scm')
-rw-r--r--guix/scripts/pack.scm33
1 files changed, 25 insertions, 8 deletions
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?