summary refs log tree commit diff
path: root/gnu/system
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 /gnu/system
parentb019496fc3643f0bd837c62078086e3ff51b6001 (diff)
downloadguix-11f0698243da27be93b16cec574fbf262279779a.tar.gz
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 'gnu/system')
-rw-r--r--gnu/system/file-systems.scm22
1 files changed, 0 insertions, 22 deletions
diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm
index 4a3c1fe008..b9eda80958 100644
--- a/gnu/system/file-systems.scm
+++ b/gnu/system/file-systems.scm
@@ -55,7 +55,6 @@
             file-system-dependencies
             file-system-location
 
-            reduce-directories
             file-system-type-predicate
             btrfs-subvolume?
             btrfs-store-subvolume-file-name
@@ -266,27 +265,6 @@ For example:
 (define (file-name-depth file-name)
   (length (string-tokenize file-name %not-slash)))
 
-(define (reduce-directories file-names)
-  "Eliminate entries in FILE-NAMES that are children of other entries in
-FILE-NAMES.  This is for example useful when passing a list of files to GNU
-tar, which would otherwise descend into each directory passed and archive the
-duplicate files as hard links, which can be undesirable."
-  (let* ((file-names/sorted
-          ;; Ascending sort by file hierarchy depth, then by file name length.
-          (stable-sort (delete-duplicates file-names)
-                       (lambda (f1 f2)
-                         (let ((depth1 (file-name-depth f1))
-                               (depth2 (file-name-depth f2)))
-                           (if (= depth1 depth2)
-                               (string< f1 f2)
-                               (< depth1 depth2)))))))
-    (reverse (fold (lambda (file-name results)
-                     (if (find (cut file-prefix? <> file-name) results)
-                         results        ;parent found -- skipping
-                         (cons file-name results)))
-                   '()
-                   file-names/sorted))))
-
 (define* (file-system-device->string device #:key uuid-type)
   "Return the string representations of the DEVICE field of a <file-system>
 record.  When the device is a UUID, its representation is chosen depending on