GNU bug report logs - #51878
[PATCH] installer: Rework installation device detection

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Josselin Poiret <dev@HIDDEN>; Keywords: patch; Done: Mathieu Othacehe <othacehe@HIDDEN>; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 51878-done <at> debbugs.gnu.org:


Received: (at 51878-done) by debbugs.gnu.org; 26 Nov 2021 10:53:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 26 05:53:17 2021
Received: from localhost ([127.0.0.1]:58781 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mqYqz-0003KL-5d
	for submit <at> debbugs.gnu.org; Fri, 26 Nov 2021 05:53:17 -0500
Received: from eggs.gnu.org ([209.51.188.92]:44682)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <othacehe@HIDDEN>) id 1mqYqx-0003K8-Da
 for 51878-done <at> debbugs.gnu.org; Fri, 26 Nov 2021 05:53:15 -0500
Received: from [2001:470:142:3::e] (port=58378 helo=fencepost.gnu.org)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <othacehe@HIDDEN>)
 id 1mqYqs-0007ZV-30; Fri, 26 Nov 2021 05:53:10 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To:
 From; bh=GKNjTXMhy4E8xrT0A3cQxcGDtFxqivpGrEZaveR4Bbk=; b=c62GxhjEwQWEn14ghEDx
 zV/q/0rVe4x5fmFHBLe6VJ8YhgoKdWkcH4AS1c/Kt0Zww+MkfJ5qrKhX+w3Rj6KBWuos9D/Gza19w
 vAuprAOfzM2Iert2Vo+120LOU7ojoAXTLiMlN91z/a8qA3rm0Zd9J/q0unKi8lkwJGaIpjFjHcOkQ
 NVZeyPaECMJ0MuCElm2pzzLnM7dnFtVsawUiT9LG2TcWYk5tMuIr64s3kbTw9h5JTM+3+5lMCTsZH
 e6c/SaMdBUOXZhIXswVyjQ8WjUk1n2YJD7iWWeyD9X3Q7zEiluNmd7iBjDLyOrlDd1Yvt20VKCii3
 VPmJQeyfUuaVkQ==;
Received: from [2a01:e0a:19b:d9a0:2ddb:d3d2:32e8:d31a] (port=57968 helo=meije)
 by fencepost.gnu.org with esmtpsa
 (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1)
 (envelope-from <othacehe@HIDDEN>)
 id 1mqYqr-00040j-On; Fri, 26 Nov 2021 05:53:09 -0500
From: Mathieu Othacehe <othacehe@HIDDEN>
To: Josselin Poiret <dev@HIDDEN>
Subject: Re: bug#51878: [PATCH] installer: Rework installation device detection
References: <87lf1mhmgw.fsf@HIDDEN> <20211123221909.11142-1-dev@HIDDEN>
 <87y25cmw0x.fsf_-_@HIDDEN> <87tufzp7re.fsf@HIDDEN>
Date: Fri, 26 Nov 2021 10:53:07 +0000
In-Reply-To: <87tufzp7re.fsf@HIDDEN> (Josselin Poiret's message of "Fri, 
 26 Nov 2021 09:48:37 +0000")
Message-ID: <878rxbqjcc.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 51878-done
Cc: 51878-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)


Hey,

> I agree that this reads better!  Feel free to push with those changes.

Pushed as b90504cdb5ce3d1981c8d7bc8a9cc918b0d60af7.

Thanks,

Mathieu




Notification sent to Josselin Poiret <dev@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Mathieu Othacehe <othacehe@HIDDEN>:
You have taken responsibility. Full text available.

Message received at 51878 <at> debbugs.gnu.org:


Received: (at 51878) by debbugs.gnu.org; 26 Nov 2021 09:48:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 26 04:48:41 2021
Received: from localhost ([127.0.0.1]:58708 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mqXqT-0001kF-JC
	for submit <at> debbugs.gnu.org; Fri, 26 Nov 2021 04:48:41 -0500
Received: from jpoiret.xyz ([206.189.101.64]:33082)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dev@HIDDEN>) id 1mqXqS-0001k7-Bh
 for 51878 <at> debbugs.gnu.org; Fri, 26 Nov 2021 04:48:40 -0500
