1
|
|
|
#!/usr/bin/env php |
2
|
|
|
<?php |
3
|
|
|
|
4
|
|
|
define('BASE_DIR', realpath(__DIR__.'/..')); |
5
|
|
|
define('PHAR_FILENAME', 'pheanstalk.phar'); |
6
|
|
|
define('PHAR_FULLPATH', BASE_DIR.'/'.PHAR_FILENAME); |
7
|
|
|
|
8
|
|
|
// ---------------------------------------- |
9
|
|
|
|
10
|
|
|
reexecute_if_phar_readonly($argv); |
11
|
|
|
delete_existing_pheanstalk_phar(); |
12
|
|
|
build_pheanstalk_phar(); |
13
|
|
|
verify_pheanstalk_phar(); |
14
|
|
|
exit(0); |
15
|
|
|
|
16
|
|
|
// ---------------------------------------- |
17
|
|
|
|
18
|
|
|
// See: http://www.php.net/manual/en/phar.configuration.php#ini.phar.readonly |
19
|
|
|
function reexecute_if_phar_readonly($argv) |
20
|
|
|
{ |
21
|
|
|
if (ini_get('phar.readonly') && !in_array('--ignore-readonly', $argv)) { |
22
|
|
|
$command = sprintf( |
23
|
|
|
'php -d phar.readonly=0 %s --ignore-readonly', |
24
|
|
|
implode($argv, ' ') |
25
|
|
|
); |
26
|
|
|
|
27
|
|
|
echo "Phar configured readonly in php.ini; attempting to re-execute:\n"; |
28
|
|
|
echo "$command\n"; |
29
|
|
|
|
30
|
|
|
passthru($command, $exitStatus); |
31
|
|
|
exit($exitStatus); |
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
function delete_existing_pheanstalk_phar() |
36
|
|
|
{ |
37
|
|
|
if (file_exists(PHAR_FULLPATH)) { |
38
|
|
|
printf("- Deleting existing %s\n", PHAR_FILENAME); |
39
|
|
|
unlink(PHAR_FULLPATH); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
function build_pheanstalk_phar() |
44
|
|
|
{ |
45
|
|
|
printf("- Building %s from %s\n", PHAR_FILENAME, BASE_DIR); |
46
|
|
|
$phar = new Phar(PHAR_FULLPATH); |
47
|
|
|
$phar->buildFromDirectory(BASE_DIR); |
48
|
|
|
$phar->setStub( |
49
|
|
|
$phar->createDefaultStub('vendor/autoload.php') |
50
|
|
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
function verify_pheanstalk_phar() |
54
|
|
|
{ |
55
|
|
|
$phar = new Phar(PHAR_FULLPATH); |
56
|
|
|
printf("- %s built with %d files.\n", PHAR_FILENAME, $phar->count()); |
57
|
|
|
} |
58
|
|
|
|