From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 30 06:06:42 2021 Received: (at 49149) by debbugs.gnu.org; 30 Jun 2021 10:06:43 +0000 Received: from localhost ([127.0.0.1]:56497 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyX7C-0000TO-Ky for submit@debbugs.gnu.org; Wed, 30 Jun 2021 06:06:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46236) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyX7A-0000TA-SW for 49149@debbugs.gnu.org; Wed, 30 Jun 2021 06:06:41 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:33782) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyX75-00015r-Nf; Wed, 30 Jun 2021 06:06:35 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42580 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyX75-0005zv-G3; Wed, 30 Jun 2021 06:06:35 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Maxim Cournoyer Subject: Re: bug#49149: [PATCH 0/7] Add deb format for guix pack. References: <20210621061205.31878-1-maxim.cournoyer@gmail.com> <20210621061205.31878-6-maxim.cournoyer@gmail.com> Date: Wed, 30 Jun 2021 12:06:34 +0200 In-Reply-To: <20210621061205.31878-6-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Mon, 21 Jun 2021 02:12:03 -0400") Message-ID: <87wnqboedx.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 49149 Cc: 49149@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Maxim Cournoyer skribis: > Tar translate duplicate files in the archive into hard links. These can = cause > problems, as not every tool support them; for example dpkg doesn't. > > * gnu/system/file-systems.scm (reduce-directories): New procedure. > (file-prefix?): Lift the restriction on file prefix. The procedure can be > useful for comparing relative file names. Adjust doc. > (file-name-depth): New procedure, extracted from ... > (btrfs-store-subvolume-file-name): ... here. > * guix/scripts/pack.scm (self-contained-tarball/builder): Use > reduce-directories. > * tests/file-systems.scm ("reduce-directories"): New test. [...] > (define (file-prefix? file1 file2) > - "Return #t if FILE1 denotes the name of a file that is a parent of FIL= E2, > -where both FILE1 and FILE2 are absolute file name. For example: > + "Return #t if FILE1 denotes the name of a file that is a parent of FIL= E2. > +For example: >=20=20 > (file-prefix? \"/gnu\" \"/gnu/store\") > =3D> #t > @@ -240,19 +241,41 @@ where both FILE1 and FILE2 are absolute file name. = For example: > (file-prefix? \"/gn\" \"/gnu/store\") > =3D> #f > " > - (and (string-prefix? "/" file1) > - (string-prefix? "/" file2) Doesn=E2=80=99t it have the effect that now: (file-prefix? "gnu" "/gnu/store") =3D> #t ? I=E2=80=99d rather insist on absolute file names and preserve the initial semantics, to avoid bad surprises. > +(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 archiv= e the > +duplicate files as hard links, which can be undesirable." > + (let* ((file-names/sorted > + ;; Ascending sort by file hierarchy depth, then by file name l= ength. > + (stable-sort (delete-duplicates file-names) > + (lambda (f1 f2) > + (let ((depth1 (file-name-depth f1)) > + (depth2 (file-name-depth f2))) > + (if (=3D 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)))) Likewise, I suspect it doesn=E2=80=99t work as intended if there are relati= ve file names in the list, no? Perhaps we could add an example to the docstring. Also, the word =E2=80=9Creduce=E2=80=9D doesn=E2=80=99t appear in the docstring, which to = me suggests suboptimal naming. ;-) Thanks, Ludo=E2=80=99.