diff --git a/composer.attr b/composer.attr new file mode 100644 index 0000000000000000000000000000000000000000..d1368cab88f75560ee447ec3c03dcfdf95131d08 --- /dev/null +++ b/composer.attr @@ -0,0 +1,3 @@ +%__composer_provides %{_rpmconfigdir}/composer.prov +%__composer_path composer/installed\\.php$ + diff --git a/composer.prov b/composer.prov new file mode 100644 index 0000000000000000000000000000000000000000..4d92e5e2bb4460d08828e7c65be33068983f9127 --- /dev/null +++ b/composer.prov @@ -0,0 +1,77 @@ +#!/usr/bin/php +. + + SPDX-3.0-License-Identifier: GPL-2.0-or-later + + This program is free software. + For more information on the license, see COPYING or + . + For more information on free software, see + . +*/ + +// Check if composer "name" and "pretty_version" are usable in RPM +function isValid(Array $package, $strict=true) { + // Only vendor/project + if (!isset($package['name']) + || !strpos($package['name'], '/') + ) { + return false; + } + // pretty_version is required + if (!isset($package['pretty_version'])) { + return false; + } + if ($strict) { + // pretty_version is usable + if (empty($package['pretty_version']) + || strpos($package['pretty_version'], '-') + ) { + return false; + } + } + return true; +} + +// Clean "pretty_version" +function getVersion(Array $package) { + return ltrim($package['pretty_version'], 'v'); +} + +// Parse an installed.php file +function run($file) { + fputs(STDERR, "Search bundled libraries installed, parsing $file\n"); + $installed = include $file; + $main = false; + if (isValid($installed['root'], false)) { + $main = $installed['root']['name']; + if (isValid($installed['root'])) { + printf("php-composer(%s) = %s\n", $main, getVersion($installed['root'])); + } + } + if (isset($installed['versions'])) foreach($installed['versions'] as $name => $v) { + if ($name !== $main) { + $v['name'] = $name; + if (isValid($v)) { + printf("bundled(php-composer(%s)) = %s\n", $name, getVersion($v)); + } else if (isValid($v, false)) { + printf("bundled(php-composer(%s))\n", $name); + } + } + } +} + +// From command line argument, manual usage +if (isset($_SERVER['argv'][1])) { + run($_SERVER['argv'][1]); + +// From input lines, rpmbuild usage +} else while($f = fgets(STDIN)) { + run(trim($f)); +} + diff --git a/php.spec b/php.spec index 55b5528d94b8f6d55287a91a2a56b78b18063352..652df6b8f6bd9399a0404b1525710e44f75834f3 100644 --- a/php.spec +++ b/php.spec @@ -14,7 +14,7 @@ %global mysql_sock %(mysql_config --socket 2>/dev/null || echo /var/lib/mysql/mysql.sock) -# Build for LiteSpeed Web Server (LSAPI), you can disable using --without tests +# Build for LiteSpeed Web Server (LSAPI), you can disable using --without lsws %bcond_without lsws # Regression tests take a long time, you can skip them using --without tests @@ -66,7 +66,7 @@ Summary: PHP scripting language for creating dynamic web sites Name: php Version: %{upver} -Release: 1 +Release: 2 # All files licensed under PHP version 3.01, except # Zend is licensed under Zend # TSRM is licensed under BSD @@ -94,6 +94,11 @@ Source50: 10-opcache.ini Source51: opcache-default.blacklist Source53: 20-ffi.ini +# Sources for composer-generators +# https://git.remirepo.net/cgit/rpms/composer-generators.git +Source1001: composer.prov +Source1002: composer.attr + # Build fixes Patch1: php-8.4.0-httpd.patch Patch5: php-8.4.0-includedir.patch @@ -746,6 +751,19 @@ scripting language and therefore develop “system code” more productively. For PHP, FFI opens a way to write PHP extensions and bindings to C libraries in pure PHP. +%package -n composer-generators +Summary: Tools for composer enabled applications packager +Buildarch: noarch +License: GPL-2.0-or-later +Requires: php-cli + +%description -n composer-generators +This package provides RPM generators which are used for +getting provides from composer enabled applications. + +* find main project name and provide it +* find bundled libraries and provide them + %package_help %prep @@ -1469,6 +1487,9 @@ rm -rf $RPM_BUILD_ROOT%{_libdir}/php/modules/*.a \ # Remove irrelevant docs rm -f README.{Zeus,QNX,CVS-RULES} +# install composer-generator +install -Dpm 755 %{S:1001} %{buildroot}%{_rpmconfigdir}/composer.prov +install -Dpm 644 %{S:1002} %{buildroot}%{_fileattrsdir}/composer.attr %post fpm %systemd_post php-fpm.service @@ -1613,7 +1634,14 @@ systemctl try-restart php-fpm.service >/dev/null 2>&1 || : %doc php-fpm.conf.default www.conf.default php.ini-* %{_mandir}/man?/* +%files -n composer-generators +%{_rpmconfigdir}/composer.prov +%{_fileattrsdir}/composer.attr + %changelog +* Tue Mar 18 2025 Funda Wang - 8.4.5-2 +- add composer-generators from remi + * Sun Mar 16 2025 Funda Wang - 8.4.5-1 - New version 8.4.5 - Resync with remi codebase