summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore7
-rw-r--r--composer.json22
-rwxr-xr-xphp-PhpCollection-get-source.sh68
-rw-r--r--php-PhpCollection.spec96
4 files changed, 115 insertions, 78 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1ab5c4f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+package-*.xml
+*.tgz
+*.tar.gz
+*.tar.xz
+*.tar.xz.asc
+*.src.rpm
+*/*rpm
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..40ac8bb
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,22 @@
+{
+ "name": "phpcollection/phpcollection",
+ "description": "General-Purpose Collection Library for PHP",
+ "keywords": ["collection", "list", "sequence", "map", "set"],
+ "license": "Apache2",
+ "authors": [
+ {"name": "Johannes M. Schmitt", "email": "schmittjoh@gmail.com"}
+ ],
+ "require": {
+ "phpoption/phpoption": "1.*"
+ },
+ "autoload": {
+ "psr-0": {
+ "PhpCollection": "src/"
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.4-dev"
+ }
+ }
+}
diff --git a/php-PhpCollection-get-source.sh b/php-PhpCollection-get-source.sh
index 5c15702..be03311 100755
--- a/php-PhpCollection-get-source.sh
+++ b/php-PhpCollection-get-source.sh
@@ -1,8 +1,13 @@
#/bin/sh
-RPM=$(which rpm)
+GIT=`which git`
+RPM=`which rpm`
-if [ -z "$RPM" ]
+if [ -z "$GIT" ]
+then
+ echo "ERROR: 'git' command not found" 1>&2
+ exit 1
+elif [ -z "$RPM" ]
then
echo "ERROR: 'rpm' command not found" 1>&2
exit 1
@@ -19,44 +24,51 @@ else
SPEC=`ls *.spec | head -1`
fi
-print "SPEC = $SPEC"
-
-NAME=$(echo $SPEC | sed 's#\.spec##')
-VERSION=$(egrep '%global\s*github_version' $SPEC | awk '{print $3}')
+NAME=`echo $SPEC | sed 's#\.spec##'`
+VERSION=`egrep '%global\s*github_version' $SPEC | awk '{print $3}'`
+print "SPEC = $SPEC"
print "NAME = $NAME"
-print "VERSION = $VERSION"
-GIT_OWNER=$(egrep '%global\s*github_owner' $SPEC | awk '{print $3}')
-GIT_NAME=$(egrep '%global\s*github_name' $SPEC | awk '{print $3}')
-GIT_COMMIT=$(egrep '%global\s*github_commit' $SPEC | awk '{print $3}')
+GIT_OWNER=`egrep '%global\s*github_owner' $SPEC | awk '{print $3}'`
+GIT_NAME=`egrep '%global\s*github_name' $SPEC | awk '{print $3}'`
+GIT_COMMIT=`egrep '%global\s*github_commit' $SPEC | awk '{print $3}'`
GIT_REPO=https://github.com/${GIT_OWNER}/${GIT_NAME}
-SOURCE_FILENAME=${NAME}-${VERSION}-${GIT_COMMIT}.tar.gz
-RPM_SOURCE_DIR=$(rpm --eval "%{_sourcedir}")
+GIT_DIR=`echo $GIT_REPO | sed 's#.*/##'`
print "GIT_OWNER = $GIT_OWNER"
print "GIT_NAME = $GIT_NAME"
print "GIT_COMMIT = $GIT_COMMIT"
print "GIT_REPO = $GIT_REPO"
-print "SOURCE_FILENAME = $SOURCE_FILENAME"
-print "RPM_SOURCE_DIR = $RPM_SOURCE_DIR"
+print "GIT_DIR = $GIT_DIR"
-pushd /tmp
- print "Getting full source..."
- rm -f ${SOURCE_FILENAME}
- wget https://github.com/${GIT_OWNER}/${GIT_NAME}/archive/${GIT_COMMIT}/${SOURCE_FILENAME}
+TEMP_DIR=$(mktemp --dir)
+TAR_FILE=$PWD/${NAME}-${VERSION}-${GIT_COMMIT}.tar.gz
+CMP_FILE=$PWD/composer.json
- print "Uncompressing full source..."
- tar -xvzf ${SOURCE_FILENAME}
- rm -f ${SOURCE_FILENAME}
+pushd $TEMP_DIR
+ print "Cloning git repo..."
+ $GIT clone $GIT_REPO
- print "Removing non-allowable licened content..."
- rm -rf ${GIT_NAME}-${GIT_COMMIT}/doc
+ pushd $GIT_DIR
+ print "Checking out commit..."
+ $GIT checkout $GIT_COMMIT
- print "Re-compressing allowable source..."
- rm -f ${RPM_SOURCE_DIR}/${SOURCE_FILENAME}
- tar -cvzf ${RPM_SOURCE_DIR}/${SOURCE_FILENAME} ${GIT_NAME}-${GIT_COMMIT}
- rm -rf ${GIT_NAME}-${GIT_COMMIT}
+ print "Removing non-allowable licened content..."
+ rm -rf doc
+ cp composer.json $CMP_FILE
+ popd
- print "Source = \"${RPM_SOURCE_DIR}/${SOURCE_FILENAME}\""
+ TAR_DIR=${GIT_NAME}-${GIT_COMMIT}
+ print "TAR_DIR = $TAR_DIR"
+
+ mv $GIT_DIR $TAR_DIR
+
+ print "TAR_FILE = $TAR_FILE"
+
+ [ -e $TAR_FILE ] && rm -f $TAR_FILE
+ tar --exclude-vcs -czf $TAR_FILE $TAR_DIR
+ chmod 0644 $TAR_FILE
popd
+
+rm -rf $TEMP_DIR
diff --git a/php-PhpCollection.spec b/php-PhpCollection.spec
index b0d8ef9..3107128 100644
--- a/php-PhpCollection.spec
+++ b/php-PhpCollection.spec
@@ -1,8 +1,8 @@
# remirepo spec file for php-PhpCollection, from Fedora:
#
-# RPM spec file for php-PhpCollection
+# Fedora spec file for php-PhpCollection
#
-# Copyright (c) 2013-2015 Shawn Iwinski <shawn.iwinski@gmail.com>
+# Copyright (c) 2013-2017 Shawn Iwinski <shawn.iwinski@gmail.com>
#
# License: MIT
# http://opensource.org/licenses/MIT
@@ -12,16 +12,15 @@
%global github_owner schmittjoh
%global github_name php-collection
-%global github_version 0.4.0
-%global github_commit b8bf55a0a929ca43b01232b36719f176f86c7e83
+%global github_version 0.5.0
+%global github_commit f2bcff45c0da7c27991bbc1f90f47c4b7fb434a6
%global composer_vendor phpcollection
%global composer_project phpcollection
-%global php_min_ver 5.3.0
# "phpoption/phpoption": "1.*"
# NOTE: min version not 1.0 because autoloader required
-%global phpoption_min_ver 1.4.0-4
+%global phpoption_min_ver 1.5.0
%global phpoption_max_ver 2.0
# Build using "--without tests" to disable tests
@@ -31,7 +30,7 @@
Name: php-PhpCollection
Version: %{github_version}
-Release: 4%{?dist}
+Release: 1%{?dist}
Summary: General purpose collection library for PHP
Group: Development/Libraries
@@ -43,29 +42,29 @@ URL: http://jmsyst.com/libs/%{github_name}
Source0: %{name}-%{github_version}-%{github_commit}.tar.gz
Source1: %{name}-get-source.sh
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
# Tests
%if %{with_tests}
-BuildRequires: %{_bindir}/phpunit
+BuildRequires: php-composer(phpunit/phpunit)
## composer.json
-BuildRequires: php(language) >= %{php_min_ver}
-#BuildRequires: php-composer(phpoption/phpoption) >= %%{phpoption_min_ver}
-BuildRequires: php-PhpOption >= %{phpoption_min_ver}
-## phpcompatinfo (computed from version 0.4.0)
+BuildRequires: php-composer(phpoption/phpoption) < %{phpoption_max_ver}
+BuildRequires: php-composer(phpoption/phpoption) >= %{phpoption_min_ver}
+## phpcompatinfo (computed from version 0.5.0)
+BuildRequires: php(language) >= 5.4.0
+BuildRequires: php-date
BuildRequires: php-spl
## Autoloader
-BuildRequires: php-composer(symfony/class-loader)
+BuildRequires: php-composer(fedora/autoloader)
%endif
-Requires: php(language) >= %{php_min_ver}
-#Requires: php-composer(phpoption/phpoption) >= %%{phpoption_min_ver}
-Requires: php-PhpOption >= %{phpoption_min_ver}
+# composer.json
Requires: php-composer(phpoption/phpoption) < %{phpoption_max_ver}
-# phpcompatinfo (computed from version 0.4.0)
+Requires: php-composer(phpoption/phpoption) >= %{phpoption_min_ver}
+# phpcompatinfo (computed from version 0.5.0)
+Requires: php(language) >= 5.4.0
Requires: php-spl
# Autoloader
-Requires: php-composer(symfony/class-loader)
+Requires: php-composer(fedora/autoloader)
# Standard "php-{COMPOSER_VENDOR}-{COMPOSER_PROJECT}" naming
Provides: php-%{composer_vendor}-%{composer_project} = %{version}-%{release}
@@ -102,67 +101,59 @@ General Characteristics:
* Sorting algorithms are unstable, that means the order for equal elements is
undefined (the default, and only PHP behavior).
+Autoloader: %{phpdir}/PhpCollection/autoload.php
+
%prep
%setup -q -n %{github_name}-%{github_commit}
+
+%build
: Create autoloader
cat <<'AUTOLOAD' | tee src/PhpCollection/autoload.php
<?php
/**
* Autoloader for %{name} and its' dependencies
- *
- * Created by %{name}-%{version}-%{release}
- *
- * @return \Symfony\Component\ClassLoader\ClassLoader
+ * (created by %{name}-%{version}-%{release}).
*/
+require_once '%{phpdir}/Fedora/Autoloader/autoload.php';
-require_once '%{phpdir}/PhpOption/autoload.php';
-
-if (!isset($fedoraClassLoader) || !($fedoraClassLoader instanceof \Symfony\Component\ClassLoader\ClassLoader)) {
- if (!class_exists('Symfony\\Component\\ClassLoader\\ClassLoader', false)) {
- require_once '%{phpdir}/Symfony/Component/ClassLoader/ClassLoader.php';
- }
-
- $fedoraClassLoader = new \Symfony\Component\ClassLoader\ClassLoader();
- $fedoraClassLoader->register();
-}
-
-$fedoraClassLoader->addPrefix('PhpCollection\\', dirname(__DIR__));
+\Fedora\Autoloader\Autoload::addPsr4('PhpCollection\\', __DIR__);
-return $fedoraClassLoader;
+\Fedora\Autoloader\Dependencies::required(array(
+ '%{phpdir}/PhpOption/autoload.php',
+));
AUTOLOAD
-%build
-# Empty build section, nothing to build
-
-
%install
-rm -rf %{buildroot}
mkdir -p %{buildroot}%{phpdir}
-cp -rp src/* %{buildroot}%{phpdir}/
+cp -rp src/PhpCollection %{buildroot}%{phpdir}/
%check
%if %{with_tests}
: Skip test known to fail
-sed 's/function testMap/function SKIP_testMap/' \
+sed 's/function testAdd/function SKIP_testAdd/' \
-i tests/PhpCollection/Tests/SequenceTest.php
-: Run tests
-%{_bindir}/phpunit --bootstrap %{buildroot}%{phpdir}/PhpCollection/autoload.php
+: Upstream tests
+RETURN_CODE=0
+PHPUNIT=$(which phpunit)
+for PHP_EXEC in "" %{?rhel:php54 php55} php56 php70 php71 php72; do
+ if [ -z "$PHP_EXEC" ] || which $PHP_EXEC; then
+ $PHP_EXEC $PHPUNIT --verbose \
+ --bootstrap %{buildroot}%{phpdir}/PhpCollection/autoload.php \
+ || RETURN_CODE=1
+ fi
+done
+exit $RETURN_CODE
%else
: Tests skipped
%endif
-%clean
-rm -rf %{buildroot}
-
-
%files
-%defattr(-,root,root,-)
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc *.md
@@ -171,6 +162,11 @@ rm -rf %{buildroot}
%changelog
+* Tue Jul 11 2017 Shawn Iwinski <shawn.iwinski@gmail.com> - 0.5.0-1
+- Updated to 0.5.0
+- Switched autoloader to php-composer(fedora/autoloader)
+- Test with SCLs if available
+
* Sun Jul 12 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 0.4.0-4
- Added spec license
- New source script %%{name}-get-source.sh instead of %%{name}-strip.sh