# File: Zope-2.6.2.spec
#
# Zope Corporation Z-Object Programming Environment (ZOPE)
#
#   "Zope is an Open Source application server and portal
#    toolkit used for building high-performance, dynamic Web sites."
#
# An independent 'BuildRoot:' directive is used so that that this package
# can be built in the /var/tmp directory, for the case where the existing
# software on the build host would be disrupted by installing-after-build-
# to-package onto that system.
#
# Sample Package Names:
#   Zope-2.6.2.i386.rpm
#   Zope-zserver-2.6.2.i386.rpm
#
# NOTE to Future ZOPE RPM Maintainers:
#
# Zope is installed to /usr/share/zope/ read only. 
# /var/zope/ is the read-write INSTANCE_HOME
#
####

####
# Section: Preamble (Items Displayed When Users Request Info About Package)
#
# The order of the entries below is unimportant.
#
####

%define PYTHONAPP /usr/bin/python2.1
%define PYTHONDIR python2.1

Name:               Zope
Version:            2.6.2
Release:            1
Copyright:          Zope Public License (ZPL)
Vendor:             Zope Corporation
URL:                http://www.zope.org/
Packager:           Alex Tucker <alex@floop.org.uk>
BuildRoot:          /var/tmp/Zope-%{version}-rootdir
Prereq:             python2.1 python2.1-devel /sbin/chkconfig /usr/sbin/useradd

Source0: http://www.zope.org/Download/Releases/Zope-%{version}/Zope-%{version}-src.tgz
Source1: Zope-%{version}-zope
Source2: Zope-%{version}-RPM-README
Source3: Zope-%{version}-zserver-wo-pcgi.sh

#----------------------------------------------------------------------
Summary:            An application server and portal toolkit for building Web sites.
Group:              Development/Web Applications
Requires:           python2.1 >= 2.1.3
%description
The Z Object Programming Environment (Zope) is a free, Open Source[tm]
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.

For a fully functional installation of Zope, install this single huge
package and then the Zope-zserver RPM

#----------------------------------------------------------------------
%package zserver
Summary:            Initial Object Database/Standalone HTTP Server
Group:              Development/Web Applications
Requires:           Zope
Conflicts:          Zope-pcgi
Provides:		Zope-webserver
Prereq: /etc/init.d 

%description zserver
The Zope-zserver package contains the files needed for setting up a
Zope website, including an empty object database. Zope is an application
server and portal toolkit.

Also included is the ZServer, which is a small, standalone web server
written in Python.  The ZServer uses the very fast Medusa technology
and is multithreaded.  This package comes preconfigured to serve
web pages on port 8080 and ftp access on 8021.  The programmer's port
interface comes disabled for security reasons but can be reenabled.


#----------------------------------------------------------------------

####
# Section: Prep Script (Prepare to Build; Usually Just Unpacking the Sources)
####
%prep
# Create Build Subdirectory and Unpack the Main Tar Ball
%setup -q -n %{name}-%{version}-src

# Reset RPM's Concept of "-n" Back to the Top-Level Package Dir Name
%setup -q -T -D -n %{name}-%{version}-src

####
# Section: Build Script (Actually Perform the Build; Usually Just 'make')
####
%build

  echo Building Zope...

%{PYTHONAPP} wo_pcgi.py

