File erp5-zope.spec of Package erp5-zope

%define realVersion 2.7.8-final
%define name        zope
%define release     8

%define version  %(echo %{realVersion} | sed -e's/-/./g')
%define sVersion %(echo %{realVersion} | cut -d- -f1)


Summary:       The patched version of Zope application server for ERP5
Name:          erp5-%{name}
Version:       %{version}
Release:       %{release}
License:       Zope Public License (ZPL)
Group:         System/Servers
URL:           http://www.zope.org
Source0:       http://zope.org/Products/Zope/%{sVersion}/Zope-%{realVersion}.tar.bz2
Source1:       skel.tar.bz2
Source2:       http://www.zope.org/Members/michel/ZB/ZopeBook.tar.bz2
Source3:       README.install.urpmi.zope
Patch0:        Zope-2.7.2-rc1-aq_dynamic.patch.bz2
Requires:      python >= 2.4.2 python-xml
BuildRequires: python-devel >= 2.4.2, expat, python-xml
BuildRoot:     %{_tmppath}/%{name}-%{version}-root-%(id -u -n)
Epoch:         1
Provides:      zope = %{?Epoch:%Epoch-}%{version}


%define python        /usr/bin/python
%define zopehome      /usr/lib/zope
%define softwarehome  %{zopehome}/lib/python
%define instancehome  /var/lib/zope
%define clienthome    %{instancehome}/data
%define statehome     /var/run/zope
%define loghome       /var/log/zope
%define configfile    /etc/zope.conf
%define zopectl       /usr/bin/zopectl
%define runzope       /usr/bin/runzope
%define zopeuser      zope

%description
Zope is an open source application server for building content managements,
intranets, portals, and custom applications. The Zope community consists of
hundreds of companies and thousands of developers all over the world, working
on building the platform and Zope applications. Zope is written in Python, a
highly-productive, object-oriented scripting language.

This version contain a patch from Nexedi about dynamic acquisition in order to
make ERP5 working well.

%prep
%setup -q -n Zope-%{realVersion}

%patch0 -p1

# Add skel
rm -rf skel
tar xvjf %{SOURCE1}
#rm skel/var/log/zope/README.txt skel/var/run/zope/README.txt

# Prepare doc (Zope Book)
tar xjf %{SOURCE2}


%build
mkdir -p build
pushd build
../configure \
  --with-python="%{python}" \
  --prefix="%{buildroot}%{zopehome}" \
  --no-compile
make build
popd

# process the skel directory into the buildroot
python << EOF
import py_compile, os
files = os.popen("find . -name '*.py'").readlines()
for file in files:
    file = file.strip()
    py_compile.compile(file, file+"o", "%{zopehome}/"+file)
    py_compile.compile(file, file+"c", "%{zopehome}/"+file)
EOF

# XXX: next release...
#env CFLAGS="$RPM_OPT_FLAGS" /usr/bin/python setup.py build
#/usr/bin/python setup.py install --root=$RPM_BUILD_ROOT \
#    --record=INSTALLED_FILES

## Clean sources
#find -type d -name "tests" | xargs rm -rf
find lib/python -type f -and \( -name 'Setup' -or -name '.cvsignore' \) \
    -exec rm -f \{\} \;
#find -type f -and \( -name '*.c' -or -name '*.h' -or -name 'Makefile*' \) \
#    -exec rm -f \{\} \;
find -name "Win32" | xargs rm -rf
rm -f ZServer/medusa/monitor_client_win32.py

# Has a bogus #!/usr/local/bin/python1.4 that confuses RPM
rm -f ZServer/medusa/test/asyn_http_bench.py

cp %{SOURCE3} README.install.urpmi

%install
%{python} "utilities/copyzopeskel.py" \
         --sourcedir="skel" \
         --targetdir="%{buildroot}" \
         --replace="INSTANCE_HOME:%{instancehome}" \
         --replace="CLIENT_HOME:%{clienthome}" \
         --replace="STATE_DIR:%{statehome}" \
         --replace="LOG_DIR:%{loghome}" \
         --replace="SOFTWARE_HOME:%{softwarehome}" \
         --replace="ZOPE_HOME:%{zopehome}" \
         --replace="CONFIG_FILE:%{configfile}" \
         --replace="PYTHON:%{python}" \
         --replace="ZOPECTL:%{zopectl}" \
         --replace="RUNZOPE:%{runzope}"

#perl -pi -e "s|data_dir\s+=\s+.*?join\(INSTANCE_HOME, 'var'\)|data_dir=INSTANCE_HOME|" lib/python/Globals.py


pushd build
make install
popd

