File php-smarty3.spec of Package php-smarty3

#
# spec file for package php-smarty3
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define php_name %(php -r "print 'php' . PHP_MAJOR_VERSION;")
%define php_major %(php -r "print PHP_MAJOR_VERSION;")

Name:           %{php_name}-smarty3
Version:        3.1.48
Release:        0
Summary:        Template/Presentation Framework for PHP
License:        LGPL-3.0-or-later
Group:          Productivity/Networking/Web/Servers
Url:            http://www.smarty.net
Source0:        https://github.com/smarty-php/smarty/archive/v%{version}.tar.gz#/smarty-%{version}.tar.gz
BuildArch:      noarch
BuildRequires:  php-devel >= 5.3

Requires:       %{php_name} >= 5.3
Requires(post): update-alternatives
Requires(postun): update-alternatives

# When a version is requried explicitly
Provides:       php-smarty3 = %{version}
Obsoletes:      php5-smarty3 <= %{version}
Obsoletes:      php7-smarty3 <= %{version}

# When any Smarty fulfills the requirements
Provides:       %{php_name}-smarty = %{version}
Provides:       php-smarty = %{version}
Obsoletes:      php-smarty <= %{version}

%description
Although Smarty is known as a "Template Engine", it would be more accurately
described as a "Template/Presentation Framework." That is, it provides the
programmer and template designer with a wealth of tools to automate tasks
commonly dealt with at the presentation layer of an application. I stress the
word Framework because Smarty is not a simple tag-replacing template engine.
Although it can be used for such a simple purpose, its focus is on quick and
painless development and deployment of your application, while maintaining
high-performance, scalability, security and future growth.

%package doc
Summary:        Docs for Smarty
Group:          Productivity/Networking/Web/Servers

%description doc
Documentation for Smarty.
Although Smarty is known as a "Template Engine", it would be more accurately
described as a "Template/Presentation Framework." That is, it provides the
programmer and template designer with a wealth of tools to automate tasks
commonly dealt with at the presentation layer of an application. I stress the
word Framework because Smarty is not a simple tag-replacing template engine.
Although it can be used for such a simple purpose, its focus is on quick and
painless development and deployment of your application, while maintaining
high-performance, scalability, security and future growth.

%prep
%setup -qn smarty-%{version}

%build

%install
install -d %{buildroot}%{_datadir}/%{php_name}/Smarty3
cp -a libs/* %{buildroot}%{_datadir}/%{php_name}/Smarty3/

# create a dummy target for /etc/alternatives/Smarty
install -d %{buildroot}%{_sysconfdir}/alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/Smarty
ln -sf %{_sysconfdir}/alternatives/Smarty %{buildroot}%{_datadir}/%{php_name}/Smarty

%post
%{_sbindir}/update-alternatives --install %{_datadir}/%{php_name}/Smarty Smarty %{_datadir}/%{php_name}/Smarty3 3

%postun
if [ "$1" = 0 ]; then
    %{_sbindir}/update-alternatives --remove Smarty %{_datadir}/%{php_name}/Smarty3
fi

%files
%license LICENSE
%dir %{_datadir}/%{php_name}/Smarty3
%{_datadir}/%{php_name}/Smarty3/*
# update-alternatives
%ghost %{_sysconfdir}/alternatives/Smarty
%{_datadir}/%{php_name}/Smarty

%files doc
%doc CHANGELOG.md demo/ README
%doc SMARTY_2_BC_NOTES.txt SMARTY_3.0_BC_NOTES.txt SMARTY_3.1_NOTES.txt

%changelog
openSUSE Build Service is sponsored by