1
0
mirror of https://github.com/php/pie.git synced 2026-03-23 23:12:17 +01:00

Merge pull request #545 from cataphract/glibc+musl

Allow distribution of musl + glibc binaries
This commit is contained in:
James Titcumb
2026-03-16 13:06:39 +01:00
committed by GitHub
3 changed files with 51 additions and 52 deletions

View File

@@ -21,51 +21,32 @@ final class PrePackagedBinaryAssetName
/** @return non-empty-list<non-empty-string> */
public static function packageNames(TargetPlatform $targetPlatform, Package $package): array
{
return array_values(array_unique([
strtolower(sprintf(
'php_%s-%s_php%s-%s-%s-%s%s%s.zip',
$package->extensionName()->name(),
$package->version(),
$targetPlatform->phpBinaryPath->majorMinorVersion(),
$targetPlatform->architecture->name,
$targetPlatform->operatingSystemFamily->value,
$targetPlatform->libcFlavour()->value,
$targetPlatform->phpBinaryPath->debugMode() === DebugBuild::Debug ? '-debug' : '',
$targetPlatform->threadSafety === ThreadSafetyMode::ThreadSafe ? '-zts' : '',
)),
strtolower(sprintf(
'php_%s-%s_php%s-%s-%s-%s%s%s.tgz',
$package->extensionName()->name(),
$package->version(),
$targetPlatform->phpBinaryPath->majorMinorVersion(),
$targetPlatform->architecture->name,
$targetPlatform->operatingSystemFamily->value,
$targetPlatform->libcFlavour()->value,
$targetPlatform->phpBinaryPath->debugMode() === DebugBuild::Debug ? '-debug' : '',
$targetPlatform->threadSafety === ThreadSafetyMode::ThreadSafe ? '-zts' : '',
)),
strtolower(sprintf(
'php_%s-%s_php%s-%s-%s-%s%s%s.zip',
$package->extensionName()->name(),
$package->version(),
$targetPlatform->phpBinaryPath->majorMinorVersion(),
$targetPlatform->architecture->name,
$targetPlatform->operatingSystemFamily->value,
$targetPlatform->libcFlavour()->value,
$targetPlatform->phpBinaryPath->debugMode() === DebugBuild::Debug ? '-debug' : '',
$targetPlatform->threadSafety === ThreadSafetyMode::ThreadSafe ? '-zts' : '-nts',
)),
strtolower(sprintf(
'php_%s-%s_php%s-%s-%s-%s%s%s.tgz',
$package->extensionName()->name(),
$package->version(),
$targetPlatform->phpBinaryPath->majorMinorVersion(),
$targetPlatform->architecture->name,
$targetPlatform->operatingSystemFamily->value,
$targetPlatform->libcFlavour()->value,
$targetPlatform->phpBinaryPath->debugMode() === DebugBuild::Debug ? '-debug' : '',
$targetPlatform->threadSafety === ThreadSafetyMode::ThreadSafe ? '-zts' : '-nts',
)),
]));
$debug = $targetPlatform->phpBinaryPath->debugMode() === DebugBuild::Debug ? '-debug' : '';
$tsNoSuffix = $targetPlatform->threadSafety === ThreadSafetyMode::ThreadSafe ? '-zts' : '';
$tsWithSuffix = $targetPlatform->threadSafety === ThreadSafetyMode::ThreadSafe ? '-zts' : '-nts';
$libc = $targetPlatform->libcFlavour()->value;
$name = $package->extensionName()->name();
$version = $package->version();
$phpVer = $targetPlatform->phpBinaryPath->majorMinorVersion();
$arch = $targetPlatform->architecture->name;
$os = $targetPlatform->operatingSystemFamily->value;
$names = [
strtolower(sprintf('php_%s-%s_php%s-%s-%s-%s%s%s.zip', $name, $version, $phpVer, $arch, $os, $libc, $debug, $tsNoSuffix)),
strtolower(sprintf('php_%s-%s_php%s-%s-%s-%s%s%s.tgz', $name, $version, $phpVer, $arch, $os, $libc, $debug, $tsNoSuffix)),
strtolower(sprintf('php_%s-%s_php%s-%s-%s-%s%s%s.zip', $name, $version, $phpVer, $arch, $os, $libc, $debug, $tsWithSuffix)),
strtolower(sprintf('php_%s-%s_php%s-%s-%s-%s%s%s.tgz', $name, $version, $phpVer, $arch, $os, $libc, $debug, $tsWithSuffix)),
];
// Fallbacks with anylibc suffix, for unified binaries compatible with both glibc and musl (Linux only)
if ($targetPlatform->operatingSystemFamily === OperatingSystemFamily::Linux) {
$names[] = strtolower(sprintf('php_%s-%s_php%s-%s-%s-anylibc%s%s.zip', $name, $version, $phpVer, $arch, $os, $debug, $tsNoSuffix));
$names[] = strtolower(sprintf('php_%s-%s_php%s-%s-%s-anylibc%s%s.tgz', $name, $version, $phpVer, $arch, $os, $debug, $tsNoSuffix));
$names[] = strtolower(sprintf('php_%s-%s_php%s-%s-%s-anylibc%s%s.zip', $name, $version, $phpVer, $arch, $os, $debug, $tsWithSuffix));
$names[] = strtolower(sprintf('php_%s-%s_php%s-%s-%s-anylibc%s%s.tgz', $name, $version, $phpVer, $arch, $os, $debug, $tsWithSuffix));
}
return array_values(array_unique($names));
}
}

