From 5e09ab237afe9cc585858c13f8ed3762acb1ff9e Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 12 Jul 2017 06:47:17 +0200 Subject: backport Fedora changes --- .gitignore | 7 ++++ composer.json | 18 ++++++++++ php-JMSParser-get-source.sh | 67 ++++++++++++++++++++--------------- php-JMSParser.spec | 85 +++++++++++++++++++++------------------------ 4 files changed, 103 insertions(+), 74 deletions(-) create mode 100644 .gitignore create mode 100644 composer.json 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..417661d --- /dev/null +++ b/composer.json @@ -0,0 +1,18 @@ +{ + "name": "jms/parser-lib", + "description": "A library for easily creating recursive-descent parsers.", + "license": "Apache2", + "require": { + "phpoption/phpoption": ">=0.9,<2.0-dev" + }, + "autoload": { + "psr-0": { + "JMS\\": "src/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + } +} \ No newline at end of file diff --git a/php-JMSParser-get-source.sh b/php-JMSParser-get-source.sh index 5c15702..fc3c842 100755 --- a/php-JMSParser-get-source.sh +++ b/php-JMSParser-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,50 @@ 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" + +TEMP_DIR=$(mktemp --dir) +TAR_FILE=$PWD/${NAME}-${VERSION}-${GIT_COMMIT}.tar.gz +CMP_FILE=$PWD/composer.json +pushd $TEMP_DIR + print "Cloning git repo..." + $GIT clone $GIT_REPO -pushd /tmp - print "Getting full source..." - rm -f ${SOURCE_FILENAME} - wget https://github.com/${GIT_OWNER}/${GIT_NAME}/archive/${GIT_COMMIT}/${SOURCE_FILENAME} + pushd $GIT_DIR + print "Checking out commit..." + $GIT checkout $GIT_COMMIT - print "Uncompressing full source..." - tar -xvzf ${SOURCE_FILENAME} - rm -f ${SOURCE_FILENAME} + print "Removing non-allowable licened content..." + rm -rf doc + cp composer.json $CMP_FILE + popd - print "Removing non-allowable licened content..." - rm -rf ${GIT_NAME}-${GIT_COMMIT}/doc + TAR_DIR=${GIT_NAME}-${GIT_COMMIT} + print "TAR_DIR = $TAR_DIR" - 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} + mv $GIT_DIR $TAR_DIR - print "Source = \"${RPM_SOURCE_DIR}/${SOURCE_FILENAME}\"" + 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-JMSParser.spec b/php-JMSParser.spec index 10ce5b1..fe59bb5 100644 --- a/php-JMSParser.spec +++ b/php-JMSParser.spec @@ -1,8 +1,8 @@ # remirepo spec file for php-JMSParser, from Fedora: # -# RPM spec file for php-JMSParser +# Fedora spec file for php-JMSParser # -# Copyright (c) 2013-2015 Shawn Iwinski +# Copyright (c) 2013-2017 Shawn Iwinski # # License: MIT # http://opensource.org/licenses/MIT @@ -18,10 +18,9 @@ %global composer_vendor jms %global composer_project parser-lib -%global php_min_ver 5.3.0 # "phpoption/phpoption": ">=0.9,<2.0-dev" -# NOTE: min version not 0.9 because autoloader required -%global phpoption_min_ver 1.4.0-4 +# NOTE: Min version not 0.9 because autoloader required +%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-JMSParser Version: %{github_version} -Release: 7%{?dist} +Release: 9%{?dist} Summary: Library for writing recursive-descent parsers Group: Development/Libraries @@ -43,36 +42,34 @@ 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(language) >= %{php_min_ver} +BuildRequires: php-composer(phpunit/phpunit) ## composer.json -#BuildRequires: php-composer(phpoption/phpoption) >= %%{phpoption_min_ver} -BuildRequires: php-PhpOption >= %{phpoption_min_ver} +BuildRequires: php-composer(phpoption/phpoption) < %{phpoption_max_ver} +BuildRequires: php-composer(phpoption/phpoption) >= %{phpoption_min_ver} ## phpcompatinfo (computed from version 1.0.0) +BuildRequires: php(language) >= 5.3.0 BuildRequires: php-json BuildRequires: php-pcre BuildRequires: php-reflection BuildRequires: php-spl ## Autoloader -BuildRequires: php-composer(symfony/class-loader) +BuildRequires: php-composer(fedora/autoloader) %endif -Requires: php(language) >= %{php_min_ver} # composer.json -#Requires: php-composer(phpoption/phpoption) >= %%{phpoption_min_ver} -Requires: php-PhpOption >= %{phpoption_min_ver} Requires: php-composer(phpoption/phpoption) < %{phpoption_max_ver} +Requires: php-composer(phpoption/phpoption) >= %{phpoption_min_ver} # phpcompatinfo (computed from version 1.0.0) +Requires: php(language) >= 5.3.0 Requires: php-json Requires: php-pcre Requires: php-reflection 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} @@ -82,63 +79,55 @@ Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version} %description %{summary}. +Autoloader: %{phpdir}/JMS/Parser/autoload.php + %prep %setup -q -n %{github_name}-%{github_commit} + +%build : Create autoloader cat <<'AUTOLOAD' | tee src/JMS/Parser/autoload.php register(); -} - -$fedoraClassLoader->addPrefix('JMS\\Parser\\', dirname(dirname(__DIR__))); +\Fedora\Autoloader\Autoload::addPsr4('JMS\\Parser\\', __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/JMS %{buildroot}%{phpdir}/ %check %if %{with_tests} -%{_bindir}/phpunit --verbose \ - --bootstrap %{buildroot}%{phpdir}/JMS/Parser/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}/JMS/Parser/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 @@ -148,6 +137,10 @@ rm -rf %{buildroot} %changelog +* Wed May 03 2017 Shawn Iwinski - 1.0.0-9 +- Switched autoloader to php-composer(fedora/autoloader) +- Test with SCLs if available + * Sun Jul 12 2015 Shawn Iwinski - 1.0.0-7 - Added spec license - New source script %%{name}-get-source.sh instead of %%{name}-strip.sh -- cgit