Received: from authenticated-user (jpoiret.xyz [206.189.101.64])
 by jpoiret.xyz (Postfix) with ESMTPA id 2A8B1184F2A;
 Fri, 26 Nov 2021 09:48:38 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim;
 t=1637920118;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:cc:mime-version:mime-version:content-type:content-type:
 in-reply-to:in-reply-to:references:references;
 bh=DHQO/V2P3+iR+gDFdqiRQmacyEH8CVF11JCnJ1DFJd0=;
 b=UYNcXWt9jlIRCdQDPiyU26MzhK3IY9JdIuS59WFUIfwm3HbzMr0Y7xO7wFVNMTKYvFQHK/
 Yl6wik4Km4gzCfnhHbX4Y3dOaDq3T9r6KzqtEBSKABKTNk9KgfvvaqtguxD1QqLYu2JiY+
 /G6EfDdx6WOPi+j7KvI5ttwwKiqA0qtaWVn6VgmZzz/FnAVkrKjAvktkc2ht04kzVcVVcj
 OU/h5dRO5oo35a0iwYATPRNBOb9gAhIsyppw/KJlTPeaQRpQggVozmNzJp2zHgifh67Vn6
 MTdXZgaHUHWlHHA40j7AhJB41iAkf6AuRVHPkAht20tlfnOcCfjN98AwJkZAsQ==
From: Josselin Poiret <dev@HIDDEN>
To: Mathieu Othacehe <othacehe@HIDDEN>
Subject: Re: bug#51878: [PATCH] installer: Rework installation device detection
In-Reply-To: <87y25cmw0x.fsf_-_@HIDDEN>
References: <87lf1mhmgw.fsf@HIDDEN>
 <20211123221909.11142-1-dev@HIDDEN> <87y25cmw0x.fsf_-_@HIDDEN>
Date: Fri, 26 Nov 2021 09:48:37 +0000
Message-ID: <87tufzp7re.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spamd-Bar: /
Authentication-Results: jpoiret.xyz;
 auth=pass smtp.auth=jpoiret@HIDDEN smtp.mailfrom=dev@HIDDEN
X-Spam-Score: 2.5 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: Mathieu Othacehe <othacehe@HIDDEN> writes: > Hello Josselin,
 > I was not very clear sorry about that. I meant something like that seems
 > a little more concise: > > --8<cut herestart>8--- > snip > --8 [...] 
 Content analysis details:   (2.5 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_PASS               SPF: sender matches SPF record
 2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
 [URI: jpoiret.xyz (xyz)]
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 0.5 FROM_SUSPICIOUS_NTLD   From abused NTLD
X-Debbugs-Envelope-To: 51878
Cc: dev@HIDDEN, 51878 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 2.5 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  Mathieu Othacehe <othacehe@HIDDEN> writes: > Hello Josselin,
    > I was not very clear sorry about that. I meant something like that seems
    > a little more concise: > > --8<cut herestart>8--- > snip > --8 [...] 
 
 Content analysis details:   (2.5 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_PASS               SPF: sender matches SPF record
  2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
                             [URI: jpoiret.xyz (xyz)]
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
  0.5 FROM_SUSPICIOUS_NTLD   From abused NTLD
  1.0 BULK_RE_SUSP_NTLD      Precedence bulk and RE: from a suspicious TLD
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

Mathieu Othacehe <othacehe@HIDDEN> writes:

> Hello Josselin,
> I was not very clear sorry about that. I meant something like that seems
> a little more concise:
>
> --8<---------------cut here---------------start------------->8---
> snip
> --8<---------------cut here---------------end--------------->8---
>
> WDYT?

I agree that this reads better!  Feel free to push with those changes.

Best,
Josselin Poiret




Information forwarded to guix-patches@HIDDEN:
bug#51878; Package guix-patches. Full text available.

Message received at 51878 <at> debbugs.gnu.org:


Received: (at 51878) by debbugs.gnu.org; 25 Nov 2021 09:20:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 25 04:20:39 2021
Received: from localhost ([127.0.0.1]:55732 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mqAvm-00053t-Ty
	for submit <at> debbugs.gnu.org; Thu, 25 Nov 2021 04:20:39 -0500
Received: from eggs.gnu.org ([209.51.188.92]:53198)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <othacehe@HIDDEN>) id 1mqAvl-00053h-Al
 for 51878 <at> debbugs.gnu.org; Thu, 25 Nov 2021 04:20:37 -0500
Received: from [2001:470:142:3::e] (port=34398 helo=fencepost.gnu.org)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <othacehe@HIDDEN>)
 id 1mqAvg-0005sQ-2D; Thu, 25 Nov 2021 04:20:32 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To:
 From; bh=ukUhF9WLIqOklJE95rClVLaOHT4Gn8Xg13nkWUYL9LI=; b=DJfuvI251KTyu4lt/Lti
 NEuHF7A/CCU8vBAZr2i+g1grPXg/s36wuCRRv8lGmwfa+c4uZI0lNepvaHryAcHpUa5+d6GzDdOWU
 0Y1VwXhoEOcjFbaTUVnAl603JzyWcSq33co/AoDDyK6J4ZWIbfqq4tnpykQd6wg/rHkZoqxt+xXas
 hvq9ZKGzXSHMRJg6/k6nCH8gl94gXP8kJU8iEjTCBWRK/v+R2NQ6QhRmkWFJoEfUOCwhEPenOWLQK
 ouaP4uIQ783KApWzZeB1jXwnh2Q8Ie4rNogpytdAu5aVhPVx077XTLO+IABi8zq+uXJUehNNBfi1/
 YgsAulYjt8varQ==;
Received: from [2a01:e0a:19b:d9a0:45b5:a14a:5c75:5737] (port=46972 helo=meije)
 by fencepost.gnu.org with esmtpsa
 (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1)
 (envelope-from <othacehe@HIDDEN>)
 id 1mqAvf-0001li-RR; Thu, 25 Nov 2021 04:20:32 -0500
From: Mathieu Othacehe <othacehe@HIDDEN>
To: Josselin Poiret <dev@HIDDEN>
Subject: Re: bug#51878: [PATCH] installer: Rework installation device detection
References: <87lf1mhmgw.fsf@HIDDEN> <20211123221909.11142-1-dev@HIDDEN>
Date: Thu, 25 Nov 2021 09:20:30 +0000
In-Reply-To: <20211123221909.11142-1-dev@HIDDEN> (Josselin Poiret's
 message of "Tue, 23 Nov 2021 22:19:09 +0000")
Message-ID: <87y25cmw0x.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 51878
Cc: 51878 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)


