summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2016-12-12 10:28:54 +0100
committerRemi Collet <fedora@famillecollet.com>2016-12-12 10:28:54 +0100
commit3f1ef106ecc8f365f3c5dbe533d4cdc1c50adc33 (patch)
tree3cb31787b236c474b3facd470d069235e6fdffdc
php-justinrainbow-json-schema4: 4.0.1 (new package)
-rw-r--r--Makefile4
-rw-r--r--composer.json62
-rw-r--r--php-justinrainbow-json-schema4-autoload.php8
-rwxr-xr-xphp-justinrainbow-json-schema4-makesrc.sh27
-rw-r--r--php-justinrainbow-json-schema4-pr342.patch24
-rw-r--r--php-justinrainbow-json-schema4-rpm.patch45
-rw-r--r--php-justinrainbow-json-schema4.spec251
7 files changed, 421 insertions, 0 deletions
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..738c09d
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,62 @@
+{
+ "name": "justinrainbow/json-schema",
+ "description": "A library to validate a json schema.",
+ "keywords": ["json", "schema"],
+ "homepage": "https://github.com/justinrainbow/json-schema",
+ "type": "library",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Bruno Prieto Reis",
+ "email": "bruno.p.reis@gmail.com"
+ },
+ {
+ "name": "Justin Rainbow",
+ "email": "justin.rainbow@gmail.com"
+ },
+ {
+ "name": "Igor Wiedler",
+ "email": "igor@wiedler.ch"
+ },
+ {
+ "name": "Robert Schönthal",
+ "email": "seroscho@googlemail.com"
+ }
+ ],
+ "repositories": [{
+ "type": "package",
+ "package": {
+ "name": "json-schema/JSON-Schema-Test-Suite",
+ "version": "1.2.0",
+ "source": {
+ "url": "https://github.com/json-schema/JSON-Schema-Test-Suite",
+ "type": "git",
+ "reference": "1.2.0"
+ }
+ }
+ }],
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "json-schema/JSON-Schema-Test-Suite": "1.2.0",
+ "phpunit/phpunit": "^4.8.22",
+ "phpdocumentor/phpdocumentor": "~2"
+ },
+ "autoload": {
+ "psr-4": { "JsonSchema\\": "src/JsonSchema/" }
+ },
+ "autoload-dev": {
+ "psr-4": { "JsonSchema\\Tests\\": "tests/" }
+ },
+ "bin": ["bin/validate-json"],
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.0.x-dev"
+ }
+ },
+ "scripts": {
+ "test" : "vendor/bin/phpunit",
+ "coverage" : "vendor/bin/phpunit --coverage-text"
+ }
+}
diff --git a/php-justinrainbow-json-schema4-autoload.php b/php-justinrainbow-json-schema4-autoload.php
new file mode 100644
index 0000000..e90a275
--- /dev/null
+++ b/php-justinrainbow-json-schema4-autoload.php
@@ -0,0 +1,8 @@
+<?php
+/**
+ * Autoloader for justinrainbow/json-schema and its dependencies
+ */
+
+require_once '/usr/share/php/Fedora/Autoloader/autoload.php';
+
+\Fedora\Autoloader\Autoload::addPsr4('JsonSchema\\', __DIR__);
diff --git a/php-justinrainbow-json-schema4-makesrc.sh b/php-justinrainbow-json-schema4-makesrc.sh
new file mode 100755
index 0000000..dfd5c2a
--- /dev/null
+++ b/php-justinrainbow-json-schema4-makesrc.sh
@@ -0,0 +1,27 @@
+#!/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}
+
+echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION\n"
+
+echo "Cloning..."
+git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT
+
+echo "Getting commit..."
+pushd $PROJECT-$COMMIT
+git checkout $COMMIT
+cp composer.json ../composer.json
+popd
+
+echo "Archiving..."
+tar czf $NAME-$VERSION-$SHORT.tgz --exclude .git $PROJECT-$COMMIT
+
+echo "Cleaning..."
+rm -rf $PROJECT-$COMMIT
+
+echo "Done."
diff --git a/php-justinrainbow-json-schema4-pr342.patch b/php-justinrainbow-json-schema4-pr342.patch
new file mode 100644
index 0000000..db15d33
--- /dev/null
+++ b/php-justinrainbow-json-schema4-pr342.patch
@@ -0,0 +1,24 @@
+From b0a382eaee1e5084e2785d516a31897f90c2b219 Mon Sep 17 00:00:00 2001
+From: Remi Collet <fedora@famillecollet.com>
+Date: Mon, 12 Dec 2016 10:17:02 +0100
+Subject: [PATCH] fix #341 validate-json command
+
+---
+ bin/validate-json | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/bin/validate-json b/bin/validate-json
+index 8184e7b..e9c1809 100755
+--- a/bin/validate-json
++++ b/bin/validate-json
+@@ -207,8 +207,8 @@ try {
+ echo $e->getMessage() . "\n";
+ exit(2);
+ }
+-$refResolver = new JsonSchema\RefResolver($retriever, $resolver);
+-$schema = $refResolver->resolve($urlSchema);
++$refResolver = new JsonSchema\SchemaStorage($retriever, $resolver);
++$schema = $refResolver->resolveRef($urlSchema);
+
+ if (isset($arOptions['--dump-schema'])) {
+ $options = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0;
diff --git a/php-justinrainbow-json-schema4-rpm.patch b/php-justinrainbow-json-schema4-rpm.patch
new file mode 100644
index 0000000..4e2d710
--- /dev/null
+++ b/php-justinrainbow-json-schema4-rpm.patch
@@ -0,0 +1,45 @@
+diff -up bin/validate-json.rpm bin/validate-json
+--- bin/validate-json.rpm 2016-04-15 11:02:32.629960716 +0200
++++ bin/validate-json 2016-04-15 11:07:01.583136406 +0200
+@@ -6,28 +6,7 @@
+ * @author Christian Weiske <christian.weiske@netresearch.de>
+ */
+
+-/**
+- * Dead simple autoloader
+- *
+- * @param string $className Name of class to load
+- *
+- * @return void
+- */
+-function __autoload($className)
+-{
+- $className = ltrim($className, '\\');
+- $fileName = '';
+- $namespace = '';
+- if ($lastNsPos = strrpos($className, '\\')) {
+- $namespace = substr($className, 0, $lastNsPos);
+- $className = substr($className, $lastNsPos + 1);
+- $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
+- }
+- $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
+- if (stream_resolve_include_path($fileName)) {
+- require_once $fileName;
+- }
+-}
++require_once '/usr/share/php/JsonSchema4/autoload.php';
+
+ /**
+ * Show the json parse error that happened last
+@@ -85,11 +64,6 @@ function parseHeaderValue($headerValue)
+ }
+
+
+-// support running this tool from git checkout
+-if (is_dir(__DIR__ . '/../src/JsonSchema')) {
+- set_include_path(__DIR__ . '/../src' . PATH_SEPARATOR . get_include_path());
+-}
+-
+ $arOptions = array();
+ $arArgs = array();
+ array_shift($argv);//script itself
diff --git a/php-justinrainbow-json-schema4.spec b/php-justinrainbow-json-schema4.spec
new file mode 100644
index 0000000..d8ec83e
--- /dev/null
+++ b/php-justinrainbow-json-schema4.spec
@@ -0,0 +1,251 @@
+# remirepo/fedora spec file for php-justinrainbow-json-schema4
+#
+# Copyright (c) 2016 Remi Collet
+# License: CC-BY-SA
+# http://creativecommons.org/licenses/by-sa/4.0/
+#
+# Please, preserve the changelog entries
+#
+%global gh_commit 10d1f6977f6be5f177dded8f585a11debdc27591
+%global gh_short %(c=%{gh_commit}; echo ${c:0:7})
+%global gh_owner justinrainbow
+%global gh_project json-schema
+%global php_home %{_datadir}/php
+%global with_tests 0%{!?_without_tests:1}
+%global major 4
+%global minor 0.1
+
+
+# Some sample files, only used for tests
+# "json-schema/JSON-Schema-Test-Suite": "1.1.0",
+%global ts_commit f3d5aeb5ffbe9d9a5a0ceb761dc47c7c4c2efa68
+%global ts_short %(c=%{ts_commit}; echo ${c:0:7})
+%global ts_owner json-schema
+%global ts_project JSON-Schema-Test-Suite
+%global ts_version 1.2.0
+
+%global eolv1 0
+%global eolv2 0
+%global with_script 0
+%if 0%{?fedora} >= 26
+%global with_script 1
+%endif
+# remirepo:1
+%global with_script 1
+
+Name: php-%{gh_owner}-%{gh_project}%{major}
+Version: %{major}.%{minor}
+Release: 1%{?dist}
+Summary: A library to validate a json schema
+
+Group: Development/Libraries
+License: MIT
+URL: https://github.com/%{gh_owner}/%{gh_project}
+# git snapshot to get upstream test suite
+Source0: %{name}-%{version}-%{gh_short}.tgz
+Source1: https://github.com/%{ts_owner}/%{ts_project}/archive/%{ts_commit}/%{ts_project}-%{ts_version}-%{ts_short}.tar.gz
+Source2: %{name}-autoload.php
+Source3: %{name}-makesrc.sh
+
+# Autoloader
+Patch0: %{name}-rpm.patch
+# https://github.com/justinrainbow/json-schema/issues/341
+Patch1: %{name}-pr342.patch
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildArch: noarch
+%if %{with_tests}
+# For tests
+BuildRequires: php(language) >= 5.3.3
+BuildRequires: php-curl
+BuildRequires: php-date
+BuildRequires: php-filter
+BuildRequires: php-json
+BuildRequires: php-mbstring
+BuildRequires: php-pcre
+BuildRequires: php-spl
+# From composer.json, "require-dev": {
+# "json-schema/JSON-Schema-Test-Suite": "1.2.0",
+# "phpunit/phpunit": "^4.8.22",
+# "phpdocumentor/phpdocumentor": "~2"
+BuildRequires: php-composer(phpunit/phpunit) >= 4.8.22
+# Autoloader
+BuildRequires: php-composer(fedora/autoloader)
+# For composer schema
+BuildRequires: composer
+%endif
+
+# From composer.json, "require": {
+# "php": ">=5.3.3"
+Requires: php(language) >= 5.3.3
+# From phpcompatinfo report for version 4.0.1
+Requires: php-curl
+Requires: php-date
+Requires: php-filter
+Requires: php-json
+Requires: php-mbstring
+Requires: php-pcre
+Requires: php-spl
+# Autoloader
+Requires: php-composer(fedora/autoloader)
+%if %{eolv1}
+Obsoletes: php-JsonSchema < 2
+%endif
+%if %{eolv2}
+Obsoletes: php-justinrainbow-json-schema < 3
+%endif
+%if %{with_script}
+Requires: php-cli
+# previous version provides the validate-json command
+Conflicts: php-JsonSchema < 1.6.1-3
+Conflicts: php-justinrainbow-json-schema < 2.0.5-4
+%endif
+
+Provides: php-composer(%{gh_owner}/%{gh_project}) = %{version}
+
+
+%description
+A PHP Implementation for validating JSON Structures against a given Schema.
+%if %{with_script}
+This package provides the library version 4 and the validate-json command.
+%else
+This package provides the library version 4.
+%endif
+The php-JsonSchema package provides the library version 1.
+The php-justinrainbow-json-schema package provides the library version 2.
+
+See http://json-schema.org/
+
+Autoloader: %{php_home}/JsonSchema%{major}/autoload.php
+
+
+%prep
+%setup -q -n %{gh_project}-%{gh_commit} -a 1
+
+%patch1 -p1 -b .342
+%patch0 -p0 -b .rpm
+
+cp %{SOURCE2} src/JsonSchema/autoload.php
+
+: Needed for the test suite - use composer default path, as easier
+mkdir -p vendor/json-schema/JSON-Schema-Test-Suite
+mv %{ts_project}-%{ts_commit}/tests \
+ vendor/json-schema/JSON-Schema-Test-Suite/tests
+
+: But without online tests
+find vendor/json-schema/JSON-Schema-Test-Suite/tests \
+ -name \*.json \
+ -exec grep -q 'http://' {} \; \
+ -exec rm {} \; \
+ -print
+
+%if ! %{with_script}
+chmod -x bin/validate-json
+%endif
+
+
+%build
+# Empty build section, most likely nothing required.
+
+
+%install
+rm -rf %{buildroot}
+
+: Library
+mkdir -p %{buildroot}%{php_home}
+cp -pr src/JsonSchema %{buildroot}%{php_home}/JsonSchema%{major}
+
+%if %{with_script}
+: Command
+install -Dpm 0755 bin/validate-json %{buildroot}%{_bindir}/validate-json
+%endif
+
+
+%check
+%if %{with_tests}
+: Test suite autoloader
+cat << 'EOF' | tee vendor/autoload.php
+<?php
+require '%{buildroot}%{php_home}/JsonSchema%{major}/autoload.php';
+\Fedora\Autoloader\Autoload::addPsr4('JsonSchema\\Tests\\', 'tests/');
+EOF
+
+: Test the command
+sed -e 's:%{php_home}:%{buildroot}%{php_home}:' \
+ bin/validate-json > bin/validate-json-test
+php bin/validate-json-test \
+ composer.json \
+ /usr/share/composer/res/composer-schema.json
+
+: Upstream test suite
+# remirepo:11
+run=0
+ret=0
+if which php56; then
+ php56 -d memory_limit=1G %{_bindir}/phpunit || ret=1
+ run=1
+fi
+if which php71; then
+ php71 -d memory_limit=1G %{_bindir}/phpunit || ret=1
+ run=1
+fi
+if [ $run -eq 0 ]; then
+%{_bindir}/phpunit -d memory_limit=1G --verbose
+# remirepo:2
+fi
+exit $ret
+%else
+: Test suite disabled
+%endif
+
+
+%clean
+rm -rf %{buildroot}
+
+
+%files
+%defattr(-,root,root,-)
+%{!?_licensedir:%global license %%doc}
+%license LICENSE
+%doc composer.json
+%doc *.md
+%if %{with_script}
+%{_bindir}/validate-json
+%else
+%doc bin/validate-json
+%endif
+%{php_home}/JsonSchema%{major}
+
+
+%changelog
+* Mon Dec 12 2016 Remi Collet <remi@fedoraproject.org> - 4.0.1-1
+- rename to php-justinrainbow-json-schema4
+- update to 4.0.1
+
+* Fri Oct 21 2016 Remi Collet <remi@fedoraproject.org> - 2.0.5-3
+- switch from symfony/class-loader to fedora/autoloader
+
+* Thu Jul 21 2016 Remi Collet <remi@fedoraproject.org> - 2.0.5-2
+- fix failed test, FTBFS detected by Koschei
+ open https://github.com/justinrainbow/json-schema/pull/292
+
+* Thu Jun 2 2016 Remi Collet <remi@fedoraproject.org> - 2.0.5-1
+- update to 2.0.5
+
+* Wed Jun 1 2016 Remi Collet <remi@fedoraproject.org> - 2.0.4-2
+- add the validate-json command, dropped from php-JsonSchema
+
+* Wed May 25 2016 Remi Collet <remi@fedoraproject.org> - 2.0.4-1
+- update to 2.0.4
+- use json-schema/JSON-Schema-Test-Suite 1.2.0
+
+* Wed May 11 2016 Remi Collet <remi@fedoraproject.org> - 2.0.3-1
+- update to 2.0.3
+- use json-schema/JSON-Schema-Test-Suite 1.1.2
+
+* Fri Apr 29 2016 Remi Collet <remi@fedoraproject.org> - 2.0.1-1
+- update to 2.0.1
+
+* Fri Apr 15 2016 Remi Collet <remi@fedoraproject.org> - 2.0.0-1
+- initial package, version 2.0.0
+