From 4076f16147e00746a9d698fb0c1dc09515a25057 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 24 Apr 2017 15:50:41 +0200 Subject: v1.1.0 (backported from Fedora) --- .gitignore | 7 +++ composer.json | 29 ++++++++-- php-asm89-stack-cors-get-source.sh | 71 ++++++++++++++++++++++++ php-asm89-stack-cors.spec | 108 ++++++++++++++++++------------------- 4 files changed, 156 insertions(+), 59 deletions(-) create mode 100644 .gitignore create mode 100755 php-asm89-stack-cors-get-source.sh 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 index 02296c6..18e96c6 100644 --- a/composer.json +++ b/composer.json @@ -12,11 +12,32 @@ } ], "require": { - "php": ">=5.3.2", - "symfony/http-foundation": "~2.1|~3.0", - "symfony/http-kernel": "~2.1|~3.0" + "php": ">=5.5.9", + "symfony/http-foundation": "~2.7|~3.0", + "symfony/http-kernel": "~2.7|~3.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.0 || ^4.8.10", + "squizlabs/php_codesniffer": "^2.3" }, "autoload": { - "psr-0": { "Asm89\\Stack": "src/" } + "psr-4": { + "Asm89\\Stack\\": "src/Asm89/Stack/" + } + }, + "autoload-dev": { + "psr-4": { + "Asm89\\Stack\\": "test/Asm89/Stack/" + } + }, + "scripts": { + "test": "phpunit", + "check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src", + "fix-style": "phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src" + }, + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } } } diff --git a/php-asm89-stack-cors-get-source.sh b/php-asm89-stack-cors-get-source.sh new file mode 100755 index 0000000..4ad1051 --- /dev/null +++ b/php-asm89-stack-cors-get-source.sh @@ -0,0 +1,71 @@ +#/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) +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 $GIT_DIR + print "Checking out commit..." + $GIT checkout $GIT_COMMIT + cp composer.json $CMP_FILE + popd + + 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-asm89-stack-cors.spec b/php-asm89-stack-cors.spec index 712b45c..591553a 100644 --- a/php-asm89-stack-cors.spec +++ b/php-asm89-stack-cors.spec @@ -2,7 +2,7 @@ # # Fedora spec file for php-asm89-stack-cors # -# Copyright (c) 2016 Shawn Iwinski +# Copyright (c) 2016-2017 Shawn Iwinski # # License: MIT # http://opensource.org/licenses/MIT @@ -12,18 +12,18 @@ %global github_owner asm89 %global github_name stack-cors -%global github_version 1.0.0 -%global github_commit 3ae8ef219bb4c9a6caf857421719aa07fa7776cc +%global github_version 1.1.0 +%global github_commit 65ccbd455370f043c2e3b93482a3813603d68731 %global composer_vendor asm89 %global composer_project stack-cors -# "php": ">=5.3.2" -%global php_min_ver 5.3.2 -# "symfony/http-foundation": "~2.1|~3.0" -# "symfony/http-kernel": "~2.1|~3.0" -# NOTE: Min version not 2.1 because autoloader required -%global symfony_min_ver %{?el6:2.3.31}%{!?el6:2.7.1} +# "php": ">=5.5.9" +%global php_min_ver 5.5.9 +# "symfony/http-foundation": "~2.7|~3.0" +# "symfony/http-kernel": "~2.7|~3.0" +# NOTE: Min version not 2.7 because autoloader required +%global symfony_min_ver 2.7.1 %global symfony_max_ver 4.0 # Build using "--without tests" to disable tests @@ -39,25 +39,26 @@ Summary: Cross-origin resource sharing library and stack middleware Group: Development/Libraries License: MIT URL: https://github.com/%{github_owner}/%{github_name} -Source0: %{url}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz -# Add LICENSE file -# https://github.com/asm89/stack-cors/pull/32 -Patch0: %{name}-pull-request-32-add-license-file.patch +# GitHub export does not include tests. +# Run php-asm89-stack-cors-get-source.sh to create full source. +Source0: %{name}-%{github_version}-%{github_commit}.tar.gz +Source1: %{name}-get-source.sh -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch # Autoloader -BuildRequires: %{_bindir}/phpab +BuildRequires: php-fedora-autoloader-devel # Tests %if %{with_tests} ## composer.json BuildRequires: php(language) >= %{php_min_ver} BuildRequires: php-composer(phpunit/phpunit) +BuildRequires: php-composer(symfony/http-foundation) < %{symfony_max_ver} BuildRequires: php-composer(symfony/http-foundation) >= %{symfony_min_ver} +BuildRequires: php-composer(symfony/http-kernel) < %{symfony_max_ver} BuildRequires: php-composer(symfony/http-kernel) >= %{symfony_min_ver} -## phpcompatinfo (computed from version 1.0.0) -BuildRequires: php-spl +## phpcompatinfo (computed from version 1.1.0) +## %endif # composer.json @@ -66,8 +67,10 @@ Requires: php-composer(symfony/http-foundation) >= %{symfony_min_ver} Requires: php-composer(symfony/http-foundation) < %{symfony_max_ver} Requires: php-composer(symfony/http-kernel) >= %{symfony_min_ver} Requires: php-composer(symfony/http-kernel) < %{symfony_max_ver} -# phpcompatinfo (computed from version 1.0.0) +# phpcompatinfo (computed from version 1.1.0) # +# Autoloader +Requires: php-composer(fedora/autoloader) # Composer Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version} @@ -85,62 +88,52 @@ Autoloader: %{phpdir}/Asm89/Stack/autoload-cors.php %prep %setup -qn %{github_name}-%{github_commit} -: Remove executable bits from non-executable files -: https://github.com/asm89/stack-cors/pull/31 -find . -type f -name '*.php' -print0 | xargs -0 chmod a-x - -: Add LICENSE file -: https://github.com/asm89/stack-cors/pull/32 -%patch0 -p1 - %build -: Create autoloader -%{_bindir}/phpab --output src/Asm89/Stack/autoload-cors.php src/ +: Generate autoloader +%{_bindir}/phpab \ + --template fedora \ + --output src/Asm89/Stack/autoload-cors.php \ + src/ cat <<'AUTOLOAD' | tee -a src/Asm89/Stack/autoload-cors.php -// Required dependencies -require_once '%{phpdir}/Symfony/Component/HttpFoundation/autoload.php'; -require_once '%{phpdir}/Symfony/Component/HttpKernel/autoload.php'; +\Fedora\Autoloader\Dependencies::required([ + [ + '%{phpdir}/Symfony3/Component/HttpFoundation/autoload.php', + '%{phpdir}/Symfony/Component/HttpFoundation/autoload.php', + ], + [ + '%{phpdir}/Symfony3/Component/HttpKernel/autoload.php', + '%{phpdir}/Symfony/Component/HttpKernel/autoload.php', + ], +]); AUTOLOAD %install -rm -rf %{buildroot} - mkdir -p %{buildroot}%{phpdir} -cp -rp src/* %{buildroot}%{phpdir}/ +cp -rp src/Asm89 %{buildroot}%{phpdir}/ %check %if %{with_tests} -run=0 -ret=0 -if which php56; then - php56 %{_bindir}/phpunit --bootstrap %{buildroot}%{phpdir}/Asm89/Stack/autoload-cors.php || ret=1 - run=1 -fi -if which php71; then - php71 %{_bindir}/phpunit --bootstrap %{buildroot}%{phpdir}/Asm89/Stack/autoload-cors.php || ret=1 - run=1 -fi -if [ $run -eq 0 -o $ret -eq 1 ]; then -%{_bindir}/phpunit --verbose \ - --bootstrap %{buildroot}%{phpdir}/Asm89/Stack/autoload-cors.php -fi -exit $ret +: Upstream tests +RETURN_CODE=0 +for PHP_EXEC in php php56 php70 php71 php72; do + if [ "php" == "$PHP_EXEC" ] || which $PHP_EXEC; then + $PHP_EXEC %{_bindir}/phpunit --verbose \ + --bootstrap %{buildroot}%{phpdir}/Asm89/Stack/autoload-cors.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 @@ -153,7 +146,12 @@ rm -rf %{buildroot} %changelog -* Fri Oct 21 2016 Remi Collet - 1.0.0-1 +* Fri Apr 14 2017 Shawn Iwinski - 1.1.0-1 +- Update to 1.1.0 (RHBZ #1441443) +- Add max versions to BuildRequires +- Switch autoloader to php-composer(fedora/autoloader) + +* Fri Oct 21 2016 Remi Collet - 1.0.0-1 - add backport stuff * Sun Oct 09 2016 Shawn Iwinski - 1.0.0-1 -- cgit