2017-01-04 02:26:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Fetch the current 3.x version from the downloads site API
|
|
|
|
$ch = curl_init();
|
|
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
curl_setopt($ch, CURLOPT_URL, 'https://downloads.joomla.org/api/v1/latest/cms');
|
|
|
|
|
|
|
|
$result = curl_exec($ch);
|
|
|
|
|
|
|
|
curl_close($ch);
|
|
|
|
|
|
|
|
if ($result === false)
|
|
|
|
{
|
|
|
|
echo 'Could not fetch version data, please check your connection.' . PHP_EOL;
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
$data = json_decode($result, true);
|
|
|
|
|
|
|
|
foreach ($data['branches'] as $branch)
|
|
|
|
{
|
|
|
|
if ($branch['branch'] === 'Joomla! 3')
|
|
|
|
{
|
|
|
|
$version = $branch['version'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($version))
|
|
|
|
{
|
|
|
|
echo 'Joomla! 3.x version data not included in API response.' . PHP_EOL;
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
$urlVersion = str_replace('.', '-', $version);
|
|
|
|
|
2018-02-09 00:07:04 +00:00
|
|
|
$filename = "Joomla_$version-Stable-Full_Package.tar.bz2";
|
2017-01-04 02:26:38 +00:00
|
|
|
|
|
|
|
// Fetch the SHA1 signature for the file
|
|
|
|
$ch = curl_init();
|
|
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
2018-01-30 17:41:09 +00:00
|
|
|
curl_setopt($ch, CURLOPT_URL, "https://downloads.joomla.org/api/v1/signatures/cms/$urlVersion");
|
2017-01-04 02:26:38 +00:00
|
|
|
|
|
|
|
$result = curl_exec($ch);
|
|
|
|
|
|
|
|
curl_close($ch);
|
|
|
|
|
|
|
|
if ($result === false)
|
|
|
|
{
|
|
|
|
echo 'Could not fetch signature data, please check your connection.' . PHP_EOL;
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
$data = json_decode($result, true);
|
|
|
|
|
|
|
|
foreach ($data['files'] as $file)
|
|
|
|
{
|
|
|
|
if ($file['filename'] === $filename)
|
|
|
|
{
|
|
|
|
$signature = $file['sha1'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($signature))
|
|
|
|
{
|
2018-02-09 00:07:04 +00:00
|
|
|
echo 'tar.bz2 file SHA1 signature not included in API response.' . PHP_EOL;
|
2017-01-04 02:26:38 +00:00
|
|
|
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2018-02-12 23:38:02 +00:00
|
|
|
$phpVersions = [];
|
2018-02-14 01:13:24 +00:00
|
|
|
$platforms = ['apache', 'fpm', 'fpm-alpine'];
|
2018-02-12 23:38:02 +00:00
|
|
|
|
|
|
|
/** @var DirectoryIterator $dir */
|
|
|
|
foreach (new DirectoryIterator(__DIR__) as $dir)
|
|
|
|
{
|
|
|
|
if (substr($dir->getFilename(), 0, 3) === 'php')
|
|
|
|
{
|
|
|
|
$phpVersions[] = $dir->getFilename();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($phpVersions as $phpVersion)
|
2017-01-04 02:26:38 +00:00
|
|
|
{
|
2018-02-12 23:38:02 +00:00
|
|
|
foreach ($platforms as $platform)
|
|
|
|
{
|
|
|
|
$dockerfile = __DIR__ . "/$phpVersion/$platform/Dockerfile";
|
2017-01-04 02:26:38 +00:00
|
|
|
|
2018-02-12 23:38:02 +00:00
|
|
|
$fileContents = file_get_contents($dockerfile);
|
|
|
|
$fileContents = preg_replace('#ENV JOOMLA_VERSION [^ ]*\n#', "ENV JOOMLA_VERSION $version\n", $fileContents);
|
|
|
|
$fileContents = preg_replace('#ENV JOOMLA_SHA1 [^ ]*\n#', "ENV JOOMLA_SHA1 $signature\n\n", $fileContents);
|
2017-01-04 02:26:38 +00:00
|
|
|
|
2018-02-12 23:38:02 +00:00
|
|
|
file_put_contents($dockerfile, $fileContents);
|
2017-01-04 02:26:38 +00:00
|
|
|
|
2018-02-12 23:38:02 +00:00
|
|
|
// To make management easier, we use these files for all variants
|
|
|
|
copy(__DIR__ . '/docker-entrypoint.sh', __DIR__ . "/$phpVersion/$platform/docker-entrypoint.sh");
|
|
|
|
copy(__DIR__ . '/makedb.php', __DIR__ . "/$phpVersion/$platform/makedb.php");
|
|
|
|
}
|
2017-01-04 02:26:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo 'Dockerfile variants updated' . PHP_EOL;
|