From b9ede20025cc6a8d002fb5b354eef97de32ae202 Mon Sep 17 00:00:00 2001 From: the-djmaze <3752035+the-djmaze@users.noreply.github.com> Date: Mon, 2 Nov 2026 22:28:58 +0100 Subject: [PATCH] Improved building plugins --- build/plugins.php | 26 ++++++++++++------- cli/release.php | 19 +++++++------- .../v/0.0.0/app/libraries/snappymail/tar.php | 17 +++++++++--- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/build/plugins.php b/build/plugins.php index 4561dae03..a15a5121d 100755 --- a/build/plugins.php +++ b/build/plugins.php @@ -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"; } } diff --git a/cli/release.php b/cli/release.php index fd17657b0..1b78000b7 100755 --- a/cli/release.php +++ b/cli/release.php @@ -2,11 +2,11 @@ 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); diff --git a/snappymail/v/0.0.0/app/libraries/snappymail/tar.php b/snappymail/v/0.0.0/app/libraries/snappymail/tar.php index 0098c69b0..43ba4e522 100644 --- a/snappymail/v/0.0.0/app/libraries/snappymail/tar.php +++ b/snappymail/v/0.0.0/app/libraries/snappymail/tar.php @@ -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);