From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 49348@debbugs.gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: [bug#49348] [PATCH v2 3/4] pack: Streamline how files are included in tarballs.
Date: Tue, 6 Jul 2021 17:11:38 -0400 [thread overview]
Message-ID: <20210706211139.2806-3-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <20210706211139.2806-1-maxim.cournoyer@gmail.com>
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 are 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.
---
gnu/system/file-systems.scm | 22 -----------------
guix/scripts/pack.scm | 49 ++++++++++++-------------------------
tests/file-systems.scm | 7 +-----
3 files changed, 17 insertions(+), 61 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
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
diff --git a/tests/file-systems.scm b/tests/file-systems.scm
index 80acb6d5b9..7f7c373884 100644
--- a/tests/file-systems.scm
+++ b/tests/file-systems.scm
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015, 2017 Ludovic Courtès <ludo@gnu.org>
-;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -50,11 +50,6 @@
(device "/foo")
(flags '(bind-mount read-only)))))))))
-(test-equal "reduce-directories"
- '("./opt/gnu/" "./opt/gnuism" "a/b/c")
- (reduce-directories '("./opt/gnu/etc" "./opt/gnu/" "./opt/gnu/bin"
- "./opt/gnu/lib/debug" "./opt/gnuism" "a/b/c" "a/b/c")))
-
(test-assert "does not pull (guix config)"
;; This module is meant both for the host side and "build side", so make
;; sure it doesn't pull in (guix config), which depends on the user's
--
2.32.0
next prev parent reply other threads:[~2021-07-06 21:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-03 6:06 [bug#49348] [PATCH] pack: Allow embedding custom control files in deb packs Maxim Cournoyer
2021-07-06 21:11 ` [bug#49348] [PATCH v2 1/4] " Maxim Cournoyer
2021-07-06 21:11 ` [bug#49348] [PATCH v2 2/4] pack/deb: Add default section and priority fields to the control file Maxim Cournoyer
2021-07-06 21:11 ` Maxim Cournoyer [this message]
2021-07-06 21:11 ` [bug#49348] [PATCH v2 4/4] build: pack: Mute error output when checking if tar supports --sort Maxim Cournoyer
[not found] ` <handler.49348.B.1625292420813.ack@debbugs.gnu.org>
2021-07-18 16:26 ` bug#49348: Acknowledgement ([PATCH] pack: Allow embedding custom control files in deb packs.) Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210706211139.2806-3-maxim.cournoyer@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=49348@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).