From e0c1ad14480e217e10462f1575af9398d31f8d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Z=C3=BClke?= Date: Tue, 25 Apr 2023 13:59:36 +0200 Subject: [PATCH] PlatformRepository library support for libpq (from ext-pq) and librdkafka (from ext-rdkafka) (#11418) * libpq library version info for ext-pq * librdkafka library version info for ext-rdkafka Computes from RD_KAFKA_VERSION, faster than output buffering --- .../Repository/PlatformRepository.php | 26 +++++++++++++++++++ .../Repository/PlatformRepositoryTest.php | 19 ++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 116f2b2dc..066fbcf15 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -450,6 +450,32 @@ class PlatformRepository extends ArrayRepository } break; + case 'pq': + $info = $this->runtime->getExtensionInfo($name); + + // Used Library => Compiled => Linked + // libpq => 14.3 (Ubuntu 14.3-1.pgdg22.04+1) => 15.0.2 + if (Preg::isMatch('/^libpq => (?.+) => (?.+)$/im', $info, $matches)) { + $this->addLibrary($name.'-libpq', $matches['linked'], 'libpq for '.$name); + } + break; + + case 'rdkafka': + if ($this->runtime->hasConstant('RD_KAFKA_VERSION')) { + /** + * Interpreted as hex \c MM.mm.rr.xx: + * - MM = Major + * - mm = minor + * - rr = revision + * - xx = pre-release id (0xff is the final release) + * + * pre-release ID in practice is always 0xff even for RCs etc, so we ignore it + */ + $libRdKafkaVersionInt = $this->runtime->getConstant('RD_KAFKA_VERSION'); + $this->addLibrary($name.'-librdkafka', sprintf('%d.%d.%d', ($libRdKafkaVersionInt & 0xFF000000) >> 24, ($libRdKafkaVersionInt & 0x00FF0000) >> 16, ($libRdKafkaVersionInt & 0x0000FF00) >> 8), 'librdkafka for '.$name); + } + break; + case 'libsodium': case 'sodium': if ($this->runtime->hasConstant('SODIUM_LIBRARY_VERSION')) { diff --git a/tests/Composer/Test/Repository/PlatformRepositoryTest.php b/tests/Composer/Test/Repository/PlatformRepositoryTest.php index fb0a2ef06..0d897003e 100644 --- a/tests/Composer/Test/Repository/PlatformRepositoryTest.php +++ b/tests/Composer/Test/Repository/PlatformRepositoryTest.php @@ -960,6 +960,25 @@ Module version => 7.1.33 Revision => $Id: 9c5f356c77143981d2e905e276e439501fe0f419 $', ['lib-pdo_pgsql-libpq' => '12.1'], ], + 'pq' => [ + 'pq', + 'pq + +PQ Support => enabled +Extension Version => 2.2.0 + +Used Library => Compiled => Linked +libpq => 14.3 (Ubuntu 14.3-1.pgdg22.04+1) => 15.0.2 + ', + ['lib-pq-libpq' => '15.0.2'], + ], + 'rdkafka' => [ + 'rdkafka', + null, + ['lib-rdkafka-librdkafka' => '1.9.2'], + [], + [['RD_KAFKA_VERSION', null, 17367807]], + ], 'libsodium' => [ 'libsodium', null,