Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > by-pkgid > 9d0a0446b20f562959ddd13ae45be2ce > files > 1

php-pgsql-4.1.2-1mdk.src.rpm

%define phpversion 4.1.2
%define phprelease 1mdk
%define phpdir %{_libdir}/php 
%define phpsource /usr/src/php-devel
%define release 1mdk

Summary:	PostgreSQL module for PHP4
Name:		php-pgsql
Version:	%{phpversion}
Release:	%{release}	
Group:		System/Servers
License:	PHP License
URL:		http://www.php.net
BuildRoot:	%{_tmppath}/%{name}-root
Prereq:		php-common = %{phpversion}, perl
Requires:	php postgresql >= 7.1.3
BuildRequires:  php-devel = %{phpversion}
BuildRequires:	postgresql-devel >= 7.1.3
Provides:	mod_php3-pgsql, mod_php-pgsql
Obsoletes:	mod_php3-pgsql, mod_php-pgsql

%description
The php-pgsql package includes a dynamic shared object (DSO) that adds
PostgreSQL database support to PHP4.  PostgreSQL is an object-relational
database management system that supports almost all SQL constructs. PHP is
an HTML-embedded scripting language. If you need back-end support for
PostgreSQL, you should install this package in addition to the main php
package.

%build
[ -e ./pgsql ] && rm -fr ./pgsql
cp -dpR %{phpsource}/extensions/pgsql .
cd pgsql

%{phpsource}/buildext pgsql pgsql.c "-lpq" \
        "-DHAVE_PQCMDTUPLES -DCOMPILE_DL_PGSQL -DHAVE_PGSQL"

%install
cd pgsql
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT 
mkdir -p $RPM_BUILD_ROOT%{phpdir}/extensions

install -m 755 -s pgsql.so $RPM_BUILD_ROOT%{phpdir}/extensions/

mkdir -p $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
echo > $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}/README <<EOF
The php-pgsql package contains a dynamic shared object (DSO) for PHP4. 
To activate it, make sure the line 'extension=pgsql.so' is uncommented
in your /etc/php.ini file.
EOF

%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
[ -e ./pgsql ] && rm -fr ./pgsql

%post
if [ $1 = "1" ]; then
  if [ -f %{_sysconfdir}/php.ini ]; then
    perl -pi -e 's|^;extension\s*=\s*pgsql.so|extension = pgsql.so|' %{_sysconfdir}/php.ini
  fi
  if [ -e /var/lib/pgsql/data/postmaster.pid ]; then
    echo "Adding user 'apache' in postgresql"
    su -l postgres -c 'createuser -a -d apache' 1>/dev/null 2>/dev/null
  else 
    echo "Don't forget to add the 'apache' user in Postgresql: run"
    echo "su -l postgres -c 'createuser -a -d apache'"
  fi	
fi
if [ $1 -gt 1 ]; then
   #We're in *upgrade mode*. Since we can't be sure the configuration files
   #are sane, remove module from the conf files to clean them, re-add again
   #in a way that the older module we're replacing won't try to erase (the
   #post scripts were broken on some packages)
   #Also, there could be extra lines, so make sure we uncomment one
   #Finally, don't check for presence of php.ini, if it's not there,
   #we have a problem, so it should generate an error message.
   perl -pi -e 's|^extension\s*=\s*pgsql.so|;extension = pgsql.so|g' %{_sysconfdir}/php.ini
   perl -pi -e 's|^;extension\s*=\s*pgsql.so|extension = pgsql.so|' %{_sysconfdir}/php.ini
fi
if [ -e %{_sbindir}/AESctl ]; then %{_sbindir}/AESctl reload;fi 

%preun
if [ $1 = "0" ]; then
  if [ -f %{_sysconfdir}/php.ini ]; then
    perl -pi -e 's|^extension\s*=\s*pgsql.so|;extension = pgsql.so|g' %{_sysconfdir}/php.ini
  fi
  if [ -e %{_sbindir}/AESctl ]; then %{_sbindir}/AESctl reload;fi 
fi

%files 
%defattr(-,root,root)
%{phpdir}/extensions/pgsql.so
%dir %{_docdir}/%{name}-%{version}
%{_docdir}/%{name}-%{version}/README

%changelog
* Mon Mar 04 2002 Jean-Michel Dault <jmdault@mandrakesoft.com> 4.1.2-1mdk
- PHP 4.1.2

* Mon Jan 07 2002 Christian Belisle <cbelisle@mandrakesoft.com> 4.1.1-1mdk
- PHP 4.1.1.

* Tue Dec 11 2001 Christian Belisle <cbelisle@mandrakesoft.com> 4.1.0-1mdk
- PHP 4.1.0.

* Thu Nov 15 2001 Christian Belisle <cbelisle@mandrakesoft.com> 4.0.6-4mdk
- Fix no-url and invalid-packager warnings in rpmlint
- Update postgresql version to 7.1.3.

* Mon Sep 10 2001 Christian Belisle <cbelisle@mandrakesoft.com> 4.0.6-3mdk
- Provides the Obsoletes (made a mistake in 2mdk).

* Mon Sep 10 2001 Christian Belisle <cbelisle@mandrakesoft.com> 4.0.6-2mdk
- Provides the Obsoletes for compatibility.

* Wed Jul  4 2001 Vincent Danen <vdanen@mandrakesoft.com> 4.0.6-1mdk
- 4.0.6
- s/Copyright/License/

* Thu Apr 12 2001 Jean-Michel Dault <jmdault@mandrakesoft.com> 4.0.4pl1-6mdk
- fix requires

* Mon Apr  9 2001 Jean-Michel Dault <jmdault@mandrakesoft.com> 4.0.4pl1-5mdk
- fix post scripts for good 

* Mon Apr  2 2001 Jean-Michel Dault <jmdault@mandrakesoft.com> 4.0.4pl1-4mdk
- Split pgsql package from php package so that when a new pgsql 
  package comes out, we don't have to recompile php, only this module