mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-04-06 21:20:33 +02:00
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.
This commit is contained in:
@@ -68,18 +68,42 @@
|
||||
#:archiver %tar-bootstrap))
|
||||
(check (gexp->derivation
|
||||
"check-tarball"
|
||||
#~(let ((bin (string-append "." #$profile "/bin")))
|
||||
(setenv "PATH"
|
||||
(string-append #$%tar-bootstrap "/bin"))
|
||||
(system* "tar" "xvf" #$tarball)
|
||||
(mkdir #$output)
|
||||
(exit
|
||||
(and (file-exists? (string-append bin "/guile"))
|
||||
(string=? (string-append #$%bootstrap-guile "/bin")
|
||||
(readlink bin))
|
||||
(string=? (string-append ".." #$profile
|
||||
"/bin/guile")
|
||||
(readlink "bin/Guile"))))))))
|
||||
(with-imported-modules '((guix build utils))
|
||||
#~(begin
|
||||
(use-modules (guix build utils)
|
||||
(srfi srfi-1))
|
||||
|
||||
(define store
|
||||
;; The unpacked store.
|
||||
(string-append "." (%store-directory) "/"))
|
||||
|
||||
(define (canonical? file)
|
||||
;; Return #t if FILE is read-only and its mtime is 1.
|
||||
(let ((st (lstat file)))
|
||||
(or (not (string-prefix? store file))
|
||||
(eq? 'symlink (stat:type st))
|
||||
(and (= 1 (stat:mtime st))
|
||||
(zero? (logand #o222
|
||||
(stat:mode st)))))))
|
||||
|
||||
(define bin
|
||||
(string-append "." #$profile "/bin"))
|
||||
|
||||
(setenv "PATH"
|
||||
(string-append #$%tar-bootstrap "/bin"))
|
||||
(system* "tar" "xvf" #$tarball)
|
||||
(mkdir #$output)
|
||||
(exit
|
||||
(and (file-exists? (string-append bin "/guile"))
|
||||
(file-exists? store)
|
||||
(every canonical?
|
||||
(find-files "." (const #t)
|
||||
#:directories? #t))
|
||||
(string=? (string-append #$%bootstrap-guile "/bin")
|
||||
(readlink bin))
|
||||
(string=? (string-append ".." #$profile
|
||||
"/bin/guile")
|
||||
(readlink "bin/Guile")))))))))
|
||||
(built-derivations (list check))))
|
||||
|
||||
;; The following test needs guile-sqlite3, libgcrypt, etc. as a consequence of
|
||||
|
||||
Reference in New Issue
Block a user