####
# Section: Install-After-Build Script (Often Just 'make install')
####
%install
  rm -rf $RPM_BUILD_ROOT

  # Directory Structure for SOFTWARE_HOME=/usr/share/zope/
  install -m0755 --directory      $RPM_BUILD_ROOT/usr/bin
  install -m0755 --directory      $RPM_BUILD_ROOT/usr/share/zope

  # Directory Structure for INSTANCE_HOME=/var/zope/
  install -m0755 --directory      $RPM_BUILD_ROOT/etc/rc.d/init.d
  install -m0775 --directory      $RPM_BUILD_ROOT/var/zope
  install -m0775 --directory      $RPM_BUILD_ROOT/var/zope/Extensions
  install -m1711 --directory      $RPM_BUILD_ROOT/var/zope/var
  install -m0775 --directory      $RPM_BUILD_ROOT/var/zope/Products
  install -m0775 --directory      $RPM_BUILD_ROOT/var/log

  cp -Rdp *                       $RPM_BUILD_ROOT/usr/share/zope/

  install -m 0755 zpasswd.py      $RPM_BUILD_ROOT/usr/bin/zpasswd
  install -m 0755 zpasswd.py      $RPM_BUILD_ROOT/usr/share/zope/utilities/

  # Establish an Empty Zope Object Database
  install -m 0600 var/Data.fs.in        $RPM_BUILD_ROOT/var/zope/var/Data.fs

  # Create a Safe Preowned Zope Logfile, for ZServer
  # (Otherwise a symlink-redirect attack may be possible!)
  touch $RPM_BUILD_ROOT/var/log/zope

  # Declare the Superuser of the Default Zope Project
  rm $RPM_BUILD_ROOT/usr/share/zope/inituser
  %{PYTHONAPP} $RPM_BUILD_ROOT/usr/bin/zpasswd -u admin -p 123 $RPM_BUILD_ROOT/var/zope/inituser
  chmod 0640 $RPM_BUILD_ROOT/var/zope/inituser

  install -m 0755 %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/zope
  install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT/usr/share/zope/RPM-README  
  install -m 0755 %{SOURCE3} $RPM_BUILD_ROOT/var/zope/zserver_wo_pcgi.sh
  install -m 0755 z2.py      $RPM_BUILD_ROOT/var/zope/z2.py
  
####
# Section: Delivery Install/Uninstall Scripts (Pre/Post Install/Erase Scripts)
####

%pre zserver
  /usr/sbin/useradd -M -r -s /bin/bash -d /var/zope -c "Zope Server" zope >/dev/null 2>&1 || :
  
%post zserver
  /sbin/chkconfig --add zope
  ln -sf /var/zope/zserver_wo_pcgi.sh /var/zope/zserver.sh
  ln -sf /usr/share/zope/import /var/zope/import

%preun zserver
  if [ "$1" = 0 ] ; then
    if [ /var/zope/zserver_wo_pcgi.sh -ef /var/zope/zserver.sh ]; then
      rm /var/zope/zserver.sh
    fi
    if [ /usr/share/zope/import -ef /var/zope/import ]; then
      rm /var/zope/import
    fi
    /etc/rc.d/init.d/zope stop > /dev/null 2>&1
    /sbin/chkconfig --del zope
  fi

%postun zserver
  if [ $1 = 0 ] ; then
	userdel zope >/dev/null 2>&1 || :
  fi
  if [ "$1" -ge "1" ]; then
	/etc/rc.d/init.d/zope condrestart > /dev/null 2>&1
  fi

####
# Section: Verify Script (Check for Proper Installation of Package)
####

%verifyscript zserver
  if [ ! /var/zope/zserver_wo_pcgi.sh -ef /var/zope/zserver.sh ]; then
    echo "/var/zope/zserver_wo_pcgi.sh should be linked to /var/zope/zserver.sh" >&2
  fi

  if [ ! /usr/share/zope/import -ef /var/zope/import ]; then
    echo "/usr/share/zope/import should be linked to /var/zope/import" >&2
  fi

####
# Section: Clean Script (Tidy Up Build Area After a Build Completes)
####
%clean

  rm -rf $RPM_BUILD_ROOT

####
# Section: Files (List of Files w/Attributes Making Up Package)
####

%files
  %defattr(-, root, root)

  %config                             /usr/share/zope
  %config                             /usr/bin/zpasswd

