From Fedora Project Wiki

< SIGs‎ | PHP

SIGs > PHP > Pear .spec File Template

This is the current template that is to be used on all php-pear packages:

%{!?__pear: %{expand: %%global __pear %{_bindir}/pear}}
%define pear_name Foo_Bar

Name:
Version:
Release:        1%{?dist}
Summary:

Group:
License:
URL:            http://pear.php.net/package/Foo_Bar
Source0:        http://pear.php.net/get/%{pear_name}-%{version}.tgz
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildArch:      noarch
BuildRequires:  php-pear >= 1:1.4.9-1.2
Requires:       php-pear(PEAR)
Requires(post): %{__pear}
Requires(postun): %{__pear}
Provides:       php-pear(%{pear_name}) = %{version}

%description


%prep
%setup -q -c
[ -f package2.xml ]  || mv package.xml package2.xml
mv package2.xml %{pear_name}-%{version}/%{pear_name}.xml
cd %{pear_name}-%{version}


%build
cd %{pear_name}-%{version}


%install
cd %{pear_name}-%{version}
rm -rf $RPM_BUILD_ROOT docdir
%{__pear} install --nodeps --packagingroot $RPM_BUILD_ROOT %{pear_name}.xml

mkdir -p docdir
mv $RPM_BUILD_ROOT%{pear_docdir}/* docdir

rm -rf $RPM_BUILD_ROOT%{pear_phpdir}/.??*

mkdir -p $RPM_BUILD_ROOT%{pear_xmldir}
install -pm 644 %{pear_name}.xml $RPM_BUILD_ROOT%{pear_xmldir}


%clean
rm -rf $RPM_BUILD_ROOT


%post
%{__pear} install --nodeps --soft --force --register-only \
%{pear_xmldir}/%{pear_name}.xml >/dev/null || :

%postun
if [ $1 -eq 0 ]  ; then
%{__pear} uninstall --nodeps --ignore-errors --register-only \
%{pear_name} >/dev/null || :
fi


%files
%defattr(-,root,root,-)
%doc %{pear_name}-%{version}/docdir/%{pear_name}/*
%{pear_xmldir}/%{pear_name}.xml
%{pear_testdir}/%{pear_name}
%{pear_datadir}/%{pear_name}
%{pear_phpdir}/*


%changelog