From 9b014783658e3023ed4ce75a5b679161784638ab Mon Sep 17 00:00:00 2001
From: Niko Tyni <ntyni@debian.org>
Date: Tue, 25 Oct 2022 18:27:05 +0100
Subject: [PATCH] Pre-load PerlIO::scalar before loading fatpacked modules

This is just for robustness in case PerlIO::scalar or its dependencies
somehow get included in the fatpacked bundle. See the Debian bug for a
full story of how this could happen.

Bug-Debian: https://bugs.debian.org/1022780
Bug: https://rt.cpan.org/Ticket/Display.html?id=144942

---
 lib/Object/Remote/FatNode.pm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/Object/Remote/FatNode.pm b/lib/Object/Remote/FatNode.pm
index cafc47e..fbc0c21 100644
--- a/lib/Object/Remote/FatNode.pm
+++ b/lib/Object/Remote/FatNode.pm
@@ -111,6 +111,10 @@ my $end = stripspace <<'END_END';
     return;
   }
 
+  # pre-load PerlIO::scalar which we need for loading the fatpacked code
+  # just in case it or its dependencies got inadvertently bundled
+  open(my $fh, '<', \"1");
+
   unshift @INC, sub { load_from_hash(\%fatpacked, $_[1]) };
   push @INC, sub { load_from_hash(\%fatpacked_extra, $_[1]) };
 
-- 
2.37.2

