gnu: grammalecte: Update to 1.12.2.
[jackhill/guix/guix.git] / tests / guix-pack-localstatedir.sh
CommitLineData
08f41083 1# GNU Guix --- Functional package management for GNU
baab87ac 2# Copyright © 2018, 2019 Ludovic Courtès <ludo@gnu.org>
08f41083
LC
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
23guix 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
baab87ac 30storedir="`guile -c '(use-modules (guix config))(display %storedir)'`"
08f41083 31localstatedir="`guile -c '(use-modules (guix config))(display %localstatedir)'`"
baab87ac 32NIX_STORE_DIR="$storedir"
08f41083
LC
33GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket"
34export NIX_STORE_DIR GUIX_DAEMON_SOCKET
35
36if ! guile -c '(use-modules (guix)) (exit (false-if-exception (open-connection)))'
37then
38 exit 77
39fi
40
41# Build a tarball with '--localstatedir'
42the_pack="`guix pack -C none --localstatedir --profile-name=current-guix \
43 guile-bootstrap`"
44test_directory="`mktemp -d`"
45trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT
46
47cd "$test_directory"
48tar -xf "$the_pack"
49
50profile="`find -name current-guix`"
51test "`readlink $profile`" = "current-guix-1-link"
52test -s "`dirname $profile`/../../../db/db.sqlite"
53test -x ".`guix build guile-bootstrap`/bin/guile"
54cd -
55
56# Make sure the store database is not completely bogus.
57guile -c "(use-modules (sqlite3) (guix config) (ice-9 match))
58
59 (define db
60 (sqlite-open (string-append \"$test_directory\"
61 %localstatedir
62 \"/guix/db/db.sqlite\")
63 SQLITE_OPEN_READONLY))
64
65 (define stmt
66 (sqlite-prepare db \"SELECT * FROM ValidPaths;\"))
67
68 (match (sqlite-fold cons '() stmt)
69 ((#(ids paths hashes times derivers sizes) ...)
70 (exit (member \"`guix build guile-bootstrap`\" paths))))"