From 2aed9730e418f2def8abb11310b984d98272a8fa Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <vagrant@reproducible-builds.org>
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

