[Zope-CVS] CVS: Products/OSCOM - buildout_zope_sandbox:1.1

Tres Seaver tseaver@zope.com
Wed, 7 May 2003 00:22:48 -0400


Update of /cvs-repository/Products/OSCOM
In directory cvs.zope.org:/tmp/cvs-serv5813/OSCOM

Added Files:
	buildout_zope_sandbox 
Log Message:
 - Buildout script for OSCOM sandboxen.

=== Added File Products/OSCOM/buildout_zope_sandbox ===
#!/bin/sh
#==============================================================================
#   OSCOM 2003: Zope CMS Interoperability Workshop
#
#   Build out a working Zope sandbox from sources.
#
#   - Python and PyXML build from tarballs, because SourceForge won't
#     do :pserver: CVS reliably.
#
#   - Zope, CMF, and other products build from CVS checkouts.
#
#   Usage:
#
#    Run this script from within an empty "sandbox" directory.
#
#      $ mkdir /tmp/OSCOM
#      $ cd /tmp/OSCOM
#      $ /tmp/build_sandbox
#
#   Theory of Operation
#
#     This script creates all the software needed to start a Zope application
#     server (with the corresponding ZEO storage server);  in particular,
#     it *builds its own Python*, to avoid clashing with the system version,
#     and to ease installation of packages which Zope depends on.
#
#     It creates the following top-level directories:
#
#     'src' -- "pristine" sources (from tarballs / CVS checkouts), in
#              "version-qualified" directories
#
#     'opt' -- "built" sources (compilation artifacts go here) are in
#              "version-qualified" directories.  The versions in actual
#               use are symlinked to "standard" names (e.g., 'opt/Python2'
#               is symlinked to 'opt/Python-2.1.3').
#
#     'bin' -- aexecutables are linked here from the 'opt' tree.
#
#     'etc' -- configuration files for the appserver / storage server.
#
#     'var' -- log, data, and pid files for running servers.  The Zope
#              INSTANCE_HOME is in 'var/zope'.
#
#     'tmp' -- fetch directory for tarballs.
#==============================================================================

#------------------------------------------------------------------------------
#   Version / repository selectors
#------------------------------------------------------------------------------
ZOPE_CVSROOT=:pserver:anonymous@cvs.zope.org:/cvs-repository

PYTHON_VERSION=2.1.3            # XXX 2.2.3?
PYTHON_ORG=http://www.python.org/ftp/python
PYTHON_SOURCE_URL=$PYTHON_ORG/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz

ZODB3_VERSION=3.1.1              # XXX 3.1.2?
ZODB3_MODULE=ZODB3
ZODB3_TAG=ZODB3-3-1-1-final

ZOPE_VERSION=2.6.1              # XXX 2.6.2, 2.7?
ZOPE_MODULE=Zope
ZOPE_TAG=Zope-2-6-1-src

CMF_VERSION=1.3.1               # XXX 1.4?
CMF_MODULE=CMF
CMF_TAG=CMF-1_3_1-release

DCWORKFLOW_VERSION=0.5          # XXX not needed for CMF >= 1.4
DCWORKFLOW_MODULE=CMF/DCWorkflow
DCWORKFLOW_TAG=DCWorkflow-0_5

DBTAB_VERSION=1.2
DBTAB_MODULE=Products/DBTab
DBTAB_TAG=DBTab-1_2

PYXML_VERSION=0.8.1             # 0.8.2?
PYXML_SF_DOWNLOAD=http://aleron.dl.sourceforge.net/sourceforge/pyxml
PYXML_URL=$PYXML_SF_DOWNLOAD/PyXML-$PYXML_VERSION.tar.gz

#------------------------------------------------------------------------------
#   Build top-level sandbox dirs
#------------------------------------------------------------------------------
sandbox=`pwd`               # XXX
srcdir=$sandbox/src
optdir=$sandbox/opt
bindir=$sandbox/bin
vardir=$sandbox/var
etcdir=$sandbox/etc
tmpdir=$sandbox/tmp

mkdir -p $srcdir
mkdir -p $optdir
mkdir -p $bindir
mkdir -p $vardir
mkdir -p $etcdir
mkdir -p $tmpdir

