+#
+# Conditional build:
+%bcond_without tests # build with tests
+
# NOTE
# - release tarballs: http://getcomposer.org/download/
-# Conditional build:
-%bcond_with bootstrap # build boostrap
-
+%define rel 15
+#define githash 5744981
+# $ git rev-list 1.0.0-alpha11..%{githash} --count
+#define commits 216
+%define subver alpha11
%define php_min_version 5.3.4
-%define subver alpha8
-%define rel 1
%include /usr/lib/rpm/macros.php
Summary: Dependency Manager for PHP
Name: composer
Version: 1.0.0
-Release: 0.%{subver}.%{rel}
+Release: %{rel}.%{subver}%{?commits:.%{commits}}%{?githash:.g%{githash}}
License: MIT
Group: Development/Languages/PHP
+#Source0: https://github.com/composer/composer/archive/%{githash}/%{name}-%{version}-%{subver}-%{commits}-g%{githash}.tar.gz
Source0: https://github.com/composer/composer/archive/%{version}-%{subver}/%{name}-%{version}-%{subver}.tar.gz
-# Source0-md5: a304aecf48b8406730d572e204afd6db
-%if %{with bootstrap}
-Source1: http://getcomposer.org/download/%{version}-%{subver}/%{name}.phar
-# Source1-md5: df1001975035f07d09307bf1f1e62584
-%endif
+# Source0-md5: 5e4ff16cff75fae31285196c5f51a8f8
Source2: https://raw.githubusercontent.com/iArren/%{name}-bash-completion/86a8129/composer
# Source2-md5: cdeebf0a0da1fd07d0fd886d0461642e
-Patch0: nogit.patch
-Patch1: no-vendors.patch
-Patch2: autoload-config.patch
+Source3: autoload.php
+Patch0: autoload.patch
+Patch1: update-memory-limit.patch
+Patch2: svn-ignore-externals.patch
+Patch3: version.patch
URL: http://www.getcomposer.org/
-BuildRequires: /usr/bin/phar
-BuildRequires: /usr/bin/php
-BuildRequires: php(ctype)
-BuildRequires: php(hash)
-BuildRequires: php(json)
-BuildRequires: php(openssl)
-BuildRequires: php(phar)
-BuildRequires: php(zip)
-BuildRequires: php(zlib)
BuildRequires: rpm-php-pearprov >= 4.4.2-11
BuildRequires: rpmbuild(macros) >= 1.673
-%if %{without bootstrap}
-BuildRequires: %{name}
-BuildRequires: php-symfony2-Console >= 2.3
-BuildRequires: php-symfony2-Finder >= 2.2
+%if %{with tests}
+BuildRequires: composer
+BuildRequires: phpab
+BuildRequires: phpunit
%endif
Requires: php(core) >= %{php_min_version}
+Requires: php(ctype)
+Requires: php(date)
+Requires: php(filter)
Requires: php(hash)
+Requires: php(json)
+Requires: php(openssl)
+Requires: php(pcre)
Requires: php(phar)
-%if %{without bootstrap}
-Requires: php-justinrainbow-json-schema >= 1.1.0
+Requires: php(posix)
+Requires: php(simplexml)
+Requires: php(spl)
+Requires: php(zip)
+Requires: php(zlib)
+Requires: php-composer-semver >= 1.0.0
+Requires: php-composer-spdx-licenses >= 1.0.0
+Requires: php-justinrainbow-json-schema >= 1.4
Requires: php-seld-jsonlint >= 1.1.2
-Requires: php-symfony2-Console >= 2.3
-Requires: php-symfony2-Finder >= 2.2
-Requires: php-symfony2-Process >= 2.1
-%endif
+Requires: php-seld-phar-utils >= 1.0.0
+Requires: php-symfony2-ClassLoader >= 2.7.7
+Requires: php-symfony2-Console >= 2.7.7
+Requires: php-symfony2-Finder >= 2.7.7
+Requires: php-symfony2-Process >= 2.7.7
Suggests: bash-completion-%{name}
Suggests: git-core
Suggests: mercurial
-Suggests: php(openssl)
-Suggests: php(zip)
Suggests: subversion
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
-%define _appdir %{_datadir}/%{name}
-
%description
-Composer is a tool for dependency management in PHP. It allows you to
-declare the dependent libraries your project needs and it will install
-them in your project for you.
+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.
%package -n bash-completion-%{name}
Summary: Bash completion for Composer
%setup -qc -n %{name}-%{version}-%{release}
mv composer-*/* .
%patch0 -p1
-%{!?with_bootstrap:%patch1 -p1}
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
mv composer.lock{,.disabled}
-%{__sed} -i -e '1s,^#!.*env php,#!%{__php},' bin/*
+# NOTE: do not use %{__php} macro here, need unversioned php binary
+%{__sed} -i -e '1s,^#!.*env php,#!/usr/bin/php,' bin/*
-%build
-%if %{with bootstrap}
-composer='%{__php} %{SOURCE1}'
-phar extract -f "%{SOURCE1}" -i vendor .
-%else
-composer=composer
-%endif
-if [ ! -d vendor ]; then
- COMPOSER_HOME=${PWD:=$(pwd)} \
- $composer dump-autoload -v
- %{__patch} -p1 < %{PATCH2}
-fi
+cp -p %{SOURCE3} src/Composer/autoload.php
-COMPOSER_VERSION=%{version}%{?subver:-%{subver}} \
-%{__php} -d phar.readonly=0 ./bin/compile
+# AutoloadGenerator needs this runtime
+mv LICENSE res
-# sanity check
-%{__php} composer.phar --version
+# move to Composer dir, this will simplify testing
+mv res src/Composer
+ln -s src/Composer/res
-install -d build
-%{__php} -r '$phar = new Phar($argv[1]); $phar->extractTo($argv[2]);' composer.phar build
+# cleanup backups after patching
+find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f
+
+# needs newer phpunit:
+# missing method PHPUnit_Framework_MockObject_Builder_InvocationMocker::willReturn()
+rm tests/Composer/Test/EventDispatcher/EventDispatcherTest.php
+rm tests/Composer/Test/IO/ConsoleIOTest.php
+rm tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php
+rm tests/Composer/Test/Package/RootAliasPackageTest.php
+rm tests/Composer/Test/Package/Version/VersionGuesserTest.php
+rm tests/Composer/Test/Util/GitHubTest.php
+
+%build
+%if %{with tests}
+phpab -n -o src/bootstrap.php -e '*/Fixtures/*' src/ tests/
+echo "require 'src/Composer/autoload.php';" >> src/bootstrap.php
+phpunit
+%endif
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_bindir},%{_appdir}}
-cd build
-cp -a bin src res vendor $RPM_BUILD_ROOT%{_appdir}
-ln -s %{_appdir}/bin/%{name} $RPM_BUILD_ROOT%{_bindir}/%{name}
-chmod +x $RPM_BUILD_ROOT%{_appdir}/bin/*
+install -d $RPM_BUILD_ROOT{%{_bindir},%{php_data_dir}/Composer,/var/cache/composer}
+cp -a src/Composer $RPM_BUILD_ROOT%{php_data_dir}
+install -p bin/composer $RPM_BUILD_ROOT%{_bindir}/%{name}
install -d $RPM_BUILD_ROOT%{bash_compdir}
cp -p %{SOURCE2} $RPM_BUILD_ROOT%{bash_compdir}/composer
%files
%defattr(644,root,root,755)
-%doc README.md CHANGELOG.md LICENSE PORTING_INFO
+%doc README.md CHANGELOG.md PORTING_INFO
+%doc src/Composer/res/LICENSE
%attr(755,root,root) %{_bindir}/composer
-%dir %{_appdir}
-%dir %{_appdir}/bin
-%attr(755,root,root) %{_appdir}/bin/*
-%{_appdir}/res
-%{_appdir}/src
-%{_appdir}/vendor
+%{php_data_dir}/Composer
+
+# top level cachedir, create user cache dirs here manually
+%dir %attr(711,root,http) /var/cache/composer
%files -n bash-completion-%{name}
%defattr(644,root,root,755)