Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ steps:
- git rev-parse origin/$MINORVERSION-dev > transfer/$MINORVERSION.txt
- php build/build.php --remote=origin/$MINORVERSION-dev --exclude-gzip --exclude-bzip2
- mv build/tmp/packages/* transfer/
- php build/build.php --remote=origin/$MINORVERSION-dev --exclude-zip --exclude-bzip2 --debug-build
- mv build/tmp/packages/* transfer/

- name: upload
image: joomlaprojects/docker-images:packager
Expand Down Expand Up @@ -520,6 +522,6 @@ trigger:

---
kind: signature
hmac: 457f0f91e84d98a759e33c32f45e878f562ca987b5bee426593263ce99bb144f
hmac: 62793a0d4a6d84bf968e0469bd34008ddd23093300c46c8e79e7078ed38c5056

...
152 changes: 88 additions & 64 deletions build/build.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function usage(string $command)
echo PHP_TAB . PHP_TAB . '--exclude-bzip2:' . PHP_TAB . PHP_TAB . 'Exclude the generation of .tar.bz2 packages' . PHP_EOL;
echo PHP_TAB . PHP_TAB . '--include-zstd:' . PHP_TAB . PHP_TAB . PHP_TAB . 'Include the generation of .tar.zst packages' . PHP_EOL;
echo PHP_TAB . PHP_TAB . '--disable-patch-packages:' . PHP_TAB . 'Disable the generation of patch packages' . PHP_EOL;
echo PHP_TAB . PHP_TAB . '--debug-build:' . PHP_TAB . 'Include development packages and build folder' . PHP_EOL;
echo PHP_TAB . PHP_TAB . '--help:' . PHP_TAB . PHP_TAB . PHP_TAB . PHP_TAB . 'Show this help output' . PHP_EOL;
echo PHP_EOL;
}
Expand Down Expand Up @@ -73,6 +74,7 @@ function clean_checkout(string $dir)
system('find . -name psalm.xml.dist | xargs rm -rf -');
system('find . -name phpcs.xml | xargs rm -rf -');
system('find . -name phpcs.xml.dist | xargs rm -rf -');
system('find . -name phpstan.neon | xargs rm -rf -');
system('find . -name phpunit.xml | xargs rm -rf -');
system('find . -name phpunit.*.xml | xargs rm -rf -');
system('find . -name phpunit.xml.dist | xargs rm -rf -');
Expand Down Expand Up @@ -224,17 +226,18 @@ function clean_composer(string $dir)
umask(022);

// Shortcut the paths to the repository root and build folder
$repo = dirname(__DIR__);
$repo = \dirname(__DIR__);
$here = __DIR__;

// Set paths for the build packages
$tmp = $here . '/tmp';
$fullpath = $tmp . '/' . $time;

// Parse input options
$options = getopt('', ['help', 'remote::', 'exclude-zip', 'exclude-gzip', 'exclude-bzip2', 'include-zstd', 'disable-patch-packages']);
$options = getopt('', ['help', 'remote::', 'exclude-zip', 'exclude-gzip', 'exclude-bzip2', 'include-zstd', 'debug-build', 'disable-patch-packages']);

$remote = $options['remote'] ?? false;
$debugBuild = isset($options['debug-build']);
$excludeZip = isset($options['exclude-zip']);
$excludeGzip = isset($options['exclude-gzip']);
$excludeBzip2 = isset($options['exclude-bzip2']);
Expand All @@ -261,6 +264,11 @@ function clean_composer(string $dir)
$includeExtraTextfiles = true;
}

$composerOptions = ' ';
if (!$debugBuild) {
$composerOptions .= '--no-dev';
}

echo "Start build for remote $remote.\n";
echo "Delete old release folder.\n";
system('rm -rf ' . $tmp);
Expand All @@ -273,7 +281,7 @@ function clean_composer(string $dir)
system('cp build/fido.jwt ' . $fullpath . '/plugins/system/webauthn/fido.jwt');
// Install PHP and NPM dependencies and compile required media assets, skip Composer autoloader until post-cleanup
chdir($fullpath);
system('composer install --no-dev --no-autoloader --ignore-platform-reqs', $composerReturnCode);
system('composer install --no-autoloader --ignore-platform-reqs' . $composerOptions, $composerReturnCode);

if ($composerReturnCode !== 0) {
echo "`composer install` did not complete as expected.\n";
Expand Down Expand Up @@ -311,16 +319,22 @@ function clean_composer(string $dir)
}

// Clean the checkout of extra resources
clean_checkout($fullpath);
if (!$debugBuild) {
clean_checkout($fullpath);
}

// Regenerate the Composer autoloader without deleted files
system('composer dump-autoload --no-dev --optimize --no-scripts');
system('composer dump-autoload --optimize --no-scripts' . $composerOptions);

// Clean the Composer manifests now
clean_composer($fullpath);
if (!$debugBuild) {
clean_composer($fullpath);
}

// And cleanup the Node installation
system('rm -rf node_modules');
if (!$debugBuild) {
system('rm -rf node_modules');
}

echo "Workspace built.\n";

Expand All @@ -329,9 +343,10 @@ function clean_composer(string $dir)
require_once $fullpath . '/libraries/src/Version.php';

// Set version information for the build
$version = Version::MAJOR_VERSION . '.' . Version::MINOR_VERSION;
$release = Version::PATCH_VERSION;
$fullVersion = (new Version())->getShortVersion();
$majorVersion = Version::MAJOR_VERSION;
$version = Version::MAJOR_VERSION . '.' . Version::MINOR_VERSION;
$release = Version::PATCH_VERSION;
$fullVersion = (new Version())->getShortVersion();

$previousRelease = Version::PATCH_VERSION - 1;

Expand Down Expand Up @@ -440,11 +455,17 @@ function clean_composer(string $dir)
// For the packages, replace spaces in stability (RC) with underscores
$packageStability = str_replace(' ', '_', Version::DEV_STATUS);

if ($debugBuild) {
$packageStability .= '-Debug';
}

// Delete the files and folders we exclude from the packages (tests, docs, build, etc.).
echo "Delete folders not included in packages.\n";

foreach ($doNotPackage as $removeFile) {
system('rm -rf ' . $time . '/' . $removeFile);
if (!$debugBuild) {
foreach ($doNotPackage as $removeFile) {
system('rm -rf ' . $time . '/' . $removeFile);
}
}

// Count down starting with the latest release and add diff files to this array
Expand Down Expand Up @@ -476,20 +497,21 @@ function clean_composer(string $dir)

$folderPath = explode('/', $fileName);
$baseFolderName = $folderPath[0];
$doNotPackageFile = in_array(trim($fileName), $doNotPackage);
$doNotPatchFile = in_array(trim($fileName), $doNotPatch);
$doNotPackageBaseFolder = in_array($baseFolderName, $doNotPackage);
$doNotPatchBaseFolder = in_array($baseFolderName, $doNotPatch);
$doNotPackageFile = \in_array(trim($fileName), $doNotPackage);
$doNotPatchFile = \in_array(trim($fileName), $doNotPatch);
$doNotPackageBaseFolder = \in_array($baseFolderName, $doNotPackage);
$doNotPatchBaseFolder = \in_array($baseFolderName, $doNotPatch);
$dirtyHackForMediaCheck = false;

// The raw files for the vue files are not packaged but are not a top level directory so aren't handled by the
// above checks. This is dirty but a fairly performant fix for now until we can come up with something better.
if (count($folderPath) >= 4) {
if (\count($folderPath) >= 4) {
$fullPath = [$folderPath[0] . '/' . $folderPath[1] . '/' . $folderPath[2] . '/' . $folderPath[3]];
$dirtyHackForMediaCheck = in_array('administrator/components/com_media/resources', $fullPath);
$dirtyHackForMediaCheck = \in_array('administrator/components/com_media/resources', $fullPath);
}

if ($dirtyHackForMediaCheck || $doNotPackageFile || $doNotPatchFile || $doNotPackageBaseFolder || $doNotPatchBaseFolder) {

if (!$debugBuild && ($dirtyHackForMediaCheck || $doNotPackageFile || $doNotPatchFile || $doNotPackageBaseFolder || $doNotPatchBaseFolder)) {
continue;
}

Expand All @@ -508,14 +530,14 @@ function clean_composer(string $dir)

break;

// Deleted files
case 'D':
// Deleted files
$deletedFiles[] = $fileName;

break;

// Regular additions and modifications
default:
// Regular additions and modifications
$filesArray[$fileName] = true;

break;
Expand Down Expand Up @@ -567,7 +589,7 @@ function clean_composer(string $dir)
if (!$excludeZstd) {
$packageName = 'Joomla_' . $version . '.' . $fromName . '_to_' . $fullVersion . '-' . $packageStability . '-Patch_Package.tar.zst';
echo "Building " . $packageName . "... ";
system('tar --create --use-compress-program=zstd --no-recursion --directory ' . $time . ' --file packages/' . $packageName . ' --files-from diffconvert/' . $version . '.' . $num . '> /dev/null');
system('tar "-I zstd --ultra -22" --create --no-recursion --directory ' . $time . ' --file packages/' . $packageName . ' --files-from diffconvert/' . $version . '.' . $num . '> /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}
Expand Down Expand Up @@ -610,57 +632,59 @@ function clean_composer(string $dir)
if (!$excludeZstd) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.tar.zst';
echo "Building " . $packageName . "... ";
system('tar --create --use-compress-program=zstd --file ../packages/' . $packageName . ' * > /dev/null');
system('tar "-I zstd --ultra -22" --create --file ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}

// Create full update file without the default logs directory, installation folder, or sample images.
echo "Build full update package.\n";
system('rm -r administrator/logs');
system('rm -r installation');
system('rm -r images/banners');
system('rm -r images/headers');
system('rm -r images/sampledata');
system('rm images/joomla_black.png');
system('rm images/powered_by.png');

// Move the search manifest back
system('mv ../pkg_search.xml administrator/manifests/packages/pkg_search.xml');

// Move the restore_finalisation.php back
system('mv ../restore_finalisation.php administrator/components/com_joomlaupdate/restore_finalisation.php');
if (!$debugBuild) {
echo "Build full update package.\n";
system('rm -r administrator/logs');
system('rm -r installation');
system('rm -r images/banners');
system('rm -r images/headers');
system('rm -r images/sampledata');
system('rm images/joomla_black.png');
system('rm images/powered_by.png');

// Move the search manifest back
system('mv ../pkg_search.xml administrator/manifests/packages/pkg_search.xml');

// Move the restore_finalisation.php back
system('mv ../restore_finalisation.php administrator/components/com_joomlaupdate/restore_finalisation.php');

if (!$excludeBzip2) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.bz2';
echo "Building " . $packageName . "... ";
system('tar --create --bzip2 --file ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}
if (!$excludeBzip2) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.bz2';
echo "Building " . $packageName . "... ";
system('tar --create --bzip2 --file ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}

if (!$excludeGzip) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.gz';
echo "Building " . $packageName . "... ";
system('tar --create --gzip --file ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}
if (!$excludeGzip) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.gz';
echo "Building " . $packageName . "... ";
system('tar --create --gzip --file ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}

if (!$excludeZip) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.zip';
echo "Building " . $packageName . "... ";
system('zip -r ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}
if (!$excludeZip) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.zip';
echo "Building " . $packageName . "... ";
system('zip -r ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}

if (!$excludeZstd) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.zst';
echo "Building " . $packageName . "... ";
system('tar --create --use-compress-program=zstd --file ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
if (!$excludeZstd) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.zst';
echo "Building " . $packageName . "... ";
system('tar "-I zstd --ultra -22" --create --file ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}
}

chdir('..');
Expand Down