From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id WEaCOTO13GA0JgEAgWs5BA (envelope-from ) for ; Wed, 30 Jun 2021 20:17:23 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id MJoeNTO13GCwDAAAbx9fmQ (envelope-from ) for ; Wed, 30 Jun 2021 18:17: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 20B701FD90 for ; Wed, 30 Jun 2021 20:17:23 +0200 (CEST) Received: from localhost ([::1]:60414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyem2-00011R-4b for larch@yhetil.org; Wed, 30 Jun 2021 14:17:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyeli-0000zb-8w for guix-patches@gnu.org; Wed, 30 Jun 2021 14:17:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:47169) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyeli-00007c-1U for guix-patches@gnu.org; Wed, 30 Jun 2021 14:17:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lyelh-0001Dn-Qi for guix-patches@gnu.org; Wed, 30 Jun 2021 14:17:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49149] [PATCH 0/7] Add deb format for guix pack. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 30 Jun 2021 18:17: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: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 49149@debbugs.gnu.org Received: via spool by 49149-submit@debbugs.gnu.org id=B49149.16250770114676 (code B ref 49149); Wed, 30 Jun 2021 18:17:01 +0000 Received: (at 49149) by debbugs.gnu.org; 30 Jun 2021 18:16:51 +0000 Received: from localhost ([127.0.0.1]:58715 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyelX-0001DM-8f for submit@debbugs.gnu.org; Wed, 30 Jun 2021 14:16:51 -0400 Received: from mail-qt1-f181.google.com ([209.85.160.181]:43820) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyelV-0001DA-Ep for 49149@debbugs.gnu.org; Wed, 30 Jun 2021 14:16:49 -0400 Received: by mail-qt1-f181.google.com with SMTP id f20so2141162qtk.10 for <49149@debbugs.gnu.org>; Wed, 30 Jun 2021 11:16:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=AkzQx2EsKzBGQtGe9/GJTe0BHXnoBZVH01jxRtRKMCA=; b=cjkLkQTBMA5la/GGcbXm4fS225z8WjnPY+30tz9vq47pxYBwAJwTQei5MbkKQMLGw6 fMw6c34UHv90MagLy5R79vSZa53M2owfu8FK02jj2DZqjRWoe12InZSxkDSKf1jXTtAq YvkXOEopxSEIK+nt7PuwvAoZ7dGCrLRIRcRelhQ0xx5Ul1LDntTCGoy8PjG5oFlidbwH MhGPDlVG8guXV3f4Wsbej1cS7ehimOcylHSt2cWUesE71ukinaf4LAp2ReLgstuTE35h 2b8unOxkQ2X9guVK61iaaEMT386tukAjAY9b4BCtJklJxVvlOyDABC8p8F2r5Hl2EEHq UPug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=AkzQx2EsKzBGQtGe9/GJTe0BHXnoBZVH01jxRtRKMCA=; b=GneAKEtxXU34fX/1kLWA8wcdm5fbFd9OKU0zMAIw9myWCbC81P/O5m5IOuMKn+UUhO eaB+MN+omUEY5V1YRG2gE4LfeUwk5NHmWIZ9nIqT2UFwjFZnISEkwK3+woPlG/gEhiPB Fgx0vAQkKlrIpx+SI1rWlKweHwZ8ViR1eTH+yCrFH79IHjoV2w+cDmP1nQm6X8SWN+kH bgMTdV3wmCdUdeZ9w4UdvOct1eds8dfU2zMoqXKW2nmq3i7u5ZdDY7zZTFOr/zn2arIF LcHfiZfjq17KRMnSdaQTLDfUz/oa8gSN7YNO9bZr0gxt6yG4wXnWTMARE/kOe+7ka+fA Rx1A== X-Gm-Message-State: AOAM532/C76Ni2xiY1scK5hre4XUdkiL5XnKZSNyrO9+6MHq/vZaB3tt gSeYJZ48iuB2vCYbpBpA6/ItqAdJJhmEyw== X-Google-Smtp-Source: ABdhPJzFY883Db5ajjBYX8SOaZesw5X/0NYzFUADfDJPhMelMDuAarFMbo9kXzIKar3fiZUt0vcByg== X-Received: by 2002:ac8:4a18:: with SMTP id x24mr32179230qtq.239.1625077003850; Wed, 30 Jun 2021 11:16:43 -0700 (PDT) Received: from hurd (dsl-150-149.b2b2c.ca. [66.158.150.149]) by smtp.gmail.com with ESMTPSA id o126sm13963499qka.74.2021.06.30.11.16.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 11:16:43 -0700 (PDT) From: Maxim Cournoyer References: <20210621061205.31878-1-maxim.cournoyer@gmail.com> <20210621061205.31878-6-maxim.cournoyer@gmail.com> <87wnqboedx.fsf_-_@gnu.org> Date: Wed, 30 Jun 2021 14:16:42 -0400 In-Reply-To: <87wnqboedx.fsf_-_@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Wed, 30 Jun 2021 12:06:34 +0200") Message-ID: <877dib43qt.fsf@gmail.com> 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=1625077043; 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:dkim-signature; bh=AkzQx2EsKzBGQtGe9/GJTe0BHXnoBZVH01jxRtRKMCA=; b=MWWOU/SM4396ELL7DN28H0yJfl7pnmWd/beoxGDougbQBc6gh9j0efA5ggsXRzYVOw5nln 5wVkSIKBC5ZNRpknLAcPy4aM67S66KSgznXTgX8vnSIx4BMVX6m0cmZaHySb/Mqrc+c5pX N44La/aBPn7sXDP3C7BUKEb9iwEKfmBqfUsmjskuErlDZhL0wTBRiAjK4ngQQyTrkzyGvN +Ae2DS+dvgsEyXd/YP7sqMU3y3GdCFArl+aVl8IDdsrGyylxqx9yg6Tgk1qRFk4jgQKwzI jK4pahInqMfkB/FPNVasFM+uLQMY2SYtR8yrZ+j+4h7U2BCl1V+h/HEdj9aEcQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625077043; a=rsa-sha256; cv=none; b=BIzMz8pLxTcfPh03TEhkGcZ91BjqBnJFPwIyjuFKBoFFopnHXKhB6NjPcFvA/YiWNByJy4 3Ra4XW48OKKk390thVDgV2B2lKMuJioIoKaS7eRjoHXy+cSAS2pLu4PV7d3qPDJkDlPKxw 6rcMKntlDSQBMlKTJU4y5j6yZ7wFo1SNDLKyVszs0T4C5AhsaNAtqJFVNxzgnNXfI6pz+0 XEqj9xBgwhJVRV8UDJIQrIYQHbfcrGOKbbwfWafQp4oh+ULMMDS1kfZCwu3Fj/7d5qB697 YD0FEXehLTJNwfLD5lys9/mwFO7EdgG2+1WDhn9KOQUhofskZ7+kyxXYP5tbZA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=cjkLkQTB; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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: -1.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=cjkLkQTB; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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: 20B701FD90 X-Spam-Score: -1.32 X-Migadu-Scanner: scn0.migadu.com X-TUID: nI2LL9ZEoPFY Hey, Ludovic Court=C3=A8s writes: [...] >> (define (file-prefix? file1 file2) >> - "Return #t if FILE1 denotes the name of a file that is a parent of FI= LE2, >> -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 FI= LE2. >> +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: --8<---------------cut here---------------start------------->8--- modified gnu/system/file-systems.scm @@ -233,6 +233,8 @@ =20 (define (file-prefix? file1 file2) "Return #t if FILE1 denotes the name of a file that is a parent of FILE2. +FILE1 and FILE2 must both be either absolute or relative, else #f is retur= ned. + For example: =20 (file-prefix? \"/gnu\" \"/gnu/store\") @@ -241,17 +243,24 @@ For example: (file-prefix? \"/gn\" \"/gnu/store\") =3D> #f " - (let loop ((file1 (string-tokenize file1 %not-slash)) - (file2 (string-tokenize file2 %not-slash))) - (match file1 - (() - #t) - ((head1 tail1 ...) - (match file2 - ((head2 tail2 ...) - (and (string=3D? head1 head2) (loop tail1 tail2))) - (() - #f)))))) + (define (absolute? file) + (string-prefix? "/" file)) + + (if (or (every absolute? (list file1 file2)) + (every (negate absolute?) (list file1 file2))) + (let loop ((file1 (string-tokenize file1 %not-slash)) + (file2 (string-tokenize file2 %not-slash))) + (match file1 + (() + #t) + ((head1 tail1 ...) + (match file2 + ((head2 tail2 ...) + (and (string=3D? head1 head2) (loop tail1 tail2))) + (() + #f))))) + ;; FILE1 and FILE2 are a mix of absolute and relative paths. + #f)) --8<---------------cut here---------------end--------------->8--- =20 (define (file-name-depth file-name) (length (string-tokenize file-name %not-slash))) > 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 :-). >> +(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 archi= ve 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 rela= tive > 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. > 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 t= o 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. Maxim