From c3f3395d61d6bcc8343a9aa95086a6ed63daab2f Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 27 Jun 2017 14:42:51 +0200 Subject: New package --- .gitignore | 7 ++ Makefile | 4 + composer.json | 45 ++++++++++ php-endroid-qrcode-el6-rpm.patch | 17 ++++ php-endroid-qrcode-rpm.patch | 17 ++++ php-endroid-qrcode.spec | 177 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 267 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100755 composer.json create mode 100644 php-endroid-qrcode-el6-rpm.patch create mode 100644 php-endroid-qrcode-rpm.patch create mode 100644 php-endroid-qrcode.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ab5c4f --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +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 100755 index 0000000..eb785a0 --- /dev/null +++ b/composer.json @@ -0,0 +1,45 @@ +{ + "name": "endroid/qrcode", + "description": "Endroid QR Code", + "keywords": ["endroid", "qrcode", "qr", "code", "bundle", "symfony"], + "homepage": "https://github.com/endroid/QrCode", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Jeroen van den Enden", + "email": "info@endroid.nl", + "homepage": "http://endroid.nl/" + } + ], + "require": { + "php": ">=5.4", + "ext-gd": "*", + "symfony/options-resolver": "^2.3|^3.0" + }, + "require-dev": { + "symfony/browser-kit": "^2.3|^3.0", + "symfony/framework-bundle": "^2.3|^3.0", + "symfony/http-kernel": "^2.3|^3.0", + "sensio/framework-extra-bundle": "^3.0", + "phpunit/phpunit": "^4.0|^5.0" + }, + "autoload": { + "psr-4": { + "Endroid\\QrCode\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Endroid\\QrCode\\Tests\\": "tests/" + } + }, + "config": { + "bin-dir": "bin" + }, + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + } +} diff --git a/php-endroid-qrcode-el6-rpm.patch b/php-endroid-qrcode-el6-rpm.patch new file mode 100644 index 0000000..beb343a --- /dev/null +++ b/php-endroid-qrcode-el6-rpm.patch @@ -0,0 +1,17 @@ +diff -up src/QrCode.php.rpm src/QrCode.php +--- src/QrCode.php.rpm 2017-06-27 14:19:50.099124286 +0200 ++++ src/QrCode.php 2017-06-27 14:19:54.373148551 +0200 +@@ -177,9 +177,10 @@ class QrCode + */ + public function __construct($text = '') + { +- $this->setPath(__DIR__.'/../assets/data'); +- $this->setImagePath(__DIR__.'/../assets/image'); +- $this->setLabelFontPath(__DIR__.'/../assets/font/opensans.ttf'); ++ $assets = (getenv('RPM_ASSETS_BUILDROOT') ?: '') . '@ASSETS@'; ++ $this->setPath($assets.'/data'); ++ $this->setImagePath($assets.'/image'); ++ $this->setLabelFontPath($assets.'/font/opensans.ttf'); + $this->setText($text); + } + diff --git a/php-endroid-qrcode-rpm.patch b/php-endroid-qrcode-rpm.patch new file mode 100644 index 0000000..39fb1d8 --- /dev/null +++ b/php-endroid-qrcode-rpm.patch @@ -0,0 +1,17 @@ +diff -up src/QrCode.php.rpm src/QrCode.php +--- src/QrCode.php.rpm 2017-06-27 14:19:50.099124286 +0200 ++++ src/QrCode.php 2017-06-27 14:19:54.373148551 +0200 +@@ -177,9 +177,10 @@ class QrCode + */ + public function __construct($text = '') + { +- $this->setPath(__DIR__.'/../assets/data'); +- $this->setImagePath(__DIR__.'/../assets/image'); +- $this->setLabelFontPath(__DIR__.'/../assets/font/opensans.ttf'); ++ $assets = (getenv('RPM_ASSETS_BUILDROOT') ?: '') . '@ASSETS@'; ++ $this->setPath($assets.'/data'); ++ $this->setImagePath($assets.'/image'); ++ $this->setLabelFontPath('/usr/share/fonts/open-sans/OpenSans-Regular.ttf'); + $this->setText($text); + } + diff --git a/php-endroid-qrcode.spec b/php-endroid-qrcode.spec new file mode 100644 index 0000000..3de0ea9 --- /dev/null +++ b/php-endroid-qrcode.spec @@ -0,0 +1,177 @@ +# remirepo/fedora spec file for php-endroid-qrcode +# +# Copyright (c) 2017 Remi Collet +# License: CC-BY-SA +# http://creativecommons.org/licenses/by-sa/4.0/ +# +# Please, preserve the changelog entries +# +%global gh_commit c9644bec2a9cc9318e98d1437de3c628dcd1ef93 +%global gh_short %(c=%{gh_commit}; echo ${c:0:7}) +%global gh_owner endroid +%global gh_project QrCode + +%global pk_vendor %{gh_owner} +%global pk_project qrcode + +%global ns_vendor Endroid +%global ns_project QrCode +%global php_home %{_datadir}/php +%global with_tests 0%{!?_without_tests:1} + +Name: php-%{pk_vendor}-%{pk_project} +Version: 1.9.3 +Release: 1%{?dist} +Summary: Endroid QR Code + +Group: Development/Libraries +License: MIT +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 + +# Assets relocation +Patch0: %{name}-rpm.patch +Patch1: %{name}-el6-rpm.patch + +BuildArch: noarch +%if %{with_tests} +# For tests +BuildRequires: php(language) >= 5.4 +BuildRequires: php-gd +BuildRequires: php-composer(symfony/options-resolver) < 4 +BuildRequires: php-composer(symfony/options-resolver) >= 2.3 +BuildRequires: php-reflection +BuildRequires: php-pcre +BuildRequires: php-spl +# From composer.json, "require-dev": { +# "symfony/browser-kit": "^2.3|^3.0", +# "symfony/framework-bundle": "^2.3|^3.0", +# "symfony/http-kernel": "^2.3|^3.0", +# "sensio/framework-extra-bundle": "^3.0", +# "phpunit/phpunit": "^4.0|^5.0" +BuildRequires: php-composer(phpunit/phpunit) +# Required by autoloader +BuildRequires: php-composer(fedora/autoloader) +%endif +# Unbundled assets +%if 0%{?rhel} != 6 +BuildRequires: open-sans-fonts +%endif + +# From composer.json, "require": { +# "php": ">=5.4", +# "ext-gd": "*", +# "symfony/options-resolver": "^2.3|^3.0" +Requires: php(language) >= 5.4 +Requires: php-gd +Requires: php-composer(symfony/options-resolver) < 4 +Requires: php-composer(symfony/options-resolver) >= 2.3 +# From phpcompatinfo report for version 1.9.3 +Requires: php-reflection +Requires: php-pcre +Requires: php-spl +# Required by autoloader +Requires: php-composer(fedora/autoloader) +# Unbundled assets +%if 0%{?rhel} != 6 +Requires: open-sans-fonts +%else +Provides: bundled(open-sans-fonts) +%endif + +Provides: php-composer(%{pk_vendor}/%{pk_project}) = %{version} + + +%description +This library based on QRcode Perl CGI & PHP scripts by Y. Swetake +helps you generate images containing a QR code. + +Autoloader: %{php_home}/%{ns_vendor}/%{ns_project}/autoload.php + + +%prep +%setup -q -n %{gh_project}-%{gh_commit} + +%if 0%{?rhel} != 6 +: Drop bundled font +rm -r assets/font + +: Relocate assets +%patch0 -p0 +%else +%patch1 -p0 +%endif +sed -e 's:@ASSETS@:%{_datadir}/%{name}/assets:' -i src/QrCode.php + +: Fix wrong-file-end-of-line-encoding +sed -e 's/\r//' -i *.md + +: Fix perms +find . -type f -exec chmod -x {} \; + +: Generate autoloader +cat << 'EOF' | tee src/autoload.php + - 1.5.1-1 +- initial package, version 1.9.3 -- cgit