summaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-07-06 12:27:36 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-07-18 02:10:49 -0400
commit11f0698243da27be93b16cec574fbf262279779a (patch)
tree2f963278251112d113a448ee8c2ab9d92e324ba6 /guix/scripts
parentb019496fc3643f0bd837c62078086e3ff51b6001 (diff)
pack: Streamline how files are included in tarballs.
Thanks to Guillem Jover <guillem@debian.org> on the OFTC's #debian-dpkg channel for helping with troubleshooting. Letting GNU Tar recursively walk the complete files hierarchy side-steps the risks associated with providing a list of file names: 1. Duplicated files in the archive (recorded as hard links by GNU Tar) 2. Missing parent directories. The above would cause dpkg to malfunction, for example by aborting early and skipping triggers when there were missing parent directories. * guix/scripts/pack.scm (self-contained-tarball/builder): Do not call POPULATE-SINGLE-PROFILE-DIRECTORY, which creates extraneous files such as /root. Instead, call POPULATE-STORE and INSTALL-DATABASE-AND-GC-ROOTS individually to more precisely generate the file system. Replace the list of files by the current directory, "." and streamline the way options are passed. * gnu/system/file-systems.scm (reduce-directories): Remove procedure. * tests/file-systems.scm ("reduce-directories"): Remove test.
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/pack.scm49
1 files changed, 16 insertions, 33 deletions
diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index 78201d6f5f..9e1f270dfb 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -231,17 +231,17 @@ its source property."
(with-imported-modules (source-module-closure
`((guix build pack)
+ (guix build store-copy)
(guix build utils)
(guix build union)
- (gnu build install)
- (gnu system file-systems))
+ (gnu build install))
#:select? import-module?)
#~(begin
(use-modules (guix build pack)
+ (guix build store-copy)
(guix build utils)
((guix build union) #:select (relative-file-name))
(gnu build install)
- ((gnu system file-systems) #:select (reduce-directories))
(srfi srfi-1)
(srfi srfi-26)
(ice-9 match))
@@ -279,11 +279,11 @@ its source property."
;; Furthermore GNU tar < 1.30 sometimes fails to extract tarballs
;; with hard links:
;; <http://lists.gnu.org/archive/html/bug-tar/2017-11/msg00009.html>.
- (populate-single-profile-directory %root
- #:profile #$profile
- #:profile-name #$profile-name
- #:closure "profile"
- #:database #+database)
+ (populate-store (list "profile") %root #:deduplicate? #f)
+
+ (when #+localstatedir?
+ (install-database-and-gc-roots %root #+database #$profile
+ #:profile-name #$profile-name))
;; Create SYMLINKS.
(for-each (cut evaluate-populate-directive <> %root)
@@ -291,31 +291,14 @@ its source property."
;; Create the tarball.
(with-directory-excursion %root
- (apply invoke tar
- `(,@(tar-base-options
- #:tar tar
- #:compressor '#+(and=> compressor compressor-command))
- "-cvf" ,#$output
- ;; Avoid adding / and /var to the tarball, so
- ;; that the ownership and permissions of those
- ;; directories will not be overwritten when
- ;; extracting the archive. Do not include /root
- ;; because the root account might have a
- ;; different home directory.
- ,#$@(if localstatedir?
- '("./var/guix")
- '())
-
- ,(string-append "." (%store-directory))
-
- ,@(reduce-directories
- (filter-map (match-lambda
- (('directory directory)
- (string-append "." directory))
- ((source '-> _)
- (string-append "." source))
- (_ #f))
- directives))))))))
+ ;; GNU Tar recurses directories by default. Simply add the whole
+ ;; current directory, which contains all the generated files so far.
+ ;; This avoids creating duplicate files in the archives that would
+ ;; be stored as hard links by GNU Tar.
+ (apply invoke tar "-cvf" #$output "."
+ (tar-base-options
+ #:tar tar
+ #:compressor '#+(and=> compressor compressor-command)))))))
(define* (self-contained-tarball name profile
#:key target