%files zserver
  %defattr(-, root, root)

  %config                             /etc/rc.d/init.d/zope
  %config(noreplace) %attr(640, root, zope)      /var/zope/inituser
  %config                             /var/zope/z2.py
  %config                             /var/zope/zserver_wo_pcgi.sh

  %defattr(-, root, root)
  %dir                                /var/zope/
  %dir                                /var/zope/Products
  %dir                                /var/zope/var/
                                      /var/zope/Extensions/
  %config(noreplace) %verify(not size md5 mtime) /var/zope/var/Data.fs
  %verify(not size md5 mtime)         /var/log/zope

%changelog
* Thu Oct 02 2003 Alex Tucker <alex@floop.org.uk>
- Updated for Zope 2.6.2

* Tue May 27 2003 Alex Tucker <alex@floop.org.uk>
  Changed bogus reference to lpd

* Wed May 21 2003 Alex Tucker <alex@floop.org.uk>
  Updated for Zope 2.6.2b1

* Wed May 07 2003 Alex Tucker <alex@floop.org.uk>
  Tweaked spec file for Zope 2.6.1

* Fri Dec 13 2002 Adam Manock <abmanock@earthlink.net>
  Updated the spec for Zope 2.6.1b1
  The /var/zope tree now owned by root.root with the sticky bit
  set on /var/zope/var to securely allow  zope to write to files after 
  dropping root privs. (see doc/SETUID.txt)
  init.d script completely reworked to handle all functions through the
  single pid file now used in 2.6+	

* Sat May 18 2002 Adam Manock <abmanock@earthlink.net>
  Completely reworked the spec for Zope 2.5.1
  PCGI is no longer built by default.
  Build now simply wraps up the default "wo_pcgi" build, creating 2 packages.
  (This will make it trivial to upgrade the spec for new Zope versions.)
  Logging via syslog is now turned off by default. See the RPM-README

* Wed Nov 14 2001 Jeff Rush <jrush@taupro.com>
  bumped to zope 2.4.3.

* Sat Nov 10 2001 Jeff Rush <jrush@taupro.com>
  changed args to useradd, to work with Red Hat 7.2.

* Sun Oct 21 2001 Jeff Rush <jrush@taupro.com>
  bumped to zope 2.4.2, removed Hotfix 2001-09-28.

* Thu Oct 18 2001 Jeff Rush <jrush@taupro.com>
  Fixed broken syslogging facility and added Hotfix 2001-09-28.

* Mon Sep 04 2001 Jeff Rush <jrush@taupro.com>
  bumped to zope 2.4.1, removed Hotfix 2001-08-04.

