diff --git a/composer-2.8.8-85ff84d.tgz b/composer-2.8.8-85ff84d.tgz new file mode 100644 index 0000000000000000000000000000000000000000..c368f6886c518fe22e8977e839861cd3f6157488 Binary files /dev/null and b/composer-2.8.8-85ff84d.tgz differ diff --git a/composer-add-sjtu.patch b/composer-add-sjtu.patch new file mode 100644 index 0000000000000000000000000000000000000000..91dee6576ee7a7f357548a71d167181ef8c7983e --- /dev/null +++ b/composer-add-sjtu.patch @@ -0,0 +1,15 @@ +diff --git a/src/Composer/Config.php b/src/Composer/Config.php +index f39579e..22b5f35 100644 +--- a/src/Composer/Config.php ++++ b/src/Composer/Config.php +@@ -90,6 +90,10 @@ class Config + + /** @var array */ + public static $defaultRepositories = [ ++ 'sjtu' => [ ++ 'type' => 'composer', ++ 'uri' => 'https://packagist.mirrors.sjtug.sjtu.edu.cn', ++ ], + 'packagist.org' => [ + 'type' => 'composer', + 'url' => 'https://repo.packagist.org', diff --git a/composer-bash-completion b/composer-bash-completion new file mode 100644 index 0000000000000000000000000000000000000000..f31bc3a82904eaff786dad791c40c10f236a1c4d --- /dev/null +++ b/composer-bash-completion @@ -0,0 +1,84 @@ +# This file is part of the Symfony package. +# +# (c) Fabien Potencier +# +# For the full copyright and license information, please view +# https://symfony.com/doc/current/contributing/code/license.html + +_sf_composer() { + # Use newline as only separator to allow space in completion values + local IFS=$'\n' + local sf_cmd="${COMP_WORDS[0]}" + + # for an alias, get the real script behind it + sf_cmd_type=$(type -t $sf_cmd) + if [[ $sf_cmd_type == "alias" ]]; then + sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/") + elif [[ $sf_cmd_type == "file" ]]; then + sf_cmd=$(type -p $sf_cmd) + fi + + if [[ $sf_cmd_type != "function" && ! -x $sf_cmd ]]; then + return 1 + fi + + local cur prev words cword + _get_comp_words_by_ref -n := cur prev words cword + + local completecmd=("$sf_cmd" "_complete" "--no-interaction" "-sbash" "-c$cword" "-S2.8.8") + for w in ${words[@]}; do + w=$(printf -- '%b' "$w") + # remove quotes from typed values + quote="${w:0:1}" + if [ "$quote" == \' ]; then + w="${w%\'}" + w="${w#\'}" + elif [ "$quote" == \" ]; then + w="${w%\"}" + w="${w#\"}" + fi + # empty values are ignored + if [ ! -z "$w" ]; then + completecmd+=("-i$w") + fi + done + + local sfcomplete + if sfcomplete=$(${completecmd[@]} 2>&1); then + local quote suggestions + quote=${cur:0:1} + + # Use single quotes by default if suggestions contains backslash (FQCN) + if [ "$quote" == '' ] && [[ "$sfcomplete" =~ \\ ]]; then + quote=\' + fi + + if [ "$quote" == \' ]; then + # single quotes: no additional escaping (does not accept ' in values) + suggestions=$(for s in $sfcomplete; do printf $'%q%q%q\n' "$quote" "$s" "$quote"; done) + elif [ "$quote" == \" ]; then + # double quotes: double escaping for \ $ ` " + suggestions=$(for s in $sfcomplete; do + s=${s//\\/\\\\} + s=${s//\$/\\\$} + s=${s//\`/\\\`} + s=${s//\"/\\\"} + printf $'%q%q%q\n' "$quote" "$s" "$quote"; + done) + else + # no quotes: double escaping + suggestions=$(for s in $sfcomplete; do printf $'%q\n' $(printf '%q' "$s"); done) + fi + COMPREPLY=($(IFS=$'\n' compgen -W "$suggestions" -- $(printf -- "%q" "$cur"))) + __ltrim_colon_completions "$cur" + else + if [[ "$sfcomplete" != *"Command \"_complete\" is not defined."* ]]; then + >&2 echo + >&2 echo $sfcomplete + fi + + return 1 + fi +} + +complete -F _sf_composer composer diff --git a/composer-noxdg.patch b/composer-noxdg.patch new file mode 100644 index 0000000000000000000000000000000000000000..29278482d662bf95b178c78133ba067a2dfa4fc0 --- /dev/null +++ b/composer-noxdg.patch @@ -0,0 +1,14 @@ +diff -up ./src/Composer/Factory.php.noxdg ./src/Composer/Factory.php +--- ./src/Composer/Factory.php.noxdg 2024-04-20 12:34:54.442117723 +0200 ++++ ./src/Composer/Factory.php 2024-04-20 12:35:39.497640757 +0200 +@@ -702,6 +702,10 @@ class Factory + + private static function useXdg(): bool + { ++ // As XDG is very partially implemented ++ // resulting in command/code in ~/.config ++ return false; ++ + foreach (array_keys($_SERVER) as $key) { + if (strpos((string) $key, 'XDG_') === 0) { + return true; diff --git a/composer-rpm.patch b/composer-rpm.patch new file mode 100644 index 0000000000000000000000000000000000000000..fdc97ac4bc02993d82741127fd6bca4ed0997af0 --- /dev/null +++ b/composer-rpm.patch @@ -0,0 +1,45 @@ +diff -up ./bin/composer.rpm ./bin/composer +--- ./bin/composer.rpm 2024-10-03 07:10:57.000000000 +0200 ++++ ./bin/composer 2024-10-03 07:11:10.751092365 +0200 +@@ -16,7 +16,7 @@ if (PHP_VERSION_ID < 70205) { + } + + setlocale(LC_ALL, 'C'); +-require __DIR__.'/../src/bootstrap.php'; ++require '/usr/share/composer/src/bootstrap.php'; + + use Composer\Console\Application; + use Composer\XdebugHandler\XdebugHandler; +diff -up ./src/Composer/InstalledVersions.php.rpm ./src/Composer/InstalledVersions.php +--- ./src/Composer/InstalledVersions.php.rpm 2024-10-03 07:10:57.000000000 +0200 ++++ ./src/Composer/InstalledVersions.php 2024-10-03 07:11:10.752092401 +0200 +@@ -266,7 +266,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 +- if (substr(__DIR__, -8, 1) !== 'C') { ++ if (substr(__DIR__, -8, 1) !== 'C' && is_file(__DIR__ . '/installed.php')) { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); +@@ -341,7 +341,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 +- if (substr(__DIR__, -8, 1) !== 'C') { ++ if (substr(__DIR__, -8, 1) !== 'C' && is_file(__DIR__ . '/installed.php')) { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; +diff -up ./vendor/composer/ca-bundle/src/CaBundle.php.rpm ./vendor/composer/ca-bundle/src/CaBundle.php +--- ./vendor/composer/ca-bundle/src/CaBundle.php.rpm 2024-09-25 09:49:53.000000000 +0200 ++++ ./vendor/composer/ca-bundle/src/CaBundle.php 2024-10-03 07:11:10.752092401 +0200 +@@ -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.csh b/composer.csh new file mode 100644 index 0000000000000000000000000000000000000000..b57b1d01d2562aa0c1861356a3963f165b49c428 --- /dev/null +++ b/composer.csh @@ -0,0 +1,9 @@ +# Composer initialization script + +# Add path to commands installed using "composer global require ..." +if ( ${euid} > 0 ) then + if ( "${path}" !~ *${HOME}/.composer/vendor/bin* ) then + set path = ( $path ${HOME}/.composer/vendor/bin ) + endif +endif + diff --git a/composer.sh b/composer.sh new file mode 100644 index 0000000000000000000000000000000000000000..c75753c2d75145b4d0ae5daa008aad7a03e4ff2b --- /dev/null +++ b/composer.sh @@ -0,0 +1,11 @@ +# Composer initialization script + +# Add path to commands installed using "composer global require ..." +if [ "${EUID:-0}" != "0" ]; then + case :$PATH: in + *:${HOME}/.composer/vendor/bin:*) ;; + *) PATH=$PATH:${HOME}/.composer/vendor/bin ;; + esac + export PATH +fi + diff --git a/composer.spec b/composer.spec new file mode 100644 index 0000000000000000000000000000000000000000..bc911b43a5e68e254fc97b95e99581a597de7d7c --- /dev/null +++ b/composer.spec @@ -0,0 +1,208 @@ +# remirepo/fedora spec file for composer +# +# SPDX-FileCopyrightText: Copyright 2015-2025 Remi Collet +# SPDX-License-Identifier: CECILL-2.1 +# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +# +# Please, preserve the changelog entries +# + +# remirepo:2 +# For compatibility with SCL +%undefine __brp_mangle_shebangs + +%global gh_commit 85ff84d6c5260ba21740a7c5c9a111890805d6e7 +%global gh_short %(c=%{gh_commit}; echo ${c:0:7}) +%global gh_branch 2.0-dev +%global gh_owner composer +%global gh_project composer +%global api_version 2.6.0 +%global run_version 2.2.2 + +%global upstream_version 2.8.8 + +%global _phpunit %{_bindir}/phpunit9 + +Name: composer +Version: %{upstream_version} +Release: 1 +Summary: Dependency Manager for PHP + +# SPDX: composer and all dependencies are MIT +License: MIT +URL: https://getcomposer.org/ +Source0: %{gh_project}-%{upstream_version}%{?upstream_prever}-%{gh_short}.tgz +# Profile scripts +Source1: %{name}-bash-completion +Source3: %{name}.sh +Source4: %{name}.csh +# Create a git snapshot with dependencies +Source5: makesrc.sh + +# Use our autoloader, resources path, fix for tests +Patch0: %{name}-rpm.patch +# Disable XDG support as only partially implemented +Patch1: %{name}-noxdg.patch +# Add sjtu as packagist mirror +Patch2: %{name}-add-sjtu.patch + +BuildArch: noarch +# platform set in makesrc.sh +BuildRequires: php(language) >= 7.2.5 +BuildRequires: php-cli libxml2-devel +BuildRequires: php-json +BuildRequires: pkgconfig(bash-completion) +BuildRequires: composer-generators + +# From composer.json, "require": { +# "php": "^7.2.5 || ^8.0", +# "composer/ca-bundle": "^1.0", +# "composer/metadata-minifier": "^1.0", +# "composer/semver": "^3.0", +# "composer/spdx-licenses": "^1.2", +# "composer/xdebug-handler": "^2.0.2 || ^3.0.3", +# "justinrainbow/json-schema": "^5.2.11", +# "psr/log": "^1.0 || ^2.0 || ^3.0" +# "seld/jsonlint": "~1.4", +# "seld/phar-utils": "^1.2", +# "symfony/console": "^5.4.1 || ^6.0", +# "symfony/filesystem": "^5.4 || ^6.0", +# "symfony/finder": "^5.4 || ^6.0", +# "symfony/process": "^5.4 || ^6.0", +# "react/promise": "^2.8", +# "composer/pcre": "^2 || ^3" +# "symfony/polyfill-php73": "^1.24", +# "symfony/polyfill-php80": "^1.24" +Requires: php(language) >= 7.2.5 +Requires: php-cli +# System certificates +Requires: ca-certificates + +# 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", +# "ext-zlib": "Allow gzip compression of HTTP requests" +Requires: php-openssl +Requires: php-zip +Requires: php-zlib +# From phpcompatinfo for version 2.2.5 +Requires: php-ctype +Requires: php-curl +Requires: php-date +Requires: php-dom +Requires: php-filter +Requires: php-hash +Requires: php-iconv +Requires: php-intl +Requires: php-json +Requires: php-libxml +Requires: php-mbstring +Requires: php-pcntl +Requires: php-pcre +Requires: php-phar +Requires: php-posix +Requires: php-reflection +Requires: php-spl +Requires: php-tokenizer +Requires: php-xsl +Requires: php-zlib + +# Special internal for Plugin API +Provides: php-composer(composer-plugin-api) = %{api_version} +Provides: php-composer(composer-runtime-api) = %{run_version} + + +%description +Composer helps you declare, manage and install dependencies of PHP projects, +ensuring you have the right stack everywhere. + +Documentation: https://getcomposer.org/doc/ + + +%prep +%setup -q -n %{gh_project}-%{gh_commit} + +%patch -P0 -p1 -b .rpm +%patch -P1 -p1 -b .noxdg +find . \( -name \*.rpm -o -name \*noxdg \) -delete -print + +rm vendor/composer/ca-bundle/res/cacert.pem + +: fix reported version +sed -e '/BRANCH_ALIAS_VERSION/s/@package_branch_alias_version@//' \ + -i src/Composer/Composer.php + +: check Plugin API version +php -r ' +namespace Composer; +include "src/bootstrap.php"; +if (version_compare(Plugin\PluginInterface::PLUGIN_API_VERSION, "%{api_version}")) { + printf("Plugin API version is %s, expected %s\n", Plugin\PluginInterface::PLUGIN_API_VERSION, "%{api_version}"); + exit(1); +} +if (version_compare(Composer::RUNTIME_API_VERSION, "%{run_version}")) { + printf("Runtime API version is %s, expected %s\n", Composer::RUNTIME_API_VERSION, "%{run_version}"); + exit(1); +}' + + +%build +: Nothing to build + + +%install +: Profile scripts +install -Dpm 644 %{SOURCE1} %{buildroot}%{bash_completions_dir}/%{name} +mkdir -p %{buildroot}%{_sysconfdir}/profile.d +install -m 644 %{SOURCE3} %{SOURCE4} %{buildroot}%{_sysconfdir}/profile.d/ + +: Library autoloader for compatibility +mkdir -p %{buildroot}%{_datadir}/php/Composer +ln -s ../../composer/vendor/autoload.php %{buildroot}%{_datadir}/php/Composer/autoload.php + +: Sources +mkdir -p %{buildroot}%{_datadir}/%{name} +cp -pr src res vendor LICENSE\ + %{buildroot}%{_datadir}/%{name}/ + +: Command +install -Dpm 755 bin/%{name} %{buildroot}%{_bindir}/%{name} + +: Licenses +ln -sf ../../%{name}/LICENSE LICENSE +cd vendor +for lic in */*/LICENSE +do dir=$(dirname $lic) + own=$(dirname $dir) + prj=$(basename $dir) + ln -sf ../../composer/vendor/$own/$prj/LICENSE ../$own-$prj-LICENSE +done + + +%check +: Check autoloader +php -r ' + include "%{buildroot}%{_datadir}/%{name}/src/bootstrap.php"; + exit (class_exists("Composer\\Composer") ? 0 : 1); +' +: Check compatibility autoloader +php -r ' + include "%{buildroot}%{_datadir}/php/Composer/autoload.php"; + exit (class_exists("Composer\\Composer") ? 0 : 2); +' + + +%files +%license *LICENSE +%doc *.md +%doc doc +%doc composer.json +%config(noreplace) %{_sysconfdir}/profile.d/%{name}.* +%{_bindir}/%{name} +%{_datadir}/php/Composer +%{_datadir}/%{name} +%{bash_completions_dir}/* + +%changelog +* Sat Apr 05 2025 Funda Wang - 2.8.8-1 +- import from remi diff --git a/makesrc.sh b/makesrc.sh new file mode 100755 index 0000000000000000000000000000000000000000..dc25efb9934e3b2c91e2755f07edd6cb7ba06b80 --- /dev/null +++ b/makesrc.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +NAME=$(sed -n '/^Name:/{s/.* //;p}' *.spec) +OWNER=$(sed -n '/^%global gh_owner/{s/.* //;p}' $NAME.spec) +PROJECT=$(sed -n '/^%global gh_project/{s/.* //;p}' $NAME.spec) +VERSION=$(sed -n '/^%global upstream_version/{s/.* //;p}' $NAME.spec) +PREVER=$(sed -n '/^%global upstream_prever/{s/.* //;p}' $NAME.spec) +COMMIT=$(sed -n '/^%global gh_commit/{s/.* //;p}' $NAME.spec) +SHORT=${COMMIT:0:7} + +if [ -f $NAME-$VERSION$PREVER-$SHORT.tgz -a "$1" != "-f" ]; 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 "Getting commit..." + pushd $PROJECT-$COMMIT + git checkout $COMMIT || exit 1 + cp composer.json ../composer.json + composer config platform.php 7.2.5 + rm composer.lock + composer install --no-interaction --no-progress --no-dev --optimize-autoloader + cp vendor/composer/installed.json ../ + # bash completion + bin/composer completion bash >../composer-bash-completion + popd + + echo "Archiving..." + tar czf $NAME-$VERSION$PREVER-$SHORT.tgz --exclude .git $PROJECT-$COMMIT + + echo "Cleaning..." + rm -rf $PROJECT-$COMMIT +fi +echo "Done."