-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.php
More file actions
53 lines (42 loc) · 1.58 KB
/
build.php
File metadata and controls
53 lines (42 loc) · 1.58 KB
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
53
<?php
$buildDir = __DIR__ . '/build';
$srcDir = __DIR__ . '/src';
$versions = include($srcDir . '/versions.php');
$tools = array_map(function($file) {
return pathinfo($file, PATHINFO_BASENAME);
}, array_filter(glob(__DIR__ . '/cli-tools/*'), function($file) {
return ! is_link($file) && strpos($file, 'update-cli-tools') === false;
}));
$allExtensions = include($srcDir . '/extensions.php');
foreach($versions as $version) {
$extensions = [];
foreach($allExtensions as $file) {
$candidates = array_map(function($file) {
return pathinfo($file, PATHINFO_BASENAME);
}, array_merge(glob($srcDir . '/' . $file), glob($srcDir . '/' . "$file:*")));
usort($candidates, 'version_compare');
$max = $file . ':' . $version['version'];
$max = preg_replace('#(-cli|-fpm)$#', '', $max);
do {
$candidate = array_pop($candidates);
} while($candidate && version_compare($candidate, $max, 'gt'));
$content = trim(file_get_contents($srcDir . '/' . $candidate), " \t\n\r\0\x0B\\");
if ($content) {
$extensions[$file] = $content;
}
}
ob_start();
if (preg_match('/-cli$/', $version['version'])) {
include($srcDir . '/' . 'block.cli');
}
$cli = ob_get_clean();
ob_start();
include $srcDir . '/' . 'layout.base';
$contents = ob_get_clean();
$toDir = $buildDir . '/' . $version['version'];
if (!file_exists($toDir)) {
mkdir($toDir, 0755, true);
}
file_put_contents($toDir . '/Dockerfile', $contents);
echo "$toDir created.\n";
}