Hello Josselin,

Thanks for the v2!

> I didn't quite get your comment about filtering the `(devices)` list.
> In both cases, we use `remove`, but here I've factored out the predicate
> used for it.

I was not very clear sorry about that. I meant something like that seems
a little more concise:

--8<---------------cut here---------------start------------->8---
diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm
index 82b01d2ce1..ad7dd6bf91 100644
--- a/gnu/installer/parted.scm
+++ b/gnu/installer/parted.scm
@@ -366,19 +366,16 @@ (define the-installer-root-partition-path
   ;; we're booting from to determine if it is the installation
   ;; device.
   (define (installation-device? device)
+    ;; When using CDROM based installation, the root partition path may be the
+    ;; device path.
     (or (string=? the-installer-root-partition-path
                   (device-path device))
         (let ((disk (disk-new device)))
           (and disk
-               (let loop ((partition #f))
-                 (let ((next-partition (disk-next-partition disk
-                                                            #:partition
-                                                            partition)))
-                   (and next-partition
-                        (or (string=? the-installer-root-partition-path
-                                      (partition-get-path
-                                       next-partition))
-                            (loop next-partition)))))))))
+               (any (lambda (partition)
+                      (string=? the-installer-root-partition-path
+                                (partition-get-path partition)))
+                    (disk-partitions disk))))))
 
   (remove installation-device? (devices)))
--8<---------------cut here---------------end--------------->8---

WDYT?

Thanks,

Mathieu




Information forwarded to guix-patches@HIDDEN:
bug#51878; Package guix-patches. Full text available.

Message received at 51878 <at> debbugs.gnu.org:


Received: (at 51878) by debbugs.gnu.org; 23 Nov 2021 22:19:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 23 17:19:28 2021
Received: from localhost ([127.0.0.1]:52431 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mpe8O-00084J-K5
	for submit <at> debbugs.gnu.org; Tue, 23 Nov 2021 17:19:28 -0500
Received: from jpoiret.xyz ([206.189.101.64]:39814)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dev@HIDDEN>) id 1mpe8M-000848-2p
 for 51878 <at> debbugs.gnu.org; Tue, 23 Nov 2021 17:19:27 -0500
Received: from authenticated-user (jpoiret.xyz [206.189.101.64])
 by jpoiret.xyz (Postfix) with ESMTPA id 5FAA2184F2B;
 Tue, 23 Nov 2021 22:19:24 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim;
 t=1637705964;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=t4ZGXHawdszxMRxUSfh8YWahLd0zlp2RrCKAk70qxv0=;
 b=FeUTzE3OzCZCUhu1oKZb9T5nuOdyrKtWDsiLS9RtX6ec3lN+16a6jt7A9dG1XGgH0iIvGq
 ye1sbxQoid9MvnJHzr4Y2xdZ6GBHDFB/SJ3aNZeVj5cwwn05+K4yOsRBo1ldLv1n9Er68t
 cwNpvdtaExvda095uUSApaqKGcNQgZj2RYMvfspsbKq8IPG0PGWfbXkeJJa6EvVxn5HSxW
 ip/K3RVz4489ysZ73Yt74DQuG/dl0riBl1bsf8exekqYHK3lD0mgHlkoNpl2pnsjYsfT8a
 3x85O3gS6sHyH0sNvGPj1BvKhOca+sAY/PHyFRSJwqzjtdMoDX+Q3rRGpJmwYQ==
