%{!?__pear: %{expand: %%global __pear %{_bindir}/pear}}
%define pear_name Event_Dispatcher
Name: php-pear-Event-Dispatcher
Version: 1.0.0
Release: 2%{?dist}
Summary: Dispatch notifications using PHP callbacks
Group: Development/Libraries
License: BSD
URL: http://pear.php.net/package/Event_Dispatcher
Source0: http://pear.php.net/get/%{pear_name}-%{version}.tgz
Source2: xml2changelog
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
The Event_Dispatcher acts as a notification dispatch table.
It is used to notify other objects of interesting things. This
information is encapsulated in Event_Notification objects. Client
objects register themselves with the Event_Dispatcher as observers of
specific notifications posted by other objects. When an event occurs,
an object posts an appropriate notification to the Event_Dispatcher.
The Event_Dispatcher dispatches a message to each registered
observer, passing the notification as the sole argument.
%prep
%setup -q -c
# Still an old package V1
%{__pear} convert package.xml %{pear_name}-%{version}/%{pear_name}.xml
%{_bindir}/php -n %{SOURCE2} package.xml >CHANGELOG
cd %{pear_name}-%{version}
%build
cd %{pear_name}-%{version}
# Empty build section, most likely nothing required.
%install
cd %{pear_name}-%{version}
rm -rf $RPM_BUILD_ROOT docdir
%{__pear} install --nodeps --packagingroot $RPM_BUILD_ROOT %{pear_name}.xml
# Move documentation
mkdir -p docdir
mv $RPM_BUILD_ROOT%{pear_docdir}/* docdir
# Clean up unnecessary files
rm -rf $RPM_BUILD_ROOT%{pear_phpdir}/.??*
# Install XML package description
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
%check
# For documentation purpose, Need php-pear-PHPUnit-1.3.2
# After install :
# cd /usr/share/pear/test/Event_Dispatcher/tests
# php test.php
# Dispatcher_testCase : Starting test1 ... Test passed
# Dispatcher_testCase : Starting test2 ... Test passed
%files
%defattr(-,root,root,-)
%doc CHANGELOG %{pear_name}-%{version}/docdir/%{pear_name}/*
%{pear_xmldir}/%{pear_name}.xml
%{pear_phpdir}/Event
%{pear_testdir}/%{pear_name}
%changelog
* Thu Aug 21 2008 Remi Collet <Fedora@FamilleCollet.com> 1.0.0-2
- Add missing Requires: php-pear(PEAR)
* Tue Jul 08 2008 Remi Collet <Fedora@FamilleCollet.com> 1.0.0-1
- initial RPM