This commit is contained in:
djmaze 2021-02-02 16:36:40 +01:00
parent 6c9b7dbe58
commit 88b0bc1a25
2 changed files with 127 additions and 116 deletions

View file

@ -12,19 +12,29 @@ if (!$rollup) {
exit('rollup not installed, run as root: npm install --global rollup');
}
$options = getopt('', ['docker']);
$options['docker'] = isset($options['docker']);
$options = getopt('', ['aur','docker']);
// Arch User Repository
// https://aur.archlinux.org/packages/snappymail/
$options['aur'] = isset($options['aur']);
// Docker build
$docker = trim(`which docker`);
$options['docker'] = isset($options['docker']) || (!$options['aur'] && $docker && strtoupper(readline("Build Docker image? (Y/N): ")) === "Y");
$package = json_decode(file_get_contents('package.json'));
$zip_destination = "snappymail-{$package->version}.zip";
$tar_destination = "snappymail-{$package->version}.tar";
$docker_zip = "./.docker/release/snappymail-{$package->version}.zip";
$destPath = "build/dist/releases/webmail/{$package->version}/";
is_dir($destPath) || mkdir($destPath, 0777, true);
$zip_destination = "{$destPath}snappymail-{$package->version}.zip";
$tar_destination = "{$destPath}snappymail-{$package->version}.tar";
@unlink($zip_destination);
@unlink($tar_destination);
@unlink("{$tar_destination}.gz");
echo "\x1b[33;1m === Gulp === \x1b[0m\n";
passthru($gulp, $return_var);
if ($return_var) {
exit("gulp failed with error code {$return_var}\n");
@ -40,6 +50,7 @@ if ($return_var) {
$cmddir = escapeshellcmd(__DIR__) . '/snappymail/v/0.0.0/static';
if ($gzip = trim(`which gzip`)) {
echo "\x1b[33;1m === Gzip *.js and *.css === \x1b[0m\n";
passthru("{$gzip} -k --best {$cmddir}/js/*.js");
passthru("{$gzip} -k --best {$cmddir}/js/min/*.js");
passthru("{$gzip} -k --best {$cmddir}/css/app*.css");
@ -48,6 +59,7 @@ if ($gzip = trim(`which gzip`)) {
}
if ($brotli = trim(`which brotli`)) {
echo "\x1b[33;1m === Brotli *.js and *.css === \x1b[0m\n";
passthru("{$brotli} -k --best {$cmddir}/js/*.js");
passthru("{$brotli} -k --best {$cmddir}/js/min/*.js");
passthru("{$brotli} -k --best {$cmddir}/css/app*.css");
@ -65,6 +77,8 @@ register_shutdown_function(function(){
@rename("snappymail/v/{$GLOBALS['package']->version}", 'snappymail/v/0.0.0');
});
echo "\x1b[33;1m === Zip/Tar === \x1b[0m\n";
$zip = new ZipArchive();
if (!$zip->open($zip_destination, ZIPARCHIVE::CREATE)) {
exit("Failed to create {$zip_destination}");
@ -104,8 +118,19 @@ $tar->addFile('data/README.md');
//$zip->addFile('data/EMPTY');
//$tar->addFile('data/EMPTY');
$zip->addFile('_include.php');
$tar->addFile('_include.php');
if ($options['aur']) {
$data = '<?php
function __get_custom_data_full_path()
{
return \'/var/lib/snappymail\';
}
';
$zip->addFromString('include.php', $data);
$tar->addFromString('include.php', $data);
} else {
$zip->addFile('_include.php');
$tar->addFile('_include.php');
}
$zip->addFile('.htaccess');
$tar->addFile('.htaccess');
@ -129,16 +154,44 @@ $zip->close();
$tar->compress(Phar::GZ);
unlink($tar_destination);
echo "\n{$zip_destination} created\n{$tar_destination}.gz created\n";
echo "{$zip_destination} created\n{$tar_destination}.gz created\n";
// Docker build
if ($options['docker'] || readline("Build Docker image? (Y/N): ") === "Y") {
copy($zip_destination, $docker_zip);
// Arch User Repository
if ($options['aur']) {
/*
file_put_contents('arch/.SRCINFO', 'pkgbase = snappymail
pkgdesc = modern PHP webmail client
pkgver = '.$package->version.'
pkgrel = 1
url = https://github.com/the-djmaze/snappymail
arch = any
license = AGPL3
makedepends = php
makedepends = nodejs
makedepends = yarn
makedepends = gulp
depends = php-fpm
optdepends = mariadb: storage backend for contacts
optdepends = php-pgsql: storage backend for contacts
optdepends = php-sqlite: storage backend for contacts
source = snappymail-'.$package->version.'.tar.gz::https://github.com/the-djmaze/snappymail/archive/v'.$package->version.'.tar.gz
source = snappymail.sysusers
source = snappymail.tmpfiles
b2sums = ?
b2sums = e020b2d4bc694ca056f5c15b148c69553ab610b5e1789f52543aa65e098f8097a41709b5b0fc22a6a01088a9d3f14d623b1b6e9ae2570acd4f380f429301c003
b2sums = 2536e11622895322cc752c6b651811b2122d3ae60099fe609609d7b45ba1ed00ea729c23f344405078698d161dbf9bcaffabf8eff14b740acdce3c681c513318
$docker = trim(`which docker`);
if(!$docker) {
exit("Docker not installed!");
}
passthru("{$docker} build " . __DIR__ . "/.docker/release/ --build-arg FILES_ZIP={$zip_destination} -t snappymail:{$package->version}");
pkgname = snappymail
');
*/
}
// Docker build
else if ($options['docker']) {
echo "\x1b[33;1m === Docker === \x1b[0m\n";
copy($zip_destination, "./.docker/release/snappymail-{$package->version}.zip");
if ($docker) {
passthru("{$docker} build " . __DIR__ . "/.docker/release/ --build-arg FILES_ZIP={$zip_destination} -t snappymail:{$package->version}");
} else {
echo "Docker not installed!\n";
}
}