From: Josselin Poiret <dev@HIDDEN>
To: Mathieu Othacehe <othacehe@HIDDEN>
Subject: [PATCH v2] installer: Rework installation device detection
Date: Tue, 23 Nov 2021 22:19:09 +0000
Message-Id: <20211123221909.11142-1-dev@HIDDEN>
In-Reply-To: <87lf1mhmgw.fsf@HIDDEN>
References: <87lf1mhmgw.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spamd-Bar: ++++
Authentication-Results: jpoiret.xyz;
 auth=pass smtp.auth=jpoiret@HIDDEN smtp.mailfrom=dev@HIDDEN
X-Spam-Level: ****
X-Spam-Score: 2.5 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  Hello, You're right, I didn't take CDs into account. Here
 is a new version which compares the device path itself to the --root argument
 as well, which is the case for CDs. I checked both iso9660 and qcow2 in [...]
 Content analysis details:   (2.5 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_PASS               SPF: sender matches SPF record
 2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
 [URI: jpoiret.xyz (xyz)]
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 0.5 FROM_SUSPICIOUS_NTLD   From abused NTLD
X-Debbugs-Envelope-To: 51878
Cc: Josselin Poiret <dev@HIDDEN>, 51878 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.5 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  Hello, You're right, I didn't take CDs into account. Here
   is a new version which compares the device path itself to the --root argument
    as well, which is the case for CDs. I checked both iso9660 and qcow2 in [...]
    
 
 Content analysis details:   (1.5 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_PASS               SPF: sender matches SPF record
  2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
                             [URI: jpoiret.xyz (xyz)]
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
  0.5 FROM_SUSPICIOUS_NTLD   From abused NTLD
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

Hello,

You're right, I didn't take CDs into account.  Here is a new version
which compares the device path itself to the --root argument as well,
which is the case for CDs.  I checked both iso9660 and qcow2 in qemu,
and both only list other devices.

I didn't quite get your comment about filtering the `(devices)` list.
In both cases, we use `remove`, but here I've factored out the predicate
used for it.

Best,
Josselin

-- >8 --
* gnu/installer/parted.scm (installation-device): Remove it.
* gnu/installer/parted.scm (installer-root-partition-path): Add it.
* gnu/installer/parted.scm (non-install-devices): Add
installation-device? predicate.
---
 gnu/installer/parted.scm | 53 +++++++++++++++++++++++-----------------
 1 file changed, 30 insertions(+), 23 deletions(-)

diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm
index 00de0a30fa..f665e67b35 100644
--- a/gnu/installer/parted.scm
+++ b/gnu/installer/parted.scm
@@ -26,6 +26,7 @@ (define-module (gnu installer parted)
   #:use-module ((gnu build file-systems)
                 #:select (canonicalize-device-spec
                           find-partition-by-label
+                          find-partition-by-uuid
                           read-partition-uuid
                           read-luks-partition-uuid))
   #:use-module ((gnu build linux-boot)
@@ -345,35 +346,41 @@ (define (remove-logical-devices)
   (with-null-output-ports
    (invoke "dmsetup" "remove_all")))
 
-(define (installation-device)
-  "Return the installation device path."
+(define (installer-root-partition-path)
+  "Return the root partition path, or #f if it could not be detected."
   (let* ((cmdline (linux-command-line))
          (root (find-long-option "--root" cmdline)))
     (and root
-         (canonicalize-device-spec (uuid root)))))
+         (or (and (access? root F_OK) root)
+             (find-partition-by-label root)
+             (and=> (uuid root)
+                    find-partition-by-uuid)))))
 
 (define (non-install-devices)
   "Return all the available devices, except the install device."
-  (define (read-only? device)
-    (dynamic-wind
-    (lambda ()
-      (device-open device))
-    (lambda ()
-      (device-read-only? device))
-    (lambda ()
-      (device-close device))))
-
-  ;; If parted reports that a device is read-only it is probably the
-  ;; installation device. However, as this detection does not always work,
-  ;; compare the device path to the installation device path read from the
-  ;; command line.
-  (let ((install-device (installation-device)))
-    (remove (lambda (device)
-              (let ((file-name (device-path device)))
-                (or (read-only? device)
-                    (and install-device
-                         (string=? file-name install-device)))))
-            (devices))))
+
+  (define the-installer-root-partition-path
+    (installer-root-partition-path))
+
+  ;; Read partition table of device and compare each path to the one
+  ;; we're booting from to determine if it is the installation
+  ;; device.
+  (define (installation-device? device)
+    (or (string=? the-installer-root-partition-path
+                  (device-path device))
+        (let ((disk (disk-new device)))
+          (and disk
+               (let loop ((partition #f))
+                 (let ((next-partition (disk-next-partition disk
+                                                            #:partition
+                                                            partition)))
+                   (and next-partition
+                        (or (string=? the-installer-root-partition-path
+                                      (partition-get-path
+                                       next-partition))
+                            (loop next-partition)))))))))
+
+  (remove installation-device? (devices)))
 
 
 ;;
-- 
2.33.1





Information forwarded to guix-patches@HIDDEN:
bug#51878; Package guix-patches. Full text available.

Message received at 51878 <at> debbugs.gnu.org:


Received: (at 51878) by debbugs.gnu.org; 17 Nov 2021 14:43:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 17 09:43:22 2021
Received: from localhost ([127.0.0.1]:60578 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mnM9i-0005UN-Bn
	for submit <at> debbugs.gnu.org; Wed, 17 Nov 2021 09:43:22 -0500
Received: from eggs.gnu.org ([209.51.188.92]:55670)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <othacehe@HIDDEN>) id 1mnM9g-0005U8-QY
 for 51878 <at> debbugs.gnu.org; Wed, 17 Nov 2021 09:43:21 -0500
Received: from [2001:470:142:3::e] (port=34192 helo=fencepost.gnu.org)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <othacehe@HIDDEN>)
 id 1mnM9b-00009L-J7; Wed, 17 Nov 2021 09:43:15 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To:
 From; bh=zDuTq1vza8HAiplrqNgitMTcpepRr6qsILzvb+XPpww=; b=C5+SYFjEjvy1mD/KoZ+N
 5+lLQv3HVjhofsGUe/PpZJUlI2mEBhGkhJWOFNH+jXaAkStT0ZE6cDE1Pf9+sSoNRKO30ZV0hA6SP
 4Wzxnwvln+gB1MzngLCIssWauGzOFJ37h68P5I6CDpBGRt0joDYSc/1x89EiKUiA+ilhl44bN06SK
 K+dg+iziRActhzmCaHHwMtXV3vFZJAi9/bCPVt0Cnyh2dblG90jQ5J63Um5UrhjipcogQG0H7SENJ
 lywzidI5cgUl3y2urXH+hSPqPBnrhD6s1NsYz6MToSMfsZaNsl8fToCLRYHfN9rBdgJztdMYmL0lI
 faoc3ePabX4rTg==;