View File

@@ -145,10 +145,15 @@ final class DownloadUrlMethodTest extends TestCase
self::assertSame(DownloadUrlMethod::PrePackagedBinary, $downloadUrlMethod);
// TargetPlatform doesn't have the libc specified, so the assertion needs to be made
// against the test machine's libc
$libc = $targetPlatform->libcFlavour()->value;
self::assertSame(
[
'php_bar-1.2.3_php8.3-x86_64-linux-glibc-debug-zts.zip',
'php_bar-1.2.3_php8.3-x86_64-linux-glibc-debug-zts.tgz',
'php_bar-1.2.3_php8.3-x86_64-linux-' . $libc . '-debug-zts.zip',
'php_bar-1.2.3_php8.3-x86_64-linux-' . $libc . '-debug-zts.tgz',
'php_bar-1.2.3_php8.3-x86_64-linux-anylibc-debug-zts.zip',
'php_bar-1.2.3_php8.3-x86_64-linux-anylibc-debug-zts.tgz',
],
$downloadUrlMethod->possibleAssetNames($package, $targetPlatform),
);
@@ -221,12 +226,19 @@ final class DownloadUrlMethodTest extends TestCase
$firstMethod = $downloadUrlMethods[0];
self::assertSame(DownloadUrlMethod::PrePackagedBinary, $firstMethod);
// TargetPlatform doesn't have the libc specified, so the assertion needs to be made
// against the test machine's libc
$libc = $targetPlatform->libcFlavour()->value;
self::assertSame(
[
'php_bar-1.2.3_php8.3-x86_64-linux-glibc-debug.zip',
'php_bar-1.2.3_php8.3-x86_64-linux-glibc-debug.tgz',
'php_bar-1.2.3_php8.3-x86_64-linux-glibc-debug-nts.zip',
'php_bar-1.2.3_php8.3-x86_64-linux-glibc-debug-nts.tgz',
'php_bar-1.2.3_php8.3-x86_64-linux-' . $libc . '-debug.zip',
'php_bar-1.2.3_php8.3-x86_64-linux-' . $libc . '-debug.tgz',
'php_bar-1.2.3_php8.3-x86_64-linux-' . $libc . '-debug-nts.zip',
'php_bar-1.2.3_php8.3-x86_64-linux-' . $libc . '-debug-nts.tgz',
'php_bar-1.2.3_php8.3-x86_64-linux-anylibc-debug.zip',
'php_bar-1.2.3_php8.3-x86_64-linux-anylibc-debug.tgz',
'php_bar-1.2.3_php8.3-x86_64-linux-anylibc-debug-nts.zip',
'php_bar-1.2.3_php8.3-x86_64-linux-anylibc-debug-nts.tgz',
],
$firstMethod->possibleAssetNames($package, $targetPlatform),
);

View File

@@ -46,6 +46,10 @@ final class PrePackagedBinaryAssetNameTest extends TestCase
'php_foobar-1.2.3_php8.2-x86_64-linux-' . $libc->value . '.tgz',
'php_foobar-1.2.3_php8.2-x86_64-linux-' . $libc->value . '-nts.zip',
'php_foobar-1.2.3_php8.2-x86_64-linux-' . $libc->value . '-nts.tgz',
'php_foobar-1.2.3_php8.2-x86_64-linux-anylibc.zip',
'php_foobar-1.2.3_php8.2-x86_64-linux-anylibc.tgz',
'php_foobar-1.2.3_php8.2-x86_64-linux-anylibc-nts.zip',
'php_foobar-1.2.3_php8.2-x86_64-linux-anylibc-nts.tgz',
],
PrePackagedBinaryAssetName::packageNames(
$targetPlatform,
@@ -83,6 +87,8 @@ final class PrePackagedBinaryAssetNameTest extends TestCase
[
'php_foobar-1.2.3_php8.3-x86_64-linux-' . $libc->value . '-zts.zip',
'php_foobar-1.2.3_php8.3-x86_64-linux-' . $libc->value . '-zts.tgz',
'php_foobar-1.2.3_php8.3-x86_64-linux-anylibc-zts.zip',
'php_foobar-1.2.3_php8.3-x86_64-linux-anylibc-zts.tgz',
],
PrePackagedBinaryAssetName::packageNames(
$targetPlatform,