[packages/php-Smarty] add smarty bc bcond building SmartyBC as Smarty class

glen glen at pld-linux.org
Thu Sep 4 12:41:43 CEST 2014


commit e8f2ceb4a7afbe9a5163135c7f980f64415cbdc4
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Tue Sep 2 14:41:59 2014 +0300

    add smarty bc bcond building SmartyBC as Smarty class

 bc.patch        | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 php-Smarty.spec | 45 +++++++++++++++++++++++++++++++++++--
 2 files changed, 112 insertions(+), 2 deletions(-)
---
diff --git a/php-Smarty.spec b/php-Smarty.spec
index 014bd96..1d7726a 100644
--- a/php-Smarty.spec
+++ b/php-Smarty.spec
@@ -1,11 +1,16 @@
+#
+# Conditional build:
+%bcond_with	bc		# build BC wrapper as default Smarty class
+
 %define		main_version 3.1.19
 %define		doc_version	3.1.14
+%define		rel	1
 %define		php_min_version 5.2.0
 Summary:	Template engine for PHP
 Summary(pl.UTF-8):	System szablonów dla PHP
 Name:		php-Smarty
 Version:	%{main_version}
-Release:	1
+Release:	%{rel}%{?with_bc:BC}
 License:	LGPL v2.1+
 Group:		Development/Languages/PHP
 Source0:	http://www.smarty.net/files/Smarty-%{version}.tar.gz
@@ -13,6 +18,7 @@ Source0:	http://www.smarty.net/files/Smarty-%{version}.tar.gz
 # Source1Download: http://www.smarty.net/documentation
 Source1:	http://www.smarty.net/files/docs/manual-en.%{doc_version}.zip
 # Source1-md5:	f54b1dd458776e4b1ccfdbfbfda1f484
+Patch0:		bc.patch
 URL:		http://www.smarty.net/
 BuildRequires:	rpm-php-pearprov >= 4.4.2-11
 BuildRequires:	rpmbuild(macros) >= 1.553
@@ -22,6 +28,10 @@ Requires:	php(date)
 Requires:	php(mbstring)
 Requires:	php(pcre)
 Requires:	php(tokenizer)
+%if %{with bc}
+Provides:	Smarty = %{version}
+Obsoletes:	Smarty < 3.0
+%endif
 BuildArch:	noarch
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
@@ -35,6 +45,9 @@ as configuration files, template functions, variable modifiers, and
 making all of this functionality as easy as possible to use for both
 programmers and template designers.
 
+%{?with_bc:This package is modified to have SmartyBC class as Smarty
+class name}
+
 %description -l pl.UTF-8
 Smarty jest systemem szablonów dla PHP. Pozwala na podstawowe
 podstawianie wartości zmiennych oraz dynamiczne operacje na blokach;
@@ -57,9 +70,14 @@ Dokumentacja do systemu szablonów Smarty.
 
 %prep
 %setup -q -n Smarty-%{main_version} -a1
-
 %undos -f php
 
+%if %{with bc}
+mv libs/Smarty.class.php libs/Smarty3.class.php
+mv libs/SmartyBC.class.php libs/Smarty.class.php
+%patch0 -p1
+%endif
+
 # cleanup backups after patching
 find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f
 
