diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2018-11-04 22:05:32 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2018-11-06 23:21:24 +0100 |
| commit | 72dc64f8f720268930eed448abfc15d2a0eca3cf (patch) | |
| tree | 25ba24f00fc197f9b53a5921faa09d8f16f0c85f /tests | |
| parent | 1ff53787dbd4b1846ae523aef86ada3996de5e6d (diff) | |
store-copy: Canonicalize the mtime and permissions of the store copy.
Fixes a bug whereby directories in the output of 'guix pack -f tarball'
would not be read-only.
* guix/build/store-copy.scm (reset-permissions): New procedure.
(populate-store): Pass #:keep-mtime? #t to 'copy-recursively'. Call
'reset-permissions'.
* tests/pack.scm ("self-contained-tarball"): In CHECK, define
'canonical?' and use it to check that every file has an mtime of 1 and
is read-only.
* tests/guix-pack.sh: Invoke "chmod -Rf +w" before "rm -rf" in trap.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/guix-pack.sh | 2 | ||||
| -rw-r--r-- | tests/pack.scm | 48 |
2 files changed, 37 insertions, 13 deletions
diff --git a/tests/guix-pack.sh b/tests/guix-pack.sh index 8c1f5564263..a43f4d128fa 100644 --- a/tests/guix-pack.sh +++ b/tests/guix-pack.sh | |||
| @@ -49,7 +49,7 @@ the_pack="`guix pack --bootstrap -S /opt/gnu/bin=bin guile-bootstrap`" | |||
| 49 | # exists because /opt/gnu/bin may be an absolute symlink to a store item that | 49 | # exists because /opt/gnu/bin may be an absolute symlink to a store item that |
| 50 | # has been GC'd. | 50 | # has been GC'd. |
| 51 | test_directory="`mktemp -d`" | 51 | test_directory="`mktemp -d`" |
| 52 | trap 'rm -rf "$test_directory"' EXIT | 52 | trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT |
| 53 | cd "$test_directory" | 53 | cd "$test_directory" |
| 54 | tar -xf "$the_pack" | 54 | tar -xf "$the_pack" |
| 55 | test -L opt/gnu/bin | 55 | test -L opt/gnu/bin |
diff --git a/tests/pack.scm b/tests/pack.scm index a9bc8948b91..40473a9fe93 100644 --- a/tests/pack.scm +++ b/tests/pack.scm | |||
| @@ -68,18 +68,42 @@ | |||
| 68 | #:archiver %tar-bootstrap)) | 68 | #:archiver %tar-bootstrap)) |
| 69 | (check (gexp->derivation | 69 | (check (gexp->derivation |
| 70 | "check-tarball" | 70 | "check-tarball" |
| 71 | #~(let ((bin (string-append "." #$profile "/bin"))) | 71 | (with-imported-modules '((guix build utils)) |
| 72 | (setenv "PATH" | 72 | #~(begin |
| 73 | (string-append #$%tar-bootstrap "/bin")) | 73 | (use-modules (guix build utils) |
| 74 | (system* "tar" "xvf" #$tarball) | 74 | (srfi srfi-1)) |
| 75 | (mkdir #$output) | 75 | |
| 76 | (exit | 76 | (define store |
| 77 | (and (file-exists? (string-append bin "/guile")) | 77 | ;; The unpacked store. |
| 78 | (string=? (string-append #$%bootstrap-guile "/bin") | 78 | (string-append "." (%store-directory) "/")) |
| 79 | (readlink bin)) | 79 | |
| 80 | (string=? (string-append ".." #$profile | 80 | (define (canonical? file) |
| 81 | "/bin/guile") | 81 | ;; Return #t if FILE is read-only and its mtime is 1. |
| 82 | (readlink "bin/Guile")))))))) | 82 | (let ((st (lstat file))) |
| 83 | (or (not (string-prefix? store file)) | ||
| 84 | (eq? 'symlink (stat:type st)) | ||
| 85 | (and (= 1 (stat:mtime st)) | ||
| 86 | (zero? (logand #o222 | ||
| 87 | (stat:mode st))))))) | ||
| 88 | |||
| 89 | (define bin | ||
| 90 | (string-append "." #$profile "/bin")) | ||
| 91 | |||
| 92 | (setenv "PATH" | ||
| 93 | (string-append #$%tar-bootstrap "/bin")) | ||
| 94 | (system* "tar" "xvf" #$tarball) | ||
| 95 | (mkdir #$output) | ||
| 96 | (exit | ||
| 97 | (and (file-exists? (string-append bin "/guile")) | ||
| 98 | (file-exists? store) | ||
| 99 | (every canonical? | ||
| 100 | (find-files "." (const #t) | ||
| 101 | #:directories? #t)) | ||
| 102 | (string=? (string-append #$%bootstrap-guile "/bin") | ||
| 103 | (readlink bin)) | ||
| 104 | (string=? (string-append ".." #$profile | ||
| 105 | "/bin/guile") | ||
| 106 | (readlink "bin/Guile"))))))))) | ||
| 83 | (built-derivations (list check)))) | 107 | (built-derivations (list check)))) |
| 84 | 108 | ||
| 85 | ;; The following test needs guile-sqlite3, libgcrypt, etc. as a consequence of | 109 | ;; The following test needs guile-sqlite3, libgcrypt, etc. as a consequence of |
