mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 14:46:56 +02:00
CoreImage: API rework
This commit is contained in:
160
.github/workflows/build-release/CoreImage.php
vendored
Normal file
160
.github/workflows/build-release/CoreImage.php
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2020 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*/
|
||||
|
||||
abstract class CoreImage
|
||||
{
|
||||
protected function create_image($exportFolder, $tempFolder, $currentVersion)
|
||||
{
|
||||
echo("[Core-Image] Scanning Dir: " . $exportFolder . "\n");
|
||||
$this->generateCurrentChecksums($exportFolder, $currentVersion);
|
||||
|
||||
echo("[Core-Image] Scanning Removed Files from Git" . "\n");
|
||||
$this->generateRemovedChecksums($tempFolder);
|
||||
}
|
||||
|
||||
protected function generateCurrentChecksums($exportFolder, $currentVersion)
|
||||
{
|
||||
$absoluteBase = realpath($exportFolder);
|
||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($exportFolder));
|
||||
|
||||
/**
|
||||
* @var $file DirectoryIterator
|
||||
*/
|
||||
foreach ($iterator as $file)
|
||||
{
|
||||
if ($file->isDir()) continue;
|
||||
|
||||
$absolutePath = $file->getRealPath();
|
||||
$relativePath = preg_replace("/^" . preg_quote($absoluteBase . "/", "/") . "/", "", $absolutePath);
|
||||
|
||||
if (empty($relativePath) || $relativePath == $absolutePath) continue;
|
||||
|
||||
$checksum = $this->checksumPath($absolutePath);
|
||||
$this->insertChecksumIntoDatabase($relativePath, $checksum, $currentVersion);
|
||||
}
|
||||
}
|
||||
|
||||
protected function checksumPath($filename)
|
||||
{
|
||||
return $this->checksum(file_get_contents($filename));
|
||||
}
|
||||
|
||||
protected function checksum($body)
|
||||
{
|
||||
return md5(str_replace(array(chr(13), chr(10)), '', $body));
|
||||
}
|
||||
|
||||
abstract protected function insertChecksumIntoDatabase(&$relativePath, &$checksum, &$releaseVersion);
|
||||
|
||||
protected function generateRemovedChecksums($tempFolder)
|
||||
{
|
||||
$tags = $this->getGitTags();
|
||||
$timeMachineFolder = $this->prepTimeMachine($tempFolder);
|
||||
$this->generateRemovedChecksumsFromTags($tags, $timeMachineFolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getGitTags()
|
||||
{
|
||||
$stdout = '';
|
||||
OsHelper::runValidated('git tag --list ' . escapeshellarg("v*"), $stdout);
|
||||
$tags = explode("\n", trim($stdout));
|
||||
$versions = [];
|
||||
foreach ($tags as $tag)
|
||||
{
|
||||
$versions[] = preg_replace("/^v/", "", $tag);
|
||||
}
|
||||
$tags = array_combine($tags, $versions);
|
||||
unset($versions);
|
||||
uasort($tags, function ($a, $b)
|
||||
{
|
||||
return -version_compare($a, $b);
|
||||
});
|
||||
$tags = array_filter($tags, function ($version)
|
||||
{
|
||||
return !preg_match("/[a-z]/i", $version);
|
||||
});
|
||||
return $tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $tempFolder
|
||||
* @param $repoFolder
|
||||
* @return string
|
||||
*/
|
||||
protected function prepTimeMachine($tempFolder)
|
||||
{
|
||||
$timeMachineFolder = $tempFolder . "/git_time_machine/";
|
||||
OsHelper::runValidated('mkdir -p ' . escapeshellarg($timeMachineFolder));
|
||||
OsHelper::runValidated('git rev-parse --show-toplevel', $repoFolder);
|
||||
$repoFolder = realpath(trim($repoFolder) . "/.git");
|
||||
OsHelper::runValidated(
|
||||
'cp -a ' .
|
||||
escapeshellarg($repoFolder) .
|
||||
' ' .
|
||||
escapeshellarg($timeMachineFolder)
|
||||
);
|
||||
return $timeMachineFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $tags
|
||||
* @param $timeMachineFolder
|
||||
* @return mixed
|
||||
*/
|
||||
protected function generateRemovedChecksumsFromTags($tags, $timeMachineFolder)
|
||||
{
|
||||
foreach ($tags as $tag => $version)
|
||||
{
|
||||
$stdout = '';
|
||||
OsHelper::runValidated(
|
||||
'git --no-pager diff --no-renames --name-only --diff-filter D ' . escapeshellarg($tag),
|
||||
$stdout
|
||||
);
|
||||
$removedFiles = explode("\n", trim($stdout));
|
||||
OsHelper::runValidated(
|
||||
'git -C ' . escapeshellarg($timeMachineFolder) . ' ' .
|
||||
'checkout ' . escapeshellarg($tag)
|
||||
);
|
||||
foreach ($removedFiles as $removedFilePath)
|
||||
{
|
||||
$checksum = $this->checksumPath($timeMachineFolder . '/' . $removedFilePath);
|
||||
$this->insertChecksumIntoDatabase($removedFilePath, $checksum, $version);
|
||||
}
|
||||
}
|
||||
|
||||
OsHelper::runValidated('rm -rf ' . escapeshellarg($timeMachineFolder));
|
||||
}
|
||||
|
||||
|
||||
protected function generateStub()
|
||||
{
|
||||
$data = "<?php\n";
|
||||
$data .= "/*\n";
|
||||
$data .= "+ ----------------------------------------------------------------------------+\n";
|
||||
$data .= "| e107 website system\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| Copyright (C) 2008-" . date("Y") . " e107 Inc. \n";
|
||||
$data .= "| http://e107.org\n";
|
||||
// $data .= "| jalist@e107.org\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| Released under the terms and conditions of the\n";
|
||||
$data .= "| GNU General Public License (http://gnu.org).\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| \$URL$\n";
|
||||
$data .= "| \$Id$\n";
|
||||
$data .= "+----------------------------------------------------------------------------+\n";
|
||||
$data .= "*/\n\n";
|
||||
$data .= "if (!defined('e107_INIT')) { exit; }\n\n";
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
143
.github/workflows/build-release/JsonCoreImage.php
vendored
143
.github/workflows/build-release/JsonCoreImage.php
vendored
@@ -9,23 +9,17 @@
|
||||
*/
|
||||
|
||||
require_once("OsHelper.php");
|
||||
require_once("CoreImage.php");
|
||||
|
||||
class JsonCoreImage
|
||||
class JsonCoreImage extends CoreImage
|
||||
{
|
||||
private $checksums = [];
|
||||
|
||||
public function __construct($exportFolder, $tempFolder, $currentVersion, $imageFile)
|
||||
{
|
||||
$this->create_image($exportFolder, $tempFolder, $currentVersion, $imageFile);
|
||||
}
|
||||
$this->create_image($exportFolder, $tempFolder, $currentVersion);
|
||||
|
||||
function create_image($exportFolder, $tempFolder, $currentVersion, $imageFile)
|
||||
{
|
||||
echo("[Core-Image] Scanning Dir: " . $exportFolder . "\n");
|
||||
$carry = $this->generateCurrentChecksums($exportFolder, $currentVersion);
|
||||
|
||||
echo("[Core-Image] Scanning Removed Files from Git" . "\n");
|
||||
$result = $this->generateRemovedChecksums($tempFolder, $carry);
|
||||
|
||||
$json_result = json_encode($result, JSON_PRETTY_PRINT);
|
||||
$json_result = json_encode($this->checksums, JSON_PRETTY_PRINT);
|
||||
$json_string_result = var_export($json_result, true);
|
||||
$data = $this->generateStub();
|
||||
$data .= '$core_image = ' . $json_string_result . ';';
|
||||
@@ -36,102 +30,24 @@ class JsonCoreImage
|
||||
|
||||
protected function generateCurrentChecksums($exportFolder, $currentVersion)
|
||||
{
|
||||
$absoluteBase = realpath($exportFolder);
|
||||
if (!is_dir($absoluteBase)) return false;
|
||||
parent::generateCurrentChecksums($exportFolder, $currentVersion);
|
||||
ksort($this->checksums);
|
||||
}
|
||||
|
||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($exportFolder));
|
||||
$checksums = [];
|
||||
protected function generateRemovedChecksums($tempFolder)
|
||||
{
|
||||
parent::generateRemovedChecksums($tempFolder);
|
||||
ksort($this->checksums);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var $file DirectoryIterator
|
||||
* @inheritDoc
|
||||
*/
|
||||
foreach ($iterator as $file)
|
||||
protected function insertChecksumIntoDatabase(&$relativePath, &$checksum, &$version)
|
||||
{
|
||||
if ($file->isDir()) continue;
|
||||
|
||||
$absolutePath = $file->getRealPath();
|
||||
$relativePath = preg_replace("/^" . preg_quote($absoluteBase . "/", "/") . "/", "", $absolutePath);
|
||||
|
||||
if (empty($relativePath) || $relativePath == $absolutePath) continue;
|
||||
|
||||
$checksum = $this->checksumPath($absolutePath);
|
||||
$item = self::array_get($checksums, $relativePath, []);
|
||||
if (!in_array($checksum, $item)) $item["v{$currentVersion}"] = $checksum;
|
||||
self::array_set($checksums, $relativePath, $item);
|
||||
}
|
||||
|
||||
ksort($checksums);
|
||||
return $checksums;
|
||||
}
|
||||
|
||||
protected function checksumPath($filename)
|
||||
{
|
||||
return $this->checksum(file_get_contents($filename));
|
||||
}
|
||||
|
||||
protected function checksum($body)
|
||||
{
|
||||
return md5(str_replace(array(chr(13), chr(10)), '', $body));
|
||||
}
|
||||
|
||||
protected function generateRemovedChecksums($tempFolder, $carry)
|
||||
{
|
||||
$checksums = $carry;
|
||||
|
||||
$stdout = '';
|
||||
OsHelper::runValidated('git tag --list ' . escapeshellarg("v*"), $stdout);
|
||||
$tags = explode("\n", trim($stdout));
|
||||
$versions = [];
|
||||
foreach ($tags as $tag)
|
||||
{
|
||||
$versions[] = preg_replace("/^v/", "", $tag);
|
||||
}
|
||||
$tags = array_combine($tags, $versions);
|
||||
unset($versions);
|
||||
uasort($tags, function ($a, $b)
|
||||
{
|
||||
return -version_compare($a, $b);
|
||||
});
|
||||
$tags = array_filter($tags, function ($version)
|
||||
{
|
||||
return !preg_match("/[a-z]/i", $version);
|
||||
});
|
||||
|
||||
$timeMachineFolder = $tempFolder . "/git_time_machine/";
|
||||
OsHelper::runValidated('mkdir -p ' . escapeshellarg($timeMachineFolder));
|
||||
OsHelper::runValidated('git rev-parse --show-toplevel', $repo_folder);
|
||||
$repo_folder = realpath(trim($repo_folder) . "/.git");
|
||||
OsHelper::runValidated(
|
||||
'cp -a ' .
|
||||
escapeshellarg($repo_folder) .
|
||||
' ' .
|
||||
escapeshellarg($timeMachineFolder)
|
||||
);
|
||||
|
||||
foreach ($tags as $tag => $version)
|
||||
{
|
||||
OsHelper::runValidated(
|
||||
'git --no-pager diff --no-renames --name-only --diff-filter D ' . escapeshellarg($tag),
|
||||
$stdout
|
||||
);
|
||||
$removedFiles = explode("\n", trim($stdout));
|
||||
OsHelper::runValidated(
|
||||
'git -C ' . escapeshellarg($timeMachineFolder) . ' ' .
|
||||
'checkout ' . escapeshellarg($tag)
|
||||
);
|
||||
foreach ($removedFiles as $removedFilePath)
|
||||
{
|
||||
$checksum = $this->checksumPath($timeMachineFolder . '/' . $removedFilePath);
|
||||
$item = self::array_get($checksums, $removedFilePath, []);
|
||||
$item = self::array_get($this->checksums, $relativePath, []);
|
||||
if (!in_array($checksum, $item)) $item["v{$version}"] = $checksum;
|
||||
self::array_set($checksums, $removedFilePath, $item);
|
||||
}
|
||||
}
|
||||
|
||||
OsHelper::runValidated('rm -rf ' . escapeshellarg($timeMachineFolder));
|
||||
|
||||
ksort($checksums);
|
||||
return $checksums;
|
||||
self::array_set($this->checksums, $relativePath, $item);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,27 +123,4 @@ class JsonCoreImage
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
private function generateStub()
|
||||
{
|
||||
$data = "<?php\n";
|
||||
$data .= "/*\n";
|
||||
$data .= "+ ----------------------------------------------------------------------------+\n";
|
||||
$data .= "| e107 website system\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| Copyright (C) 2008-" . date("Y") . " e107 Inc. \n";
|
||||
$data .= "| http://e107.org\n";
|
||||
// $data .= "| jalist@e107.org\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| Released under the terms and conditions of the\n";
|
||||
$data .= "| GNU General Public License (http://gnu.org).\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| \$URL$\n";
|
||||
$data .= "| \$Id$\n";
|
||||
$data .= "+----------------------------------------------------------------------------+\n";
|
||||
$data .= "*/\n\n";
|
||||
$data .= "if (!defined('e107_INIT')) { exit; }\n\n";
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
169
.github/workflows/build-release/SqlpharCoreImage.php
vendored
169
.github/workflows/build-release/SqlpharCoreImage.php
vendored
@@ -9,11 +9,25 @@
|
||||
*/
|
||||
|
||||
require_once("OsHelper.php");
|
||||
require_once("CoreImage.php");
|
||||
|
||||
class SqlpharCoreImage
|
||||
class SqlpharCoreImage extends CoreImage
|
||||
{
|
||||
/** @var PDO */
|
||||
protected $db;
|
||||
/**
|
||||
* @var PDOStatement
|
||||
*/
|
||||
private $insert_statement;
|
||||
/**
|
||||
* @var PDOStatement
|
||||
*/
|
||||
private $check_statement;
|
||||
|
||||
// Insert bindings
|
||||
private $relativePath;
|
||||
private $releaseVersion;
|
||||
private $checksum;
|
||||
|
||||
public function __construct($exportFolder, $tempFolder, $currentVersion, $imageFile)
|
||||
{
|
||||
@@ -44,6 +58,12 @@ class SqlpharCoreImage
|
||||
# LEFT JOIN versions ON versions.version_id = file_hashes.release_version
|
||||
# ORDER BY path ASC;
|
||||
|
||||
$this->check_statement = $this->db->prepare('SELECT COUNT(*) FROM file_hashes WHERE path = :path AND hash = :hash');
|
||||
$this->insert_statement = $this->bind_insert(
|
||||
$this->relativePath,
|
||||
$this->releaseVersion,
|
||||
$this->checksum);
|
||||
|
||||
$this->create_image($exportFolder, $tempFolder, $currentVersion);
|
||||
|
||||
$phar->startBuffering();
|
||||
@@ -54,108 +74,11 @@ class SqlpharCoreImage
|
||||
rename($imagePharFile, $imageFile);
|
||||
}
|
||||
|
||||
function create_image($exportFolder, $tempFolder, $currentVersion)
|
||||
{
|
||||
echo("[Core-Image] Scanning Dir: " . $exportFolder . "\n");
|
||||
$this->generateCurrentChecksums($exportFolder, $currentVersion);
|
||||
|
||||
echo("[Core-Image] Scanning Removed Files from Git" . "\n");
|
||||
$this->generateRemovedChecksums($tempFolder);
|
||||
}
|
||||
|
||||
protected function generateCurrentChecksums($exportFolder, $currentVersion)
|
||||
{
|
||||
$absoluteBase = realpath($exportFolder);
|
||||
if (!is_dir($absoluteBase)) return false;
|
||||
|
||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($exportFolder));
|
||||
|
||||
$insert_statement = $this->insert_statement($relativePath, $currentVersion, $checksum);
|
||||
$this->db->beginTransaction();
|
||||
|
||||
$this->insert_version($currentVersion);
|
||||
|
||||
/**
|
||||
* @var $file DirectoryIterator
|
||||
*/
|
||||
foreach ($iterator as $file) {
|
||||
if ($file->isDir()) continue;
|
||||
|
||||
$absolutePath = $file->getRealPath();
|
||||
$relativePath = preg_replace("/^" . preg_quote($absoluteBase . "/", "/") . "/", "", $absolutePath);
|
||||
|
||||
if (empty($relativePath) || $relativePath == $absolutePath) continue;
|
||||
|
||||
$checksum = $this->checksumPath($absolutePath);
|
||||
$insert_statement->execute();
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
}
|
||||
|
||||
protected function checksumPath($filename)
|
||||
{
|
||||
return $this->checksum(file_get_contents($filename));
|
||||
}
|
||||
|
||||
protected function checksum($body)
|
||||
{
|
||||
return md5(str_replace(array(chr(13), chr(10)), '', $body));
|
||||
}
|
||||
|
||||
protected function generateRemovedChecksums($tempFolder)
|
||||
{
|
||||
$stdout = '';
|
||||
OsHelper::runValidated('git tag --list ' . escapeshellarg("v*"), $stdout);
|
||||
$tags = explode("\n", trim($stdout));
|
||||
$versions = [];
|
||||
foreach ($tags as $tag) {
|
||||
$versions[] = preg_replace("/^v/", "", $tag);
|
||||
}
|
||||
$tags = array_combine($tags, $versions);
|
||||
unset($versions);
|
||||
uasort($tags, function ($a, $b) {
|
||||
return -version_compare($a, $b);
|
||||
});
|
||||
$tags = array_filter($tags, function ($version) {
|
||||
return !preg_match("/[a-z]/i", $version);
|
||||
});
|
||||
|
||||
$timeMachineFolder = $tempFolder . "/git_time_machine/";
|
||||
OsHelper::runValidated('mkdir -p ' . escapeshellarg($timeMachineFolder));
|
||||
OsHelper::runValidated('git rev-parse --show-toplevel', $repo_folder);
|
||||
$repo_folder = realpath(trim($repo_folder) . "/.git");
|
||||
OsHelper::runValidated(
|
||||
'cp -a ' .
|
||||
escapeshellarg($repo_folder) .
|
||||
' ' .
|
||||
escapeshellarg($timeMachineFolder)
|
||||
);
|
||||
|
||||
$insert_statement = $this->insert_statement($removedFilePath, $version, $checksum);
|
||||
$check_statement = $this->db->prepare('SELECT COUNT(*) FROM file_hashes WHERE path = :path AND hash = :hash');
|
||||
$this->db->beginTransaction();
|
||||
|
||||
foreach ($tags as $tag => $version) {
|
||||
$this->insert_version($version);
|
||||
OsHelper::runValidated(
|
||||
'git --no-pager diff --no-renames --name-only --diff-filter D ' . escapeshellarg($tag),
|
||||
$stdout
|
||||
);
|
||||
$removedFiles = explode("\n", trim($stdout));
|
||||
OsHelper::runValidated(
|
||||
'git -C ' . escapeshellarg($timeMachineFolder) . ' ' .
|
||||
'checkout ' . escapeshellarg($tag)
|
||||
);
|
||||
foreach ($removedFiles as $removedFilePath) {
|
||||
$checksum = $this->checksumPath($timeMachineFolder . '/' . $removedFilePath);
|
||||
$check_statement->execute([':path' => $removedFilePath, ':hash' => $checksum]);
|
||||
if ($check_statement->fetchColumn() == 0) $insert_statement->execute();
|
||||
}
|
||||
}
|
||||
|
||||
OsHelper::runValidated('rm -rf ' . escapeshellarg($timeMachineFolder));
|
||||
|
||||
parent::generateCurrentChecksums($exportFolder, $currentVersion);
|
||||
$this->db->commit();
|
||||
}
|
||||
|
||||
@@ -165,7 +88,7 @@ class SqlpharCoreImage
|
||||
* @param $checksum
|
||||
* @return PDOStatement
|
||||
*/
|
||||
private function insert_statement(&$relativePath, &$releaseVersion, &$checksum)
|
||||
private function bind_insert(&$relativePath, &$releaseVersion, &$checksum)
|
||||
{
|
||||
$relativePath = $relativePath ?: null;
|
||||
$releaseVersion = $releaseVersion ?: null;
|
||||
@@ -180,7 +103,7 @@ class SqlpharCoreImage
|
||||
$insert_statement->bindParam(":path", $relativePath);
|
||||
$insert_statement->bindParam(":release_version", $releaseVersion);
|
||||
$insert_statement->bindParam(":hash", $checksum);
|
||||
return $insert_statement;
|
||||
return $this->insert_statement = $insert_statement;
|
||||
}
|
||||
|
||||
private function insert_version($releaseVersion)
|
||||
@@ -191,27 +114,35 @@ class SqlpharCoreImage
|
||||
$statement->execute([$releaseVersion]);
|
||||
}
|
||||
|
||||
private function generateStub()
|
||||
protected function generateRemovedChecksums($tempFolder)
|
||||
{
|
||||
$data = "<?php\n";
|
||||
$data .= "/*\n";
|
||||
$data .= "+ ----------------------------------------------------------------------------+\n";
|
||||
$data .= "| e107 website system\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| Copyright (C) 2008-" . date("Y") . " e107 Inc. \n";
|
||||
$data .= "| http://e107.org\n";
|
||||
// $data .= "| jalist@e107.org\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| Released under the terms and conditions of the\n";
|
||||
$data .= "| GNU General Public License (http://gnu.org).\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| \$URL$\n";
|
||||
$data .= "| \$Id$\n";
|
||||
$data .= "+----------------------------------------------------------------------------+\n";
|
||||
$data .= "*/\n\n";
|
||||
$data .= "if (!defined('e107_INIT')) { exit; }\n\n";
|
||||
$this->db->beginTransaction();
|
||||
$tags = $this->getGitTags();
|
||||
foreach ($tags as $tag => $version)
|
||||
{
|
||||
$this->insert_version($version);
|
||||
}
|
||||
parent::generateRemovedChecksums($tempFolder);
|
||||
$this->db->commit();
|
||||
}
|
||||
|
||||
protected function generateStub()
|
||||
{
|
||||
$data = parent::generateStub();
|
||||
$data .= "__HALT_COMPILER();";
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function insertChecksumIntoDatabase(&$relativePath, &$checksum, &$releaseVersion)
|
||||
{
|
||||
$this->relativePath = $relativePath;
|
||||
$this->checksum = $checksum;
|
||||
$this->releaseVersion = $releaseVersion;
|
||||
$this->check_statement->execute([':path' => $relativePath, ':hash' => $checksum]);
|
||||
if ($this->check_statement->fetchColumn() == 0) $this->insert_statement->execute();
|
||||
}
|
||||
}
|
18
.github/workflows/build-release/e107_make.php
vendored
18
.github/workflows/build-release/e107_make.php
vendored
@@ -67,7 +67,7 @@ class e107Build
|
||||
exec("git describe --tags", $output, $rc);
|
||||
$gitVersion = array_pop($output);
|
||||
$verFileVersion = self::getVerFileVersion($this->gitDir . "/e107_admin/ver.php");
|
||||
$this->version = self::gitVersionToPhpVersion($gitVersion, $verFileVersion);
|
||||
$this->version = OsHelper::gitVersionToPhpVersion($gitVersion, $verFileVersion);
|
||||
|
||||
$this->validateReadme();
|
||||
}
|
||||
@@ -113,19 +113,6 @@ class e107Build
|
||||
return '0';
|
||||
}
|
||||
|
||||
private static function gitVersionToPhpVersion($gitVersion, $verFileVersion)
|
||||
{
|
||||
$verFileVersion = array_shift(explode(" ", $verFileVersion));
|
||||
$version = preg_replace("/^v/", "", $gitVersion);
|
||||
$versionSplit = explode("-", $version);
|
||||
if (count($versionSplit) > 1)
|
||||
{
|
||||
if (version_compare($verFileVersion, $versionSplit[0], '>')) $versionSplit[0] = $verFileVersion;
|
||||
$versionSplit[0] .= "dev";
|
||||
}
|
||||
return implode("-", $versionSplit);
|
||||
}
|
||||
|
||||
private function validateReadme()
|
||||
{
|
||||
//check for readme files associated with configured releases
|
||||
@@ -249,7 +236,8 @@ class e107Build
|
||||
|
||||
$zipExportFile = 'release_' . $c . ".zip";
|
||||
|
||||
$this->gitArchive($zipExportFile, $rel['since']);
|
||||
$since = isset($rel['since']) ? $rel['since'] : null;
|
||||
$this->gitArchive($zipExportFile, $since);
|
||||
|
||||
$this->gitArchiveUnzip($zipExportFile);
|
||||
|
||||
|
@@ -16,12 +16,33 @@ require_once("e_file_inspector_interface.php");
|
||||
*/
|
||||
abstract class e_file_inspector implements e_file_inspector_interface
|
||||
{
|
||||
protected $database;
|
||||
protected $currentVersion;
|
||||
private $validatedBitmask;
|
||||
|
||||
protected $defaultDirsCache;
|
||||
protected $customDirsCache;
|
||||
|
||||
/**
|
||||
* e_file_inspector constructor
|
||||
* @param string $database The database from which integrity data may be read or to which integrity data may be
|
||||
* written. This should be an URL or absolute file path for most implementations.
|
||||
*/
|
||||
public function __construct($database)
|
||||
{
|
||||
$this->database = $database;
|
||||
$this->loadDatabase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the provided database for reading or writing
|
||||
*
|
||||
* Should tolerate a non-existent database and try to create it if a write operation is executed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function loadDatabase();
|
||||
|
||||
/**
|
||||
* Check the integrity of the provided path
|
||||
*
|
||||
|
@@ -17,11 +17,21 @@ class e_file_inspector_json extends e_file_inspector
|
||||
* @param $jsonFilePath string Absolute path to the file inspector database
|
||||
*/
|
||||
public function __construct($jsonFilePath = null)
|
||||
{
|
||||
parent::__construct($jsonFilePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function loadDatabase()
|
||||
{
|
||||
global $core_image;
|
||||
if ($jsonFilePath === null) $jsonFilePath = e_ADMIN . "core_image.php";
|
||||
require($jsonFilePath);
|
||||
$this->coreImage = self::array_slash(json_decode($core_image, true));
|
||||
@include($this->database);
|
||||
$this->coreImage = json_decode($core_image, true);
|
||||
if (!is_array($this->coreImage)) $this->coreImage = [];
|
||||
$this->coreImage = self::array_slash($this->coreImage);
|
||||
if (!$this->coreImage) $this->coreImage = [];
|
||||
unset($core_image);
|
||||
}
|
||||
|
||||
|
@@ -14,13 +14,19 @@ class e_file_inspector_sqlphar extends e_file_inspector
|
||||
private $coreImage;
|
||||
|
||||
/**
|
||||
* e_file_inspector_sqlphar constructor.
|
||||
* @param $pharFilePath string Absolute path to the file inspector database
|
||||
*/
|
||||
public function __construct($pharFilePath = null)
|
||||
{
|
||||
if ($pharFilePath === null) $pharFilePath = e_ADMIN . "core_image.php";
|
||||
Phar::loadPhar($pharFilePath, "core_image.phar");
|
||||
parent::__construct($pharFilePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function loadDatabase()
|
||||
{
|
||||
Phar::loadPhar($this->database, "core_image.phar");
|
||||
$tmpFile = tmpfile();
|
||||
$tmpFilePath = stream_get_meta_data($tmpFile)['uri'];
|
||||
$this->copyUrlToResource("phar://core_image.phar/core_image.sqlite", $tmpFile);
|
||||
@@ -84,7 +90,6 @@ class e_file_inspector_sqlphar extends e_file_inspector
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Copy file to destination with low memory footprint
|
||||
* @param $source string URL of the source
|
||||
|
Reference in New Issue
Block a user