#------------------------------------------------------------------------------
#   Build Python
#------------------------------------------------------------------------------
cd $tmpdir
wget --continue $PYTHON_SOURCE_URL
cd $srcdir
tar xzf $tmpdir/Python-$PYTHON_VERSION.tgz
cd $optdir
mkdir -p Python-$PYTHON_VERSION/build
cd Python-$PYTHON_VERSION/build
$srcdir/Python-$PYTHON_VERSION/configure \
    --with-threads --prefix=$sandbox
#    --with-threads --prefix=$optdir/Python-$PYTHON_VERSION
make
make install
cd $optdir
ln -s Python-$PYTHON_VERSION Python2
#cd $bindir
#ln -s $optdir/Python2/bin/python .

#------------------------------------------------------------------------------
#   Install ZODB
#------------------------------------------------------------------------------
cd $srcdir
cvs -d $ZOPE_CVSROOT co -d ZODB3-$ZODB3_VERSION -r $ZODB3_TAG $ZODB3_MODULE
cd $optdir
cp -rs $srcdir/ZODB3-$ZODB3_VERSION .
ln -s ZODB3-$ZODB3_VERSION ZODB3
cd ZODB3
$bindir/python setup.py install

#------------------------------------------------------------------------------
#   Install PyXML
#------------------------------------------------------------------------------
cd $tmpdir
wget --continue $PYXML_URL
cd $srcdir
tar xzf $tmpdir/PyXML-$PYXML_VERSION.tar.gz
cd $srcdir/PyXML-$PYXML_VERSION
#
#   Work around a bug with Unicode DTD URLs.
#
patch xml/sax/xmlreader.py << PYXML_081_PATCH_EOF
@@ -221,7 +221,7 @@
 
     def getSystemId(self):
         "Returns the system identifier of this InputSource."
