summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-03-14 22:43:10 +0100
committerLudovic Courtès <ludo@gnu.org>2017-03-14 23:18:32 +0100
commit850edd77f92c1f40a1593f3505ff82fdd8719bad (patch)
tree75381e7abef46571bf0e2ec766821da4addda24b /guix
parent36f213fb704b96856d037df26e8e125aeb08edf2 (diff)
downloadguix-patches-850edd77f92c1f40a1593f3505ff82fdd8719bad.tar
guix-patches-850edd77f92c1f40a1593f3505ff82fdd8719bad.tar.gz
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.
Diffstat (limited to 'guix')
-rw-r--r--guix/scripts/pack.scm13
1 files changed, 11 insertions, 2 deletions
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"