diff --git a/lib/spack/spack/build_systems/perl.py b/lib/spack/spack/build_systems/perl.py index bdd1e7fda3a..28f1fc56083 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()