From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id KMGEMkPC3WAhJAAAgWs5BA (envelope-from ) for ; Thu, 01 Jul 2021 15:25:23 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id yARBLkPC3WAkUQAA1q6Kng (envelope-from ) for ; Thu, 01 Jul 2021 13:25:23 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1569BA43D for ; Thu, 1 Jul 2021 15:25:23 +0200 (CEST) Received: from localhost ([::1]:53434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lywh0-0000oH-5B for larch@yhetil.org; Thu, 01 Jul 2021 09:25:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lywgg-0000jv-9k for guix-patches@gnu.org; Thu, 01 Jul 2021 09:25:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48402) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lywgf-0004kB-Vt for guix-patches@gnu.org; Thu, 01 Jul 2021 09:25:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lywgf-0001Ls-Sl for guix-patches@gnu.org; Thu, 01 Jul 2021 09:25:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49149] [PATCH 0/7] Add deb format for guix pack. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 01 Jul 2021 13:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49149 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: 49149@debbugs.gnu.org Received: via spool by 49149-submit@debbugs.gnu.org id=B49149.16251458875165 (code B ref 49149); Thu, 01 Jul 2021 13:25:01 +0000 Received: (at 49149) by debbugs.gnu.org; 1 Jul 2021 13:24:47 +0000 Received: from localhost ([127.0.0.1]:59948 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lywgQ-0001LE-Ns for submit@debbugs.gnu.org; Thu, 01 Jul 2021 09:24:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48432) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lywgO-0001L2-Vx for 49149@debbugs.gnu.org; Thu, 01 Jul 2021 09:24:45 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50786) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lywgJ-0004Rj-Pl; Thu, 01 Jul 2021 09:24:39 -0400 Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=36606 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lywgJ-0003zj-Hd; Thu, 01 Jul 2021 09:24:39 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20210621061205.31878-1-maxim.cournoyer@gmail.com> <20210621061205.31878-6-maxim.cournoyer@gmail.com> <87wnqboedx.fsf_-_@gnu.org> <877dib43qt.fsf@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 13 Messidor an 229 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Thu, 01 Jul 2021 15:24:38 +0200 In-Reply-To: <877dib43qt.fsf@gmail.com> (Maxim Cournoyer's message of "Wed, 30 Jun 2021 14:16:42 -0400") Message-ID: <87im1ukvzd.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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1625145923; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=POB3T+917ljeOISm3vWZFVbhdSutMPnykxYwFisv4sw=; b=iLI3EK7X5IPPtIqsr9AZ9C8AupYBA5obweFwW8jurQxSeDQpCatJ9JvGMyEkvPI6QXW1em D96obR/tUjxZ+eTf1fv9bPKurZaIUNsuA9Azlaafwd+TLybFv48bIKVc8t/C0ZG9Fd3lqG dzHD6oRvKA2DCwDdMJ79t09VuCsQVE3Jws1bHxBYBAN4eSpKkOFCUej5QfpGa8bCh6UZO4 vv2b02GYkNVWD+7LZGjyr/zqE3aNwA3hpm8TrxLrfn45Quz5VW28Kjqe/phcIWtYW8I4VN nUo+ZPOjm1n+V4MSkdeo9UqU/bqVh2bQuaTvxlTRbiJlBnKsA5DJURRbIAQAtA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625145923; a=rsa-sha256; cv=none; b=Nmbsyd9jHTPZcQGYhhB/Ud3JhAAaGOzhCLHQSSS6Ydm5NzyOjICbJ8p3h3hcjxNJoxuGKz WaJxUliQZ9Ixw+qPwrYi3EWlb2gv3kVDUMtMbq3fVwGYmLCiUE3IapElkjNyEj7nVqOm7q GS8PlYK7vD9sKCl1soY2iajKoeURbSwEh7IZIK6LjjYYYW+1OAY9LQkAAVvZ3fdmytNnDx vLQTegAK/bb3ZnkGQefDCQowbt2RTyCEIzCpZIXfwCe7CSLhEBHrDlPsNlqNUFoOxMUTTV jF4vHIvZFptM7HWQnxQHJaTc0r4dN90P1O/nIa7EACSHidt+xNraPwda7d4UeQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -2.92 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 1569BA43D X-Spam-Score: -2.92 X-Migadu-Scanner: scn0.migadu.com X-TUID: nW/GnN5xZ2O4 Hi! Maxim Cournoyer skribis: [...] >>> (define (file-prefix? file1 file2) >>> - "Return #t if FILE1 denotes the name of a file that is a parent of F= ILE2, >>> -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 F= ILE2. >>> +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 >> >> ? > > Good catch. That seems sub-optimal. How about: [...] > + (define (absolute? file) > + (string-prefix? "/" file)) > + > + (if (or (every absolute? (list file1 file2)) > + (every (negate absolute?) (list file1 file2))) Yes, that could work. >> I=E2=80=99d rather insist on absolute file names and preserve the initial >> semantics, to avoid bad surprises. > > I agree that not changing the original semantics would be safest; > nevertheless, we're talking about an internal helper that isn't widely > use; its couple usages are easy to review (and deals with mount points > which seems safe to assume are exclusively using absolute paths). > Especially after the above fix :-). Sure, but it=E2=80=99s always easier to reason about code that is stricter. >>> +(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 t= o GNU >>> +tar, which would otherwise descend into each directory passed and arch= ive 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 (=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 rel= ative >> file names in the list, no? > > You can see it at work in the tests/file-systems test module; it reduces > > (reduce-directories '("./opt/gnu/etc" "./opt/gnu/" "./opt/gnu/bin" > "./opt/gnu/lib/debug" "./opt/gnuism" "a/b/c" > "a/b/c")) > > into '("./opt/gnu/" "./opt/gnuism" "a/b/c"), none of which are absolute > file names. Oh right! >> 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. ;-) > > That the word 'reduce' doesn't appear in the docstring was a conscious > effort of mine to not bore the reader with repeating the same terms, ah! > But naming is hard; I'm open to suggestions. Actually I don=E2=80=99t have a good suggestion. :-) =E2=80=98strip-child-directories=E2=80=99 maybe? Thanks, Ludo=E2=80=99.