summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2015-02-26 11:02:01 +0100
committerRemi Collet <fedora@famillecollet.com>2015-02-26 11:02:01 +0100
commitde23e65be845f6a7bf5b00857a4c8674b1691120 (patch)
treea4674594bb5fa141589e3b21cef2f8eec1774bf2
composer: experimental package
-rw-r--r--Makefile4
-rw-r--r--composer-autoload.php16
-rw-r--r--composer-bootstrap.php6
-rw-r--r--composer-rpm.patch52
-rw-r--r--composer.spec160
5 files changed, 238 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1e65467
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+SRCDIR := $(shell pwd)
+NAME := $(shell basename $(SRCDIR))
+include ../common/Makefile
+
diff --git a/composer-autoload.php b/composer-autoload.php
new file mode 100644
index 0000000..546fe98
--- /dev/null
+++ b/composer-autoload.php
@@ -0,0 +1,16 @@
+<?php
+$vendorDir = '/usr/share/php';
+require_once $vendorDir . '/Symfony/Component/ClassLoader/UniversalClassLoader.php';
+use Symfony\Component\ClassLoader\UniversalClassLoader;
+
+$loader = new UniversalClassLoader();
+$loader->registerNamespaces(array(
+ 'Seld\\JsonLint' => $vendorDir,
+ 'JsonSchema' => $vendorDir,
+ 'Symfony\\Component\\Console' => $vendorDir,
+ 'Symfony\\Component\\Finder' => $vendorDir,
+ 'Symfony\\Component\\Process' => $vendorDir,
+ 'Symfony\\Component\\ClassLoader' => $vendorDir,
+ 'Composer' => dirname(__DIR__)
+));
+$loader->register();
diff --git a/composer-bootstrap.php b/composer-bootstrap.php
new file mode 100644
index 0000000..dcc5a5a
--- /dev/null
+++ b/composer-bootstrap.php
@@ -0,0 +1,6 @@
+<?php
+require 'Composer/autoload.php';
+$loader->registerNamespaces(array(
+ 'Composer\\Test' => __DIR__
+));
+require __DIR__.'/Composer/TestCase.php';
diff --git a/composer-rpm.patch b/composer-rpm.patch
new file mode 100644
index 0000000..b065e68
--- /dev/null
+++ b/composer-rpm.patch
@@ -0,0 +1,52 @@
+diff -up ./bin/composer.rpm ./bin/composer
+--- ./bin/composer.rpm 2015-02-25 20:44:34.000000000 +0100
++++ ./bin/composer 2015-02-26 10:25:16.012610034 +0100
+@@ -1,11 +1,11 @@
+-#!/usr/bin/env php
++#!/usr/bin/php
+ <?php
+
+ if (PHP_SAPI !== 'cli') {
+ echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
+ }
+
+-require __DIR__.'/../src/bootstrap.php';
++require 'Composer/autoload.php';
+
+ use Composer\Console\Application;
+
+diff -up ./src/Composer/Json/JsonFile.php.rpm ./src/Composer/Json/JsonFile.php
+--- ./src/Composer/Json/JsonFile.php.rpm 2015-02-25 20:44:34.000000000 +0100
++++ ./src/Composer/Json/JsonFile.php 2015-02-26 10:25:16.012610034 +0100
+@@ -149,7 +149,7 @@ class JsonFile
+ self::validateSyntax($content, $this->path);
+ }
+
+- $schemaFile = __DIR__ . '/../../../res/composer-schema.json';
++ $schemaFile = (getenv('BUILDROOT')?:'') . '/usr/share/composer/res/composer-schema.json';
+ $schemaData = json_decode(file_get_contents($schemaFile));
+
+ if ($schema === self::LAX_SCHEMA) {
+diff -up ./src/Composer/Util/SpdxLicenseIdentifier.php.rpm ./src/Composer/Util/SpdxLicenseIdentifier.php
+--- ./src/Composer/Util/SpdxLicenseIdentifier.php.rpm 2015-02-25 20:44:34.000000000 +0100
++++ ./src/Composer/Util/SpdxLicenseIdentifier.php 2015-02-26 10:25:16.012610034 +0100
+@@ -61,7 +61,7 @@ class SpdxLicenseIdentifier
+ */
+ private function initIdentifiers()
+ {
+- $jsonFile = new JsonFile(__DIR__ . '/../../../res/spdx-identifier.json');
++ $jsonFile = new JsonFile((getenv('BUILDROOT')?:'') . '/usr/share/composer/res/spdx-identifier.json');
+ $this->identifiers = $jsonFile->read();
+ }
+
+diff -up ./tests/Composer/Test/Json/JsonFileTest.php.rpm ./tests/Composer/Test/Json/JsonFileTest.php
+--- ./tests/Composer/Test/Json/JsonFileTest.php.rpm 2015-02-26 10:26:10.607821640 +0100
++++ ./tests/Composer/Test/Json/JsonFileTest.php 2015-02-26 10:27:05.430034125 +0100
+@@ -54,6 +54,7 @@ class JsonFileTest extends \PHPUnit_Fram
+
+ public function testParseErrorDetectSingleQuotes()
+ {
++ $this->markTestSkipped('jsonc issue');
+ $json = '{
+ \'foo\': "bar"
+ }';
diff --git a/composer.spec b/composer.spec
new file mode 100644
index 0000000..a28670b
--- /dev/null
+++ b/composer.spec
@@ -0,0 +1,160 @@
+# spec file for composer
+#
+# Copyright (c) 2015 Remi Collet
+# License: CC-BY-SA
+# http://creativecommons.org/licenses/by-sa/4.0/
+#
+# Please, preserve the changelog entries
+#
+%global gh_commit e5985a9b559747a5f3868361ff26c31818d8c184
+%global gh_short %(c=%{gh_commit}; echo ${c:0:7})
+%global gh_branch 1.0-dev
+%global gh_date 20150225
+%global gh_owner composer
+%global gh_project composer
+%global with_tests %{?_without_tests:0}%{!?_without_tests:1}
+
+Name: composer
+Version: 1.0.0
+Release: 0.1.%{gh_date}git%{gh_short}%{?dist}
+Summary: Dependency Manager for PHP
+
+Group: Development/Libraries
+License: MIT
+URL: https://github.com/%{gh_owner}/%{gh_project}
+Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}-%{gh_short}.tar.gz
+Source1: %{name}-autoload.php
+Source2: %{name}-bootstrap.php
+
+# Fix shebang and use our autoloader
+Patch0: %{name}-rpm.patch
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildArch: noarch
+%if %{with_tests}
+BuildRequires: php-composer(justinrainbow/json-schema) >= 1.3
+BuildRequires: php-composer(seld/jsonlint) >= 1.0
+BuildRequires: php-composer(symfony/console) >= 2.5
+BuildRequires: php-composer(symfony/finder) >= 2.2
+BuildRequires: php-composer(symfony/process) >= 2.1
+BuildRequires: php-composer(symfony/class-loader)
+BuildRequires: %{_bindir}/phpunit
+%endif
+
+# From composer.json, requires
+# "php": ">=5.3.2",
+# "justinrainbow/json-schema": "~1.3",
+# "seld/jsonlint": "~1.0",
+# "symfony/console": "~2.5",
+# "symfony/finder": "~2.2",
+# "symfony/process": "~2.1"
+Requires: php(language) >= 5.3.2
+Requires: php-composer(justinrainbow/json-schema) >= 1.3
+Requires: php-composer(justinrainbow/json-schema) < 2
+Requires: php-composer(seld/jsonlint) >= 1.0
+Requires: php-composer(seld/jsonlint) < 2
+Requires: php-composer(symfony/console) >= 2.5
+Requires: php-composer(symfony/console) < 3
+Requires: php-composer(symfony/finder) >= 2.2
+Requires: php-composer(symfony/finder) < 3
+Requires: php-composer(symfony/process) >= 2.1
+Requires: php-composer(symfony/process) < 3
+# From composer.json, suggest
+# "ext-zip": "Enabling the zip extension allows you to unzip archives, and allows gzip compression of all internet traffic",
+# "ext-openssl": "Enabling the openssl extension allows you to access https URLs for repositories and packages"
+Requires: php-zip
+Requires: php-openssl
+# For our autoloader
+Requires: php-composer(symfony/class-loader)
+# From phpcompatinfo
+Requires: php-ctype
+Requires: php-curl
+Requires: php-date
+Requires: php-filter
+Requires: php-hash
+Requires: php-iconv
+Requires: php-intl
+Requires: php-json
+Requires: php-libxml
+Requires: php-mbstring
+Requires: php-pcre
+Requires: php-phar
+Requires: php-reflection
+Requires: php-simplexml
+Requires: php-spl
+Requires: php-tokenizer
+Requires: php-xsl
+Requires: php-zlib
+Provides: php-composer(composer/composer) = %{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}
+
+%patch0 -p1 -b .rpm
+cp -p %{SOURCE1} src/Composer/autoload.php
+cp -p %{SOURCE2} tests/bootstrap.php
+rm src/bootstrap.php
+
+: fix reported version
+DATE=%{gh_date}
+DATE=${DATE:0:4}-${DATE:4:2}-${DATE:2:2}
+sed -e '/VERSION/s/@package_version@/%{gh_commit}/' \
+ -e '/BRANCH_ALIAS_VERSION/s/@package_branch_alias_version@/%{gh_branch}/' \
+ -e "/RELEASE_DATE/s/@release_date@/$DATE/" \
+ -i src/Composer/Composer.php
+
+
+%build
+# Nothing
+
+
+%install
+rm -rf %{buildroot}
+
+: Library
+mkdir -p %{buildroot}%{_datadir}/php
+cp -pr src/* %{buildroot}%{_datadir}/php
+
+: Resources
+mkdir -p %{buildroot}%{_datadir}/%{name}
+cp -pr res %{buildroot}%{_datadir}/%{name}/res
+
+: Command
+install -Dpm 755 bin/%{name} %{buildroot}%{_bindir}/%{name}
+
+
+%check
+%if %{with_tests}
+: Run test suite
+export BUILDROOT=%{buildroot}
+%{_bindir}/phpunit --include-path $PWD/src
+%else
+: Test suite disabled
+%endif
+
+
+%clean
+rm -rf %{buildroot}
+
+
+%files
+%defattr(-,root,root,-)
+%{!?_licensedir:%global license %%doc}
+%license LICENSE
+%doc *.md doc
+%{_bindir}/%{name}
+%{_datadir}/php/Composer
+%{_datadir}/%{name}
+
+
+%changelog
+* Thu Feb 26 2015 Remi Collet <remi@fedoraproject.org> - 1.0.0-0.1.20150225gite5985a9
+- Initial package \ No newline at end of file