forked from spack/spack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sbang: add support for php (spack#18299)
PHP supports an initial shebang, but its comment syntax can't handle our 2-line shebangs. So, we need to embed the 2nd-line shebang comment to look like a PHP comment: <?php #!/path/to/php ?> This adds patching support to the sbang hook and support for instrumenting php shebangs. This also patches `phar`, which is a tool used to create php packages. `phar` itself has to add sbangs to those packages (as phar archives apparently contain UTF-8, as well as binary blobs), and `phar` sets a checksum based on the contents of the package. Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
- Loading branch information
Showing
5 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- spack-src/ext/phar/phar/pharcommand.inc.org 2019-12-18 01:35:53.000000000 +0900 | ||
+++ spack-src/ext/phar/phar/pharcommand.inc 2020-08-20 12:26:16.207347572 +0900 | ||
@@ -68,6 +68,12 @@ | ||
'inf' => '<bang> Hash-bang line to start the archive (e.g. #!/usr/bin/php). The hash ' | ||
.' mark itself \'#!\' and the newline character are optional.' | ||
), | ||
+ 'z' => array( | ||
+ 'typ' => 'any', | ||
+ 'val' => NULL, | ||
+ 'inf' => '<bang> Hash-bang line to start the archive for spack. The hash ' | ||
+ .' mark itself \'#!\' and the newline character are optional.' | ||
+ ), | ||
'c' => array( | ||
'typ' => 'compalg', | ||
'val' => NULL, | ||
@@ -455,7 +461,7 @@ | ||
*/ | ||
static function cli_cmd_arg_pack() | ||
{ | ||
- $args = self::phar_args('abcFhilpsxy', 'pharnew'); | ||
+ $args = self::phar_args('azbcFhilpsxy', 'pharnew'); | ||
|
||
$args[''] = array( | ||
'typ' => 'any', | ||
@@ -560,6 +566,7 @@ | ||
} | ||
|
||
$alias = $this->args['a']['val']; | ||
+ $spack_hb = $this->args['z']['val']; | ||
$hashbang = $this->args['b']['val']; | ||
$archive = $this->args['f']['val']; | ||
$hash = $this->args['h']['val']; | ||
@@ -571,6 +578,9 @@ | ||
$invregex = $this->args['x']['val']; | ||
$input = $this->args['']['val']; | ||
|
||
+ if (isset($spack_hb)) { | ||
+ $hashbang = "$spack_hb\n<?php #!$hashbang ?>"; | ||
+ } | ||
$hash = self::phar_check_hash($hash, $privkey); | ||
|
||
$phar = new Phar($archive, 0, $alias); |