From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 3957A7BDF9; Wed, 28 Sep 2022 14:03:09 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 496) id 6A6997BDEE; Wed, 28 Sep 2022 14:03:06 +0000 (UTC) Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by atuin.qyliss.net (Postfix) with ESMTPS id A363F7BDED for ; Wed, 28 Sep 2022 14:03:03 +0000 (UTC) Received: by mail-lf1-x12e.google.com with SMTP id s6so20503016lfo.7 for ; Wed, 28 Sep 2022 07:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unikie.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=ktjL2bUIpqwEsIvGr1Eeda2bT4fHE2aU4W19cad2PKY=; b=eiqKmH2dhKgr1t++N9qBIPis8VIm9rshgqUnv8y0kKqPZHGexQyrMca2838c1EIyTc xx1d2H4b33buXOQRGGXuMahRUwCGxSsgSHJjkAakx0gK/J0rOgMtYacw6l/wto2D3k35 Eg9p7krUBHJzFfY+H19y697lQx0TZOpptAKDJfMDMZUo83LQedq8hu4RlbI94u9isGBS sT6v+mqextRRdPA+W1N+qkHvuDe5D068WAaqV7ta0sVWbwuLwFRzSp/pTP6wVHeZYtwH nEIloLg6RVNU/j1mC7k/Ji7uHUe7E1I5BG9U0kX2dsrQk1LNEQfzHOiZ6iagE6BuY3p7 72/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=ktjL2bUIpqwEsIvGr1Eeda2bT4fHE2aU4W19cad2PKY=; b=M4yZ5NXboRG5fga8DrL9o8is6evwX+ZxTI9vdKRcx8U3MWdMSGFigTT9C8bHO8vhFL lLrH3scrw0xNzFbG+bWOHvx1N0NmjxXlcLEjkEr5Fr0wbNcfHdwUN0W1wT52R0xlOxZN 2GWGvzlr+4zvV/s0qw140na8G+p0vpr1oxI/N5Swva6K8ft1Z0h/WxUDCXZmNt9fGS1h Omx43eBzEG6aG0dyPCwGxboEQLeLmxmoQfItqHF9ireySWq8h6dzL2lp9aE5TGRh66u4 i9S/Fw69COjqDZIgnLHO1sejpsnlyplFHXTAYqW1BsH3guf/3De3jcLH1PhnhrgBxO3v CMIQ== X-Gm-Message-State: ACrzQf2GfjdF1CfAXnad5aCjt6kkIVRPDK4z3o4ty8TBTPK0/btYMoUH UG8gaZd0JzdXaCMcm27VolQ1qFy2lUPF5v9S X-Google-Smtp-Source: AMsMyM42vJSAY70GMN4ichRFzEZRfY85AhiZQeaNsnzVm+N8Y88tj+FUb0pR/XvDV+46bsc2AvjcHQ== X-Received: by 2002:a05:6512:2592:b0:49c:53de:7eb8 with SMTP id bf18-20020a056512259200b0049c53de7eb8mr12698104lfb.401.1664373781594; Wed, 28 Sep 2022 07:03:01 -0700 (PDT) Received: from localhost.localdomain ([109.204.204.138]) by smtp.gmail.com with ESMTPSA id r1-20020ac25a41000000b00499fe9ce5f2sm482708lfn.175.2022.09.28.07.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 07:03:01 -0700 (PDT) From: Ivan Nikolaenko To: devel@spectrum-os.org Subject: [PATCH] scripts/make-gpt.sh: make GPT offset configurable Date: Wed, 28 Sep 2022 17:02:39 +0300 Message-Id: <20220928140239.2380361-1-ivan.nikolaenko@unikie.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: CBMVRGY33KDMHH6WCO3OMUNUWYOE7LZI X-Message-ID-Hash: CBMVRGY33KDMHH6WCO3OMUNUWYOE7LZI X-MailFrom: ivan.nikolaenko@unikie.com X-Mailman-Rule-Hits: header-match-devel.spectrum-os.org-0 X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1 CC: Ivan Nikolaenko X-Mailman-Version: 3.3.5 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: These changes can be used in an external configuration layer as follows: overlays = [ (self: super: { gptOffset = 9437184; }) ]; Signed-off-by: Ivan Nikolaenko --- This patch is not a solution but just a proposal about how things can be done. There is at least one another way of doing this (having our own make-gpt.sh script), but I thought that editing of the current one is better way. Also I don't know should we also consider other images and rootfs be fixed this way. img/live/Makefile | 3 ++- img/live/default.nix | 1 + scripts/make-gpt.sh | 22 ++++++++++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/img/live/Makefile b/img/live/Makefile index 9815c88..5a29156 100644 --- a/img/live/Makefile +++ b/img/live/Makefile @@ -19,7 +19,8 @@ build/live.img: $(SCRIPTS)/format-uuid.sh $(SCRIPTS)/make-gpt.sh build/boot.fat build/boot.fat:c12a7328-f81f-11d2-ba4b-00a0c93ec93b \ build/rootfs.verity.superblock:2c7357ed-ebd2-46d9-aec1-23d437ec2bf5:$$($(SCRIPTS)/format-uuid.sh "$$(dd if=build/rootfs.verity.roothash bs=32 skip=1 count=1 status=none)") \ $(ROOT_FS):4f68bce3-e8cd-4db1-96e7-fbcaf984b709:$$($(SCRIPTS)/format-uuid.sh "$$(head -c 32 build/rootfs.verity.roothash)") \ - $(EXT_FS):9293e1ff-cee4-4658-88be-898ec863944f + $(EXT_FS):9293e1ff-cee4-4658-88be-898ec863944f \ + --gptoffset=$(GPT_OFFSET) mv $@.tmp $@ build/spectrum.conf: build/rootfs.verity.roothash diff --git a/img/live/default.nix b/img/live/default.nix index 5461384..c529206 100644 --- a/img/live/default.nix +++ b/img/live/default.nix @@ -34,6 +34,7 @@ stdenvNoCC.mkDerivation { KERNEL = "${rootfs.kernel}/${stdenv.hostPlatform.linux-kernel.target}"; ROOT_FS = rootfs; SYSTEMD_BOOT_EFI = "${systemd}/lib/systemd/boot/efi/systemd-bootx64.efi"; + GPT_OFFSET=pkgs.gptOffset or null; buildFlags = [ "build/live.img" ]; makeFlags = [ "SCRIPTS=${scripts}" ]; diff --git a/scripts/make-gpt.sh b/scripts/make-gpt.sh index 56076d3..e8dd067 100755 --- a/scripts/make-gpt.sh +++ b/scripts/make-gpt.sh @@ -41,8 +41,25 @@ shift nl=$'\n' table="label: gpt" -# Keep 1MiB free at the start, and 1MiB free at the end. -gptBytes=$TWO_MiB +TEMP=`getopt -o g:: --long gptoffset:: -- "$@"` +eval set -- "$TEMP" + +while true ; do + case "$1" in + -g|--gptoffset) + gptBytes=$2 ; shift 2 ;; + --) shift ; break ;; + *) break ;; + esac +done + +if [ -z "$gptBytes" ] +then + gptBytes=${TWO_MiB} +fi + +FIRST_LBA="$(expr ${gptBytes} / 1024)" + for partition; do sizeMiB="$(sizeMiB "$(partitionPath "$partition")")" table="$table${nl}size=${sizeMiB}MiB,$(awk -f "$scriptsDir/sfdisk-field.awk" -v partition="$partition")" @@ -52,6 +69,7 @@ done rm -f "$out" truncate -s "$gptBytes" "$out" sfdisk "$out" <