#rm -rf $RPM_BUILD_ROOT
#install -d $RPM_BUILD_ROOT{%{_bindir},%{_sbindir},%{_libdir}/zope/lib/python} \
#    $RPM_BUILD_ROOT{/etc/rc.d/init.d,/var/log,/var/lib/zope}
#
#cp -a lib/python/* $RPM_BUILD_ROOT%{_libdir}/zope/lib/python
#cp -a ZServer/ utilities/ import/ $RPM_BUILD_ROOT%{_libdir}/zope
#find $RPM_BUILD_ROOT%{_libdir}/zope -type f -name '*.py' -or -name '*.txt' \
#    | xargs -r rm -f
#cp -a ZServer/medusa/test/* $RPM_BUILD_ROOT%{_libdir}/zope/ZServer/medusa/test/
#
#install zpasswd.py $RPM_BUILD_ROOT%{_bindir}/zpasswd
#install z2.py $RPM_BUILD_ROOT%{_libdir}/zope
#install %{SOURCE8} $RPM_BUILD_ROOT%{_sbindir}/zope-zserver
#install %{SOURCE7} $RPM_BUILD_ROOT/etc/rc.d/init.d/zope
#install var/Data.fs $RPM_BUILD_ROOT/var/lib/zope/Data.fs

mkdir -p $RPM_BUILD_ROOT/var/log/zope
touch $RPM_BUILD_ROOT/var/log/zope/event.log
touch $RPM_BUILD_ROOT/var/log/zope/Z2.log


%clean
rm -rf $RPM_BUILD_ROOT

%pre
/usr/sbin/groupadd zope
/usr/sbin/useradd -d /var/lib/zope -s /bin/false zope


%post
#%_post_service zope
/sbin/chkconfig --add zope

# disable this feature : it creates problem during update and
# is confusing for somebody who don't care about installation message
# zope display a how to create an administrative user if it doesn't exit
# README.install.urpmi display the rest of the text

# # write a 10 digit random default admin password into acl_users
# passwd=`head -c4 /dev/urandom | od -tu4 -N4 | sed -ne '1s/.* //p'`
# %{zopectl} adduser admin $passwd
# # inform the user of the default username/password combo and port
# echo
# echo A Zope instance has been installed.  Run it via
# echo \"/etc/rc.d/init.d/zope start\".  Log in via a browser on port 9080.
# echo
# echo Zope has default administrative username/password combination.  The
# echo "administrative username is \"admin\" and the password is \"$passwd\"."
# echo Please remember this so you are able to log in for the first time.
# echo

%preun
#%_preun_service zope
/sbin/chkconfig --add zope


%postun
/usr/sbin/userdel zope
/usr/sbin/groupdel zope

%files
%defattr(0644,root,root,755)
%dir %{zopehome}
%{zopehome}/doc
%{zopehome}/import
%{zopehome}/lib
%{zopehome}/skel

