From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id oHDsERHmr2bdawAAe85BDQ:P1 (envelope-from ) for ; Sun, 04 Aug 2024 20:35:29 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id oHDsERHmr2bdawAAe85BDQ (envelope-from ) for ; Sun, 04 Aug 2024 22:35:29 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=YwrXgnua; dkim=fail ("headers rsa verify failed") header.d=lunabee.space header.s=purelymail2 header.b=Kg8pdnBj; dkim=fail ("headers rsa verify failed") header.d=purelymail.com header.s=purelymail2 header.b=rFuZNzuF; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1722803729; h=from:from:sender:sender:reply-to: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=84/2yjYQnU7+z8GmMgD4MuSxb3CRyFMyRCZ/dLM81BQ=; b=E2LH/yAMmxhv61VLc5LzZwnT96vvFo86/o3spEMEOhPXgJ7sCqM3ajmyGleIm3Js+xL1h5 b248WPA3YGAssPEwoRMvnlNPi0Tgp0G7vdQ87q45tb6tQ1KaiLRJhrrnDT9L8nq0gEmcNh qoKU1L9F+/sd0s16BoEeUsZCwjctPiPhgv3/lELXeBtDwN4RJJJ6lGOIrGZlVltHP1Q+Gg UU6gHqLIBYgiHktDzAYRFmv+nDlSxQ0q3u/rNmwWGqxvnM5CRLStGTRdDfRS7gSk2TK8p3 JfK8TDR7CeSz2pdCl3Mb6ic4rlovQcVWdoM5xTa7Swvwlxt0gNsr5xXap/SzXw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=YwrXgnua; dkim=fail ("headers rsa verify failed") header.d=lunabee.space header.s=purelymail2 header.b=Kg8pdnBj; dkim=fail ("headers rsa verify failed") header.d=purelymail.com header.s=purelymail2 header.b=rFuZNzuF; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1722803729; a=rsa-sha256; cv=none; b=hjShEqY2WDgQtGRczGnSwNpN9S1zXDR27RxMRTuVYEQLT9oxfyHQJBXLVuaz//qmB903VJ VgTgHZFlux5SzTcxTNmrzXkJKBmAFTMLgAKAkZK/X3DE++bnBaHsJH6VmAU2Gb8GmPUdlC +O3CWTVklo/4qwVuPA+uE1b57QNv1R/+/YClYcNrDGHV0x7/lsukirRMv8XlVmlKvAvJyN uHUdlCFkYNruOTpeDdqHd9lip0qRa/lOiT+E96FhmJCzBS4cRORik6KtHtJGBH2csAIk4j luKJT2gsH6qPHgzg1M3cjizDn2D6HRlWOlTUk2Dvm3JxfUTVTika6wlkaGSSEw== 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 F3AD076B8D for ; Sun, 4 Aug 2024 22:35:28 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sahwG-0002J8-7h; Sun, 04 Aug 2024 16:34:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sahwD-0002Gl-Ln for guix-patches@gnu.org; Sun, 04 Aug 2024 16:34:45 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sahwD-0008Kc-BT; Sun, 04 Aug 2024 16:34:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=84/2yjYQnU7+z8GmMgD4MuSxb3CRyFMyRCZ/dLM81BQ=; b=YwrXgnua6n+q0eHQt/ETHGbFQ39fZF+j29X5l7ky2ySDArBJyqSJFYl2DP5RUindLJWYqX6OrGDQc9II6acKBra9HbixSEtDKMAdEBQ020PZkkDcli5NjlQ9V+Ghmcc85ePyOlbloFnB2dlQ2RAlyf+LVM6UI75roy+1niZ4J2LdShKUiT68t58Cs3NxA7JeXSMed8wKhApSYrnIdYrodH/wQCCQA7YDdQIOgdrpiEO8+Di5yGQ4DggTWR9xem/fkU86j+Xos9hk1Vxww9z56zbFaHJwa5DBJvIkTrpPeM0gS+t53inv1mTfiz4jS3+1r4ONHWgq9wrYxhrUMpS04g==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sahwU-0006Nk-70; Sun, 04 Aug 2024 16:35:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#72457] [PATCH v3 01/15] guix: scripts: Rewrite reinstall-bootloader to use provenance data. Resent-From: Lilah Tascheter Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sun, 04 Aug 2024 20:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72457 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 72457@debbugs.gnu.org Cc: Lilah Tascheter , Sergey Trofimov , Christopher Baines , Josselin Poiret , Ludovic Court??s , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic Court??s , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 72457-submit@debbugs.gnu.org id=B72457.172280364924162 (code B ref 72457); Sun, 04 Aug 2024 20:35:02 +0000 Received: (at 72457) by debbugs.gnu.org; 4 Aug 2024 20:34:09 +0000 Received: from localhost ([127.0.0.1]:57325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sahvd-0006Hc-0V for submit@debbugs.gnu.org; Sun, 04 Aug 2024 16:34:09 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:56724) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sahva-0006Gg-NK for 72457@debbugs.gnu.org; Sun, 04 Aug 2024 16:34:07 -0400 DKIM-Signature: a=rsa-sha256; b=Kg8pdnBjHdlUbJmHUysfaT1yWD/zUwot8Q/fqu+DgTvR0nnXeMwOVpNg58B1C5nXC5gEMxa1O2r5RtY/uVeA8AL5uTYqcFMICmm7TmR8/B8NICGxn76id/ldKBHmc2prKpct4DBfgkDkFOK5WM1PRWOQrc+tub9hKZxLbrJ3fLbEskm6NUGWXtpni8ipzIuUBxbnGQjtmYnU8t9ennfNY1DWttrz63Sw2XzvL01848ZjTAoF0AxeTUkXSR+qelXpo2R0fgnsoTxwnmhJYPaUlo0R6AKdzZSOnYBKAXIsmb+MvScsHNShwZeqszHuN6FiV5kjSCxCZdIaVpoiby+45Q==; s=purelymail2; d=lunabee.space; v=1; bh=NGAX//6gbaSkVGZaNWtJqH+fpDh0lE7iNJYijsJRixk=; h=Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=rFuZNzuFiiHVcpJHRVXFYfORSCauHt0urKpTPBZCRDTRBbkvMZWKH5bKCT5/JFxMBE+A+CIPYA1gOc4vCm8Il2WOME75dGimmbdmEj9oTwz8ab00XYWn8Q0hAiZsYVxfdDAvMJ0qne5qC5cqfVozuqnrIMJ7tviAw/xZTwtLrwE0tbAlnuDwwXu70i6PH+Drj6YCVY8ilsUHRwV4Q9uJpl2w5GXi33YRwoz1Wjey/oFztChM91daX7h8YfINc0PFwoPJHO85TQmERSGHCnc08dbovSDjuFVPrjYrkX3Vget566QgRl757KhVKsIW7AAGeZC5Zc+xfXB+BkRou/tAug==; s=purelymail2; d=purelymail.com; v=1; bh=NGAX//6gbaSkVGZaNWtJqH+fpDh0lE7iNJYijsJRixk=; h=Feedback-ID:Received:From:To:Subject:Date; Feedback-ID: 8937:2070:null:purelymail X-Pm-Original-To: 72457@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -1317130453; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Sun, 04 Aug 2024 20:33:35 +0000 (UTC) Date: Sun, 4 Aug 2024 15:31:47 -0500 Message-ID: <6d8a2015a9e54642e3ecf0f7d1d95300496cbbde.1722803521.git.lilah@lunabee.space> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by Purelymail Content-Type: text/plain; charset=UTF-8 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: , From: Lilah Tascheter via Guix-patches Reply-To: Lilah Tascheter Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -5.44 X-Migadu-Queue-Id: F3AD076B8D X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -5.44 X-TUID: xC+qAPAa2OQf The current implementation is broken anyway. Multiple bootloaders share a name (including both versions of extlinux) and bootloader-configuration data is significant to bootloader installation. It shouldn't be just faked. Rely on the provenance service instead, which while not always present, should be for the vast majority of systems. * guix/scripts/system.scm (reinstall-bootloader): Rename to... (install-bootloader-from-provenance): ...this, and rewrite to extract bootloader-configuration data from system provenance. (switch-to-system-generation, process-command): Use install-bootloader-from-provenance. Change-Id: I5713a43ad4f9f32a129d980db06d70de16b03f27 --- guix/scripts/system.scm | 75 ++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 50 deletions(-) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 0f7d864e06..bb7b5d37bf 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -88,6 +88,7 @@ (define-module (guix scripts system) #:use-module (srfi srfi-37) #:use-module (ice-9 format) #:use-module (ice-9 match) + #:use-module (ice-9 receive) #:use-module (rnrs bytevectors) #:export (guix-system read-operating-system @@ -377,60 +378,33 @@ (define (switch-to-system-generation store spec) (activate (string-append generation "/activate"))) (if number (begin - (reinstall-bootloader store number) + (install-bootloader-from-provenance store number) (switch-to-generation* %system-profile number) (unless-file-not-found (primitive-load activate))) (leave (G_ "cannot switch to system generation '~a'~%") spec)))) =20 -(define* (system-bootloader-name #:optional (system %system-profile)) - "Return the bootloader name stored in SYSTEM's \"parameters\" file." - (let ((params (unless-file-not-found - (read-boot-parameters-file system)))) - (boot-parameters-bootloader-name params))) - -(define (reinstall-bootloader store number) - "Re-install bootloader for existing system profile generation NUMBER. -STORE is an open connection to the store." +(define (install-bootloader-from-provenance store number) + "Re-install an old bootloader using provenance data for system profile +generation NUMBER with store STORE." (let* ((generation (generation-file-name %system-profile number)) - ;; Detect the bootloader used in %system-profile. - (bootloader (lookup-bootloader-by-name (system-bootloader-name))) - - ;; Use the detected bootloader with default configuration. - ;; It will be enough to allow the system to boot. - (bootloader-config (bootloader-configuration - (bootloader bootloader))) - - ;; Make the specified system generation the default entry. - (chosen-alternative (generation->boot-alternative - %system-profile number)) - (params (boot-alternative-parameters chosen-alternative)) - (locale (boot-parameters-locale params)) - (store-crypto-devices (boot-parameters-store-crypto-devices param= s)) - (store-directory-prefix - (boot-parameters-store-directory-prefix params)) - (old-generations - (delv number (reverse (generation-numbers %system-profile)))) - (previous-boot-alternatives (profile->boot-alternatives - %system-profile old-generations)) - (entries (list (boot-parameters->menu-entry params))) - (old-entries (map boot-parameters->menu-entry - (map boot-alternative-parameters - previous-boot-alternatives)))) - (run-with-store store - (mlet* %store-monad - ((bootcfg (lower-object - ((bootloader-configuration-file-generator bootloader) - bootloader-config entries - #:locale locale - #:store-crypto-devices store-crypto-devices - #:store-directory-prefix store-directory-prefix - #:old-entries old-entries))) - (drvs -> (list bootcfg))) - (mbegin %store-monad - (built-derivations drvs) - ;; Only install bootloader configuration file. - (install-bootloader local-eval bootloader-config bootcfg - #:run-installer? #f)))))) + (os (receive (_ os) (system-provenance generation) + (and=3D> os read-operating-system))) + (bootloader-config (operating-system-bootloader os)) + (bootloader (bootloader-configuration-bootloader bootloader-confi= g)) + (numbers (delv number (reverse (generation-numbers %system-profil= e)))) + (old (profile->boot-alternatives %system-profile numbers))) + (if os + (run-with-store store + (mlet* %store-monad + ((bootcfg (lower-object (operating-system-bootcfg os old))) + (drvs -> (list bootcfg))) + (mbegin %store-monad + (built-derivations drvs) + ;; Only install bootloader configuration file. + (install-bootloader local-eval bootloader-config bootcfg + #:run-installer? #f)))) + (leave (G_ "cannot rollback to provenanceless generation '~a'~%") + number)))) =20 =0C ;;; @@ -1416,7 +1390,8 @@ (define (process-command command args opts) (x (leave (G_ "wrong number of arguments~%")))))) (with-store* store (delete-matching-generations store %system-profile pattern) - (reinstall-bootloader store (generation-number %system-profile)))= )) + (install-bootloader-from-provenance store + (generation-number %system-profile))))) ((switch-generation) (let ((pattern (match args ((pattern) pattern) --=20 2.45.2