Fri Mar 06 06:33:30 2020: Request 132055 was acted upon.
Transaction: Correspondence added by RSCHUPP
       Queue: PAR-Packer
     Subject: PodStrip filter corrupts __FILE__ in modules
   Broken in: (no value)
    Severity: (no value)
       Owner: Nobody
  Requestors: db...@cpan.org
      Status: open
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=132055 >


On 2020-03-05 11:22:46, DBOOK wrote:
> On Thu Mar 05 03:31:08 2020, RSCHUPP wrote:
> FWIW, the distribution that ran into this problem is Mojolicious. It
> uses the path to modules to find its bundled resource files in several
> places.

The explicit use of __FILE__ in Mojo::Util is easily fixed.
The implicit use via "(caller)[1]" in Mojo::File is a bit trickier.

Does the attched patch help?

Cheers, Roderich

diff --git a/lib/PAR/Filter/PatchContent.pm b/lib/PAR/Filter/PatchContent.pm
index d261f03..c23fb66 100644
--- a/lib/PAR/Filter/PatchContent.pm
+++ b/lib/PAR/Filter/PatchContent.pm
@@ -30,6 +30,16 @@ sub PATCH_CONTENT () { +{
         'File::Spec->catfile(dirname(__FILE__),' =>
         'File::Spec->catfile($ENV{PAR_TEMP}, qw(inc lib MIME),',
     ],
+    'Mojo/File.pm' => [
+        'sub curfile { __PACKAGE__->new(Cwd::realpath((caller)[1])) }' => 
+        'sub curfile { my $fn = (caller)[1];
+             $fn = catfile($ENV{PAR_TEMP}, qw(inc lib), $fn) unless file_name_is_absolute($fn);
+             return __PACKAGE__->new(Cwd::realpath($fn)) }',
+    ],
+    'Mojo/Util.pm' => [
+        'File::Spec->catfile(dirname(__FILE__),' =>
+        'File::Spec->catfile($ENV{PAR_TEMP}, qw(inc lib Mojo),',
+    ],
     'Mozilla/CA.pm' => [
         'File::Spec->catfile(dirname(__FILE__), "CA", "cacert.pem")' =>
         'File::Spec->catfile($ENV{PAR_TEMP}, qw(inc lib Mozilla CA cacert.pem))',

Reply via email to