mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-11-03 02:48:49 +03:00
Improved building plugins
This commit is contained in:
parent
66bfb04330
commit
b9ede20025
3 changed files with 39 additions and 23 deletions
|
|
@ -28,7 +28,7 @@ $keys = [
|
|||
'url',
|
||||
'version'
|
||||
];
|
||||
/*
|
||||
|
||||
$released = [
|
||||
'add-x-originating-ip-header',
|
||||
'attachments-force-open',
|
||||
|
|
@ -80,12 +80,15 @@ $released = [
|
|||
'view-ics',
|
||||
'white-list'
|
||||
];
|
||||
*/
|
||||
|
||||
foreach (glob(ROOT_DIR . '/plugins/*', GLOB_NOSORT | GLOB_ONLYDIR) as $dir) {
|
||||
if (is_file("{$dir}/index.php") && !strpos($dir, '.bak')) {
|
||||
require "{$dir}/index.php";
|
||||
$name = basename($dir);
|
||||
// if (!in_array($name, $released)) continue;
|
||||
if (!isset($options['plugins-all']) && !in_array($name, $released)) {
|
||||
echo "s {$name}\n";
|
||||
continue;
|
||||
}
|
||||
require "{$dir}/index.php";
|
||||
$class = new ReflectionClass(str_replace('-', '', $name) . 'Plugin');
|
||||
$manifest_item = [];
|
||||
foreach ($class->getConstants() as $key => $value) {
|
||||
|
|
@ -119,11 +122,16 @@ foreach (glob(ROOT_DIR . '/plugins/*', GLOB_NOSORT | GLOB_ONLYDIR) as $dir) {
|
|||
$tgz_destination = PLUGINS_DEST_DIR . "/{$name}-{$version}.tgz";
|
||||
@unlink($tgz_destination);
|
||||
@unlink("{$tar_destination}.gz");
|
||||
$tar = new PharData($tar_destination);
|
||||
$tar = new \SnappyMail\TAR($tgz_destination);
|
||||
// $tar = new PharData($tar_destination);
|
||||
$tar->buildFromDirectory('./plugins/', '/' . \preg_quote("./plugins/{$name}/", '/') . '((?!\.bak).)*$/');
|
||||
$tar->compress(Phar::GZ);
|
||||
unlink($tar_destination);
|
||||
rename("{$tar_destination}.gz", $tgz_destination);
|
||||
if ($tar instanceof PharData) {
|
||||
$tar->compress(Phar::GZ);
|
||||
unlink($tar_destination);
|
||||
rename("{$tar_destination}.gz", $tgz_destination);
|
||||
} else {
|
||||
$tar->close();
|
||||
}
|
||||
/*
|
||||
if (Phar::canWrite()) {
|
||||
$phar_destination = PLUGINS_DEST_DIR . "/{$name}.phar";
|
||||
|
|
@ -146,7 +154,7 @@ foreach (glob(ROOT_DIR . '/plugins/*', GLOB_NOSORT | GLOB_ONLYDIR) as $dir) {
|
|||
echo "- {$name} {$version}\n";
|
||||
}
|
||||
} else {
|
||||
echo "- {$name}\n";
|
||||
echo "x {$name}\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
<?php
|
||||
define('ROOT_DIR', dirname(__DIR__));
|
||||
chdir(ROOT_DIR);
|
||||
require(ROOT_DIR . '/snappymail/v/0.0.0/app/libraries/snappymail/tar.php');
|
||||
require ROOT_DIR . '/snappymail/v/0.0.0/app/libraries/snappymail/tar.php';
|
||||
|
||||
$options = getopt('', ['aur','docker','plugins','skip-gulp','debian','nextcloud','owncloud','cpanel','sign']);
|
||||
$options = getopt('', ['aur','docker','plugins','plugins-all','skip-gulp','debian','nextcloud','owncloud','cpanel','sign']);
|
||||
|
||||
if (isset($options['plugins'])) {
|
||||
if (isset($options['plugins']) || isset($options['plugins-all'])) {
|
||||
require(ROOT_DIR . '/build/plugins.php');
|
||||
}
|
||||
|
||||
|
|
@ -47,10 +47,11 @@ is_dir($destPath) || mkdir($destPath, 0777, true);
|
|||
|
||||
$zip_destination = "{$destPath}snappymail-{$package->version}.zip";
|
||||
$tar_destination = "{$destPath}snappymail-{$package->version}.tar";
|
||||
$tgz_destination = "{$tar_destination}.gz";
|
||||
|
||||
@unlink($zip_destination);
|
||||
@unlink($tar_destination);
|
||||
@unlink("{$tar_destination}.gz");
|
||||
@unlink($tgz_destination);
|
||||
|
||||
if (!isset($options['skip-gulp'])) {
|
||||
echo "\x1b[33;1m === Gulp === \x1b[0m\n";
|
||||
|
|
@ -99,8 +100,7 @@ if (!$zip->open($zip_destination, ZIPARCHIVE::CREATE)) {
|
|||
exit("Failed to create {$zip_destination}");
|
||||
}
|
||||
|
||||
$tar_destination .= '.gz';
|
||||
$tar = new \SnappyMail\TAR($tar_destination);
|
||||
$tar = new \SnappyMail\TAR($tgz_destination);
|
||||
//$tar = new PharData($tar_destination);
|
||||
|
||||
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('snappymail/v'), RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
|
@ -164,12 +164,11 @@ $zip->close();
|
|||
if ($tar instanceof PharData) {
|
||||
$tar->compress(Phar::GZ);
|
||||
unlink($tar_destination);
|
||||
$tar_destination .= '.gz';
|
||||
} else {
|
||||
$tar->close();
|
||||
}
|
||||
|
||||
echo "{$zip_destination} created\n{$tar_destination} created\n";
|
||||
echo "{$zip_destination} created\n{$tgz_destination} created\n";
|
||||
|
||||
if (isset($options['nextcloud'])) {
|
||||
require(ROOT_DIR . '/build/nextcloud.php');
|
||||
|
|
@ -204,7 +203,7 @@ if ($options['aur']) {
|
|||
}
|
||||
|
||||
$b2sums = function_exists('b2sum') ? [
|
||||
b2sum($tar_destination),
|
||||
b2sum($tgz_destination),
|
||||
b2sum(ROOT_DIR . '/build/arch/snappymail.sysusers'),
|
||||
b2sum(ROOT_DIR . '/build/arch/snappymail.tmpfiles')
|
||||
] : [];
|
||||
|
|
@ -260,7 +259,7 @@ if (isset($options['sign'])) {
|
|||
echo "\x1b[33;1m === PGP Sign === \x1b[0m\n";
|
||||
$gpg = 'gpg --local-user 1016E47079145542F8BA133548208BA13290F3EB ';
|
||||
$gpg_sign = $gpg . '--armor --detach-sign ';
|
||||
passthru($gpg_sign . escapeshellarg($tar_destination), $return_var);
|
||||
passthru($gpg_sign . escapeshellarg($tgz_destination), $return_var);
|
||||
passthru($gpg_sign . escapeshellarg($zip_destination), $return_var);
|
||||
if (isset($options['nextcloud'])) {
|
||||
passthru($gpg_sign . escapeshellarg("{$destPath}snappymail-{$package->version}-nextcloud.tar.gz"), $return_var);
|
||||
|
|
|
|||
|
|
@ -109,7 +109,16 @@ class TAR
|
|||
$stream = null,
|
||||
$stream_info = null;
|
||||
|
||||
public function start(): void
|
||||
/*
|
||||
const
|
||||
OVERWRITE = 1,
|
||||
CREATE = 2,
|
||||
RDONLY = 4,
|
||||
EXCL = 8,
|
||||
CHECKCONS = 16;
|
||||
public function open(string $filename, int $flags = 0): bool|int
|
||||
*/
|
||||
public function open(): void
|
||||
{
|
||||
if ($this->stream) {
|
||||
return;
|
||||
|
|
@ -159,7 +168,7 @@ class TAR
|
|||
|
||||
public function addFile(string $name, ?string $localName = null, ?\SplFileInfo $fileinfo = null): void
|
||||
{
|
||||
$this->start();
|
||||
$this->open();
|
||||
if (!$fileinfo) {
|
||||
$fileinfo = new \SplFileInfo($name);
|
||||
}
|
||||
|
|
@ -211,7 +220,7 @@ class TAR
|
|||
|
||||
public function addFromString(string $name, string $contents): void
|
||||
{
|
||||
$this->start();
|
||||
$this->open();
|
||||
$this->writeEntryHeader(
|
||||
$name,
|
||||
static::TYPE_FILE,
|
||||
|
|
@ -227,7 +236,7 @@ class TAR
|
|||
|
||||
public function buildFromDirectory(string $dir, string $pattern = ''): array
|
||||
{
|
||||
$this->start();
|
||||
$this->open();
|
||||
\clearstatcache();
|
||||
$dir = \rtrim($dir,'\\/') . '/';
|
||||
$dirl = \strlen($dir);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue