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 d30d6e79f2d01921c4b57226438f1c82e764cf13..88d366164d90ff393f0d9f843ec279074e5f966f 100644 --- a/php.spec +++ b/php.spec @@ -49,6 +49,10 @@ Source13: 20-ffi.ini Source14: nginx-php.conf Source15: https://www.php.net/distributions/php-keyring.gpg +# Sources for composer-generators +# https://git.remirepo.net/cgit/rpms/composer-generators.git +Source1001: composer.prov +Source1002: composer.attr Patch0: php-7.4.0-httpd.patch Patch1: php-7.2.0-includedir.patch @@ -205,6 +209,7 @@ Provides: php-spl, php-spl%{?_isa} Provides: php-standard = %{version}, php-standard%{?_isa} = %{version} Provides: php-tokenizer, php-tokenizer%{?_isa} Provides: php-zlib, php-zlib%{?_isa} +Requires: (libxml2%{?_isa} >= %(rpm -q --queryformat="%%{VERSION}" libxml2) if libxml2) %description common The php-common package contains files used by both the php @@ -581,6 +586,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 @@ -1164,6 +1182,9 @@ rm -rf $RPM_BUILD_ROOT%{_libdir}/php/modules/*.a \ 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 @@ -1310,7 +1331,15 @@ 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 +* Sat Mar 22 2025 Funda Wang - 8.3.19-2 +- add composer-generators from remi +- hardcode libxml2 version as what was used for building + * Wed Mar 12 2025 Funda Wang - 8.3.19-1 - New version 8.3.19