summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2013-05-10 09:15:21 +0200
committerRemi Collet <fedora@famillecollet.com>2013-05-10 09:15:21 +0200
commitc85d0c5e0e84c66871c861f994e81e9fa6470dee (patch)
tree489e2fd879e6af3fe2f39e3b1d686a4601221aef
parent2860fea937acb75d5a5a22a40803fe89d08a4394 (diff)
php-tcpdf: 1 cache dir per user
-rw-r--r--php-tcpdf.spec40
-rw-r--r--php-tcpdf_config.patch36
2 files changed, 60 insertions, 16 deletions
diff --git a/php-tcpdf.spec b/php-tcpdf.spec
index 5cd2d82..15ab9cd 100644
--- a/php-tcpdf.spec
+++ b/php-tcpdf.spec
@@ -4,7 +4,7 @@
Name: php-tcpdf
Summary: PHP class for generating PDF documents
Version: 6.0.012
-Release: 1%{?dist}
+Release: 2%{?dist}
Source0: http://downloads.sourceforge.net/%{real_name}/%{real_name}_%{dl_version}.zip
URL: http://www.tcpdf.org
@@ -17,7 +17,7 @@ Patch1: php-tcpdf_config.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
-Requires: php >= 5.2
+Requires: php(language) >= 5.2
Requires: php-openssl
#imagick is optionnal (and conflicts with gmagick)
#Requires: php-pecl(imagick)
@@ -30,6 +30,7 @@ Requires: php-hash
Requires: php-mbstring
Requires: php-mcrypt
Requires: php-pcre
+Requires: php-posix
Requires: php-tidy
Requires: php-xml
@@ -123,6 +124,15 @@ iconv -f iso8859-1 -t utf-8 example_030.php > example_030.php.conv \
&& mv -f example_030.php.conv example_030.php
popd
+cat >README.cache <<EOF
+This folder contains a sub-folder per user uid.
+
+If the user running PHP doesn't appear here, you need to create it.
+ mkdir <useruid>
+ chown <useruid> <useruid>
+
+EOF
+
%build
: empty build section, nothing required
@@ -144,6 +154,27 @@ cp -a config/*.php $RPM_BUILD_ROOT%{_sysconfdir}/%{name}
# Cache
install -d $RPM_BUILD_ROOT%{_localstatedir}/cache/%{name}
+install README.cache $RPM_BUILD_ROOT%{_localstatedir}/cache/%{name}/README
+
+
+%post
+# We don't want to require "httpd" in case PHP is used with some other web
+# server or without any, but we do want the owner of this directory to default
+# to apache for a working "out of the box" experience on the most common setup.
+
+for server in apache lighttpd nginx
+do
+ uid=$(getent passwd $server | cut -d: -f3)
+ if [ -n "$uid" ]
+ then
+ cache=%{_var}/cache/%{name}/$uid
+ if [ ! -d $cache ]
+ then
+ mkdir -p $cache
+ chown $uid $cache
+ fi
+ fi
+done
%clean
@@ -156,9 +187,12 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/php/%{real_name}
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/*
-%dir %attr(-,apache,apache) %{_localstatedir}/cache/%{name}
+%{_localstatedir}/cache/%{name}
%changelog
+* Fri May 10 2013 Remi Collet <remi@fedoraproject.org> - 6.0.012-2
+- improve cache ownership, on folder per web server
+
* Thu May 09 2013 Johan Cwiklinski <johan AT x-tnd DOt be> - 6.0.012-1
- Initial packaging
diff --git a/php-tcpdf_config.patch b/php-tcpdf_config.patch
index bb6f5a2..10cd020 100644
--- a/php-tcpdf_config.patch
+++ b/php-tcpdf_config.patch
@@ -1,6 +1,6 @@
-diff -up ./config/tcpdf_config_alt.php.config ./config/tcpdf_config_alt.php
---- ./config/tcpdf_config_alt.php.config 2013-04-21 21:15:04.000000000 +0200
-+++ ./config/tcpdf_config_alt.php 2013-05-09 16:47:02.868144489 +0200
+diff -up tcpdf/config/tcpdf_config_alt.php.config tcpdf/config/tcpdf_config_alt.php
+--- tcpdf/config/tcpdf_config_alt.php.config 2013-04-21 21:15:04.000000000 +0200
++++ tcpdf/config/tcpdf_config_alt.php 2013-05-10 08:52:56.098202050 +0200
@@ -61,7 +61,7 @@ if (substr($k_path_main, -1) != '/') {
* Installation path (/var/www/tcpdf/).
* By default it is automatically calculated but you can also set it as a fixed string to improve performances.
@@ -10,18 +10,23 @@ diff -up ./config/tcpdf_config_alt.php.config ./config/tcpdf_config_alt.php
// Automatic calculation for the following K_PATH_URL constant
if (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) {
-@@ -89,7 +89,7 @@ define ('K_PATH_FONTS', K_PATH_MAIN.'fon
+@@ -89,7 +89,12 @@ define ('K_PATH_FONTS', K_PATH_MAIN.'fon
/**
* cache directory for temporary files (full path)
*/
-define ('K_PATH_CACHE', K_PATH_MAIN.'cache/');
-+define ('K_PATH_CACHE', '/var/cache/php-tcpdf/');
++$k_path_cache = '/var/cache/php-tcpdf/'.posix_getuid().'/';
++if (is_dir($k_path_cache) && is_writable($k_path_cache)) {
++ define ('K_PATH_CACHE', $k_path_cache);
++} else {
++ define ('K_PATH_CACHE', sys_get_temp_dir().'/');
++}
/**
* cache directory for temporary files (url path)
-diff -up ./config/tcpdf_config.php.config ./config/tcpdf_config.php
---- ./config/tcpdf_config.php.config 2013-04-21 21:15:04.000000000 +0200
-+++ ./config/tcpdf_config.php 2013-05-09 16:46:46.391084498 +0200
+diff -up tcpdf/config/tcpdf_config.php.config tcpdf/config/tcpdf_config.php
+--- tcpdf/config/tcpdf_config.php.config 2013-04-21 21:15:04.000000000 +0200
++++ tcpdf/config/tcpdf_config.php 2013-05-10 08:55:59.206957827 +0200
@@ -65,7 +65,7 @@ if (!defined('K_TCPDF_EXTERNAL_CONFIG'))
* Installation path (/var/www/tcpdf/).
* By default it is automatically calculated but you can also set it as a fixed string to improve performances.
@@ -31,18 +36,23 @@ diff -up ./config/tcpdf_config.php.config ./config/tcpdf_config.php
// Automatic calculation for the following K_PATH_URL constant
$k_path_url = $k_path_main; // default value for console mode
-@@ -94,7 +94,7 @@ if (!defined('K_TCPDF_EXTERNAL_CONFIG'))
+@@ -94,7 +94,12 @@ if (!defined('K_TCPDF_EXTERNAL_CONFIG'))
/**
* cache directory for temporary files (full path)
*/
- define ('K_PATH_CACHE', K_PATH_MAIN.'cache/');
-+ define ('K_PATH_CACHE', '/var/cache/php-tcpdf/');
++ $k_path_cache = '/var/cache/php-tcpdf/'.posix_getuid().'/';
++ if (is_dir($k_path_cache) && is_writable($k_path_cache)) {
++ define ('K_PATH_CACHE', $k_path_cache);
++ } else {
++ define ('K_PATH_CACHE', sys_get_temp_dir().'/');
++ }
/**
* cache directory for temporary files (url path)
-diff -up ./tcpdf.php.config ./tcpdf.php
---- ./tcpdf.php.config 2013-05-09 16:43:00.199254100 +0200
-+++ ./tcpdf.php 2013-05-09 16:43:00.212254149 +0200
+diff -up tcpdf/tcpdf.php.config tcpdf/tcpdf.php
+--- tcpdf/tcpdf.php.config 2013-05-10 08:52:06.656998071 +0200
++++ tcpdf/tcpdf.php 2013-05-10 08:52:06.669998125 +0200
@@ -144,7 +144,7 @@
if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {