From 01bbe4863e571beb02bd69170fef9dad54cf4f2e Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Jan 25 2022 10:05:08 +0000 Subject: use system libraries on Fedora, bundled libraries on EL --- diff --git a/composer-noxdg.patch b/composer-noxdg.patch index fc6b127..607e449 100644 --- a/composer-noxdg.patch +++ b/composer-noxdg.patch @@ -1,7 +1,7 @@ diff -up ./src/Composer/Factory.php.noxdg ./src/Composer/Factory.php ---- ./src/Composer/Factory.php.noxdg 2021-05-31 15:37:50.548115679 +0200 -+++ ./src/Composer/Factory.php 2021-05-31 15:39:05.192882880 +0200 -@@ -653,6 +653,10 @@ class Factory +--- ./src/Composer/Factory.php.noxdg 2022-01-25 09:39:15.000000000 +0100 ++++ ./src/Composer/Factory.php 2022-01-25 09:50:21.374957261 +0100 +@@ -701,6 +701,10 @@ class Factory */ private static function useXdg() { diff --git a/composer-rpm.patch b/composer-rpm.patch index cbb4b3c..bdf807b 100644 --- a/composer-rpm.patch +++ b/composer-rpm.patch @@ -1,6 +1,6 @@ diff -up ./bin/composer.rpm ./bin/composer ---- ./bin/composer.rpm 2021-09-14 15:45:17.000000000 +0200 -+++ ./bin/composer 2021-09-14 15:45:33.025118009 +0200 +--- ./bin/composer.rpm 2022-01-25 09:39:15.000000000 +0100 ++++ ./bin/composer 2022-01-25 09:50:21.372957269 +0100 @@ -6,7 +6,7 @@ if (PHP_SAPI !== 'cli' && PHP_SAPI !== ' } @@ -11,9 +11,9 @@ diff -up ./bin/composer.rpm ./bin/composer use Composer\Console\Application; use Composer\XdebugHandler\XdebugHandler; diff -up ./src/Composer/Autoload/AutoloadGenerator.php.rpm ./src/Composer/Autoload/AutoloadGenerator.php ---- ./src/Composer/Autoload/AutoloadGenerator.php.rpm 2021-09-14 15:45:17.000000000 +0200 -+++ ./src/Composer/Autoload/AutoloadGenerator.php 2021-09-14 15:45:33.025118009 +0200 -@@ -395,7 +395,7 @@ EOF; +--- ./src/Composer/Autoload/AutoloadGenerator.php.rpm 2022-01-25 09:39:15.000000000 +0100 ++++ ./src/Composer/Autoload/AutoloadGenerator.php 2022-01-25 09:50:21.373957265 +0100 +@@ -419,7 +419,7 @@ EOF; $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform)); $filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php'); @@ -23,9 +23,9 @@ diff -up ./src/Composer/Autoload/AutoloadGenerator.php.rpm ./src/Composer/Autolo if ($this->runScripts) { $this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, array(), array( diff -up ./src/Composer/Compiler.php.rpm ./src/Composer/Compiler.php ---- ./src/Composer/Compiler.php.rpm 2021-09-14 15:45:17.000000000 +0200 -+++ ./src/Composer/Compiler.php 2021-09-14 15:45:33.025118009 +0200 -@@ -118,7 +118,7 @@ class Compiler +--- ./src/Composer/Compiler.php.rpm 2022-01-25 09:39:15.000000000 +0100 ++++ ./src/Composer/Compiler.php 2022-01-25 09:50:21.373957265 +0100 +@@ -125,7 +125,7 @@ class Compiler // Add Composer resources $finder = new Finder(); $finder->files() @@ -35,9 +35,9 @@ diff -up ./src/Composer/Compiler.php.rpm ./src/Composer/Compiler.php ; foreach ($finder as $file) { diff -up ./src/Composer/InstalledVersions.php.rpm ./src/Composer/InstalledVersions.php ---- ./src/Composer/InstalledVersions.php.rpm 2021-09-14 15:45:17.000000000 +0200 -+++ ./src/Composer/InstalledVersions.php 2021-09-14 15:45:33.026118007 +0200 -@@ -251,7 +251,7 @@ class InstalledVersions +--- ./src/Composer/InstalledVersions.php.rpm 2022-01-25 09:39:15.000000000 +0100 ++++ ./src/Composer/InstalledVersions.php 2022-01-25 09:50:21.373957265 +0100 +@@ -264,7 +264,7 @@ class InstalledVersions if (null === self::$installed) { // only require the installed.php file if this file is loaded from its dumped location, // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 @@ -46,7 +46,7 @@ diff -up ./src/Composer/InstalledVersions.php.rpm ./src/Composer/InstalledVersio self::$installed = include __DIR__ . '/installed.php'; } else { self::$installed = array(); -@@ -324,7 +324,7 @@ class InstalledVersions +@@ -337,7 +337,7 @@ class InstalledVersions if (null === self::$installed) { // only require the installed.php file if this file is loaded from its dumped location, // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 @@ -56,9 +56,9 @@ diff -up ./src/Composer/InstalledVersions.php.rpm ./src/Composer/InstalledVersio } else { self::$installed = array(); diff -up ./src/Composer/Json/JsonFile.php.rpm ./src/Composer/Json/JsonFile.php ---- ./src/Composer/Json/JsonFile.php.rpm 2021-09-14 15:45:17.000000000 +0200 -+++ ./src/Composer/Json/JsonFile.php 2021-09-14 15:46:22.434026477 +0200 -@@ -34,7 +34,7 @@ class JsonFile +--- ./src/Composer/Json/JsonFile.php.rpm 2022-01-25 09:39:15.000000000 +0100 ++++ ./src/Composer/Json/JsonFile.php 2022-01-25 09:50:21.373957265 +0100 +@@ -35,7 +35,7 @@ class JsonFile const JSON_PRETTY_PRINT = 128; const JSON_UNESCAPED_UNICODE = 256; @@ -67,7 +67,7 @@ diff -up ./src/Composer/Json/JsonFile.php.rpm ./src/Composer/Json/JsonFile.php /** @var string */ private $path; -@@ -191,7 +191,7 @@ class JsonFile +@@ -197,7 +197,7 @@ class JsonFile $isComposerSchemaFile = false; if (null === $schemaFile) { $isComposerSchemaFile = true; @@ -77,9 +77,9 @@ diff -up ./src/Composer/Json/JsonFile.php.rpm ./src/Composer/Json/JsonFile.php // Prepend with file:// only when not using a special schema already (e.g. in the phar) diff -up ./tests/Composer/Test/Json/ComposerSchemaTest.php.rpm ./tests/Composer/Test/Json/ComposerSchemaTest.php ---- ./tests/Composer/Test/Json/ComposerSchemaTest.php.rpm 2021-09-14 15:45:17.000000000 +0200 -+++ ./tests/Composer/Test/Json/ComposerSchemaTest.php 2021-09-14 15:45:33.025118009 +0200 -@@ -93,7 +93,8 @@ class ComposerSchemaTest extends TestCas +--- ./tests/Composer/Test/Json/ComposerSchemaTest.php.rpm 2022-01-25 09:39:15.000000000 +0100 ++++ ./tests/Composer/Test/Json/ComposerSchemaTest.php 2022-01-25 09:50:21.373957265 +0100 +@@ -97,7 +97,8 @@ class ComposerSchemaTest extends TestCas private function check($json) { $validator = new Validator(); @@ -90,8 +90,8 @@ diff -up ./tests/Composer/Test/Json/ComposerSchemaTest.php.rpm ./tests/Composer/ if (!$validator->isValid()) { $errors = $validator->getErrors(); diff -up ./tests/Composer/Test/PolyfillTestCase.php.rpm ./tests/Composer/Test/PolyfillTestCase.php ---- ./tests/Composer/Test/PolyfillTestCase.php.rpm 2021-09-14 15:45:17.000000000 +0200 -+++ ./tests/Composer/Test/PolyfillTestCase.php 2021-09-14 15:45:33.026118007 +0200 +--- ./tests/Composer/Test/PolyfillTestCase.php.rpm 2022-01-25 09:39:15.000000000 +0100 ++++ ./tests/Composer/Test/PolyfillTestCase.php 2022-01-25 09:50:21.373957265 +0100 @@ -15,10 +15,35 @@ namespace Composer\Test { use PHPUnit\Framework\Constraint\LogicalNot; use PHPUnit\Framework\Constraint\StringContains; @@ -129,3 +129,15 @@ diff -up ./tests/Composer/Test/PolyfillTestCase.php.rpm ./tests/Composer/Test/Po } else { abstract class PolyfillTestCase extends TestCase { +diff -up ./src/Composer/vendor/composer/ca-bundle/src/CaBundle.php.rpm ./src/Composer/vendor/composer/ca-bundle/src/CaBundle.php +--- ./src/Composer/vendor/composer/ca-bundle/src/CaBundle.php.rpm 2022-01-25 09:50:57.595802751 +0100 ++++ ./src/Composer/vendor/composer/ca-bundle/src/CaBundle.php 2022-01-25 09:51:36.038638770 +0100 +@@ -125,7 +125,7 @@ class CaBundle + */ + public static function getBundledCaBundlePath() + { +- $caBundleFile = __DIR__.'/../res/cacert.pem'; ++ $caBundleFile = '/etc/pki/tls/certs/ca-bundle.crt'; // System CA, always + + // cURL does not understand 'phar://' paths + // see https://github.com/composer/ca-bundle/issues/10 diff --git a/composer.spec b/composer.spec index 62b7a0f..72f5399 100644 --- a/composer.spec +++ b/composer.spec @@ -10,7 +10,13 @@ # For compatibility with SCL %undefine __brp_mangle_shebangs +%if 0%{?fedora} %bcond_without tests +%bcond_without syslib +%else +%bcond_with tests +%bcond_with syslib +%endif %global gh_commit 22c41ef275c7bb64fa28fb2c0871a39666832cb9 %global gh_short %(c=%{gh_commit}; echo ${c:0:7}) @@ -32,9 +38,10 @@ Name: composer Version: %{upstream_version}%{?upstream_prever:~%{upstream_lower}} -Release: 1%{?dist} +Release: 2%{?dist} Summary: Dependency Manager for PHP +# composer and all dependencies are MIT License: MIT URL: https://getcomposer.org/ Source0: %{gh_project}-%{upstream_version}%{?upstream_prever}-%{gh_short}.tgz @@ -50,7 +57,10 @@ Patch0: %{name}-rpm.patch Patch1: %{name}-noxdg.patch BuildArch: noarch +# platform set in makesrc.sh +BuildRequires: php(language) >= 7.4 BuildRequires: php-cli +BuildRequires: php-json %if %{with tests} BuildRequires: (php-composer(composer/ca-bundle) >= 1.0 with php-composer(composer/ca-bundle) < 2) BuildRequires: (php-composer(composer/metadata-minifier) >= 1.0 with php-composer(composer/metadata-minifier) < 2) @@ -58,8 +68,8 @@ BuildRequires: (php-composer(composer/semver) >= 3.0 with php-com BuildRequires: (php-composer(composer/spdx-licenses) >= 1.2 with php-composer(composer/spdx-licenses) < 2) BuildRequires: (php-composer(composer/xdebug-handler) >= 2.0 with php-composer(composer/xdebug-handler) < 3) BuildRequires: (php-composer(seld/jsonlint) >= 1.4 with php-composer(seld/jsonlint) < 2) -BuildRequires: (php-composer(seld/phar-utils) >= 1.0 with php-composer(seld/phar-utils) < 2) -BuildRequires: (php-composer(psr/log) >= 1.0 with php-composer(psr/log) < 3) +BuildRequires: (php-composer(seld/phar-utils) >= 1.1 with php-composer(seld/phar-utils) < 2) +BuildRequires: (php-composer(psr/log) >= 1.1 with php-composer(psr/log) < 3) BuildRequires: (php-composer(justinrainbow/json-schema) >= 5.2.11 with php-composer(justinrainbow/json-schema) < 6) BuildRequires: (php-composer(react/promise) >= 2.7 with php-composer(react/promise) < 3) BuildRequires: (php-composer(composer/pcre) >= 1.0 with php-composer(composer/pcre) < 2) @@ -74,8 +84,6 @@ BuildRequires: php-zip BuildRequires: %{_phpunit} # For autoloader BuildRequires: php-fedora-autoloader-devel -BuildRequires: php-seld-phar-utils >= 1.1 -BuildRequires: php-PsrLog >= 1.1 %endif # From composer.json, "require": { @@ -95,16 +103,17 @@ BuildRequires: php-PsrLog >= 1.1 # "symfony/process": "^^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0", # "react/promise": "^1.2 || ^2.7", # "composer/pcre": "^1.0" -Requires: php(language) >= 5.3.2 +Requires: php(language) >= 7.4 Requires: php-cli +%if %{with syslib} Requires: (php-composer(composer/ca-bundle) >= 1.0 with php-composer(composer/ca-bundle) < 2) Requires: (php-composer(composer/metadata-minifier) >= 1.0 with php-composer(composer/metadata-minifier) < 2) Requires: (php-composer(composer/semver) >= 3.0 with php-composer(composer/semver) < 4) Requires: (php-composer(composer/spdx-licenses) >= 1.2 with php-composer(composer/spdx-licenses) < 2) Requires: (php-composer(composer/xdebug-handler) >= 2.0 with php-composer(composer/xdebug-handler) < 3) Requires: (php-composer(seld/jsonlint) >= 1.4 with php-composer(seld/jsonlint) < 2) -Requires: (php-composer(seld/phar-utils) >= 1.0 with php-composer(seld/phar-utils) < 2) -Requires: (php-composer(psr/log) >= 1.0 with php-composer(psr/log) < 3) +Requires: (php-composer(seld/phar-utils) >= 1.1 with php-composer(seld/phar-utils) < 2) +Requires: (php-composer(psr/log) >= 1.1 with php-composer(psr/log) < 3) Requires: (php-composer(justinrainbow/json-schema) >= 5.2.11 with php-composer(justinrainbow/json-schema) < 6) Requires: (php-composer(react/promise) >= 2.7 with php-composer(react/promise) < 3) Requires: (php-composer(composer/pcre) >= 1.0 with php-composer(composer/pcre) < 2) @@ -112,6 +121,38 @@ Requires: %{symfony_prefix}-console >= %{symfony_min} Requires: %{symfony_prefix}-finder >= %{symfony_min} Requires: %{symfony_prefix}-process >= %{symfony_min} Requires: %{symfony_prefix}-filesystem >= %{symfony_min} +# For our autoloader +Requires: php-composer(fedora/autoloader) +%else +# System certificates +Requires: ca-certificates +# Bundled libraries +Provides: bundled(php-composer-ca-bundle) = 1.3.1 +Provides: bundled(php-composer-metadata-minifier) = 1.0.0 +Provides: bundled(php-composer-pcre) = 1.0.1 +Provides: bundled(php-composer-semver) = 3.2.7 +Provides: bundled(php-composer-spdx-licenses) = 1.5.6 +Provides: bundled(php-composer-xdebug-handler) = 2.0.4 +Provides: bundled(php-justinrainbow-json-schema) = 5.2.11 +Provides: bundled(php-psr-container) = 1.1.2 +Provides: bundled(php-psr-log) = 1.1.4 +Provides: bundled(php-react-promise) = v2.8.0 +Provides: bundled(php-seld-jsonlint) = 1.8.3 +Provides: bundled(php-seld-phar-utils) = 1.2.0 +Provides: bundled(php-symfony-console) = v5.4.2 +Provides: bundled(php-symfony-deprecation-contracts) = v2.5.0 +Provides: bundled(php-symfony-filesystem) = v5.4.0 +Provides: bundled(php-symfony-finder) = v5.4.2 +Provides: bundled(php-symfony-polyfill-ctype) = v1.24.0 +Provides: bundled(php-symfony-polyfill-intl-grapheme) = v1.24.0 +Provides: bundled(php-symfony-polyfill-intl-normalizer) = v1.24.0 +Provides: bundled(php-symfony-polyfill-mbstring) = v1.24.0 +Provides: bundled(php-symfony-polyfill-php73) = v1.24.0 +Provides: bundled(php-symfony-polyfill-php80) = v1.24.0 +Provides: bundled(php-symfony-process) = v5.4.2 +Provides: bundled(php-symfony-service-contracts) = v2.5.0 +Provides: bundled(php-symfony-string) = v5.4.2 +%endif # From composer.json, suggest # "ext-openssl": "Enabling the openssl extension allows you to access https URLs for repositories and packages", # "ext-zip": "Enabling the zip extension allows you to unzip archives", @@ -119,10 +160,6 @@ Requires: %{symfony_prefix}-filesystem >= %{symfony_min} Requires: php-openssl Requires: php-zip Requires: php-zlib -# For our autoloader -Requires: php-composer(fedora/autoloader) -Requires: php-seld-phar-utils >= 1.1 -Requires: php-PsrLog >= 1.1 # From phpcompatinfo for version 2.0.0 Requires: php-ctype Requires: php-curl @@ -170,6 +207,12 @@ if grep -r '\.\./res'; then exit 1 fi +rm src/bootstrap.php +rm src/Composer/vendor/composer/ca-bundle/res/cacert.pem + +%if %{with syslib} +rm -rf src/Composer/vendor + phpab --template fedora --output src/Composer/autoload.php src/Composer cat << 'EOF' | tee -a src/Composer/autoload.php @@ -201,8 +244,30 @@ require 'Composer/autoload.php'; \Fedora\Autoloader\Autoload::addPsr0('Composer\\Test\\', __DIR__ . '/'); EOF -rm src/bootstrap.php +%else +: symlink autoloader for library +ln -s vendor/autoload.php src/Composer/autoload.php +: fix layout +sed -e "s:/../..' . '/src/Composer::" -i src/Composer/vendor/composer/autoload_static.php + +: List bundled libraries and Licenses +php -r ' + $pkgs = file_get_contents("src/Composer/vendor/composer/installed.json"); + $pkgs = json_decode($pkgs, true); + if (!is_array($pkgs) || !isset($pkgs["packages"])) { + echo "cant decode json file\n"; + exit(3); + } + $lic = []; + foreach($pkgs["packages"] as $pkg) { + printf("Provides: bundled(php-%s) = %s\n", str_replace(["/", "_"], ["-", "-"], $pkg["name"]), $pkg["version"]); + $lic = array_merge($lic, $pkg["license"]); + } + sort($lic); + printf("\nLicense: %s\n\n", implode(" and ", array_unique($lic))); +' +%endif : fix reported version %if 0%{?gh_date} @@ -256,7 +321,7 @@ install -Dpm 755 bin/%{name} %{buildroot}%{_bindir}/%{name} %check -%if %{with tests} +%if %{with tests} && %{with syslib} : Online tests rm tests/Composer/Test/Util/RemoteFilesystemTest.php @@ -304,6 +369,9 @@ exit $ret %changelog +* Tue Jan 25 2022 Remi Collet - 2.2.5-2 +- use system libraries on Fedora, bundled libraries on EL + * Sat Jan 22 2022 Remi Collet - 2.2.5-1 - update to 2.2.5 diff --git a/makesrc.sh b/makesrc.sh index 9615a91..1d89e2e 100755 --- a/makesrc.sh +++ b/makesrc.sh @@ -8,21 +8,29 @@ PREVER=$(sed -n '/^%global upstream_prever/{s/.* //;p}' $NAME.spec) COMMIT=$(sed -n '/^%global gh_commit/{s/.* //;p}' $NAME.spec) SHORT=${COMMIT:0:7} -echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION$PREVER\n" +if [ -f $NAME-$VERSION$PREVER-$SHORT.tgz ]; then + echo skip $NAME-$VERSION$PREVER-$SHORT.tgz already here +else + echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION$PREVER\n" -echo "Cloning..." -git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT + echo "Cloning..." + git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT -echo "Getting commit..." -pushd $PROJECT-$COMMIT -git checkout $COMMIT -cp composer.json ../composer.json -popd + echo "Getting commit..." + pushd $PROJECT-$COMMIT + git checkout $COMMIT || exit 1 + cp composer.json ../composer.json + composer config platform.php 7.4 + rm composer.lock + export COMPOSER_VENDOR_DIR=src/Composer/vendor + composer install --no-interaction --no-progress --no-dev --optimize-autoloader + cp src/Composer/vendor/composer/installed.json ../ + popd -echo "Archiving..." -tar czf $NAME-$VERSION$PREVER-$SHORT.tgz --exclude .git $PROJECT-$COMMIT - -echo "Cleaning..." -rm -rf $PROJECT-$COMMIT + echo "Archiving..." + tar czf $NAME-$VERSION$PREVER-$SHORT.tgz --exclude .git $PROJECT-$COMMIT + echo "Cleaning..." + rm -rf $PROJECT-$COMMIT +fi echo "Done." diff --git a/sources b/sources index b3069cc..febbfd2 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (composer-2.2.5-22c41ef.tgz) = 5854ee3efca274c6c88e327244edec91c3e297db0921382a0cd30767d87db0407040245055b7b3484c6932afd4b97bbc99d25e87afa8ebb00173591c6948b7fb +SHA512 (composer-2.2.5-22c41ef.tgz) = dce37e84638863780975745e09771eaf473561eddd6557f8cd0a0de79e4b78dde6e92a7002287d4fb857d3178a6a17d142df1f9dd4d61dc0258af6cf49717205