From 378e427e1b46127b3f9b94467686f9b046834c8d Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 12 Sep 2019 15:06:09 +0200 Subject: new package --- .gitignore | 8 ++ Makefile | 4 + composer.json | 89 +++++++++++++++ php-williamdes-mariadb-mysql-kbs-layout.patch | 41 +++++++ php-williamdes-mariadb-mysql-kbs.spec | 154 ++++++++++++++++++++++++++ 5 files changed, 296 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 composer.json create mode 100644 php-williamdes-mariadb-mysql-kbs-layout.patch create mode 100644 php-williamdes-mariadb-mysql-kbs.spec 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 + - 1.2.7-1 +- initial package -- cgit