Received: from 2a01cb000492e90078753f5c96c7583f.ipv6.abo.wanadoo.fr
 ([2a01:cb00:492:e900:7875:3f5c:96c7:583f]:58194 helo=meije)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <othacehe@HIDDEN>)
 id 1mnM9b-0004J2-CS; Wed, 17 Nov 2021 09:43:15 -0500
From: Mathieu Othacehe <othacehe@HIDDEN>
To: Josselin Poiret <dev@HIDDEN>
Subject: Re: bug#51878: [PATCH] installer: Rework installation device detection
References: <20211115210404.10680-1-dev@HIDDEN>
Date: Wed, 17 Nov 2021 14:43:11 +0000
In-Reply-To: <20211115210404.10680-1-dev@HIDDEN> (Josselin Poiret's
 message of "Mon, 15 Nov 2021 21:04:04 +0000")
Message-ID: <87lf1mhmgw.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 51878
Cc: 51878 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)


Hello Josselin,

> properly detect the device as it was comparing a disk block device path (eg
> `/dev/sda`) with a partition block device path (`/dev/sda2`).  Instead, this

When using an ISO installer image,

> -                (or (read-only? device)
> -                    (and install-device
> -                         (string=? file-name install-device)))))
> -            (devices))))

file-name and install-device both equal "/dev/sr0" for the cdrom device,
which means it will be correctly filtered out. Is it handled correctly
with your patch?

When using a raw disk image, we may indeed compare devices and
partitions currently.