-        return self.__system_id
+        return str(self.__system_id)
 
     def setEncoding(self, encoding):
         """Sets the character encoding of this InputSource.
PYXML_081_PATCH_EOF
cd $optdir
cp -rs $srcdir/PyXML-$PYXML_VERSION .
ln -s PyXML-$PYXML_VERSION PyXML
cd PyXML
$bindir/python setup.py install

#------------------------------------------------------------------------------
#   Build Zope SOFTWARE_HOME
#------------------------------------------------------------------------------
cd $srcdir
cvs -d $ZOPE_CVSROOT co -d Zope-$ZOPE_VERSION -r $ZOPE_TAG $ZOPE_MODULE
cd $optdir
cp -rs $srcdir/Zope-$ZOPE_VERSION .
ln -s Zope-$ZOPE_VERSION Zope
cd Zope-$ZOPE_VERSION
$bindir/python wo_pcgi.py
rm inituser
#
#   Remove stuff we get from ZODB installed in site-packages.
#
echo Removing duplicated ZODB modules and packages.
for pkg in 'BTrees' 'Persistence' 'ThreadedAsync' 'zdaemon' 'zLOG' \
           'ZODB' 'ZopeUndo';
do
    rm -r lib/python/$pkg
done
for ext in 'Acquisition' 'ComputedAttribute' 'ExtensionClass' 'MethodObject' \
             'Missing' 'MultiMapping' 'Record' 'Sync' 'ThreadLock';
do
    rm lib/python/$ext.so
done

#------------------------------------------------------------------------------
#   Fetch products.
#------------------------------------------------------------------------------
cd $srcdir
cvs -d $ZOPE_CVSROOT co -d CMF-$CMF_VERSION -r $CMF_TAG $CMF_MODULE
cd $optdir
cp -rs $srcdir/CMF-$CMF_VERSION .
ln -s CMF-$CMF_VERSION CMF

cd $srcdir
cvs -d $ZOPE_CVSROOT co -d DCWorkflow-$DCWORKFLOW_VERSION \
                        -r $DCWORKFLOW_TAG $DCWORKFLOW_MODULE
cd $optdir
cp -rs $srcdir/DCWorkflow-$DCWORKFLOW_VERSION .
ln -s DCWorkflow-$DCWORKFLOW_VERSION DCWorkflow

cd $srcdir
cvs -d $ZOPE_CVSROOT co -d DBTab-$DBTAB_VERSION -r $DBTAB_TAG $DBTAB_MODULE
cd $optdir
cp -rs $srcdir/DBTab-$DBTAB_VERSION .
ln -s DBTab-$DBTAB_VERSION DBTab

#------------------------------------------------------------------------------
#   Build ZEO INSTANCE_HOME
#------------------------------------------------------------------------------
cd $vardir
mkdir -p storage/var

#------------------------------------------------------------------------------
#   Build Zope INSTANCE_HOME
#------------------------------------------------------------------------------
cd $vardir
mkdir -p zope/var zope/Products zope/import zope/Extensions
echo Creating initial "manager" account.
$bindir/python $optdir/Zope/zpasswd.py $vardir/zope/inituser

#------------------------------------------------------------------------------
#   Install products
#------------------------------------------------------------------------------
cd $vardir/zope/Products
ln -s $optdir/CMF/CMFCore .
ln -s $optdir/CMF/CMFDefault .
ln -s $optdir/CMF/CMFTopic .
ln -s $optdir/CMF/CMFCalendar .
ln -s $optdir/DCWorkflow .
ln -s $optdir/DBTab .

#------------------------------------------------------------------------------
#   Set up DBTab
#------------------------------------------------------------------------------
cd $vardir/zope
ln -s Products/DBTab/custom_zodb.py .
cat > $etcdir/dbtab.conf << DBTAB_CONF_EOF
[Storage: Main]
type=ClientStorage
addr=zeo://localhost:8001
storage=1
wait=1
cache_size=20000000

[Database: Main]
cache_size=4000
mount_paths=/
open_at_startup=True
DBTAB_CONF_EOF
ln -s $etcdir/dbtab.conf .

#------------------------------------------------------------------------------
#   Set up start / stop scripts
#------------------------------------------------------------------------------
cd $bindir

sed -e "s#<<SANDBOX>>#$sandbox#" > start_zeo << START_ZEO_EOF
#!/bin/sh
#------------------------------------------------------------------------------
#   Start ZEO storage server
#------------------------------------------------------------------------------
zeo_port=8001
python=<<SANDBOX>>/bin/python
zeo_start=<<SANDBOX>>/lib/python2.1/site-packages/ZEO/start.py

INSTANCE_HOME=<<SANDBOX>>/var/storage
export INSTANCE_HOME

echo \$python \$zeo_start -p \$zeo_port "\$@"
\$python \$zeo_start -p \$zeo_port "\$@"
START_ZEO_EOF
chmod +x start_zeo

sed -e "s#<<SANDBOX>>#$sandbox#" > stop_zeo << STOP_ZEO_EOF
#!/bin/sh
#------------------------------------------------------------------------------
#   Stop ZEO storage server
#------------------------------------------------------------------------------
pid=\`cat <<SANDBOX>>/var/storage/var/ZEO_SERVER.pid\`

echo kill "\$@" \$pid
kill "\$@" \$pid
STOP_ZEO_EOF
chmod +x stop_zeo

sed -e "s#<<SANDBOX>>#$sandbox#" > start_zope << START_ZOPE_EOF
#!/bin/sh
#------------------------------------------------------------------------------
#   Start Zope application storage server
#------------------------------------------------------------------------------
www_port=8080
python=<<SANDBOX>>/bin/python
zope_home=<<SANDBOX>>/opt/Zope
zope_start=\$zope_home/z2.py

INSTANCE_HOME=<<SANDBOX>>/var/zope
SOFTWARE_HOME=\$zope_home/lib/python
PYTHONPATH=\$SOFTWARE_HOME:\$PYTHONPATH
export INSTANCE_HOME SOFTWARE_HOME PYTHONPATH

echo \$python \$zope_start -X -w \$www_port "\$@"
\$python \$zope_start -X -w \$www_port "\$@"
START_ZOPE_EOF
chmod +x start_zope

sed -e "s#<<SANDBOX>>#$sandbox#" > stop_zope << STOP_ZOPE_EOF
#!/bin/sh
#------------------------------------------------------------------------------
#   Stop Zope application server
#------------------------------------------------------------------------------
pid=\`cat <<SANDBOX>>/var/zope/var/Z2.pid\`

echo kill "\$@" \$pid
kill "\$@" \$pid
STOP_ZOPE_EOF
chmod +x stop_zope

#------------------------------------------------------------------------------
#   Start the storage and the appserver
#------------------------------------------------------------------------------
cd $sandbox

$bindir/start_zeo
$bindir/start_zope