diff options
author | Remi Collet <remi@remirepo.net> | 2019-09-12 15:06:09 +0200 |
---|---|---|
committer | Remi Collet <remi@remirepo.net> | 2019-09-12 15:06:09 +0200 |
commit | 378e427e1b46127b3f9b94467686f9b046834c8d (patch) | |
tree | 8697d436d0bae0ea9089ccb1631a839244cd4b2e |
new package
-rw-r--r-- | .gitignore | 8 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | composer.json | 89 | ||||
-rw-r--r-- | php-williamdes-mariadb-mysql-kbs-layout.patch | 41 | ||||
-rw-r--r-- | php-williamdes-mariadb-mysql-kbs.spec | 154 |
5 files changed, 296 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fc9aa8c --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +clog +package-*.xml +*.tgz +*.tar.gz +*.tar.xz +*.tar.xz.asc +*.src.rpm +*/*rpm diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..91b0fd5 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../../common/Makefile + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..28ad97e --- /dev/null +++ b/composer.json @@ -0,0 +1,89 @@ +{ + "name": "williamdes/mariadb-mysql-kbs", + "description": "An index of the MariaDB and MySQL Knowledge bases", + "homepage": "https://github.com/williamdes/mariadb-mysql-kbs", + "type": "library", + "readme": "https://github.com/williamdes/mariadb-mysql-kbs/blob/master/README.md", + "license": "MPL-2.0", + "version": "1.2.7", + "keywords": [ + "mariadb", + "mysql", + "dataset", + "kb", + "knowledge-base", + "json", + "library", + "mysql-knowledge-bases", + "mariadb-knowledge-bases", + "composer-package", + "npm-package" + ], + "support": { + "email": "williamdes@wdes.fr", + "issues": "https://github.com/williamdes/mariadb-mysql-kbs/issues", + "source": "https://github.com/williamdes/mariadb-mysql-kbs" + }, + "authors": [ + { + "name": "William Desportes", + "email": "williamdes@wdes.fr" + } + ], + "scripts": { + "build": "php src/merge.php", + "test": "phpunit --testdox --configuration ./test/phpunit.xml", + "phpstan": "phpstan analyse src test --configuration=phpstan.neon --level=max --memory-limit=100M", + "phpcs": "phpcs --standard=phpcs.xml --no-cache --colors -p -n", + "phpcbf": "phpcbf --standard=phpcs.xml" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0 || ^8.0", + "phpstan/phpstan": "^0.11.3", + "slevomat/coding-standard": "^5.0", + "squizlabs/php_codesniffer": "^3.3", + "php-school/cli-menu": "^3.0", + "swaggest/json-schema": "^0.12.9" + }, + "archive": { + "exclude": [ + "/scripts", + "/data", + "/dist/merged-raw.json", + "/test", + "*.js", + "/.dependabot", + "/.jshintrc", + "/.npmignore", + "/.editorconfig", + "/.gitmodules", + "/CODEOWNERS", + "/williamdes-mariadb-mysql-kbs-*.tar", + "/docs", + "/package.json", + "/package-lock.json", + "/.prettierignore", + "/.gitignore", + "/phpcs.xml", + "/phpstan.neon", + "/.travis.yml", + "/dist/merged-raw.md", + "/.jshintignore", + "/.phpunit.result.cache" + ] + }, + "autoload": { + "psr-4": { + "Williamdes\\MariaDBMySQLKBS\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Williamdes\\MariaDBMySQLKBS\\Test\\": "test/" + } + }, + "non-feature-branches": ["update/*"] +} diff --git a/php-williamdes-mariadb-mysql-kbs-layout.patch b/php-williamdes-mariadb-mysql-kbs-layout.patch new file mode 100644 index 0000000..9858a8e --- /dev/null +++ b/php-williamdes-mariadb-mysql-kbs-layout.patch @@ -0,0 +1,41 @@ +diff -up ./src/merge.php.rpm ./src/merge.php +diff -up ./src/Search.php.rpm ./src/Search.php +--- ./src/Search.php.rpm 2019-09-12 10:53:45.797567100 +0200 ++++ ./src/Search.php 2019-09-12 11:01:04.702560202 +0200 +@@ -25,7 +25,7 @@ class Search + public const MYSQL = 1; + public const MARIADB = 2; + public const DS = DIRECTORY_SEPARATOR; +- public static $DATA_DIR = __DIR__.self::DS."..".self::DS."dist".self::DS; ++ public static $DATA_DIR = '/usr/share/php-williamdes-mariadb-mysql-kbs/dist/'; + + /** + * Load data from disk +diff -up ./test/SearchTest.php.rpm ./test/SearchTest.php +--- ./test/SearchTest.php.rpm 2019-09-12 14:45:12.103423385 +0200 ++++ ./test/SearchTest.php 2019-09-12 14:45:15.407409867 +0200 +@@ -175,4 +175,24 @@ class SearchTest extends TestCase + $this->assertEquals("boolean", $type); + } + ++ ++ /** ++ * test RPM Layout ++ * ++ * @runInSeparateProcess ++ * ++ * @return void ++ */ ++ public function testLayout(): void ++ { ++ if (!getenv("RPM_BUILDROOT")) { ++ $this->markTestSkipped("No RPM_BUILDROOT"); ++ } ++ Search::$loaded = false; ++ Search::$DATA_DIR = getenv("RPM_BUILDROOT") . Search::$DATA_DIR; ++ $found = Search::getByName("max_connections", Search::MYSQL); ++ $this->assertContains('php-williamdes-mariadb-mysql-kb', Search::$DATA_DIR); ++ $this->assertContains(getenv("RPM_BUILDROOT"), Search::$DATA_DIR); ++ $this->assertTrue(Search::$loaded); ++ } + } diff --git a/php-williamdes-mariadb-mysql-kbs.spec b/php-williamdes-mariadb-mysql-kbs.spec new file mode 100644 index 0000000..a8841a6 --- /dev/null +++ b/php-williamdes-mariadb-mysql-kbs.spec @@ -0,0 +1,154 @@ +# remirepo/fedora spec file for php-williamdes-mariadb-mysql-kbs +# +# Copyright (c) 2019 Remi Collet +# License: CC-BY-SA +# http://creativecommons.org/licenses/by-sa/4.0/ +# +# Please, preserve the changelog entries +# + +%global with_tests 0%{!?_without_tests:1} +# Github +%global gh_commit 64167803686aff4090f72a6d89826364b1d88d7d +%global gh_short %(c=%{gh_commit}; echo ${c:0:7}) +%global gh_owner williamdes +%global gh_project mariadb-mysql-kbs +# Packagist +%global pk_vendor %{gh_owner} +%global pk_project %{gh_project} +# Namespace +%global ns_vendor Williamdes +%global ns_project MariaDBMySQLKBS +%global major %nil + +Name: php-%{pk_vendor}-%{pk_project}%{major} +Version: 1.2.7 +Release: 1%{?gh_date?%{gh_date}git%{gh_short}}%{?dist} +Summary: An index of the MariaDB and MySQL Knowledge bases + +License: MPLv2.0 +URL: https://github.com/%{gh_owner}/%{gh_project} +Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{name}-%{version}-%{?gh_short}.tar.gz + +Patch0: %{name}-layout.patch + +BuildArch: noarch +%if %{with_tests} +BuildRequires: php(language) >= 7.1 +BuildRequires: php-json +BuildRequires: php-pcre +# For tests, from composer.json "require-dev": { +# "phpunit/phpunit": "^7.0 || ^8.0", +# "phpstan/phpstan": "^0.11.3", +# "slevomat/coding-standard": "^5.0", +# "squizlabs/php_codesniffer": "^3.3", +# "php-school/cli-menu": "^3.0", +# "swaggest/json-schema": "^0.12.9" +BuildRequires: phpunit7 +%global phpunit %{_bindir}/phpunit7 +%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8 +BuildRequires: (php-composer(swaggest/json-schema) > 0.12.9 with php-composer(swaggest/json-schema) < 1) +%else +BuildRequires: php-composer(swaggest/json-schema) < 1 +BuildRequires: php-composer(swaggest/json-schema) >= 0.12.9 +%endif +# For autoloader +BuildRequires: php-composer(fedora/autoloader) +%endif + +# From composer.json, "require": { +# "php": "^7.1" +Requires: php(language) >= 7.1 +# From phpcompatinfo report for 1.2.7 +Requires: php-json +Requires: php-pcre +# For generated autoloader +Requires: php-composer(fedora/autoloader) + +# Composer +Provides: php-composer(%{pk_vendor}/%{pk_project}) = %{version} + + +%description +An index of the MariaDB and MySQL Knowledge bases. + + +Autoloader: %{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}/autoload.php + + +%prep +%setup -q -n %{gh_project}-%{gh_commit} +%patch0 -p1 + +: Create autoloader +cat <<'AUTOLOAD' | tee src/autoload.php +<?php +/* Autoloader for %{name} and its dependencies */ +require_once '%{_datadir}/php/Fedora/Autoloader/autoload.php'; + +\Fedora\Autoloader\Autoload::addPsr4('%{ns_vendor}\\%{ns_project}\\', __DIR__); +AUTOLOAD + + +%build +: Generate merged data +%{_bindir}/php -d auto_prepend_file=src/autoload.php src/merge.php + + +%install +: Library +mkdir -p %{buildroot}%{_datadir}/php/%{ns_vendor} +cp -pr src %{buildroot}%{_datadir}/php/%{ns_vendor}/%{ns_project}%{major} + +: Data +mkdir -p %{buildroot}%{_datadir}/%{name} +# only dist is used at runtime +cp -pr dist %{buildroot}%{_datadir}/%{name}/dist +cp -pr data %{buildroot}%{_datadir}/%{name}/data +cp -pr schemas %{buildroot}%{_datadir}/%{name}/schemas + + +%check +%if %{with_tests} +mkdir vendor +cat << 'EOF' | tee vendor/autoload.php +<?php +require '%{buildroot}%{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}/autoload.php'; +\Fedora\Autoloader\Autoload::addPsr4('%{ns_vendor}\\%{ns_project}\\Test\\', dirname(__DIR__).'/test'); +require '%{_datadir}/php/Swaggest/JsonSchema/autoload.php'; +EOF + +cd test +export RPM_BUILDROOT=%{buildroot} + +ret=0 +for cmd in php php71 php72 php73 php74; do + if which $cmd; then + $cmd %{phpunit} --no-coverage --verbose || ret=1 + fi +done +exit $ret +%else +: Test suite disabled +%endif + + +%files +# remirepo:1 +%{!?_licensedir:%global license %%doc} +%license LICENSE +%doc composer.json +%doc *.md +%dir %{_datadir}/php/%{ns_vendor}/ + %{_datadir}/php/%{ns_vendor}/%{ns_project}%{major} +%exclude %{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}/merge.php +%exclude %{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}/*.js +%dir %{_datadir}/%{name}/ + %{_datadir}/%{name}/dist +%doc %{_datadir}/%{name}/data +%doc %{_datadir}/%{name}/schemas + + +%changelog +* Thu Sep 12 2019 Remi Collet <remi@remirepo.net> - 1.2.7-1 +- initial package |