From 850edd77f92c1f40a1593f3505ff82fdd8719bad Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 14 Mar 2017 22:43:10 +0100 Subject: pack: Add unit test. * guix/scripts/pack.scm (self-contained-tarball): Add #:tar option. [build](tar-supports-sort?): New variable. Use it. * tests/pack.scm: New file. * Makefile.am (SCM_TESTS): Add it. --- guix/scripts/pack.scm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'guix/scripts/pack.scm') diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index c3d85c568c..067b1227e0 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -70,7 +70,8 @@ found." #:key deduplicate? (compressor (first %compressors)) localstatedir? - (symlinks '())) + (symlinks '()) + (tar tar)) "Return a self-contained tarball containing a store initialized with the closure of PROFILE, a derivation. The tarball contains /gnu/store; if LOCALSTATEDIR? is true, it also contains /var/guix, including /var/guix/db @@ -104,6 +105,14 @@ added to the pack." ;; Fully-qualified symlinks. (append-map symlink->directives '#$symlinks)) + ;; The --sort option was added to GNU tar in version 1.28, released + ;; 2014-07-28. For testing, we use the bootstrap tar, which is + ;; older and doesn't support it. + (define tar-supports-sort? + (zero? (system* (string-append #+tar "/bin/tar") + "cf" "/dev/null" "--files-from=/dev/null" + "--sort=name"))) + ;; We need Guix here for 'guix-register'. (setenv "PATH" (string-append #$(if localstatedir? @@ -137,7 +146,7 @@ added to the pack." ;; mtime = 1, not zero, because that is what the ;; daemon does for files in the store (see the ;; 'mtimeStore' constant in local-store.cc.) - "--sort=name" + (if tar-supports-sort? "--sort=name" "--mtime=@1") "--mtime=@1" ;for files in /var/guix "--owner=root:0" "--group=root:0" -- cgit v1.2.3