-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.php
52 lines (46 loc) · 1017 Bytes
/
build.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
$descriptorspec = [
0 => ["pipe", "w"], // STDIN
1 => ["file", "php://stdout", "w"], // STDOUT
2 => ["file", "php://stderr", "w"] // STDERR
];
$sh = function () {
$a = [
"/usr/lib/libphpcpp.a.2.1.1",
"/usr/lib/libphpcpp.a",
"/usr/lib/libphpcpp.so",
"/usr/lib/libphpcpp.so.2.1.1",
"/usr/lib/libphpcpp.so.2.1",
"/usr/include/phpcpp",
"/usr/include/phpcpp.h"
];
$c = true;
foreach ($a as $v) {
$c = $c && file_exists($v);
if (!$c) {
return true;
}
}
return false;
};
$commands = [
[
(!file_exists("/tmp/phpcpp")),
"wget https://api.github.com/repos/CopernicaMarketingSoftware/PHP-CPP/tarball/v2.1.2 -O /tmp/phpcpp"
],
[
($sh()),
"cd /tmp && sudo tar -xf phpcpp && cd *PHP* && make release -j 5 && sudo make install -j 5"
],
[
true,
"cd ~/repo && composer install -n --prefer-dist -vvv"
],
];
foreach($commands as $command) {
if ($command[0]) {
$proc = proc_open($command[1], $descriptorspec, $pipes);
fclose($pipes[0]);
proc_close($proc);
}
}