> +
> +  (define the-intaller-root-partition-path
> +    (installer-root-partition-path))
> +
> +  ;; Read partition table of device and compare each path to the one
> +  ;; we're booting from to determine if it is the installation
> +  ;; device.
> +  (define (installation-device? device)
> +    (let ((disk (disk-new device)))
> +      (and disk
> +           (let loop ((partition #f))
> +             (let ((next-partition (disk-next-partition disk
> +                                                        #:partition
> +                                                        partition)))
> +               (and next-partition
> +                    (or (string=? the-installer-root-partition-path
> +                                  (partition-get-path
> +                                   next-partition))
> +                        (loop next-partition))))))))

Filtering the "(devices)" list can cause extra iterations compared to
your implementation, but is easier to read I think.

Thanks,

Mathieu




Information forwarded to guix-patches@HIDDEN:
bug#51878; Package guix-patches. Full text available.

Message received at 51878 <at> debbugs.gnu.org:


Received: (at 51878) by debbugs.gnu.org; 15 Nov 2021 21:33:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 15 16:33:28 2021
Received: from localhost ([127.0.0.1]:56363 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mmjbU-0001zg-7P
	for submit <at> debbugs.gnu.org; Mon, 15 Nov 2021 16:33:28 -0500
Received: from jpoiret.xyz ([206.189.101.64]:39056)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dev@HIDDEN>) id 1mmjbR-0001zX-U9
 for 51878 <at> debbugs.gnu.org; Mon, 15 Nov 2021 16:33:26 -0500
Received: from authenticated-user (jpoiret.xyz [206.189.101.64])
 by jpoiret.xyz (Postfix) with ESMTPA id 9E0D8184F5D;
 Mon, 15 Nov 2021 21:33:24 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim;
 t=1637012004;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=TCTjsensS/MQ+qswBJfYSOva6SeiV6WJhLyMNpGYly0=;
 b=ig9zkialW0oJ6vd6ShKGvKhfr3t0ybhISQbxoc/t/yzFytOzp8g8APfYfvvGu5P8Cy/3Fl
 Pf/d/6mUpifG1yRA+4wq+Q1RVPHUA6ERv2ttUq3Xg4a4cfhZzZYeMoLckBWLw1Td5s/28k
 8qeRFrsLIUCdbr2xYFzf7ge6RBe2bRsE7Dh9TCYyFiw8Tr4LRUl/Zaun4M4frEl3ma/O2F
 CC3K/4JTWzKHq1+wDcjTuq2WUUxWZRoQ6hce/GGMLOXGhebEoWUggdWtBPnPWcg/SWNm7j
 2bYYZ1hQlGiTN1r/mW1IJIu7xcJbSZEUz8wPukFLAUGMIMwJP9nn3eihLF8iqQ==
From: Josselin Poiret <dev@HIDDEN>
To: Josselin Poiret <dev@HIDDEN>
Subject: [PATCH v2] installer: Rework installation device detection
Date: Mon, 15 Nov 2021 21:32:32 +0000
Message-Id: <20211115213232.15112-1-dev@HIDDEN>
In-Reply-To: <20211115210404.10680-1-dev@HIDDEN>
References: <20211115210404.10680-1-dev@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spamd-Bar: /
Authentication-Results: jpoiret.xyz;
 auth=pass smtp.auth=jpoiret@HIDDEN smtp.mailfrom=dev@HIDDEN
X-Spam-Score: 2.5 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  Sorry for the noise,
 Josselin Poiret -- >8 -- * gnu/installer/parted.scm
 (installation-device): Remove it. * gnu/installer/parted.scm
 (installer-root-partition-path):
 Add it. * gnu/installer/parted.sc [...] 
 Content analysis details:   (2.5 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_PASS               SPF: sender matches SPF record
 2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
 [URI: jpoiret.xyz (xyz)]
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 0.5 FROM_SUSPICIOUS_NTLD   From abused NTLD
X-Debbugs-Envelope-To: 51878
Cc: 51878 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.5 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  Sorry for the noise, Josselin Poiret -- >8 -- * gnu/installer/parted.scm
    (installation-device): Remove it. * gnu/installer/parted.scm (installer-root-partition-path):
    Add it. * gnu/installer/parted.sc [...] 
 
 Content analysis details:   (1.5 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_PASS               SPF: sender matches SPF record
  2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
                             [URI: jpoiret.xyz (xyz)]
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
  0.5 FROM_SUSPICIOUS_NTLD   From abused NTLD
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

Sorry for the noise,
Josselin Poiret
-- >8 --
* gnu/installer/parted.scm (installation-device): Remove it.
* gnu/installer/parted.scm (installer-root-partition-path): Add it.
* gnu/installer/parted.scm (non-install-devices): Add
installation-device? predicate.
---
 gnu/installer/parted.scm | 51 ++++++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 23 deletions(-)

diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm
index 00de0a30fa..42456a1d18 100644
--- a/gnu/installer/parted.scm
+++ b/gnu/installer/parted.scm
@@ -26,6 +26,7 @@ (define-module (gnu installer parted)
   #:use-module ((gnu build file-systems)
                 #:select (canonicalize-device-spec
                           find-partition-by-label
+                          find-partition-by-uuid
                           read-partition-uuid
                           read-luks-partition-uuid))
   #:use-module ((gnu build linux-boot)
@@ -345,35 +346,39 @@ (define (remove-logical-devices)
   (with-null-output-ports
    (invoke "dmsetup" "remove_all")))
 
-(define (installation-device)
-  "Return the installation device path."
+(define (installer-root-partition-path)
+  "Return the root partition path, or #f if it could not be detected."
   (let* ((cmdline (linux-command-line))
          (root (find-long-option "--root" cmdline)))
     (and root
-         (canonicalize-device-spec (uuid root)))))
+         (or (and (access? root F_OK) root)
+             (find-partition-by-label root)
+             (and=> (uuid root)
+                    find-partition-by-uuid)))))
 
 (define (non-install-devices)
   "Return all the available devices, except the install device."
-  (define (read-only? device)
-    (dynamic-wind
-    (lambda ()
-      (device-open device))
-    (lambda ()
-      (device-read-only? device))
-    (lambda ()
-      (device-close device))))
-
-  ;; If parted reports that a device is read-only it is probably the
-  ;; installation device. However, as this detection does not always work,
-  ;; compare the device path to the installation device path read from the
-  ;; command line.
-  (let ((install-device (installation-device)))
-    (remove (lambda (device)
-              (let ((file-name (device-path device)))
-                (or (read-only? device)
-                    (and install-device
-                         (string=? file-name install-device)))))
-            (devices))))
+
+  (define the-installer-root-partition-path
+    (installer-root-partition-path))
+
+  ;; Read partition table of device and compare each path to the one
+  ;; we're booting from to determine if it is the installation
+  ;; device.
+  (define (installation-device? device)
+    (let ((disk (disk-new device)))
+      (and disk
+           (let loop ((partition #f))
+             (let ((next-partition (disk-next-partition disk
+                                                        #:partition
+                                                        partition)))
+               (and next-partition
+                    (or (string=? the-installer-root-partition-path
+                                  (partition-get-path
+                                   next-partition))
+                        (loop next-partition))))))))
+
+  (remove installation-device? (devices)))
 
 
 ;;
-- 
2.33.1





Information forwarded to guix-patches@HIDDEN:
bug#51878; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 15 Nov 2021 21:04:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 15 16:04:28 2021
Received: from localhost ([127.0.0.1]:56327 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mmj9P-00019x-U1
	for submit <at> debbugs.gnu.org; Mon, 15 Nov 2021 16:04:28 -0500
Received: from lists.gnu.org ([209.51.188.17]:43836)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dev@HIDDEN>) id 1mmj9N-00019p-NB
 for submit <at> debbugs.gnu.org; Mon, 15 Nov 2021 16:04:25 -0500
Received: from eggs.gnu.org ([209.51.188.92]:35952)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <dev@HIDDEN>) id 1mmj9E-0000zY-FX
 for guix-patches@HIDDEN; Mon, 15 Nov 2021 16:04:25 -0500
Received: from jpoiret.xyz ([206.189.101.64]:35916)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <dev@HIDDEN>) id 1mmj9C-0007nd-JE
 for guix-patches@HIDDEN; Mon, 15 Nov 2021 16:04:16 -0500
