From patchwork Thu Oct 3 12:13:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Scherer X-Patchwork-Id: 31609 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 169FA27BBEA; Thu, 3 Oct 2024 13:15:14 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 32FE127BBE2 for ; Thu, 3 Oct 2024 13:15:13 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swKjW-000426-UW; Thu, 03 Oct 2024 08:15:02 -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 1swKjV-00041C-4H for guix-patches@gnu.org; Thu, 03 Oct 2024 08:15:01 -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 1swKjU-0000eZ-Rj; Thu, 03 Oct 2024 08:15:00 -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=YQPlJc5zN9a9lk0fsYXF3Q8GOGieM7xJoADiitgiv5E=; b=NWTiTaMgwskhC3qxW4K1gjiwdVluXg7u/WjeimK1wPNmkvcxnGVt5SVDuhbWYwYEtKvrCYHQWi87HmmCAYPfCgiY0fIK4pFDXW7W4qnpEnl1s8Q27DuPYdzfCSmzxCoPellHMoNPv0rejLFWNnu/IJ2Oe7pmDaQYxsXi0flVn90GkaKr4hcppW/hVsc3UKQjFTDeXZAeSP1reNQOLT7TmfrUegZyMdWnzHMNmWc4B0Hc4zO454wXgxXxYB5Q8oNe9LflwztaNoE6z5/ZwjwbOrSr5tCoGfyFvheVeTubPMHXglWeYNnUB8EDNJPNinE33R1stS1CgBJY1MdnQ3xbmA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1swKjW-0008JT-Hs; Thu, 03 Oct 2024 08:15:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73612] [PATCH 2/2] image: Add support for btrfs. Resent-From: Roman Scherer Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Thu, 03 Oct 2024 12:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73612 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 73612@debbugs.gnu.org Cc: Roman Scherer , Florian Pelz , Ludovic Court?s , Maxim Cournoyer X-Debbugs-Original-Xcc: Florian Pelz , Ludovic Court?s , Maxim Cournoyer Received: via spool by 73612-submit@debbugs.gnu.org id=B73612.172795768631913 (code B ref 73612); Thu, 03 Oct 2024 12:15:02 +0000 Received: (at 73612) by debbugs.gnu.org; 3 Oct 2024 12:14:46 +0000 Received: from localhost ([127.0.0.1]:60234 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1swKjG-0008Ie-8w for submit@debbugs.gnu.org; Thu, 03 Oct 2024 08:14:46 -0400 Received: from mail-lf1-f44.google.com ([209.85.167.44]:47560) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1swKjD-0008IR-Uj for 73612@debbugs.gnu.org; Thu, 03 Oct 2024 08:14:44 -0400 Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5399651d21aso767669e87.3 for <73612@debbugs.gnu.org>; Thu, 03 Oct 2024 05:14:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burningswell-com.20230601.gappssmtp.com; s=20230601; t=1727957621; x=1728562421; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YQPlJc5zN9a9lk0fsYXF3Q8GOGieM7xJoADiitgiv5E=; b=uueIlAxYr4Iw0vg2HsStlTekOP0R5E1WTjzQtdaHeMUBteV5UH0GVaOjHkfIFEM3Va NsFaejHl7Yh8bI0RImhuv62JGXpdYsleRgmnkkB1VP9iDChfjA3rV3yOSl0erJUQEg/t 4LtHRVH0x5xJfLHpoOy5uq0WSFwKLJt6UmjOZYIGDTdNkJ+iXZBAikDn3go88PAdssof REUOJjJHAVd15Y5Bk6JbpxXLo6XFdl6Y6fCAsFx+YlLo2frnyna4zEF/SS0FN0xxySo6 nHAMZD8IrZyyfinHoxQO7dFoKSp1CwyVHvS6Qbr9RXXzVOiD6GhbP6hXEfdj0TZ6BOgC b6NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727957621; x=1728562421; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YQPlJc5zN9a9lk0fsYXF3Q8GOGieM7xJoADiitgiv5E=; b=vK9UWe9UI1iggKAGT8NcuBzaDgCuE3IOtm3+lCmOA1D9YVMycRgGIHsyQhrM/UABCI q8uMcfI1GAJMRgLKdarX6Nt0o9EpuiUzc0n+0C2CCIVTUJMvhiEkdEh9wdWngN7y5188 o6KqWf3E9a9cyAoZ8Hk2Y46RzsNfetfbVF66SRR1JBsoe/YmkDwNVzA4KkEhHzDgQp9e VHKQQSAe4C+g3wvXmvEKrACI/wBtJwp5m0fj+dJjjF+skxHNm1Imf07PZPEvgXrqaFk6 8lQXOvUF16PtRcxCjCOMS1bJjjam7Y+R9qKwLn/AJgB5dzwgweVM1cNsGpwsEmY4GBxQ wkjQ== X-Gm-Message-State: AOJu0YxfeclX40ahDzjlnZqwwko0kzDTSzC6abLLSDvP4ZDe9JiA6/ug lsXu2UF1j1BvU1MNWLiLcgHGPZPVm2cRE1J7XgLK1hDtHIVQfqJMwWI2l/nujNHwqlsZmpAYtPX w X-Google-Smtp-Source: AGHT+IG0HAXq+/Kyt3FOKyc+HbxDdi+vVJhaEt66PErUYRlr/rbLnZogO6kWz/mzcmy+ZAsy0wtPtA== X-Received: by 2002:a05:6512:398c:b0:539:979e:8952 with SMTP id 2adb3069b0e04-539a07a8e62mr3960443e87.59.1727957620551; Thu, 03 Oct 2024 05:13:40 -0700 (PDT) Received: from localhost.localdomain ([2a01:599:11c:96e4:28c8:f563:d9da:c488]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99104c6d1esm78088066b.189.2024.10.03.05.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2024 05:13:40 -0700 (PDT) From: Roman Scherer Date: Thu, 3 Oct 2024 14:13:32 +0200 Message-ID: <2858a7b9fa0f064f3dc8130a6e786828ce7206ee.1727957293.git.roman@burningswell.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/build/image.scm (make-btrfs-image): New variable. * gnu/system/image.scm (system-disk-image): Support btrfs. Change-Id: I80a5b52ec478ce5927d6208e324cbb70282c647a --- doc/guix.texi | 2 +- gnu/build/image.scm | 19 +++++++++++++++++++ gnu/system/image.scm | 8 ++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 87904761f0..34970fa398 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -47910,7 +47910,7 @@ partition Reference The partition file system as a string, defaulting to @code{"ext4"}. The supported values are @code{"vfat"}, @code{"fat16"}, @code{"fat32"}, -and @code{"ext4"}. +@code{"btrfs"}, and @code{"ext4"}. @code{"vfat"}, @code{"fat16"}, and @code{"fat32"} partitions without the @code{'esp} flag are by default LBA compatible. diff --git a/gnu/build/image.scm b/gnu/build/image.scm index 50518585f8..2332b72b17 100644 --- a/gnu/build/image.scm +++ b/gnu/build/image.scm @@ -73,6 +73,23 @@ (define (estimate-partition-size root) (max (ash 1 20) (* 1.25 (file-size root)))) +(define* (make-btrfs-image partition target root) + "Handle the creation of BTRFS partition images. See +'make-partition-image'." + (let ((size (partition-size partition)) + (fs-options (partition-file-system-options partition)) + (label (partition-label partition)) + (uuid (partition-uuid partition))) + (apply invoke + `("fakeroot" "mkfs.btrfs" "-r" ,root + "-L" ,label + ,@(if uuid + `("-U" ,(uuid->string uuid)) + '()) + "--shrink" + ,@fs-options + ,target)))) + (define* (make-ext-image partition target root #:key (owner-uid 0) @@ -141,6 +158,8 @@ (define* (make-partition-image partition-sexp target root) (let* ((partition (sexp->partition partition-sexp)) (type (partition-file-system partition))) (cond + ((string=? "btrfs" type) + (make-btrfs-image partition target root)) ((string-prefix? "ext" type) (make-ext-image partition target root)) ((or (string=? type "vfat") (string=? type "fat16")) diff --git a/gnu/system/image.scm b/gnu/system/image.scm index b0c96c60f0..af0f3eb354 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -402,7 +402,8 @@ (define* (system-disk-image image (file-system (partition-file-system partition))) (cond ((member 'esp flags) "0xEF") - ((string-prefix? "ext" file-system) "0x83") + ((or (string=? file-system "btrfs") + (string-prefix? "ext" file-system)) "0x83") ((or (string=? file-system "vfat") (string=? file-system "fat16")) "0x0E") ((string=? file-system "fat32") "0x0C") @@ -421,7 +422,8 @@ (define* (system-disk-image image (file-system (partition-file-system partition))) (cond ((member 'esp flags) "U") - ((string-prefix? "ext" file-system) "L") + ((or (string=? file-system "btrfs") + (string-prefix? "ext" file-system)) "L") ((or (string=? file-system "vfat") (string=? file-system "fat16") (string=? file-system "fat32")) "F") @@ -453,6 +455,8 @@ (define* (system-disk-image image (let ((initializer (or #$(partition-initializer partition) initialize-root-partition)) (inputs '#+(cond + ((string=? type "btrfs") + (list btrfs-progs fakeroot)) ((string-prefix? "ext" type) (list e2fsprogs fakeroot)) ((or (string=? type "vfat")