mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
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.
This commit is contained in:
parent
9b05ccfedd
commit
6b63c43e06
4 changed files with 56 additions and 21 deletions
|
@ -488,7 +488,7 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \
|
||||||
guix-binary.%.tar.xz:
|
guix-binary.%.tar.xz:
|
||||||
$(AM_V_GEN)GUIX_PACKAGE_PATH= \
|
$(AM_V_GEN)GUIX_PACKAGE_PATH= \
|
||||||
tarball=`$(top_builddir)/pre-inst-env guix pack -C xz \
|
tarball=`$(top_builddir)/pre-inst-env guix pack -C xz \
|
||||||
-s "$*" guix` ; \
|
-s "$*" --localstatedir guix` ; \
|
||||||
cp "$$tarball" "$@.tmp" ; mv "$@.tmp" "$@"
|
cp "$$tarball" "$@.tmp" ; mv "$@.tmp" "$@"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -535,7 +535,7 @@ make guix-binary.@var{system}.tar.xz
|
||||||
... which, in turn, runs:
|
... which, in turn, runs:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
guix pack -s @var{system} guix
|
guix pack -s @var{system} --localstatedir guix
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@xref{Invoking guix pack}, for more info on this handy tool.
|
@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}
|
@itemx -C @var{tool}
|
||||||
Compress the resulting tarball using @var{tool}---one of @code{gzip},
|
Compress the resulting tarball using @var{tool}---one of @code{gzip},
|
||||||
@code{bzip2}, @code{xz}, or @code{lzip}.
|
@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
|
@end table
|
||||||
|
|
||||||
In addition, @command{guix pack} supports all the common build options
|
In addition, @command{guix pack} supports all the common build options
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; 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>
|
;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
|
@ -192,13 +192,16 @@ (define* (register-closure store closure
|
||||||
|
|
||||||
(define* (populate-single-profile-directory directory
|
(define* (populate-single-profile-directory directory
|
||||||
#:key profile closure
|
#:key profile closure
|
||||||
deduplicate?)
|
deduplicate?
|
||||||
|
register?)
|
||||||
"Populate DIRECTORY with a store containing PROFILE, whose closure is given
|
"Populate DIRECTORY with a store containing PROFILE, whose closure is given
|
||||||
in the file called CLOSURE (as generated by #:references-graphs.) DIRECTORY
|
in the file called CLOSURE (as generated by #:references-graphs.) DIRECTORY
|
||||||
is initialized to contain a single profile under /root pointing to PROFILE.
|
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)
|
(define (scope file)
|
||||||
(string-append directory "/" file))
|
(string-append directory "/" file))
|
||||||
|
|
||||||
|
@ -213,6 +216,8 @@ (define (symlink* old new)
|
||||||
|
|
||||||
;; Populate the store.
|
;; Populate the store.
|
||||||
(populate-store (list closure) directory)
|
(populate-store (list closure) directory)
|
||||||
|
|
||||||
|
(when register?
|
||||||
(register-closure (canonicalize-path directory) closure
|
(register-closure (canonicalize-path directory) closure
|
||||||
#:deduplicate? deduplicate?)
|
#:deduplicate? deduplicate?)
|
||||||
|
|
||||||
|
@ -220,7 +225,7 @@ (define (symlink* old new)
|
||||||
;; target uses $TMPDIR. Fix that.
|
;; target uses $TMPDIR. Fix that.
|
||||||
(delete-file (scope "/var/guix/gcroots/profiles"))
|
(delete-file (scope "/var/guix/gcroots/profiles"))
|
||||||
(symlink* "/var/guix/profiles"
|
(symlink* "/var/guix/profiles"
|
||||||
"/var/guix/gcroots/profiles")
|
"/var/guix/gcroots/profiles"))
|
||||||
|
|
||||||
;; Make root's profile, which makes it a GC root.
|
;; Make root's profile, which makes it a GC root.
|
||||||
(mkdir-p* %root-profile)
|
(mkdir-p* %root-profile)
|
||||||
|
|
|
@ -69,10 +69,12 @@ (define (lookup-compressor name)
|
||||||
|
|
||||||
(define* (self-contained-tarball name profile
|
(define* (self-contained-tarball name profile
|
||||||
#:key deduplicate?
|
#:key deduplicate?
|
||||||
(compressor (first %compressors)))
|
(compressor (first %compressors))
|
||||||
|
localstatedir?)
|
||||||
"Return a self-contained tarball containing a store initialized with the
|
"Return a self-contained tarball containing a store initialized with the
|
||||||
closure of PROFILE, a derivation. The tarball contains /gnu/store, /var/guix,
|
closure of PROFILE, a derivation. The tarball contains /gnu/store; if
|
||||||
and PROFILE is available as /root/.guix-profile."
|
LOCALSTATEDIR? is true, it also contains /var/guix, including /var/guix/db
|
||||||
|
with a properly initialized store database."
|
||||||
(define build
|
(define build
|
||||||
(with-imported-modules '((guix build utils)
|
(with-imported-modules '((guix build utils)
|
||||||
(guix build store-copy)
|
(guix build store-copy)
|
||||||
|
@ -85,7 +87,10 @@ (define %root "root")
|
||||||
|
|
||||||
;; We need Guix here for 'guix-register'.
|
;; We need Guix here for 'guix-register'.
|
||||||
(setenv "PATH"
|
(setenv "PATH"
|
||||||
(string-append #$guix "/sbin:" #$tar "/bin:"
|
(string-append #$(if localstatedir?
|
||||||
|
(file-append guix "/sbin:")
|
||||||
|
"")
|
||||||
|
#$tar "/bin:"
|
||||||
#$(compressor-package compressor) "/bin"))
|
#$(compressor-package compressor) "/bin"))
|
||||||
|
|
||||||
;; Note: there is not much to gain here with deduplication and
|
;; Note: there is not much to gain here with deduplication and
|
||||||
|
@ -94,7 +99,8 @@ (define %root "root")
|
||||||
(populate-single-profile-directory %root
|
(populate-single-profile-directory %root
|
||||||
#:profile #$profile
|
#:profile #$profile
|
||||||
#:closure "profile"
|
#:closure "profile"
|
||||||
#:deduplicate? #f)
|
#:deduplicate? #f
|
||||||
|
#:register? #$localstatedir?)
|
||||||
|
|
||||||
;; Create the tarball. Use GNU format so there's no file name
|
;; Create the tarball. Use GNU format so there's no file name
|
||||||
;; length limitation.
|
;; length limitation.
|
||||||
|
@ -119,7 +125,10 @@ (define %root "root")
|
||||||
;; extracting the archive. Do not include /root
|
;; extracting the archive. Do not include /root
|
||||||
;; because the root account might have a
|
;; because the root account might have a
|
||||||
;; different home directory.
|
;; different home directory.
|
||||||
"./var/guix"
|
#$@(if localstatedir?
|
||||||
|
'("./var/guix")
|
||||||
|
'())
|
||||||
|
|
||||||
(string-append "." (%store-directory))))))))
|
(string-append "." (%store-directory))))))))
|
||||||
|
|
||||||
(gexp->derivation (string-append name ".tar."
|
(gexp->derivation (string-append name ".tar."
|
||||||
|
@ -163,6 +172,9 @@ (define %options
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
(alist-cons 'compressor (lookup-compressor arg)
|
(alist-cons 'compressor (lookup-compressor arg)
|
||||||
result)))
|
result)))
|
||||||
|
(option '("localstatedir") #f #f
|
||||||
|
(lambda (opt name arg result)
|
||||||
|
(alist-cons 'localstatedir? #t result)))
|
||||||
|
|
||||||
(append %transformation-options
|
(append %transformation-options
|
||||||
%standard-build-options)))
|
%standard-build-options)))
|
||||||
|
@ -178,6 +190,8 @@ (define (show-help)
|
||||||
-s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
|
-s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
|
||||||
(display (_ "
|
(display (_ "
|
||||||
-C, --compression=TOOL compress using TOOL--e.g., \"lzip\""))
|
-C, --compression=TOOL compress using TOOL--e.g., \"lzip\""))
|
||||||
|
(display (_ "
|
||||||
|
--localstatedir include /var/guix in the resulting pack"))
|
||||||
(newline)
|
(newline)
|
||||||
(display (_ "
|
(display (_ "
|
||||||
-h, --help display this help and exit"))
|
-h, --help display this help and exit"))
|
||||||
|
@ -209,14 +223,17 @@ (define opts
|
||||||
(specification->package+output spec))
|
(specification->package+output spec))
|
||||||
list))
|
list))
|
||||||
specs))
|
specs))
|
||||||
(compressor (assoc-ref opts 'compressor)))
|
(compressor (assoc-ref opts 'compressor))
|
||||||
|
(localstatedir? (assoc-ref opts 'localstatedir?)))
|
||||||
(with-store store
|
(with-store store
|
||||||
(run-with-store store
|
(run-with-store store
|
||||||
(mlet* %store-monad ((profile (profile-derivation
|
(mlet* %store-monad ((profile (profile-derivation
|
||||||
(packages->manifest packages)))
|
(packages->manifest packages)))
|
||||||
(drv (self-contained-tarball "pack" profile
|
(drv (self-contained-tarball "pack" profile
|
||||||
#:compressor
|
#:compressor
|
||||||
compressor)))
|
compressor
|
||||||
|
#:localstatedir?
|
||||||
|
localstatedir?)))
|
||||||
(mbegin %store-monad
|
(mbegin %store-monad
|
||||||
(show-what-to-build* (list drv)
|
(show-what-to-build* (list drv)
|
||||||
#:use-substitutes?
|
#:use-substitutes?
|
||||||
|
|
Loading…
Reference in a new issue