[packages/composer22] New package: composer 2.2 LTS for PHP older than 7.2.5
arekm
arekm at pld-linux.org
Wed Oct 28 12:18:50 CET 2026
commit b11207b25ffc250aff107163df81eb2b27fc9a8e
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Wed Oct 28 12:17:27 2026 +0100
New package: composer 2.2 LTS for PHP older than 7.2.5
Composer 2.3+ needs PHP 7.2.5, while PLD still ships php53 to php71.
Installs as /usr/share/composer22 and /usr/bin/composer22, so it can be
installed in parallel with composer. vendor/ comes from upstream
composer.lock; update-source.sh regenerates the archive.
composer22.spec | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
update-source.sh | 59 +++++++++++++++++++++++++++++++++++
2 files changed, 153 insertions(+)
---
diff --git a/composer22.spec b/composer22.spec
new file mode 100644
index 0000000..eedf8fa
--- /dev/null
+++ b/composer22.spec
@@ -0,0 +1,94 @@
+#
+# Conditional build:
+%bcond_with online # online self-test
+
+%if 0%{?_pld_builder:1}
+%undefine with_online
+%endif
+
+%define php_min_version 5.3.2
+Summary: Dependency Manager for PHP - 2.2 LTS line
+Name: composer22
+Version: 2.2.30
+Release: 1
+License: MIT
+Group: Development/Languages/PHP
+Source0: https://github.com/composer/composer/archive/%{version}/composer-%{version}.tar.gz
+# Source0-md5: b4e7da814c38352cb3e2769b0bd4daf8
+# vendor/ installed from upstream composer.lock, as in the official phar;
+# regenerate with ./update-source.sh [version]
+Source1: %{name}-vendor-%{version}.tar.xz
+# Source1-md5: 6e54aee399b0a0cb505a782f60043c71
+URL: https://getcomposer.org/
+BuildRequires: php-devel
+BuildRequires: rpm-php-pearprov >= 4.4.2-11
+BuildRequires: rpmbuild(macros) >= 1.673
+%{?with_online:BuildRequires: %{php_name}-cli}
+Requires: php(core) >= %{php_min_version}
+Requires: php(ctype)
+Requires: php(date)
+Requires: php(filter)
+Requires: php(hash)
+Requires: php(json)
+Requires: php(mbstring)
+Requires: php(openssl)
+Requires: php(pcntl)
+Requires: php(pcre)
+Requires: php(phar)
+Requires: php(posix)
+Requires: php(simplexml)
+Requires: php(spl)
+Requires: php(zip)
+Requires: php(zlib)
+Requires: unzip
+Suggests: git-core
+Suggests: mercurial
+Suggests: subversion
+BuildArch: noarch
+BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+Composer is a tool for dependency management in PHP.
+
+Composer helps you declare, manage and install dependencies of PHP
+projects, ensuring you have the right stack everywhere.
+
+This is the 2.2 LTS line for PHP versions older than 7.2.5, installed
+as composer22.
+
+%prep
+%setup -q -n composer-%{version} -a1
+
+# NOTE: do not use %{__php} macro here, need unversioned php binary
+%{__sed} -i -e '1s,^#!.*env php,#!/usr/bin/php,' bin/composer
+
+%build
+%if %{with online}
+# always run self-test
+%{__php} ./bin/composer diagnose
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT{%{_bindir},%{_datadir}/%{name}/bin}
+# AutoloadGenerator copies LICENSE from the top of the tree into generated autoloaders
+cp -a LICENSE res src vendor $RPM_BUILD_ROOT%{_datadir}/%{name}
+install -p bin/composer $RPM_BUILD_ROOT%{_datadir}/%{name}/bin
+# command line tools of the bundled libraries, composer does not run them
+%{__rm} -r $RPM_BUILD_ROOT%{_datadir}/%{name}/vendor/{bin,justinrainbow/json-schema/bin,seld/jsonlint/bin}
+ln -s %{_datadir}/%{name}/bin/composer $RPM_BUILD_ROOT%{_bindir}/%{name}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(644,root,root,755)
+%doc CHANGELOG.md README.md UPGRADE-2.0.md
+%attr(755,root,root) %{_bindir}/%{name}
+%dir %{_datadir}/%{name}
+%dir %{_datadir}/%{name}/bin
+%attr(755,root,root) %{_datadir}/%{name}/bin/composer
+%{_datadir}/%{name}/LICENSE
+%{_datadir}/%{name}/res
+%{_datadir}/%{name}/src
+%{_datadir}/%{name}/vendor
diff --git a/update-source.sh b/update-source.sh
new file mode 100755
index 0000000..c6fcbd7
--- /dev/null
+++ b/update-source.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Regenerate the vendor/ archive (Source1) from upstream composer.lock.
+# usage: ./update-source.sh [version] (default: Version from the spec)
+set -e
+
+dir=$(cd "$(dirname "$0")" && pwd)
+cd "$dir"
+pkg=$(basename "$dir")
+specfile=$pkg.spec
+php=${PHP:-php}
+
+oldversion=$(awk '/^Version:/{print $2; exit}' $specfile)
+version=${1:-$oldversion}
+tarball=composer-$version.tar.gz
+vendor=$pkg-vendor-$version.tar.xz
+
+test -f $tarball || wget -nv -O $tarball https://github.com/composer/composer/archive/$version/$tarball
+
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT INT TERM
+
+# installer of the same version, checked against the published checksum
+wget -nv -O $tmp/composer.phar https://getcomposer.org/download/$version/composer.phar
+sum=$(wget -qO- https://getcomposer.org/download/$version/composer.phar.sha256sum | awk '{print $1}')
+echo "$sum $tmp/composer.phar" | sha256sum -c -
+
+tar xzf $tarball -C $tmp
+cd $tmp/composer-$version
+export COMPOSER_ROOT_VERSION=$version COMPOSER_HOME=$tmp/home COMPOSER_CACHE_DIR=$tmp/cache COMPOSER_NO_INTERACTION=1
+# 2.2 picks a random autoloader suffix; pin it to the lock's content-hash as 2.3+ does
+hash=$(sed -n 's/^ *"content-hash": "\([0-9a-f]*\)".*/\1/p' composer.lock)
+mkdir $COMPOSER_HOME
+echo "{\"config\": {\"autoloader-suffix\": \"$hash\"}}" > $COMPOSER_HOME/config.json
+$php $tmp/composer.phar install --no-dev --no-plugins --no-scripts --no-progress --quiet
+# the phar ships whitespace-stripped sources; dump again with this tree so
+# vendor/composer/ClassLoader.php is the tag's own file
+$php bin/composer dump-autoload --no-dev --no-plugins --no-scripts --quiet
+cmp vendor/composer/ClassLoader.php src/Composer/Autoload/ClassLoader.php
+$php <<'EOF'
+<?php
+$lock = json_decode(file_get_contents('composer.lock'), true);
+$inst = json_decode(file_get_contents('vendor/composer/installed.json'), true);
+$inst = isset($inst['packages']) ? $inst['packages'] : $inst;
+$want = $got = array();
+foreach ($lock['packages'] as $p) $want[$p['name']] = $p['version'];
+foreach ($inst as $p) $got[$p['name']] = $p['version'];
+ksort($want); ksort($got);
+if ($want !== $got) { fwrite(STDERR, "vendor/ does not match composer.lock\n"); exit(1); }
+echo count($got), " packages, matching composer.lock\n";
+EOF
+
+tar --sort=name --owner=0 --group=0 --numeric-owner --mode=u+rwX,go+rX,go-w \
+ --mtime=@$(stat -c %Y composer.json) -cf - vendor | xz -T1 -9 > "$dir/$vendor"
+cd "$dir"
+
+if [ "$version" != "$oldversion" ]; then
+ sed -i -e "s/^\(Version:[[:space:]]*\).*/\1$version/" -e "s/^\(Release:[[:space:]]*\).*/\11/" $specfile
+fi
+../builder -ncs -5 $specfile
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/composer22.git/commitdiff/b11207b25ffc250aff107163df81eb2b27fc9a8e
More information about the pld-cvs-commit
mailing list