From 47beb6c3a9727f354666be67b5df7767401a9719 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 14 Jul 2015 08:17:43 +0200 Subject: php-gliph: backport rawhide changes --- php-gliph-get-source.sh | 69 ++++++++++++++++++++++++++++ php-gliph.spec | 117 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 162 insertions(+), 24 deletions(-) create mode 100755 php-gliph-get-source.sh diff --git a/php-gliph-get-source.sh b/php-gliph-get-source.sh new file mode 100755 index 0000000..ba71f5d --- /dev/null +++ b/php-gliph-get-source.sh @@ -0,0 +1,69 @@ +#/bin/sh + +GIT=`which git` +RPM=`which 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 +fi + +function print { + echo -e "\e[0;33m>>>>> ${1}\e[0m" +} + +if [ -x "$1" ] +then + SPEC=$1 +else + SPEC=`ls *.spec | head -1` +fi + +NAME=`echo $SPEC | sed 's#\.spec##'` +VERSION=`egrep '%global\s*github_version' $SPEC | awk '{print $3}'` + +print "SPEC = $SPEC" +print "NAME = $NAME" + +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} +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 "GIT_DIR = $GIT_DIR" + +TEMP_DIR=$(mktemp --dir) + +pushd $TEMP_DIR + print "Cloning git repo..." + $GIT clone $GIT_REPO + + pushd $GIT_DIR + print "Checking out commit..." + $GIT checkout $GIT_COMMIT + popd + + TAR_DIR=${GIT_NAME}-${GIT_COMMIT} + print "TAR_DIR = $TAR_DIR" + + mv $GIT_DIR $TAR_DIR + + TAR_FILE=`$RPM --eval='%{_sourcedir}'`/${NAME}-${VERSION}-${GIT_COMMIT}.tar.gz + 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-gliph.spec b/php-gliph.spec index 4613909..b03eebe 100644 --- a/php-gliph.spec +++ b/php-gliph.spec @@ -1,3 +1,4 @@ +# remirepo spec file for php-gliph, from Fedora: # # RPM spec file for php-gliph # @@ -17,31 +18,52 @@ %global composer_vendor sdboyer %global composer_project gliph -%global lib_name Gliph - # "php": ">=5.3" %global php_min_ver 5.3.0 -Name: php-%{composer_project} -Version: %{github_version} -Release: 1%{?github_release}%{?dist} -Summary: A graph library for PHP - -Group: Development/Libraries -License: MIT -URL: https://github.com/%{github_owner}/%{github_name} -Source0: %{url}/archive/%{github_commit}/%{name}-%{version}-%{github_commit}.tar.gz - -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildArch: noarch +# Build using "--without tests" to disable tests +%global with_tests 0%{!?_without_tests:1} + +%{!?phpdir: %global phpdir %{_datadir}/php} + +Name: php-%{composer_project} +Version: %{github_version} +Release: 4%{?github_release}%{?dist} +Summary: A graph library for PHP + +Group: Development/Libraries +License: MIT +URL: https://github.com/%{github_owner}/%{github_name} + +# Run "php-gliph-get-source.sh" to create source +Source0: %{name}-%{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 +## composer.json +BuildRequires: php(language) >= %{php_min_ver} +## phpcompatinfo (computed from version 0.1.8) +BuildRequires: php-reflection +BuildRequires: php-spl +## Autoloader +BuildRequires: php-composer(symfony/class-loader) +%endif # composer.json -Requires: php(language) >= %{php_min_ver} +Requires: php(language) >= %{php_min_ver} # phpcompatinfo (computed from version 0.1.8) -Requires: php-spl +Requires: php-spl +# Autoloader +Requires: php-composer(symfony/class-loader) +# Standard "php-{COMPOSER_VENDOR}-{COMPOSER_PROJECT}" naming +Provides: php-%{composer_vendor}-%{composer_project} = %{version}-%{release} # Composer -Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version} +Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version} %description Gliph is a graph library for PHP. It provides graph building blocks and @@ -53,6 +75,31 @@ Neo4J (http://neo4j.org/). %prep %setup -qn %{github_name}-%{github_commit} +: Create autoloader +cat <<'AUTOLOAD' | tee src/Gliph/autoload.php +register(); +} + +$fedoraClassLoader->addPrefix('Gliph\\', dirname(__DIR__)); + +return $fedoraClassLoader; +AUTOLOAD + %build # Empty build section, nothing to build @@ -60,14 +107,27 @@ Neo4J (http://neo4j.org/). %install rm -rf %{buildroot} -mkdir -pm 0755 %{buildroot}%{_datadir}/php -cp -rp src/%{lib_name} %{buildroot}%{_datadir}/php/ +mkdir -p %{buildroot}%{phpdir} +cp -rp src/* %{buildroot}%{phpdir}/ %check -# As of version 0.1.5, "phpunit.xml.dist" and "/tests" are git export-ignored -# therefore the RPM source tarball does not contain tests. Upstream will be -# contacted to revert the git export-ignore so tests may be run here. +%if %{with_tests} +: Create tests bootstrap +cat <<'BOOTSTRAP' | tee bootstrap.php +addPrefix(null, __DIR__ . '/tests'); +BOOTSTRAP + +: Run tests +%{_bindir}/phpunit --verbose --bootstrap ./bootstrap.php . +%else +: Tests skipped +%endif %clean @@ -78,11 +138,20 @@ rm -rf %{buildroot} %defattr(-,root,root,-) %{!?_licensedir:%global license %%doc} %license LICENSE -%doc README.md composer.json -%{_datadir}/php/%{lib_name} +%doc *.md +%doc composer.json +%{phpdir}/Gliph %changelog +* Sat Jul 11 2015 Shawn Iwinski - 0.1.8-4 +- Added missing autoloader require + +* Sat Jul 11 2015 Shawn Iwinski - 0.1.8-3 +- Added autoloader +- Added tests +- Added standard "php-{COMPOSER_VENDOR}-{COMPOSER_PROJECT}" naming provides + * Sun Aug 17 2014 Shawn Iwinski - 0.1.8-1 - Updated to 0.1.8 (BZ #1125361) -- cgit