summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--composer.json34
-rw-r--r--php-udan11-sql-parser-autoload.patch68
-rw-r--r--php-udan11-sql-parser-pma.patch26
-rw-r--r--php-udan11-sql-parser.spec51
4 files changed, 140 insertions, 39 deletions
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..d3d3f17
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,34 @@
+{
+ "name": "phpmyadmin/sql-parser",
+ "description": "A validating SQL lexer and parser with a focus on MySQL dialect.",
+ "license": "GPL-2.0+",
+ "keywords": ["sql", "lexer", "parser", "analysis"],
+ "homepage": "https://github.com/phpmyadmin/sql-parser",
+ "authors": [
+ {
+ "name": "The phpMyAdmin Team",
+ "email": "developers@phpmyadmin.net",
+ "homepage": "https://www.phpmyadmin.net/team/"
+ }
+ ],
+ "support": {
+ "issues": "https://github.com/phpmyadmin/sql-parser/issues",
+ "source": "https://github.com/phpmyadmin/sql-parser"
+ },
+ "require": {
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "phpunit/php-code-coverage": "~2.0 || ~3.0",
+ "phpunit/phpunit": "~4.8 || ~5.1"
+ },
+ "bin": [
+ "bin/highlight-query",
+ "bin/lint-query"
+ ],
+ "autoload": {
+ "psr-4": {
+ "SqlParser\\": "src"
+ }
+ }
+}
diff --git a/php-udan11-sql-parser-autoload.patch b/php-udan11-sql-parser-autoload.patch
new file mode 100644
index 0000000..a6bd9da
--- /dev/null
+++ b/php-udan11-sql-parser-autoload.patch
@@ -0,0 +1,68 @@
+diff -up bin/highlight-query.rpm bin/highlight-query
+--- bin/highlight-query.rpm 2016-07-26 08:44:20.461742790 +0200
++++ bin/highlight-query 2016-07-26 08:44:57.594944077 +0200
+@@ -1,29 +1,7 @@
+ #!/usr/bin/env php
+ <?php
+
+-$files = array(
+- __DIR__ . "/../vendor/autoload.php",
+- __DIR__ . "/../../vendor/autoload.php",
+- __DIR__ . "/../../../autoload.php",
+- "vendor/autoload.php"
+-);
+-
+-$found = false;
+-foreach ($files as $file) {
+- if (file_exists($file)) {
+- require_once $file;
+- $found = true;
+- break;
+- }
+-}
+-
+-if (!$found) {
+- die(
+- "You need to set up the project dependencies using the following commands:" . PHP_EOL .
+- "curl -s http://getcomposer.org/installer | php" . PHP_EOL .
+- "php composer.phar install" . PHP_EOL
+- );
+-}
++require '/usr/share/php/SqlParser/autoload.php';
+
+ $cli = new SqlParser\Utils\CLI();
+ exit($cli->runHighlight());
+diff -up bin/lint-query.rpm bin/lint-query
+--- bin/lint-query.rpm 2016-07-26 08:44:29.869793788 +0200
++++ bin/lint-query 2016-07-26 08:45:05.123984889 +0200
+@@ -1,29 +1,7 @@
+ #!/usr/bin/env php
+ <?php
+
+-$files = array(
+- __DIR__ . "/../vendor/autoload.php",
+- __DIR__ . "/../../vendor/autoload.php",
+- __DIR__ . "/../../../autoload.php",
+- "vendor/autoload.php"
+-);
+-
+-$found = false;
+-foreach ($files as $file) {
+- if (file_exists($file)) {
+- require_once $file;
+- $found = true;
+- break;
+- }
+-}
+-
+-if (!$found) {
+- die(
+- "You need to set up the project dependencies using the following commands:" . PHP_EOL .
+- "curl -s http://getcomposer.org/installer | php" . PHP_EOL .
+- "php composer.phar install" . PHP_EOL
+- );
+-}
++require '/usr/share/php/SqlParser/autoload.php';
+
+ $cli = new SqlParser\Utils\CLI();
+ exit($cli->runLint());
diff --git a/php-udan11-sql-parser-pma.patch b/php-udan11-sql-parser-pma.patch
deleted file mode 100644
index 41e2926..0000000
--- a/php-udan11-sql-parser-pma.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From 3a6a9a807d99371ee126635e1a505fc1fe0df32c Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= <michal@cihar.com>
-Date: Thu, 25 Feb 2016 09:06:52 +0100
-Subject: [PATCH] Escape query when displaying
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Signed-off-by: Michal Čihař <michal@cihar.com>
----
- libraries/sql-parser/src/Utils/Error.php | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/libraries/sql-parser/src/Utils/Error.php b/libraries/sql-parser/src/Utils/Error.php
-index a9c0814..f0ad5af 100644
---- a/libraries/sql-parser/src/Utils/Error.php
-+++ b/libraries/sql-parser/src/Utils/Error.php
-@@ -90,7 +90,7 @@ public static function format(
- ++$i,
- $err[0],
- $err[1],
-- $err[2],
-+ htmlspecialchars($err[2]),
- $err[3]
- );
- }
diff --git a/php-udan11-sql-parser.spec b/php-udan11-sql-parser.spec
index dc3ec19..95e5212 100644
--- a/php-udan11-sql-parser.spec
+++ b/php-udan11-sql-parser.spec
@@ -6,16 +6,16 @@
#
# Please, preserve the changelog entries
#
-%global gh_commit 5c489d91f561cb0a63e0b63b29d6da71f626a137
+%global gh_commit 1ec169a2a76110bbd0734da23a43c4d23c1eecfb
%global gh_short %(c=%{gh_commit}; echo ${c:0:7})
-%global gh_owner udan11
+%global gh_owner phpmyadmin
#global gh_date 20150820
%global gh_project sql-parser
%global with_tests 0%{!?_without_tests:1}
%global psr0 SqlParser
-Name: php-%{gh_owner}-%{gh_project}
-Version: 3.4.0
+Name: php-udan11-%{gh_project}
+Version: 3.4.4
Release: 1%{?gh_date?%{gh_date}git%{gh_short}}%{?dist}
Summary: A validating SQL lexer and parser with a focus on MySQL dialect
@@ -24,9 +24,8 @@ License: GPLv2+
URL: https://github.com/%{gh_owner}/%{gh_project}
Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}-%{?gh_short}.tar.gz
-# patch from phpMyAdmin 4.5.5.1
-# https://github.com/phpmyadmin/phpmyadmin/commit/3a6a9a807d99371ee126635e1a505fc1fe0df32c
-Patch0: %{name}-pma.patch
+# Use our autoloader
+Patch0: %{name}-autoload.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
@@ -53,8 +52,11 @@ Requires: php-spl
# Rename
Obsoletes: php-dmitry-php-sql-parser < 0-0.2
Provides: php-dmitry-php-sql-parser = %{version}-%{release}
+# New packagist name
+Provides: php-phpmyadmin-sql-parser = %{version}-%{release}
# Composer
+Provides: php-composer(udan11/%{gh_project}) = %{version}
Provides: php-composer(%{gh_owner}/%{gh_project}) = %{version}
@@ -64,13 +66,12 @@ A validating SQL lexer and parser with a focus on MySQL dialect.
This library was originally developed for phpMyAdmin during
the Google Summer of Code 2015.
-To use this library, you just have to add, in your project:
- require_once '%{_datadir}/php/%{psr0}/autoload.php';
+Autoloader: %{_datadir}/php/%{psr0}/autoload.php
%prep
%setup -q -n %{gh_project}-%{gh_commit}
-%patch0 -p3
+%patch0 -p0 -b .rpm
%build
@@ -80,9 +81,15 @@ To use this library, you just have to add, in your project:
%install
rm -rf %{buildroot}
+
+: Library
mkdir -p %{buildroot}%{_datadir}/php
cp -pr src %{buildroot}%{_datadir}/php/%{psr0}
+: Commands
+install -Dpm 0755 bin/highlight-query %{buildroot}%{_bindir}/%{gh_project}-highlight-query
+install -Dpm 0755 bin/lint-query %{buildroot}%{_bindir}/%{gh_project}-lint-query
+
%check
%if %{with_tests}
@@ -92,13 +99,24 @@ cat << 'EOF' | tee vendor/autoload.php
require '%{buildroot}%{_datadir}/php/%{psr0}/autoload.php';
EOF
+# remirepo:11
+run=0
+ret=0
+if which php56; then
+ php56 %{_bindir}/phpunit --no-coverage || ret=1
+ run=1
+fi
+if which php71; then
+ php71 %{_bindir}/phpunit --no-coverage || ret=1
+ run=1
+fi
+if [ $run -eq 0 ]; then
if %{_bindir}/phpunit --atleast-version 4.8; then
%{_bindir}/phpunit --no-coverage --verbose
fi
-
-if which php70; then
- php70 %{_bindir}/phpunit --no-coverage --verbose
+# remirepo:2
fi
+exit $ret
%else
: Test suite disabled
%endif
@@ -115,9 +133,16 @@ rm -rf %{buildroot}
%doc composer.json
%doc README.md
%{_datadir}/php/%{psr0}
+%{_bindir}/%{gh_project}-highlight-query
+%{_bindir}/%{gh_project}-lint-query
%changelog
+* Tue Jul 26 2016 Remi Collet <remi@fedoraproject.org> - 3.4.4-1
+- update to 3.4.4
+- switch from udan11/sql-parser to phpmyadmin/sql-parser
+- add sql-parser-highlight-query and sql-parser-lint-query commands
+
* Tue Mar 1 2016 Remi Collet <remi@fedoraproject.org> - 3.4.0-1
- update to 3.4.0 (for phpMyAdmin 4.5.5.1)
- add patch from phpMyAdmin