From 08a6577861883aefa41fd813904dc9f34c3b4dec Mon Sep 17 00:00:00 2001 From: Glenn P Johnson Date: Tue, 24 Sep 2019 21:01:12 -0500 Subject: [PATCH] Fix perl build when using Build.PL This fixes #12852 where perl builds that use Build.PL will fail when the shebang of the Build script produced from the configure step is too long. --- lib/spack/spack/build_systems/perl.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/spack/spack/build_systems/perl.py b/lib/spack/spack/build_systems/perl.py index bdd1e7fda3..28f1fc5608 100644 --- a/lib/spack/spack/build_systems/perl.py +++ b/lib/spack/spack/build_systems/perl.py @@ -10,6 +10,7 @@ from spack.directives import depends_on, extends from spack.package import PackageBase, run_after from spack.util.executable import Executable +from llnl.util.filesystem import filter_file class PerlPackage(PackageBase): @@ -80,6 +81,17 @@ def configure(self, spec, prefix): inspect.getmodule(self).perl(*options) + # It is possible that the shebang in the Build script that is created from + # Build.PL may be too long causing the build to fail. Patching the shebang + # does not happen until after install so set '/usr/bin/env perl' here in + # the Build script. + @run_after('configure') + def fix_shebang(self): + if self.build_method == 'Build.PL': + pattern = '#!{0}'.format(self.spec['perl'].command.path) + repl = '#!/usr/bin/env perl' + filter_file(pattern, repl, 'Build', backup=False) + def build(self, spec, prefix): """Builds a Perl package.""" self.build_executable()