%attr(755,root,root)/usr/bin/runzope
%attr(755,root,root)/usr/bin/zopectl
%attr(755,root,root) %{zopehome}/bin/*
%attr(755,root,root) %config(noreplace) /etc/rc.d/zope
%config(noreplace) /etc/zope.conf
%config(noreplace) /etc/logrotate.d

%attr(770, %{zopeuser}, %{zopeuser}) %config(noreplace) %verify(not md5 size mtime) %{instancehome}
%attr(755, %{zopeuser}, %{zopeuser}) %dir /var/run/zope
%attr(770, %{zopeuser}, %{zopeuser}) %dir /var/log/zope
%ghost /var/log/zope/Z2.log
%ghost /var/log/zope/event.log

%doc README.install.urpmi

#%defattr(644,root,root,755)
#%config(noreplace) %attr(755,root,root) /etc/rc.d/init.d/zope
#%attr(755,root,root) %{_bindir}/*
#%attr(755,root,root) %{_sbindir}/*
#%{_libdir}/zope
#%attr(1771,root,zope) %dir /var/lib/zope
#%attr(660,root,zope) %config(noreplace) %verify(not md5 size mtime) /var/lib/zope/*
##%attr(640,root,root) %ghost /var/log/zope


##############################################################################

%package docs
Summary:    Documentation for the Zope application server
Group:      Networking/WWW

%description docs
Documentation for the Z Object Programming Environment (Zope), a free, Open
Source Python-based application server for building high-performance, dynamic
web sites, using a powerful and simple scripting object model and
high-performance, integrated object database.

%files docs
%defattr(644, root, root, 755)
%doc ZopeBook doc


##############################################################################

%changelog
* Tue Jan 23 2007 Kevin Deldycke <kevin@nexedi.com> 2.7.8-8mdv2007.0
- Generate empty log files

* Mon Jan 22 2007 Kevin Deldycke <kevin@nexedi.com> 2.7.8-7mdv2007.0
- Rebuild for Mandriva 2007.0

* Tue Aug 29 2006 Kevin Deldycke <kevin@nexedi.com> 2.7.8-6nxd
- Compile every python script, not just the one in lib directory.
- Cleanup patch

* Fri Apr 14 2006 Kevin Deldycke <kevin@nexedi.com> 2.7.8-5nxd
- Remove conflict with "python-zope-interface" which was too violent

* Fri Apr 14 2006 Kevin Deldycke <kevin@nexedi.com> 2.7.8-4nxd
- Add "python-zope-interface" as a conflict package
- Required package for build is libpython-devel not python-devel

* Tue Jan 24 2006 Kevin Deldycke <kevin@nexedi.com> 2.7.8-3nxd
- Doc package doesn't requires zope
- Add Epoch tag
- Add "Conflicts: zope"
- Add version to "Provides" statement

* Wed Jan 5 2006 Kevin Deldycke <kevin@nexedi.com> 2.7.8-2nxd
- Rewrite spec file based on the one written by Gaetan Lehmann for the zope-2.7.7 release for Mandriva 2006
- Add 'erp5' prefix to package name
- Add README.install.urpmi.zope
- Remove default admin user

* Fri Oct 28 2005 Yoshinori Okuji <yo@nexedi.com> 2.7.8-1nxd
- New upstream release

* Wed Oct 12 2005 Yoshinori Okuji <yo@nexedi.com> 2.7.7b1-1nxd
- New upstream release

* Sun Apr 24 2005 Yoshinori Okuji <yo@nexedi.com> 2.7.6b2-2nxd
- Rebuild against Python 2.4

* Thu Apr 21 2005 Yoshinori Okuji <yo@nexedi.com> 2.7.6b2-1nxd
- Bump to Zope 2.7.6b2

* Thu Feb 3 2005 Yoshinori Okuji <yo@nexedi.com> 2.7.2rc1-3nxd
- The source tarball was not bzip2'ed even though the suffix was bz2

* Tue Feb 1 2005 Yoshinori Okuji <yo@nexedi.com> 2.7.2rc1-2nxd
- Fix the method bounding in _aq_dynamic

* Mon Aug 2 2004 Yoshinori Okuji <yo@nexedi.com> 2.7.2rc1-1nxd
- Bump to 2.7.2rc1
- Patch Acquistion to support _aq_dynamic

* Sat Feb 07 2004 St�ane Fermigier <sf@nuxeo.com> 2.7.0rc2-1mdk
- Bump to Zope 2.7.0rc2

* Sun Jan 11 2004 St�ane Fermigier <sf@nuxeo.com> 2.7.0b4-1mdk
- Bump to Zope 2.7.0b4

* Sun Sep 14 2003 St�ane Fermigier <sf@nuxeo.com> 2.7.0b2-1pyp
- Update to Zope 2.7.0b2

* Fri Aug 15 2003 St�ane Fermigier <sf@nuxeo.com> 2.7.0b1-3pyp
- Update for Python 2.3

* Sat Aug 9 2003 St�ane Fermigier <sf@nuxeo.com> 2.7.0b1-2pyp
- Added copyright notice
- Compile to .pyc as well as to .pyo

* Sat Jul 26 2003 St�ane Fermigier <sf@nuxeo.com> 2.7.0b1-1mdk
- Update to Zope 2.7.0b1
- Merged stuff from the Zope.org RPM

* Sat May 3 2003 St�ane Fermigier <sf@nuxeo.com> 2.6.1-6mdk
- Moved python stuff from /usr/lib/zope to /usr/lib/zope/lib/python

* Mon Mar 24 2003 St�ane Fermigier <sf@nuxeo.com> 2.6.1-5mdk
- Moved python stuff from /usr/lib/zope to /usr/lib/zope/lib/python

* Tue Feb 25 2003 St�ane Fermigier <sf@nuxeo.com> 2.6.1-4mdk
- changes by Frederic Lepied
- fixed dependency problem between zope-docs and zope
- removed unused directive

* Sun Feb 23 2003 St�ane Fermigier <sf@nuxeo.com> 2.6.1-3mdk
- fix bugs

* Sat Feb 22 2003 St�ane Fermigier <sf@nuxeo.com> 2.6.1-2mdk
- dont ship tests
- separate docs package, including the Zope Book.

* Sat Feb 22 2003 St�ane Fermigier <sf@nuxeo.com> 2.6.1-1mdk
- First release starting from PLD RPM.
openSUSE Build Service is sponsored by