Received: from authenticated-user (jpoiret.xyz [206.189.101.64])
 by jpoiret.xyz (Postfix) with ESMTPA id E7856184D40;
 Mon, 15 Nov 2021 21:04:11 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim;
 t=1637010252;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding;
 bh=TXnTb3XJlY+soMLCf/Qsz2IIfjTRAAedI3PkeCfH+1A=;
 b=U6UeN+MZO8Ts7YsGIlBu6rpODUITx1cOE7LrmNw3igxZJi9854okuoJ4fKRIi31Pio3cnJ
 ZRk4dJkQtocRhlAqBqXp0UnIcQFtpvIVDL46jzVECTDu8+lr0O4/cR76dRZ0hAqMl9fIuy
 tm4s/3D6VGx7jF08V2trDpUvk8kND+42dJU3sU/hF7CsxXWPwCIDEfglufDb9T42cwSQgH
 GVizX8LhmlEPmfAN5U23bd0MRlFKs2jSTPO6X1izvWV/Xr1pmJs/O9Myovf8ieEVytM7JR
 cXXHL6aCF5BKEZTeaPmoNQ7/MHekgHvTK9B+laQJF3h9qn7GtTiGyU6mgGxNlg==
From: Josselin Poiret <dev@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH] installer: Rework installation device detection
Date: Mon, 15 Nov 2021 21:04:04 +0000
Message-Id: <20211115210404.10680-1-dev@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spamd-Bar: ++++
Authentication-Results: jpoiret.xyz;
 auth=pass smtp.auth=jpoiret@HIDDEN smtp.mailfrom=dev@HIDDEN
X-Spam-Level: ****
Received-SPF: pass client-ip=206.189.101.64; envelope-from=dev@HIDDEN;
 helo=jpoiret.xyz
