From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.weber@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id EC876911F7
 for <pve-devel@lists.proxmox.com>; Mon,  2 Oct 2023 17:15:43 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id C624919ECE
 for <pve-devel@lists.proxmox.com>; Mon,  2 Oct 2023 17:15:13 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS
 for <pve-devel@lists.proxmox.com>; Mon,  2 Oct 2023 17:15:12 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 080C641B82
 for <pve-devel@lists.proxmox.com>; Mon,  2 Oct 2023 17:15:12 +0200 (CEST)
Message-ID: <327a34bb-db3a-a1e7-4df2-37d9840b1882@proxmox.com>
Date: Mon, 2 Oct 2023 17:15:11 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.15.1
Content-Language: en-US
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Stoiko Ivanov <s.ivanov@proxmox.com>
References: <20230928140533.653796-1-s.ivanov@proxmox.com>
From: Friedrich Weber <f.weber@proxmox.com>
In-Reply-To: <20230928140533.653796-1-s.ivanov@proxmox.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 1.403 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 NICE_REPLY_A           -3.058 Looks like a legit reply (A)
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: Re: [pve-devel] [PATCH installer] install: install correct grub
 metapackage for the current boot-mode
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 02 Oct 2023 15:15:44 -0000

Tested-by: Friedrich Weber <f.weber@proxmox.com>

Tested patched ISO provided by Stoiko:
* installed in legacy VM
** checked that `grub-pc` is installed
** re-installing it prints "Installing for i386-pc platform"
* installed in UEFI VM
** checked that `grub-efi-amd64` is installed
** re-installing it prints "Installing for x86_64-efi platform" and
updates the mtime of /boot/efi/EFI/proxmox/grubx64.efi

On 28/09/2023 16:05, Stoiko Ivanov wrote:
> grub packages in debian split between:
> * meta-packages, which handles (among other things) the reinstalling
>   grub to the actual device/ESP in case of a version upgrade (grub-pc,
>   grub-efi-amd64)
> * bin-packages, which contain the actual boot-loaders
> The bin-packages can coexist on a system, but the meta-package
> conflict with each other (didn't check why, but I don't see a hard
> conflict on a quick glance)
> 
> Currently our ISO installs grub-pc unconditionally (and both bin
> packages, since we install the legacy bootloader also on uefi-booted
> systems). This results in uefi-systems not getting a new grub
> installed automatically upon upgrade.
> 
> Reported in our community-forum from users who upgraded to PVE 8.0,
> and still run into an issue fixed in grub for bookworm:
> https://forum.proxmox.com/threads/.123512/
> 
> Reproduced and analyzed by Friedrich.
> 
> This patch changes the installer, to install the meta-package fitting
> for the boot-mode.
> 
> We do not set the debconf variable install_devices, because in my
> tests a plain debian installed in uefi mode has this set, and a
> `grep -ri install_devices /var/lib/dpkg/info` yields only results with
> grub-pc.
> 
> Reported-by: Friedrich Weber <f.weber@proxmox.com>
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
> quickly tested by building an ISO (with the necessary modifications to
> ship both packages as .deb) and installing in legacy mode and uefi mode
> once.
>  Proxmox/Install.pm | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/Proxmox/Install.pm b/Proxmox/Install.pm
> index 1117fc4..d775ac0 100644
> --- a/Proxmox/Install.pm
> +++ b/Proxmox/Install.pm
> @@ -1057,6 +1057,12 @@ _EOD
>  	    chomp;
>  	    my $path = $_;
>  	    my ($deb) = $path =~ m/${proxmox_pkgdir}\/(.*\.deb)/;
> +
> +	    # the grub-pc/grub-efi-amd64 packages (w/o -bin) are the ones actually updating grub
> +	    # upon upgrade - and conflict with each other - install the fitting one only
> +	    next if ($deb =~ /grub-pc_/ && $run_env->{boot_type} ne 'bios');
> +	    next if ($deb =~ /grub-efi-amd64_/ && $run_env->{boot_type} ne 'efi');
> +
>  	    update_progress($count/$pkg_count, 0.5, 0.75, "extracting $deb");
>  	    print STDERR "extracting: $deb\n";
>  	    syscmd("chroot $targetdir dpkg $dpkg_opts --force-depends --no-triggers --unpack /tmp/pkg/$deb") == 0