3
5
Fork 0
mirror of git://git.savannah.gnu.org/guix.git synced 2023-12-14 03:33:07 +01:00

pack: Import (guix store database) only when '--localstatedir' is passed.

This is another way to address <https://bugs.gnu.org/32184>, which was
previously addressed in commit 19c924af4f.

* gnu/build/install.scm (register-closure): Move to...
* gnu/build/vm.scm (register-closure): ... here.  New procedure.
* guix/scripts/pack.scm (self-contained-tarball)[build]: Remove
now unneeded 'with-extensions' form and custom (guix config) module.
* tests/guix-pack.sh: Revert the strategy from
commit 19c924af4f.
* tests/pack.scm ("self-contained-tarball"): Likewise.
This commit is contained in:
Ludovic Courtès 2018-10-28 00:17:08 +02:00
parent ec4c81fe32
commit b27ef1d46c
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
5 changed files with 147 additions and 167 deletions

View file

@ -18,7 +18,6 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu build install)
#:use-module (guix store database)
#:use-module (guix build utils)
#:use-module (guix build store-copy)
#:use-module (srfi srfi-26)
@ -141,23 +140,6 @@ includes /etc, /var, /run, /bin/sh, etc., and all the symlinks to SYSTEM."
(try))
(apply throw args)))))))
(define* (register-closure prefix closure
#:key
(deduplicate? #t) (reset-timestamps? #t)
(schema (sql-schema)))
"Register CLOSURE in PREFIX, where PREFIX is the directory name of the
target store and CLOSURE is the name of a file containing a reference graph as
produced by #:references-graphs.. As a side effect, if RESET-TIMESTAMPS? is
true, reset timestamps on store files and, if DEDUPLICATE? is true,
deduplicates files common to CLOSURE and the rest of PREFIX."
(let ((items (call-with-input-file closure read-reference-graph)))
(register-items items
#:prefix prefix
#:deduplicate? deduplicate?
#:reset-timestamps? reset-timestamps?
#:registration-time %epoch
#:schema schema)))
(define* (populate-single-profile-directory directory
#:key profile closure
(profile-name "guix-profile")

View file

@ -25,7 +25,7 @@
#:use-module (guix build utils)
#:use-module (guix build store-copy)
#:use-module (guix build syscalls)
#:use-module ((guix store database) #:select (reset-timestamps))
#:use-module (guix store database)
#:use-module (gnu build linux-boot)
#:use-module (gnu build install)
#:use-module (gnu system uuid)
@ -191,6 +191,23 @@ the #:references-graphs parameter of 'derivation'."
(mkdir output)
(copy-recursively "xchg" output)))))
(define* (register-closure prefix closure
#:key
(deduplicate? #t) (reset-timestamps? #t)
(schema (sql-schema)))
"Register CLOSURE in PREFIX, where PREFIX is the directory name of the
target store and CLOSURE is the name of a file containing a reference graph as
produced by #:references-graphs.. As a side effect, if RESET-TIMESTAMPS? is
true, reset timestamps on store files and, if DEDUPLICATE? is true,
deduplicates files common to CLOSURE and the rest of PREFIX."
(let ((items (call-with-input-file closure read-reference-graph)))
(register-items items
#:prefix prefix
#:deduplicate? deduplicate?
#:reset-timestamps? reset-timestamps?
#:registration-time %epoch
#:schema schema)))
;;;
;;; Partitions.

View file

@ -164,14 +164,11 @@ added to the pack."
"/db/db.sqlite")))
(define build
(with-imported-modules `(((guix config) => ,(make-config.scm))
,@(source-module-closure
(with-imported-modules (source-module-closure
`((guix build utils)
(guix build union)
(guix build store-copy)
(gnu build install))
#:select? not-config?))
(with-extensions gcrypt-sqlite3&co
#:select? not-config?)
#~(begin
(use-modules (guix build utils)
((guix build union) #:select (relative-file-name))
@ -270,7 +267,7 @@ added to the pack."
((source '-> _)
(string-append "." source))
(_ #f))
directives))))))))))
directives)))))))))
(gexp->derivation (string-append name ".tar"
(compressor-extension compressor))

View file

@ -29,33 +29,21 @@ fi
guix pack --version
# Starting from commit 66e9944e078cbb9e0d618377dd6df6e639640efa, 'guix pack'
# produces derivations that refer to guile-sqlite3 and libgcrypt. 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
# Use --no-substitutes because we need to verify we can do this ourselves.
GUIX_BUILD_OPTIONS="--no-substitutes"
export GUIX_BUILD_OPTIONS
# Build a tarball with no compression.
guix pack --compression=none guile-bootstrap
guix pack --compression=none --bootstrap guile-bootstrap
# Build a tarball (with compression). Check that '-e' works as well.
out1="`guix pack guile-bootstrap`"
out2="`guix pack -e '(@ (gnu packages bootstrap) %bootstrap-guile)'`"
out1="`guix pack --bootstrap guile-bootstrap`"
out2="`guix pack --bootstrap -e '(@ (gnu packages bootstrap) %bootstrap-guile)'`"
test -n "$out1"
test "$out1" = "$out2"
# Build a tarball with a symlink.
the_pack="`guix pack -S /opt/gnu/bin=bin guile-bootstrap`"
the_pack="`guix pack --bootstrap -S /opt/gnu/bin=bin guile-bootstrap`"
# Try to extract it. Note: we cannot test whether /opt/gnu/bin/guile itself
# exists because /opt/gnu/bin may be an absolute symlink to a store item that

View file

@ -29,6 +29,9 @@
#:use-module (gnu packages bootstrap)
#:use-module (srfi srfi-64))
(define %store
(open-connection-for-tests))
;; Globally disable grafts because they can trigger early builds.
(%graft? #f)
@ -48,15 +51,8 @@
(test-begin "pack")
;; The following test needs guile-sqlite3, libgcrypt, etc. as a consequence of
;; commit c45477d2a1a651485feede20fe0f3d15aec48b39 and related changes. Thus,
;; run it on the user's store, if it's available, on the grounds that these
;; dependencies may be already there, or we can get substitutes or build them
;; quite inexpensively; see <https://bugs.gnu.org/32184>.
(with-external-store store
(unless store (test-skip 1))
(test-assertm "self-contained-tarball" store
(unless (network-reachable?) (test-skip 1))
(test-assertm "self-contained-tarball" %store
(mlet* %store-monad
((profile (profile-derivation (packages->manifest
(list %bootstrap-guile))
@ -81,7 +77,7 @@
(string=? (string-append ".." #$profile
"/bin/guile")
(readlink "bin/Guile"))))))))
(built-derivations (list check)))))
(built-derivations (list check))))
(test-end)