X-Spam_score_int: 3
X-Spam_score: 0.3
X-Spam_bar: /
X-Spam_report: (0.3 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1,
 DKIM_SIGNED=0.1, FROM_SUSPICIOUS_NTLD=0.001, FROM_SUSPICIOUS_NTLD_FP=1.999,
 PDS_OTHER_BAD_TLD=0.001, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.7 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  Hello, While testing the installer to add LUKS2 support in
 a VM,
 the installer was having trouble detecting which device was the installation
 one, so I decided to rewrite that part using guile-parted. The ol [...] 
 Content analysis details:   (1.7 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
 [URI: jpoiret.xyz (xyz)]
 0.9 SPF_FAIL               SPF: sender does not match SPF record (fail)
 [SPF failed: Please see http://www.openspf.org/Why?s=mfrom;
 id=dev%40jpoiret.xyz; ip=209.51.188.17; r=debbugs.gnu.org]
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 -0.0 RCVD_IN_MSPIKE_H2      RBL: Average reputation (+2)
 [209.51.188.17 listed in wl.mailspike.net]
 -2.3 RCVD_IN_DNSWL_MED      RBL: Sender listed at https://www.dnswl.org/,
 medium trust [209.51.188.17 listed in list.dnswl.org]
 0.5 FROM_SUSPICIOUS_NTLD_FP From abused NTLD
 0.5 FROM_SUSPICIOUS_NTLD   From abused NTLD
X-Debbugs-Envelope-To: submit
Cc: Josselin Poiret <dev@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.1 (/)

Hello,

While testing the installer to add LUKS2 support in a VM, the installer
was having trouble detecting which device was the installation one, so I
decided to rewrite that part using guile-parted.  The old code could not
properly detect the device as it was comparing a disk block device path (eg
`/dev/sda`) with a partition block device path (`/dev/sda2`).  Instead, this
patch just iterates over all partitions of each device and tries to find if
the root partition is among one of them.

Best,
Josselin Poiret

-- >8 --
* gnu/installer/parted.scm (installation-device): Remove it.
* gnu/installer/parted.scm (installer-root-partition-path): Add it.
* gnu/installer/parted.scm (non-install-devices): Add
installation-device? predicate.
---
 gnu/installer/parted.scm | 51 ++++++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 23 deletions(-)

diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm
index 00de0a30fa..ea2e26ddad 100644
--- a/gnu/installer/parted.scm
+++ b/gnu/installer/parted.scm
@@ -26,6 +26,7 @@ (define-module (gnu installer parted)
   #:use-module ((gnu build file-systems)
                 #:select (canonicalize-device-spec
                           find-partition-by-label
+                          find-partition-by-uuid
                           read-partition-uuid
                           read-luks-partition-uuid))
   #:use-module ((gnu build linux-boot)
@@ -345,35 +346,39 @@ (define (remove-logical-devices)
   (with-null-output-ports
    (invoke "dmsetup" "remove_all")))
 
-(define (installation-device)
-  "Return the installation device path."
+(define (installer-root-partition-path)
+  "Return the root partition path, or #f if it could not be detected."
   (let* ((cmdline (linux-command-line))
          (root (find-long-option "--root" cmdline)))
     (and root
-         (canonicalize-device-spec (uuid root)))))
+         (or (and (access? root F_OK) root)
+             (find-partition-by-label root)
+             (and=> (uuid root)
+                    find-partition-by-uuid)))))
 
 (define (non-install-devices)
   "Return all the available devices, except the install device."
-  (define (read-only? device)
-    (dynamic-wind
-    (lambda ()
-      (device-open device))
-    (lambda ()
-      (device-read-only? device))
-    (lambda ()
-      (device-close device))))
-
-  ;; If parted reports that a device is read-only it is probably the
-  ;; installation device. However, as this detection does not always work,
-  ;; compare the device path to the installation device path read from the
-  ;; command line.
-  (let ((install-device (installation-device)))
-    (remove (lambda (device)
-              (let ((file-name (device-path device)))
-                (or (read-only? device)
-                    (and install-device
-                         (string=? file-name install-device)))))
-            (devices))))
+
+  (define the-intaller-root-partition-path
+    (installer-root-partition-path))
+
+  ;; Read partition table of device and compare each path to the one
+  ;; we're booting from to determine if it is the installation
+  ;; device.
+  (define (installation-device? device)
+    (let ((disk (disk-new device)))
+      (and disk
+           (let loop ((partition #f))
+             (let ((next-partition (disk-next-partition disk
+                                                        #:partition
+                                                        partition)))
+               (and next-partition
+                    (or (string=? the-installer-root-partition-path
+                                  (partition-get-path
+                                   next-partition))
+                        (loop next-partition))))))))
+
+  (remove installation-device? (devices)))
 
 
 ;;
-- 
2.33.1





Acknowledgement sent to Josselin Poiret <dev@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#51878; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 26 Nov 2021 11:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.