Source: grub2
Severity: normal
Tags: patch
User: [email protected]
Usertags: randomness
X-Debbugs-Cc: [email protected]

The debian/platform-subst script used to generate .postinst for grub-xen
uses readdir to determine which platform to embed. The directory
ordering may not be deterministic, and can result in differences between
the resulting .postinst script. (/boot/grub/i386-xen_pvh/core.img
vs. /boot/grub/i386-xen/core.img):

  
https://reproduce.debian.net/amd64/api/v1/builds/153376/artifacts/383901/diffoscope

The attached patch sorts the list of platforms before picking the first
one, so it can at least pick consistently. Perhaps there is a more
elegant way to pull this off, but I believe this ought to work. :)

live well,
  vagrant
From 2aed9730e418f2def8abb11310b984d98272a8fa Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <[email protected]>
Date: Sun, 31 May 2026 22:10:36 -0700
Subject: [PATCH] debian/platform-subst: Use sorted list of cpu_platforms.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Without sorting the readdir output, the platform order may come out
non-deterministically:

--- /srv/rebuilderd/tmp/rebuilderdLk2QMC/inputs/grub-xen_2.14-2_amd64.deb
+++ /srv/rebuilderd/tmp/rebuilderdLk2QMC/out/grub-xen_2.14-2_amd64.deb
...
│ │ ├── ./postinst
│ │ │ @@ -335,15 +335,15 @@
│ │ │
│ │ │      case grub-xen in
│ │ │        grub-pc)
│ │ │          if running_in_container; then
│ │ │            # Skip grub-install in containers.
│ │ │            :
│ │ │          elif test -e /boot/grub/core.img || \
│ │ │ -             test -e /boot/grub/i386-xen_pvh/core.img; then
│ │ │ +             test -e /boot/grub/i386-xen/core.img; then
---
 debian/platform-subst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/debian/platform-subst b/debian/platform-subst
index 436ffca52..003d1839e 100755
--- a/debian/platform-subst
+++ b/debian/platform-subst
@@ -14,9 +14,10 @@ die "no package specified\n" unless exists $subst{PACKAGE};
 my $grub_dir_path = "debian/tmp-$package/usr/lib/grub";
 opendir my $grub_dir, $grub_dir_path or die "can't opendir $grub_dir_path: $!";
 my @cpu_platforms = grep { !/^\./ } readdir $grub_dir;
+my @cpu_platforms_sorted = sort @cpu_platforms;
 closedir $grub_dir;
 
-$subst{FIRST_CPU_PLATFORM} = $cpu_platforms[0];
+$subst{FIRST_CPU_PLATFORM} = $cpu_platforms_sorted[0];
 
 sub emit ($) {
 	my $line = shift;
-- 
2.47.3

Attachment: signature.asc
Description: PGP signature

Reply via email to