From 8e769d64c7e52986f3150abb97b4d10164a9e20c Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 30 Sep 2021 11:15:28 +0200 Subject: New package --- .gitignore | 9 +++ Makefile | 3 + composer.json | 74 +++++++++++++++++ makesrc.sh | 31 +++++++ php-laminas-cli-rpm.patch | 88 ++++++++++++++++++++ php-laminas-cli.spec | 201 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 406 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 composer.json create mode 100755 makesrc.sh create mode 100644 php-laminas-cli-rpm.patch create mode 100644 php-laminas-cli.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01f0400 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +clog +package-*.xml +*.tgz +*.tar.bz2 +*.tar.gz +*.tar.xz +*.tar.xz.asc +*.src.rpm +*/*rpm diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a2cd659 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../../../common/Makefile diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..8db7d20 --- /dev/null +++ b/composer.json @@ -0,0 +1,74 @@ +{ + "name": "laminas/laminas-cli", + "description": "Command-line interface for Laminas projects", + "license": "BSD-3-Clause", + "keywords": [ + "laminas", + "cli", + "console", + "command" + ], + "support": { + "docs": "https://docs.laminas.dev/laminas-cli/", + "issues": "https://github.com/mezzio/laminas-cli/issues", + "source": "https://github.com/mezzio/laminas-cli", + "rss": "https://github.com/mezzio/laminas-cli/releases.atom", + "chat": "https://laminas.dev/chat", + "forum": "https://discourse.laminas.dev" + }, + "config": { + "sort-packages": true + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev", + "dev-develop": "1.1.x-dev" + } + }, + "require": { + "php": "^7.3 || ~8.0.0", + "composer/package-versions-deprecated": "^1.10.99", + "psr/container": "^1.0", + "symfony/console": "^4.3 || ^5.1.2", + "symfony/event-dispatcher": "^4.0 || ^5.0", + "symfony/polyfill-php80": "^1.17", + "webmozart/assert": "^1.9" + }, + "require-dev": { + "laminas/laminas-coding-standard": "~2.0.0", + "laminas/laminas-mvc": "^3.1.1", + "laminas/laminas-servicemanager": "^3.4", + "mikey179/vfsstream": "2.0.x-dev", + "phpunit/phpunit": "^9.4.1", + "vimeo/psalm": "^4.4.1" + }, + "autoload": { + "files": [ + "src/autoload.php" + ], + "psr-4": { + "Laminas\\Cli\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Local\\": "test/TestAsset/Local/", + "LaminasTest\\Cli\\": "test/" + } + }, + "bin": [ + "bin/laminas" + ], + "scripts": { + "check": [ + "@cs-check", + "@test", + "@static-analysis" + ], + "cs-check": "phpcs", + "cs-fix": "phpcbf", + "static-analysis": "psalm --shepherd --stats", + "test": "phpunit --colors=always", + "test-coverage": "phpunit --colors=always --coverage-clover clover.xml" + } +} diff --git a/makesrc.sh b/makesrc.sh new file mode 100755 index 0000000..f26d8ba --- /dev/null +++ b/makesrc.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +NAME=$(basename $PWD) +OWNER=$(sed -n '/^%global gh_owner/{s/.* //;p}' $NAME.spec) +PROJECT=$(sed -n '/^%global gh_project/{s/.* //;p}' $NAME.spec) +VERSION=$(sed -n '/^Version:/{s/.* //;p}' $NAME.spec) +COMMIT=$(sed -n '/^%global gh_commit/{s/.* //;p}' $NAME.spec) +SHORT=${COMMIT:0:7} + +if [ -f $NAME-$VERSION-$SHORT.tgz ]; then + echo Skip $NAME-$VERSION-$SHORT.tgz +else + echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION\n" + + echo "Cloning..." + rm -rf $PROJECT-$COMMIT + git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT + + echo "Getting commit..." + pushd $PROJECT-$COMMIT + git checkout $COMMIT || exit 1 + cp composer.json ../composer.json + popd + + echo "Archiving..." + tar czf $NAME-$VERSION-$SHORT.tgz --exclude-vcs $PROJECT-$COMMIT + + echo "Cleaning..." + rm -rf $PROJECT-$COMMIT +fi +echo "Done." diff --git a/php-laminas-cli-rpm.patch b/php-laminas-cli-rpm.patch new file mode 100644 index 0000000..cea2e75 --- /dev/null +++ b/php-laminas-cli-rpm.patch @@ -0,0 +1,88 @@ +diff -up ./src/ApplicationFactory.php.rpm ./src/ApplicationFactory.php +--- ./src/ApplicationFactory.php.rpm 2021-09-30 10:42:36.170299767 +0200 ++++ ./src/ApplicationFactory.php 2021-09-30 10:43:04.214217583 +0200 +@@ -4,7 +4,6 @@ declare(strict_types=1); + + namespace Laminas\Cli; + +-use PackageVersions\Versions; + use Symfony\Component\Console\Application; + use Symfony\Component\Console\Input\InputOption; + use Webmozart\Assert\Assert; +@@ -25,7 +24,7 @@ final class ApplicationFactory + public function __invoke(): Application + { + /** @psalm-suppress DeprecatedClass */ +- $version = strstr(Versions::getVersion('laminas/laminas-cli'), '@', true); ++ $version = '@VERSION@'; + Assert::string($version); + $application = new Application('laminas', $version); + $application->setAutoExit(false); +diff -up ./src/Command/AbstractParamAwareCommand.php.rpm ./src/Command/AbstractParamAwareCommand.php +--- ./src/Command/AbstractParamAwareCommand.php.rpm 2021-09-30 10:42:33.546307457 +0200 ++++ ./src/Command/AbstractParamAwareCommand.php 2021-09-30 10:42:58.841233330 +0200 +@@ -10,7 +10,6 @@ use Laminas\Cli\Input\InputParamInterfac + use Laminas\Cli\Input\NonHintedParamAwareInput; + use Laminas\Cli\Input\ParamAwareInputInterface; + use Laminas\Cli\Input\TypeHintedParamAwareInput; +-use PackageVersions\Versions; + use RuntimeException; + use Symfony\Component\Console\Command\Command; + use Symfony\Component\Console\Helper\HelperSet; +@@ -91,11 +90,7 @@ abstract class AbstractParamAwareCommand + return $input; + } + +- /** @psalm-suppress DeprecatedClass */ +- $consoleVersion = strstr(Versions::getVersion('symfony/console'), '@', true); +- Assert::string($consoleVersion); +- +- $inputDecoratorClass = str_replace('v', '', $consoleVersion) >= '5.0.0' ++ $inputDecoratorClass = false /* Symfony < 5.0 */ + ? TypeHintedParamAwareInput::class + : NonHintedParamAwareInput::class; + +diff -up ./test/Command/ParamAwareCommandTest.php.rpm ./test/Command/ParamAwareCommandTest.php +--- ./test/Command/ParamAwareCommandTest.php.rpm 2021-09-30 10:42:40.802286197 +0200 ++++ ./test/Command/ParamAwareCommandTest.php 2021-09-30 10:42:47.139267624 +0200 +@@ -8,7 +8,6 @@ use Laminas\Cli\Input\BoolParam; + use Laminas\Cli\Input\ParamAwareInputInterface; + use LaminasTest\Cli\TestAsset\ParamAwareCommandStub; + use LaminasTest\Cli\TestAsset\ParamAwareCommandStubNonHinted; +-use PackageVersions\Versions; + use PHPUnit\Framework\MockObject\MockObject; + use PHPUnit\Framework\TestCase; + use Symfony\Component\Console\Helper\HelperSet; +@@ -44,9 +43,7 @@ class ParamAwareCommandTest extends Test + ) + ->willReturn($this->questionHelper); + +- /** @psalm-suppress DeprecatedClass */ +- $consoleVersion = strstr(Versions::getVersion('symfony/console'), '@', true) ?: ''; +- $commandClass = str_replace('v', '', $consoleVersion) >= '5.0.0' ++ $commandClass = false /* Symfony < 5.0 */ + ? ParamAwareCommandStub::class + : ParamAwareCommandStubNonHinted::class; + +diff -up ./test/Input/ParamAwareInputTest.php.rpm ./test/Input/ParamAwareInputTest.php +--- ./test/Input/ParamAwareInputTest.php.rpm 2021-09-30 10:42:38.426293159 +0200 ++++ ./test/Input/ParamAwareInputTest.php 2021-09-30 10:42:52.938250628 +0200 +@@ -13,7 +13,6 @@ use Laminas\Cli\Input\NonHintedParamAwar + use Laminas\Cli\Input\PathParam; + use Laminas\Cli\Input\StringParam; + use Laminas\Cli\Input\TypeHintedParamAwareInput; +-use PackageVersions\Versions; + use PHPUnit\Framework\MockObject\MockObject; + use PHPUnit\Framework\TestCase; + use Symfony\Component\Console\Formatter\NullOutputFormatter; +@@ -67,9 +66,7 @@ class ParamAwareInputTest extends TestCa + + public function setUp(): void + { +- /** @psalm-suppress DeprecatedClass */ +- $consoleVersion = strstr(Versions::getVersion('symfony/console'), '@', true) ?: ''; +- $this->class = str_replace('v', '', $consoleVersion) >= '5.0.0' ++ $this->class = false /* Symfony < 5.0 */ + ? TypeHintedParamAwareInput::class + : NonHintedParamAwareInput::class; + diff --git a/php-laminas-cli.spec b/php-laminas-cli.spec new file mode 100644 index 0000000..aa5556d --- /dev/null +++ b/php-laminas-cli.spec @@ -0,0 +1,201 @@ +# remirepo/Fedora spec file for php-laminas-cli +# +# Copyright (c) 2021 Remi Collet +# License: CC-BY-SA +# http://creativecommons.org/licenses/by-sa/4.0/ +# +# Please, preserve the changelog entries +# +%global bootstrap 0 +%global gh_commit 875a174c161c84c84c43bdff1e10cfe4ecbda704 +%global gh_short %(c=%{gh_commit}; echo ${c:0:7}) +%global gh_owner laminas +%global gh_project laminas-cli +%global php_home %{_datadir}/php +%global namespace Laminas +%global library Cli +%global major %nil +%if %{bootstrap} +%global with_tests 0%{?_with_tests:1} +%else +%global with_tests 0%{!?_without_tests:1} +%endif + +Name: php-%{gh_project}%{major} +Version: 1.1.1 +Release: 1%{?dist} +Summary: Laminas Framework %{library} component v1 + +License: BSD +URL: https://github.com/%{gh_owner}/%{gh_project} +Source0: %{gh_commit}/%{name}-%{version}-%{gh_short}.tgz +Source1: makesrc.sh + +# Get rid of composer/package-versions-deprecated +Patch0: %{name}-rpm.patch + +BuildArch: noarch +# Tests +%if %{with_tests} +BuildRequires: php(language) >= 7.3 +BuildRequires: php-reflection +BuildRequires: php-pcre +BuildRequires: php-spl +# remirepo:1 +%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8 +BuildRequires: (php-composer(psr/container) >= 1.0 with php-composer(psr/container) < 2) +BuildRequires: (php-composer(symfony/console) >= 4.3 with php-composer(symfony/console) < 5) +BuildRequires: (php-composer(symfony/event-dispatcher) >= 4.3 with php-composer(symfony/event-dispatcher) < 5) +BuildRequires: (php-composer(symfony/polyfill-php80) >= 1.17 with php-composer(symfony/polyfill-php80) < 2) +BuildRequires: (php-composer(webmozart/assert) >= 1.9 with php-composer(webmozart/assert) < 2) +# From composer, "require-dev": { +# "laminas/laminas-coding-standard": "~2.0.0", +# "laminas/laminas-mvc": "^3.1.1", +# "laminas/laminas-servicemanager": "^3.4", +# "mikey179/vfsstream": "2.0.x-dev", +# "phpunit/phpunit": "^9.4.1", +# "vimeo/psalm": "^4.4.1" +BuildRequires: (php-autoloader(%{gh_owner}/laminas-mvc) >= 3.1.1 with php-autoloader(%{gh_owner}/laminas-mvc) < 4) +BuildRequires: (php-autoloader(%{gh_owner}/laminas-servicemanager) >= 3.7 with php-autoloader(%{gh_owner}/laminas-servicemanager) < 4) +BuildRequires: (php-composer(mikey179/vfsstream) >= 1.6.10 with php-composer(mikey179/vfsstream) < 2) +# remirepo:10 +%else +BuildRequires: php-psr-container >= 1.0 +BuildRequires: php-symfony4-console >= 4.3 +BuildRequires: php-symfony4-event-dispatcher >= 4.3 +BuildRequires: php-symfony-polyfill >= 1.17 +BuildRequires: php-webmozart-assert >= 1.9 +BuildRequires: php-laminas-mvc >= 3.1.1 +BuildRequires: php-laminas-servicemanager >= 3.4 +BuildRequires: php-mikey179-vfsstream +%endif +BuildRequires: phpunit9 >= 9.4.1 +%endif +# Autoloader +BuildRequires: php-fedora-autoloader-devel + +# From composer, "require": { +# "php": "^7.3 || ~8.0.0", +# "composer/package-versions-deprecated": "^1.10.99", +# "psr/container": "^1.0", +# "symfony/console": "^4.3 || ^5.1.2", +# "symfony/event-dispatcher": "^4.0 || ^5.0", +# "symfony/polyfill-php80": "^1.17", +# "webmozart/assert": "^1.9" +Requires: php(language) >= 7.3 +# remirepo:1 +%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8 +Requires: (php-composer(psr/container) >= 1.0 with php-composer(psr/container) < 2) +Requires: (php-composer(symfony/console) >= 4.3 with php-composer(symfony/console) < 5) +Requires: (php-composer(symfony/event-dispatcher) >= 4.3 with php-composer(symfony/event-dispatcher) < 5) +Requires: (php-composer(symfony/polyfill-php80) >= 1.17 with php-composer(symfony/polyfill-php80) < 2) +Requires: (php-composer(webmozart/assert) >= 1.9 with php-composer(webmozart/assert) < 2) +# From composer, "require": { +# "laminas/laminas-servicemanager": "An IoC container without auto wiring capabilities" +Suggests: php-autoloader(%{gh_owner}/laminas-servicemanager) +# remirepo:7 +%else +Requires: php-psr-container >= 1.0 +Requires: php-symfony4-console >= 4.3 +Requires: php-symfony4-event-dispatcher >= 4.3 +Requires: php-symfony-polyfill >= 1.17 +Requires: php-webmozart-assert >= 1.9 +%endif +# Autoloader +Requires: php-composer(fedora/autoloader) +# From phpcompatinfo report for version 1.1.1 +Requires: php-json +Requires: php-pcre +Requires: php-reflection +Requires: php-spl + +Provides: php-composer(%{gh_owner}/%{gh_project}) = %{version} +Provides: php-autoloader(%{gh_owner}/%{gh_project}) = %{version} + + +%description +Command-line interface for Laminas projects. + +Documentation: https://docs.laminas.dev/%{gh_project}/ + + +%prep +%setup -q -n %{gh_project}-%{gh_commit} +%patch0 -p1 -b .rpm +sed -e 's/@VERSION@/%{version}/' -i src/ApplicationFactory.php +find . -name \*.rpm -delete -print +# As we don't have mikey179/vfsstream v2 +sed -e 's/ bovigo/ org\\bovigo/' -i test/ContainerResolverTest.php +mv LICENSE.md LICENSE + + + +%build +: Create autoloader +phpab --template fedora --output src/autoload.php src + +cat << 'EOF' | tee -a src/autoload.php +\Fedora\Autoloader\Dependencies::required([ + '%{php_home}/Psr/Container/autoload.php', + '%{php_home}/Symfony4/Component/Console/autoload.php', + '%{php_home}/Symfony4/Component/EventDispatcher/autoload.php', + '%{php_home}/Symfony/Polyfill/autoload.php', + '%{php_home}/Webmozart/Assert/autoload.php', +]); + +// For Symfony 4 (use ContainerCommandLoaderTypeHint with Symfony 5) +class_alias(Laminas\Cli\ContainerCommandLoaderNoTypeHint::class, Laminas\Cli\ContainerCommandLoader::class); +EOF + + +%install +: Laminas library +mkdir -p %{buildroot}%{php_home}/%{namespace}/ +cp -pr src %{buildroot}%{php_home}/%{namespace}/%{library}%{major} + + +%check +%if %{with_tests} +mkdir vendor +cat << 'EOF' | tee vendor/autoload.php + - 1.1.1-1 +- initial package -- cgit