* Mon Aug 15 2001 Jeff Rush <jrush@taupro.com>
  bumped to zope 2.4.0, changed to use python2.1, added Hotfix 2001-08-04.

  Merged in Jun 29 2001 patch from Durval Menezes re support for ZPatterns:
  "No longer removes cPersistence.h from lib/python/ZODB before installing
  (this is needed to compile DynPersist, as part of the ZPatterns
  installation.  Installs ExtensionClass.h into /usr/include/python2.1
  (it too is needed to compile DynPersist, as part of the ZPatterns install)"

  Merged in Jun 12 2001 additions from Jared Kelsey <jared@dolphinsearch.com>
  to make more compatible with future releases of python.

* Mon Aug 14 2001 Jeff Rush <jrush@taupro.com>
  bumped to zope 2.3.3, added Hotfix 2001-08-04.

* Mon May 07 2001 Jeff Rush <jrush@taupro.com>
  bumped to zope 2.3.2, added Hotfix 2001-05-01, revised access
  file permissions (600->640) and ownership (root.root->root.zope)
  to fix the "can't log in" bug under ZServer subpackage.

* Sat Mar 31 2001 Jeff Rush <jrush@taupro.com>
  bumped to zope 2.3.1

* Mon Jan 29 2001 Jeff Rush <jrush@taupro.com>
  bumped to zope 2.3.0; removed obsolete Hotfixes.

* Fri Dec 08 2000 Jeff Rush <jrush@taupro.com>
  bumped to zope 2.2.4; removed obsolete Hotfixes.

* Fri Nov 03 2000 Jeff Rush <jrush@taupro.com>
  fixed misplaced SiteAccess, where dirs in tar moved btw v1 and v2.

* Sun Oct 16 2000 Jeff Rush <jrush@taupro.com>
  bumped to zope 2.2.2; added Hotfixes  2000-10-02 and 2000-10-11.

* Sun Aug 27 2000 Jeff Rush <jrush@taupro.com>
  bumped to zope 2.2.1; removed no-longer-needed Hotfix_2000-08-17

* Tue Aug 22 2000 Jeff Rush <jrush@taupro.com>
- added Hotfix_2000-08-17
- temporarily removed /etc/init.d (RH7.0) until I figure out how
  to support both RH6.x *and* RH7.0 in the same RPM. <sigh>
- removed troublesome/obsolete ComputedAttribute.py

* Sun Jul 16 2000 Jeff Rush <jrush@taupro.com>
- bumped to zope 2.2.0; removed no-longer-needed Hotfix-06_16_2000

* Thu Jul 06 2000 Tim Powers <timp@redhat.com>
- fixed PreReq to PreReq /etc/init.d
- added Hotfix-06_16_2000
 
* Thu Jun 15 2000 Preston Brown <pbrown@redhat.com>
- moved init script, added condrestart directive
- auto stop/restart service on upgrades

* Thu Jun 1 2000 Tim Powers <timp@redhat.com>
- fixed so that it's no longer putting files into /home, instead they are
  going into /var/www (FHS compliant).

* Mon May 22 2000 Tim Powers <timp@redhat.com>
- built for 7.0, thanks Jeff!

* Fri Apr 28 2000 Jeff Rush <jrush@taupro.com>
- bumped to zope 2.1.6

* Sun Mar 12 2000 Jeff Rush <jrush@taupro.com>
- added zpasswd.py back in, since my rename to just zpasswd confused some.
  both are now present in the RPM, for all audiences.
- modified the README.RPM re the section about Apache rewrite rules; I
  discussed and removed the trailing slash, the presence of which causes
  Zope to reject attempts to delete objects in the root folder.

* Thu Feb 26 2000 Jeff Rush <jrush@taupro.com>
- 2.1.4-1 Release on Zope.org site
- bumped to zope 2.1.4
- changed Zope-core to provide 'Zope', to satisfy zserver and pcgi subpkgs.

* Fri Jan 14 2000 Tim Powers <timp@redhat.com>
- added Provides lines to Zope-pcgi and Zope-zserver so that addon packages
	such as Squishdot have something useful to require.

* Thu Jan 13 2000 Tim Powers <timp@redhat.com>
- built for Powertools 6.2

* Thu Jan 11 2000 Jeff Rush <jrush@taupro.com>
- bumped to zope 2.1.2
- folded in Jonathan Marsden <jonathan@xc.org> Changes (many below)
- used zpasswd.py to generate initial pw in encrypted form.
- fixed syslog logging in various ways, and re-enabled it, for both
-    ZServer AND pcgi-wrapper.
- fixed /etc/rc.d/init.d/zope to be consistent about pid file.
- fixed /etc/rc.d/init.d/zope to use RH killproc function.
- added 'noreplace' so that Zope database and access file are retained
-    on an RPM upgrade.
- patched PCGI to support syslog logging, and then default to it.
- patched ZServer/Medusa to properly support syslog logging.
- added a user 'zope' and made many zope files/dirs owned by it.
- cleaned up pcgi-wrapper's msg about can't find ZServer, since it is
-    one of the most common errors.  It now explains what it is doing.
- moved all *.{pid,soc} files into /var/run, to cleanly separate ownership
-    issues in /var/zope hierarchy for user 'zope' and user 'nobody'.

* Mon Jan 03 2000 Jeff Rush <jrush@taupro.com>
- bumped to zope 2.1.1
- added to /etc/rc.d/init.d/zope code to correctly kill the process specified
-    in /var/zope/pcgi.pid
- changed permissions on /var/zope/access such that only root can read/write
-    it, to protect the Zope superuser password.

* Sat Nov 29 1999 Jeff Rush <jrush@taupro.com>
- changed ownership on /var/zope/access from nobody.nobody to root.root.

* Sat Nov 20 1999 Jeff Rush <jrush@taupro.com>
- updated to zope 2.1.0beta2
- fixed permissions/ownership on /var/zope/access to be more secure (600).
- removed pypath.patch, as those changes got into the zope distribution.

* Tue Nov 2 1999 Jeff Rush <jrush@taupro.com>
- added accidentally omitted /usr/bin/zpasswd to the RPM output.
- clarified wording re use of zpasswd in README.RPM file.
- added "-u nobody" to both zserver_*.sh files, for clarity of intent;
-    it already ran as nobody by default, but some people worried.

* Wed Oct 27 1999 Jeff Rush <jrush@taupro.com>
- fixed /etc/rc.d/init.d/zope file to *NOT* delete /var/zope/zserver.pid
- fixed /var/zope/Zope.cgi to use PCGI_PUBLISHER=/var/zope/pcgi_nullpublisher.py,
-    so that when the PCGI wrapper can't find ZServer, it won't try to start one
-    and generate bogus error messages, because PCGI doesn't do it right.
- fixed /var/zope/zserver.sh to NOT specify syslog-style logging, since under
-    Red Hat 6.1, the syslog daemon no longer listens to the port we expected.

* Sat Sep 25 1999 Jeff Rush <jrush@taupro.com>
- updated documents ZCMG, ZSQL and ZDTML to Sep 24th 1999 versions
- added empty directories /var/zope/{import,Extensions}
- relocated zope from /usr/lib/python1.5/site-packages/ZopeWorld/
-    to /usr/share/zope/
- added user zope, for better security control

* Fri Sep 17 1999 Jeff Rush <jrush@taupro.com>
- updated sources to minor (security fix) release 2.0.1

* Fri Sep 10 1999 Jeff Rush <jrush@taupro.com>
- heavily reworked spec file for 2.0.0

* Thu Sep 9 1999 Tim Powers <timp@redhat.com>
- updated sources to 2.0.0
- _major_ spec file cleanups
- merged patch from src.rpm authored by Andreas Kostyrka <andreas@mtg.co.at>
- borrowed some things from Andreas Kostyrka's spec file

* Mon Aug 30 1999 Tim Powers <timp@redhat.com>
- changed groups

* Tue Aug 17 1999 Tim Powers <timp@redhat.com>
- chown permissions on some files in /var/local for the pcgi package

* Mon Aug 2 1999 Tim Powers <timp@redhat.com>
- changed buildroot to be in /var/tmp instead of /tmp
- rebuilt for 6.1

* Mon Jul 21 1999 Jeff Rush <jrush@taupro.com>
- Added in accidently omitted SearchIndex/{Query,Splitter}.so

* Tue Jul 6 1999 Tim Powers <timp@redhat.com>
- started changelog
- cleaned up spec file
- built for powertools

* Mon Jun 24 1999 Jeff Rush <jrush@taupro.com>
- Updated to 1.10.3

* Mon Jun 23 1999 Jeff Rush <jrush@taupro.com>
- Added /etc/rc.d/init.d/zope and reworked scripts

* Tue Mar 1 1999 Jeff Rush <jrush@taupro.com>
- Updated to 1.10.2

* Wed Jan 29 1999 Jeff Rush <jrush@taupro.com>
- Updated to 1.9.0 Final Release

* Wed Dec 9 1998 Jeff Rush <jrush@taupro.com>
- Original 1.9beta1 Release
