summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Marusich <cmmarusich@gmail.com>2018-03-11 01:13:01 +0100
committerChris Marusich <cmmarusich@gmail.com>2018-03-24 03:04:07 +0100
commit272c07096251ea3dae237fd016fc5d66fe25e147 (patch)
tree554adb0c940ab91bc5cf1ba02abffd7200a87f62
parent24fa6bcac6b6991e19b7108291e3b16cc40ceaf9 (diff)
tests: Add tests for "guix pack".
* guix/scripts/pack.scm (bootstrap-xz): New variable. (%options) <--bootstrap>: New option. (show-help): Document the new --bootstrap option. (guix-pack): When --bootstrap is specified, use the bootstrap Guile, tar, and xz to build the pack, and do not use any profile hooks or locales. * doc/guix.texi (Invoking guix pull): Document the new --bootstrap option. * tests/guix-pack.sh: New file. * Makefile.am (SH_TESTS): Add guix-pack.sh. * gnu/packages/package-management.scm (guix) <inputs>: Add util-linux.
-rw-r--r--Makefile.am1
-rw-r--r--doc/guix.texi6
-rw-r--r--gnu/packages/package-management.scm2
-rw-r--r--guix/scripts/pack.scm64
-rw-r--r--tests/guix-pack.sh83
5 files changed, 138 insertions, 18 deletions
diff --git a/Makefile.am b/Makefile.am
index 0c653b54e4f..feb99490d34 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -374,6 +374,7 @@ SH_TESTS = \
374 tests/guix-download.sh \ 374 tests/guix-download.sh \
375 tests/guix-gc.sh \ 375 tests/guix-gc.sh \
376 tests/guix-hash.sh \ 376 tests/guix-hash.sh \
377 tests/guix-pack.sh \
377 tests/guix-package.sh \ 378 tests/guix-package.sh \
378 tests/guix-package-net.sh \ 379 tests/guix-package-net.sh \
379 tests/guix-system.sh \ 380 tests/guix-system.sh \
diff --git a/doc/guix.texi b/doc/guix.texi
index 482fa463cfe..9744704ea79 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -23,7 +23,7 @@ Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
23Copyright @copyright{} 2015, 2016, 2017 Leo Famulari@* 23Copyright @copyright{} 2015, 2016, 2017 Leo Famulari@*
24Copyright @copyright{} 2015, 2016, 2017, 2018 Ricardo Wurmus@* 24Copyright @copyright{} 2015, 2016, 2017, 2018 Ricardo Wurmus@*
25Copyright @copyright{} 2016 Ben Woodcroft@* 25Copyright @copyright{} 2016 Ben Woodcroft@*
26Copyright @copyright{} 2016, 2017 Chris Marusich@* 26Copyright @copyright{} 2016, 2017, 2018 Chris Marusich@*
27Copyright @copyright{} 2016, 2017, 2018 Efraim Flashner@* 27Copyright @copyright{} 2016, 2017, 2018 Efraim Flashner@*
28Copyright @copyright{} 2016 John Darrington@* 28Copyright @copyright{} 2016 John Darrington@*
29Copyright @copyright{} 2016, 2017 Nils Gillmann@* 29Copyright @copyright{} 2016, 2017 Nils Gillmann@*
@@ -2899,6 +2899,10 @@ added to it or removed from it after extraction of the pack.
2899 2899
2900One use case for this is the Guix self-contained binary tarball 2900One use case for this is the Guix self-contained binary tarball
2901(@pxref{Binary Installation}). 2901(@pxref{Binary Installation}).
2902
2903@item --bootstrap
2904Use the bootstrap binaries to build the pack. This option is only
2905useful to Guix developers.
2902@end table 2906@end table
2903 2907
2904In addition, @command{guix pack} supports all the common build options 2908In addition, @command{guix pack} supports all the common build options
diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index 709cdfd0f75..a90ba7a21aa 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -257,6 +257,8 @@
257 ;; Many tests rely on the 'guile-bootstrap' package, which is why we 257 ;; Many tests rely on the 'guile-bootstrap' package, which is why we
258 ;; have it here. 258 ;; have it here.
259 ("boot-guile" ,(bootstrap-guile-origin (%current-system))) 259 ("boot-guile" ,(bootstrap-guile-origin (%current-system)))
260 ;; Some of the tests use "unshare" when it is available.
261 ("util-linux" ,util-linux)
260 ,@(if (and (not (%current-target-system)) 262 ,@(if (and (not (%current-target-system))
261 (string=? (%current-system) "x86_64-linux")) 263 (string=? (%current-system) "x86_64-linux"))
262 `(("boot-guile/i686" ,(bootstrap-guile-origin "i686-linux"))) 264 `(("boot-guile/i686" ,(bootstrap-guile-origin "i686-linux")))
diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index 59dd117edbe..0ec1ef4d24d 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -3,6 +3,7 @@
3;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il> 3;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
4;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net> 4;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
5;;; Copyright © 2018 Konrad Hinsen <konrad.hinsen@fastmail.net> 5;;; Copyright © 2018 Konrad Hinsen <konrad.hinsen@fastmail.net>
6;;; Copyright © 2018 Chris Marusich <cmmarusich@gmail.com>
6;;; 7;;;
7;;; This file is part of GNU Guix. 8;;; This file is part of GNU Guix.
8;;; 9;;;
@@ -33,7 +34,9 @@
33 #:use-module (guix derivations) 34 #:use-module (guix derivations)
34 #:use-module (guix scripts build) 35 #:use-module (guix scripts build)
35 #:use-module (gnu packages) 36 #:use-module (gnu packages)
37 #:use-module (gnu packages bootstrap)
36 #:use-module (gnu packages compression) 38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages guile)
37 #:autoload (gnu packages base) (tar) 40 #:autoload (gnu packages base) (tar)
38 #:autoload (gnu packages package-management) (guix) 41 #:autoload (gnu packages package-management) (guix)
39 #:autoload (gnu packages gnupg) (libgcrypt) 42 #:autoload (gnu packages gnupg) (libgcrypt)
@@ -67,6 +70,11 @@
67 #~(#+(file-append bzip2 "/bin/bzip2") "-9")) 70 #~(#+(file-append bzip2 "/bin/bzip2") "-9"))
68 (compressor "none" "" #f))) 71 (compressor "none" "" #f)))
69 72
73;; This one is only for use in this module, so don't put it in %compressors.
74(define bootstrap-xz
75 (compressor "bootstrap-xz" ".xz"
76 #~(#+(file-append %bootstrap-coreutils&co "/bin/xz") "-e -T0")))
77
70(define (lookup-compressor name) 78(define (lookup-compressor name)
71 "Return the compressor object called NAME. Error out if it could not be 79 "Return the compressor object called NAME. Error out if it could not be
72found." 80found."
@@ -325,6 +333,9 @@ the image."
325 (option '("localstatedir") #f #f 333 (option '("localstatedir") #f #f
326 (lambda (opt name arg result) 334 (lambda (opt name arg result)
327 (alist-cons 'localstatedir? #t result))) 335 (alist-cons 'localstatedir? #t result)))
336 (option '("bootstrap") #f #f
337 (lambda (opt name arg result)
338 (alist-cons 'bootstrap? #t result)))
328 339
329 (append %transformation-options 340 (append %transformation-options
330 %standard-build-options))) 341 %standard-build-options)))
@@ -352,6 +363,8 @@ Create a bundle of PACKAGE.\n"))
352 -m, --manifest=FILE create a pack with the manifest from FILE")) 363 -m, --manifest=FILE create a pack with the manifest from FILE"))
353 (display (G_ " 364 (display (G_ "
354 --localstatedir include /var/guix in the resulting pack")) 365 --localstatedir include /var/guix in the resulting pack"))
366 (display (G_ "
367 --bootstrap use the bootstrap binaries to build the pack"))
355 (newline) 368 (newline)
356 (display (G_ " 369 (display (G_ "
357 -h, --help display this help and exit")) 370 -h, --help display this help and exit"))
@@ -393,28 +406,43 @@ Create a bundle of PACKAGE.\n"))
393 (else (packages->manifest packages))))) 406 (else (packages->manifest packages)))))
394 407
395 (with-error-handling 408 (with-error-handling
396 (parameterize ((%graft? (assoc-ref opts 'graft?))) 409 (let* ((dry-run? (assoc-ref opts 'dry-run?))
397 (let* ((dry-run? (assoc-ref opts 'dry-run?)) 410 (manifest (manifest-from-args opts))
398 (manifest (manifest-from-args opts)) 411 (pack-format (assoc-ref opts 'format))
399 (pack-format (assoc-ref opts 'format)) 412 (name (string-append (symbol->string pack-format)
400 (name (string-append (symbol->string pack-format) 413 "-pack"))
401 "-pack")) 414 (target (assoc-ref opts 'target))
402 (target (assoc-ref opts 'target)) 415 (bootstrap? (assoc-ref opts 'bootstrap?))
403 (compressor (assoc-ref opts 'compressor)) 416 (compressor (if bootstrap?
404 (symlinks (assoc-ref opts 'symlinks)) 417 bootstrap-xz
405 (build-image (match (assq-ref %formats pack-format) 418 (assoc-ref opts 'compressor)))
406 ((? procedure? proc) proc) 419 (tar (if bootstrap?
407 (#f 420 %bootstrap-coreutils&co
408 (leave (G_ "~a: unknown pack format") 421 tar))
409 format)))) 422 (symlinks (assoc-ref opts 'symlinks))
410 (localstatedir? (assoc-ref opts 'localstatedir?))) 423 (build-image (match (assq-ref %formats pack-format)
411 (with-store store 424 ((? procedure? proc) proc)
425 (#f
426 (leave (G_ "~a: unknown pack format")
427 format))))
428 (localstatedir? (assoc-ref opts 'localstatedir?)))
429 (with-store store
430 (parameterize ((%graft? (assoc-ref opts 'graft?))
431 (%guile-for-build (package-derivation
432 store
433 (if (assoc-ref opts 'bootstrap?)
434 %bootstrap-guile
435 (canonical-package guile-2.2)))))
412 ;; Set the build options before we do anything else. 436 ;; Set the build options before we do anything else.
413 (set-build-options-from-command-line store opts) 437 (set-build-options-from-command-line store opts)
414 438
415 (run-with-store store 439 (run-with-store store
416 (mlet* %store-monad ((profile (profile-derivation 440 (mlet* %store-monad ((profile (profile-derivation
417 manifest 441 manifest
442 #:hooks (if bootstrap?
443 '()
444 %default-profile-hooks)
445 #:locales? (not bootstrap?)
418 #:target target)) 446 #:target target))
419 (drv (build-image name profile 447 (drv (build-image name profile
420 #:target 448 #:target
@@ -424,7 +452,9 @@ Create a bundle of PACKAGE.\n"))
424 #:symlinks 452 #:symlinks
425 symlinks 453 symlinks
426 #:localstatedir? 454 #:localstatedir?
427 localstatedir?))) 455 localstatedir?
456 #:tar
457 tar)))
428 (mbegin %store-monad 458 (mbegin %store-monad
429 (show-what-to-build* (list drv) 459 (show-what-to-build* (list drv)
430 #:use-substitutes? 460 #:use-substitutes?
diff --git a/tests/guix-pack.sh b/tests/guix-pack.sh
new file mode 100644
index 00000000000..1b63b957be0
--- /dev/null
+++ b/tests/guix-pack.sh
@@ -0,0 +1,83 @@
1# GNU Guix --- Functional package management for GNU
2# Copyright © 2018 Chris Marusich <cmmarusich@gmail.com>
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' command-line utility.
21#
22
23# A network connection is required to build %bootstrap-coreutils&co,
24# which is required to run these tests with the --bootstrap option.
25if ! guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null; then
26 exit 77
27fi
28
29guix pack --version
30
31# Use --no-substitutes because we need to verify we can do this ourselves.
32GUIX_BUILD_OPTIONS="--no-substitutes"
33export GUIX_BUILD_OPTIONS
34
35# Build a tarball with no compression.
36guix pack --compression=none --bootstrap guile-bootstrap
37
38# Build a tarball (with compression).
39guix pack --bootstrap guile-bootstrap
40
41# Build a tarball with a symlink.
42the_pack="`guix pack --bootstrap -S /opt/gnu/bin=bin guile-bootstrap`"
43
44# Try to extract it.
45test_directory="`mktemp -d`"
46trap 'rm -rf "$test_directory"' EXIT
47cd "$test_directory"
48tar -xf "$the_pack"
49test -x opt/gnu/bin/guile
50
51is_available () {
52 # Use the "type" shell builtin to see if the program is on PATH.
53 type "$1" > /dev/null
54}
55
56if is_available chroot && is_available unshare; then
57 # Verify we can use what we built.
58 unshare -r chroot . /opt/gnu/bin/guile --version
59 cd -
60else
61 echo "warning: skipped some verification because chroot or unshare is unavailable" >&2
62fi
63
64# For the tests that build Docker images below, we currently have to use
65# --dry-run because if we don't, there are only two possible cases:
66#
67# Case 1: We do not use --bootstrap, and the build takes hours to finish
68# because it needs to build tar etc.
69#
70# Case 2: We use --bootstrap, and the build fails because the bootstrap
71# Guile cannot dlopen shared libraries. Not to mention the fact
72# that we would still have to build many non-bootstrap inputs
73# (e.g., guile-json) in order to create the Docker image.
74
75# Build a Docker image.
76guix pack --dry-run --bootstrap -f docker guile-bootstrap
77
78# Build a Docker image with a symlink.
79guix pack --dry-run --bootstrap -f docker -S /opt/gnu=/ guile-bootstrap
80
81# Build a tarball pack of cross-compiled software. Use coreutils because
82# guile-bootstrap is not intended to be cross-compiled.
83guix pack --dry-run --bootstrap --target=arm-unknown-linux-gnueabihf coreutils