@@ -68,9 +86,26 @@ rm -rf $RPM_BUILD_ROOT
 install -d $RPM_BUILD_ROOT%{appdir}
 cp -a libs/* $RPM_BUILD_ROOT%{appdir}
 
+%if %{with bc}
+ln -s Smarty3/Smarty.class.php $RPM_BUILD_ROOT%{php_data_dir}
+ln -s Smarty3 $RPM_BUILD_ROOT%{php_data_dir}/Smarty
+%endif
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
+%if %{with bc}
+# compat symlink, but need to mv dir first due rpm dir-symlink issue
+%pretrans
+test -L %{php_data_dir}/Smarty && exit 0
+if [ -d %{php_data_dir}/Smarty/plugins ]; then
+	mv %{php_data_dir}/Smarty/plugins/* %{appdir}/plugins
+	rmdir %{php_data_dir}/Smarty/plugins 2>/dev/null
+fi
+rmdir %{php_data_dir}/Smarty 2>/dev/null || mv -v %{php_data_dir}/Smarty{,.rpmsave}
+ln -s Smarty3 %{php_data_dir}/Smarty
+%endif
+
 %files
 %defattr(644,root,root,755)
 %doc README SMARTY_3.1_NOTES.txt
@@ -83,6 +118,12 @@ rm -rf $RPM_BUILD_ROOT
 %{appdir}/plugins/*.php
 %{appdir}/sysplugins/*.php
 
+%if %{with bc}
+%{appdir}/Smarty3.class.php
+%{php_data_dir}/Smarty.class.php
+%{php_data_dir}/Smarty
+%endif
+
 %files doc
 %defattr(644,root,root,755)
 %doc demo manual-en
diff --git a/bc.patch b/bc.patch
new file mode 100644
index 0000000..87e4f87
--- /dev/null
+++ b/bc.patch
@@ -0,0 +1,69 @@
+--- Smarty-3.1.19/libs/Smarty3.class.php~	2014-09-02 14:46:50.940253560 +0300
++++ Smarty-3.1.19/libs/Smarty3.class.php	2014-09-02 14:46:52.640228305 +0300
+@@ -101,7 +101,7 @@
+  *
+  * @package Smarty
+  */
+-class Smarty extends Smarty_Internal_TemplateBase
++class Smarty3 extends Smarty_Internal_TemplateBase
+ {
+     /**#@+
+      * constant definitions
+@@ -110,7 +110,7 @@
+     /**
+      * smarty version
+      */
+-    const SMARTY_VERSION = 'Smarty-3.1.19';
++    const SMARTY_VERSION = 'Smarty-3.1.19BC';
+ 
+     /**
+      * define variable scopes
+@@ -1589,11 +1589,11 @@
+ }
+ 
+ // Check if we're running on windows
+-Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
++Smarty3::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
+ 
+ // let PCRE (preg_*) treat strings as ISO-8859-1 if we're not dealing with UTF-8
+-if (Smarty::$_CHARSET !== 'UTF-8') {
+-    Smarty::$_UTF8_MODIFIER = '';
++if (Smarty3::$_CHARSET !== 'UTF-8') {
++    Smarty3::$_UTF8_MODIFIER = '';
+ }
+ 
+ /**
+--- Smarty-3.1.19/libs/Smarty.class.php~	2014-09-02 14:47:19.543161977 +0300
++++ Smarty-3.1.19/libs/Smarty.class.php	2014-09-02 14:47:21.126471790 +0300
+@@ -28,14 +28,14 @@
+ /**
+  * @ignore
+  */
+-require_once(dirname(__FILE__) . '/Smarty.class.php');
++require_once(dirname(__FILE__) . '/Smarty3.class.php');
+ 
+ /**
+  * Smarty Backward Compatability Wrapper Class
+  *
+  * @package Smarty
+  */
+-class SmartyBC extends Smarty
++class Smarty extends Smarty3
+ {
+     /**
+      * Smarty 2 BC
+--- /dev/null	2009-03-03 10:35:25.000000000 +0200
++++ Smarty-3.1.19/libs/SmartyBC.class.php	2014-09-04 13:21:01.978505628 +0300
+@@ -0,0 +1,12 @@
++<?php
++/**
++ * @ignore
++ */
++require_once(dirname(__FILE__) . '/Smarty.class.php');
++
++/**
++ * Class to use Smarty3 BC layer
++ *
++ * @package Smarty
++ */
++class SmartyBC extends Smarty {}
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/php-Smarty.git/commitdiff/e8f2ceb4a7afbe9a5163135c7f980f64415cbdc4



More information about the pld-cvs-commit mailing list