Commit e352bcc5 authored by Christian Theune's avatar Christian Theune

Added WinBuilder flavour for Zope 2.8

parent da426df2
Manifest and description of included files
|-- Makefile.python: the Makefile used to create a Python binary from source
|-- Makefile.zeo: the Makefile used to create a ZEO installer package
|-- Makefile.zope: the Makefile used to create a Zope installer package
|-- README.txt
|-- bin
| |-- compilezpy.py: compiles a tree of Python scripts into .pyc bytecode
| |-- decompilezpy.py: deletes a tree full of .pyc bytecode files
| |-- escape.sh: utility script that converts backslashes between unix & win
| |-- fixreg.py: utility to manage Zope Corporation Win registry entries
| |-- makezope.bat: utility script to build Zope, getting around NMAKE "bug"
| `-- runzeo.bat: script which starts a ZEO instance
|-- buildout: the main script used to build Zope and/or ZEO installers
|-- doc
| `-- ZC_PY_DIST_README.txt: readme for the Zope Corp. Python distro
|-- etc
| |-- README.html: custom template used for Zope Quick Start page.
| |-- sitecustomize.py: adds Zope dirs to sys.path automagically in distro
| |-- zeo.iss.in: the Innosetup file to create a ZEO installer
| |-- zlogo_left.bmp: used by Innosetup
| |-- zlogo_top.bmp: used by Innosetup
| `-- zope.iss.in: the Innosetup file to create a Zope installer
|-- mk
| |-- common.mk: common make routines
| |-- python.mk: routines for creating a Python distro
| |-- zeo.mk: routines for creating a ZEO server distro
| `-- zope.mk: routines for creating a Zope distro
`-- zeo_addons: a custom INSTANCE_HOME for ZEO
|-- skel
| |-- README.txt
| |-- bin
| | |-- runzeo.bat.in
| | `-- zeoservice.py.in
| |-- etc
| | |-- zeo.conf.in
| | `-- zeoctl.conf.in
| |-- log
| | `-- README.txt
| `-- var
| `-- README.txt
`-- utilities
|-- compilezpy.py
|-- copyskel.py
|-- decompilezpy.py
`-- mkzeoinstance.py
# Zope/ZEO build and install Makefile for Python (gnumake-style).
# Puts binaries into build/bin
# See README.txt for system requirements.
# See python.mk for the input files required in tmp/.
# do "make -f <makefile_name> build"
# then "make -f <makefile_name" install
default: install
build: build_python
unbuild:
$(RMRF) "$(BUILD_DIR)"
install: build install_python
# XXX test_python doesn't exist: there's not enough stuff in the
# build/ directory to run the Python tests successfully.
test: test_python
clean: clean_python clean_libs unbuild
clobber: clean
$(RMRF) src
include mk/common.mk
include mk/python.mk
# Justs repackages the Spread binaries.
# Puts binaries into build/bin.
# See README.txt for system requirements.
# See spread.mk for the input files required in tmp/.
default: install_spread
build: build_spread
install: install_spread
include mk/common.mk
include mk/spread.mk
# Zope2 build and install Makefile for win32 (gnumake-style).
# Creates an installable executable for the Python Spread wrapper module.
# See README.txt for system requirements.
# See spreadwrapper.mk for the input files required in tmp/.
default: install
build: build_spreadwrapper
install: install_spreadwrapper
include mk/common.mk
include mk/spreadwrapper.mk
# Zope2 build and install Makefile for win32 (gnumake-style).
# Creates an installable executable of ZEO/ZODB3.
# Use a Win2k/XP machine with Cygwin, VC++, and InnoSetup4
# Install Inno Setup 4 into Program Files\Inno Setup 4
# also obtain and situate the following supporting files before
# attempting to run the makefile:
#
# obtain the source distribution of ZODB 3.X.X and put the tar.gz file
# in tmp\ZODB3-3.2.tar.gz
# see python.mk for files needed to build Python
# To produce the executable:
# do "make -f <makefile_name> build"
# then "make -f <makefile_name" install
# The resulting executable will show up in the "build" subdirectory
# as "ZEO-3.X.X-win32.exe".
# include common subroutines
default: install
build: build_python
unbuild:
$(RMRF) "$(BUILD_DIR)"
install: build install_python install_zeo
test: test_python test_zeo
clean: clean_python clean_zeo clean_libs unbuild
clobber: clean
$(RMRF) src
include mk/common.mk
include mk/python.mk
include mk/zeo.mk
# Zope2 build and install Makefile for win32 (gnumake-style).
# Creates an installable executable of Zope 2.
# Use a Win2k/XP machine with Cygwin, VC++, and InnoSetup4
# Install Inno Setup 4 into Program Files\Inno Setup 4
# also obtain and situate the following supporting files before
# attempting to run the makefile:
#
# obtain the source distribution of Zope 2.7.X and put the tar.gz file
# in tmp\Zope-2.7.X.tar.gz
# see python.mk for files needed to build Python
# To produce the executable:
# do "make -f <makefile_name> build"
# then "make -f <makefile_name" install
# The resulting executable will show up in the "build" subdirectory
# as "Zope-2.X.X-X-win32.exe".
# include common subroutines
default: install
build: build_python
unbuild:
$(RMRF) "$(BUILD_DIR)"
install: build install_python install_zope
test: test_python test_zope
clean: clean_python clean_zope clean_libs unbuild
clobber: clean
$(RMRF) src
include mk/common.mk
include mk/python.mk
include mk/zope.mk
Quick instructions:
The installers have only been tested under Windows 2K, but should work
without incident on XP. It "almost works" on Win98SE (see bottom of
file for discussion).
Install Cygwin from cygwin.org (the default installation should give
you everything you need).
Install Microsoft Visual C++ 6.0.
Install InnoSetup 4.0 from www.jrsofware.org (into its default location).
4.0.4-beta seems to work, while 4.0.7 does not. Symptom: type error
on compilation. 4.0.11 appears to work.
Unpack this package into a directory.
Launch a Cygwin bash shell. If necessary, run the VCVARS.bat to set up
the VC++ environment. This shouldn't be necessary on Win2K, provided
you've brought up the GUI at least once (MSDev doesn't finish writing
all the registry keys it should until the GUI is first launched). See
below for Win98SE.
If you're building Zope against Python 2.3.X, you may need to add some
registry entries due to a bug in the distutils msvccompiler.py:
[HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Build System\Components\Platforms\Win32 (x86)\Directories]
"path dirs"="c:\\windows\\system32;c:\\Program Files\\Microsoft Visual Studio\\Common\\Tools\\WinNT; c:\\Program Files\\Microsoft Visual Studio\\Common\\MSDev98\\Bin;c:\\Program Files\\Microsoft Visual Studio\\Common\\Tools;c:\\Program Files\\Microsoft Visual Studio\\VC98\\bin"
"library dirs"="C:\\Program Files\\Microsoft Visual Studio\\VC98\\mfc\\lib;C:\\Program Files\\Microsoft Visual Studio\\VC98\\lib"
"include dirs"="C:\\Program Files\\Microsoft Visual Studio\\VC98\\atl\\include;C:\\Program Files\\Microsoft Visual Studio\\VC98\\mfc\\include;C:\\Program Files\\Microsoft Visual Studio\\VC98\\include"
This is unecessary if building against Python 2.2.X. [Tim didn't find
this necessary building against Python 2.3.3 and Christian against 2.3.4 either.]
From the parent directory of the package, make a "tmp" directory.
Get necessary source packages and place them in the tmp directory. At the time
of this writing, this includes:
- Python-2.3.4.tgz
- Python-2.3.4.exe (used for binary modules)
- win32all-163.exe
- Zope.tgz
As time marches on, these version numbers will obviously change.
If you see any make errors with references to one of these files, it's because
you've not downloaded them or you've not placed them in 'tmp'.
From the parent directory of the package, type WinBuilders/buildout <type>
where type is one of "python", "zope", or "zeo".
For python, the buildout populates the "build" directory with a Python
laid out for Zope and/or ZEO.
For 'zope', the buildout populates the "build" directory with a Windows
executable installer (read the Makfile.zope for special instructions).
For 'zeo', the buildout populates the "build" directory with a Windows
executable installer (read the Makefile.zeo for special instructions).
Win98SE notes
-------------
- You have to run vcvars32.bat to set up envars for MSVC 6. Running that
from a bash shell doesn't have any effect on the Cygwin PATH.
This works:
+ Open a native DOS box.
+ Run vcvars32.bat.
+ Start a bash shell from the same box (== run cygwin.bat, found in the
root of your Cygwin installation -- the same thing the Cygwin shell
desktop shortcut resolves to, so you can get the exact path by looking
at the icon's Properties).
- Every time a makefile runs xcopy, there's a segfault in kernel32.dll,
which hangs the bash shell with an endless succession of error boxes.
The only way I found to break out of this was to bring up the debugger,
close it, then type Ctrl+C at the hung bash shell. The bash shell
appears to be fine at that point, but you can never close it (short of
killing it via the task manager).
Same thing if xcopy32 is used instead.
xcopy works OK directly from a bash shell. The segfaults occur if it's
run via a makefile, or via a shell script. Guessing a problem with I/O
redirection, since some other apps can't see keyboard input before the
hung stuff is killed.
Workaround: xxcopy works fine <http://www.xxcopy.com/>; free for
personal use, but not for commercial use. Rename it to xcopy.exe and
get it into your path before the native xcopy, or fiddle the XCOPY
defn in common.mk to use xxcopy instead of xcopy.
#!/usr/bin/env python
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import compileall, os, sys
class Shutup:
def write(*args): pass # :)
class NoteErr:
wrote = 0
def write(self, *args):
self.wrote = 1
apply(stderr.write, args)
def compile_non_test(dir):
"""Byte-compile all modules except those in test directories."""
success = compileall.compile_dir(dir, maxlevels=0)
try:
names = os.listdir(dir)
except os.error:
print "Can't list", dir
names = []
names.sort()
for name in names:
fullname = os.path.join(dir, name)
if (name != os.curdir and name != os.pardir and
os.path.isdir(fullname) and not os.path.islink(fullname) and
name != 'test' and name != 'tests' and name != 'skins'):
success = success and compile_non_test(fullname)
return success
print
print '-'*78
print 'Compiling python modules'
stdout = sys.stdout
stderr = sys.stderr
try:
try:
success = 0
sys.stdout = Shutup()
sys.stderr = NoteErr()
success = compile_non_test(os.getcwd())
finally:
success = success and not sys.stderr.wrote
sys.stdout = stdout
sys.stderr = stderr
except:
success = 0
import traceback
traceback.print_exc()
if not success:
print
print '!' * 78
print 'There were errors during Python module compilation.'
print '!' * 78
print
sys.exit(1)
#!/usr/bin/env python
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import os
import sys
def main(dirname):
os.path.walk(dirname, rmpycs, None)
def rmpycs(arg, dirname, names):
for name in names:
path = os.path.join(dirname, name)
if ( name.endswith('.pyc') or name.endswith('.pyo') and
os.path.isfile(path) ):
os.unlink(path)
if __name__ == '__main__':
main(sys.argv[1])
echo $1 | sed 's@\\@\\\\\\\\@g'
""" Fix up registry entries on Zope uninstall """
from _winreg import *
import sys
def manageZopeRegEntries(uninstalling):
""" Called at uninstall time from innosetup installer to
manage the 'current' and 'previous' Zope versions. This is
just a convenience to make the Pascal coding in innosetup a little
less baroque """
prefix = 'Software\\Zope Corporation'
try:
zope = openKeyAllAccess(HKEY_LOCAL_MACHINE, '%s\\Zope\\' % prefix)
except EnvironmentError:
# this should never happen (the key is created by ISS)
return
try:
current = QueryValueEx(zope, 'CurrentVersion')[0]
except WindowsError:
current = uninstalling
try:
previous = QueryValueEx(zope, 'PreviousVersion')[0]
except WindowsError:
previous = uninstalling
if current != uninstalling:
# someone installed on top of us, punt
CloseKey(zope)
return
# make the previous known version into the current version if it still
# exists
try:
old = openKeyAllAccess(zope, previous)
except (WindowsError, EnvironmentError):
pass
else:
CloseKey(old)
SetValueEx(zope, 'CurrentVersion', None, REG_SZ, previous)
recurseDelete(HKEY_LOCAL_MACHINE, '%s\\Zope\\%s' % (prefix, uninstalling))
recurseDelete(HKEY_LOCAL_MACHINE, '%s\\Zope\\' % prefix)
recurseDelete(HKEY_LOCAL_MACHINE, prefix)
def openKeyAllAccess(key, subkey):
return OpenKey(key, subkey, 0, KEY_ALL_ACCESS)
def recurseDelete(key, subkey):
""" Delete all keys in subkey that are empty, recursively """
names = filter(None, subkey.split('\\'))
done = []
keys = []
while names:
name = names.pop(0)
done.append(name)
keyname = '\\'.join(done)
thiskey = openKeyAllAccess(key, keyname)
keys.append(thiskey)
try:
EnumKey(thiskey, 0)
except:
# no subkeys, ok to delete
DeleteKey(key, keyname)
for openkey in keys:
CloseKey(openkey)
if __name__ == '__main__':
manageZopeRegEntries(sys.argv[1])
cd %1%
set MAKEFLAGS=
nmake build
nmake install
@set PYTHON=C:\Program Files\Zope-2.7.0-b1+\bin\python.exe
@set ZOPE_HOME=C:\Program Files\Zope-2.7.0-b1+\lib\python
@set INSTANCE_HOME=C:\ZEO-Instance
@set CONFIG_FILE=%INSTANCE_HOME%\etc\zeo.conf
@set PYTHONPATH=%ZOPE_HOME%
@set ZEO_RUN=%ZOPE_HOME%\ZEO\runzeo.py
"%PYTHON%" "%ZEO_RUN%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5
#! /bin/sh
#
# buildout <server_type> [<make_args>]*
#
# <server_type> should be one of 'squid', 'zope', or 'zeo' (or some
# other server instance for whom we have a specific makefile)
#
# <makefile_args> are additional arguments to pass to make, e.g.
# 'compile', 'install', etc.
#
reldir=`dirname $0`
reldir=`realpath $reldir`
server_type=$1
shift
if [ -n "$PYTHONHOME" -o -n "$PYTHONPATH" ]; then
echo "** Python build is likely to malfunction if either of" 1>&2
echo "** PYTHONHOME ('$PYTHONHOME') or PYTHONPATH ('$PYTHONPATH')" 1>&2
echo "** is set - please unset them before doing the buildout." 1>&2
exit 1
fi
if [ -f $reldir/Makefile.$server_type ]; then
/usr/bin/make -f $reldir/Makefile.$server_type \
-I $reldir MAKEFILEDIR=$reldir $@
else
echo "buildout <server_type> [make_args]*"
fi
The version of Python shipped in this package has been compiled for
win32 using Microsoft's Visual C++ 6.0. There are differences between
the Win32 Python version shipped with Zope and ZEO (the "ZC" version)
and the version available from the Python.org website:
- The ZC version does not write the same registry entries as the
Python.org distribution.
- The ZC version includes Mark Hammond's win32all package, although the
package structure is lost, and whenever there's more than one file
with the same name in win32all only one of them gets included here.
This ought to be fixed, but the uses Zope makes of win32all appear
not to care about the ways in which the win32all installation is
flawed.
- The Doc, Tools and Script directories aren't installed.
- Tcl/Tk is not included.
- Python's Lib/test directory doesn't contain enough to run the Python
tests successfully (the expected-output subdirectory isn't installed,
and various test-input data files aren't installed -- only .py files
are installed).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Zope Windows Binary Post-Installation QuickStart</title>
</head>
<body bgcolor="#ffffff" link="#000099" alink="#000099" vlink="#000099"
style="font-family: Arial, Helvetica">
<p>
Welcome to <strong>Zope</strong>, a high-performance object-oriented
platform for building dynamic Web applications. Here are some quick
pointers to get you started:
</p>
<ul>
<li>
<p>
If you've launched your Zope instance, and you'd like to get started right
away, you can go directly to the <a href="http://localhost:8080/manage"
target="_new">Zope Management Interface</a>. Use the username
"admin" and the password you specified during installation process
to log in. Please be patient as it may take a few moments for your Zope
instance to start before you can connect to it successfully.
</p>
<li>
<p>
If you've not started your Zope instance, you can do so by choosing the
"Run Zope" command from the Zope program group in your Start Menu. If you
installed Zope as a Windows 'service' (NT/2000/XP only), you may use the
Control Panel --> Administrative Tools --> Services applet to start
your Zope instance as well. The service will be named "Zope instance at
&lt;instance home directory name&gt;".
</p>
</li>
<li>
<p>
If you've not yet created a Zope instance, perform the following steps to
do so:
</p>
<ol>
<li>
Visit a console window (type "cmd" (NT/2000/XP) or "command" (95/98/ME) in the Run box from the Start Menu).
</li>
<li>
Change to the "bin" directory directory of your Zope software home using
the "cd" command, e.g. "cd c:\Program Files\Zope-2.7\bin".
</li>
<li>
Type "python.exe mkzopeinstance.py"
</li>
<li>
Follow the instructions provided by 'mkzopeinstance.py'.
</li>
</ol>
<p>
To start the resulting instance, visit the directory you specified during your interaction with 'mkzopeinstance.py' and type "bin\runzope.bat".
</p>
</li>
<li>
<p>
For the most complete "starter" documentation,
<a href="http://www.zope.org/Documentation/ZopeBook/" target="_new">Read The
Fine Manual</a>. This document guides you through the whole process of
learning Zope, from logging in for the first time to creating your own
web applications.
</p>
</li>
<li>
<p>
For further documentation, go to the main <a href="http://www.zope.org/Documentation/" target="_new">
Documentation Overview</a> on Zope.org. Here you will find pointers to
official and community contributed documentation.
</p>
</li>
<li>
<p>
To get personal assistance with Zope, look at the various <a
href="http://www.zope.org/Resources/MailingLists" target="_new">Mailing
Lists</a> about Zope. The Mailing Lists are where you can get
quick, accurate, friendly help from a large community of Zope
users from around the world.
</p>
</li>
<li>
<p>
If you wish, you can find out about <a href="http://www.zope.com/" target="_new">Zope
Corporation</a>, the publishers of Zope.
</p>
</li>
</ul>
</body>
</html>
""" Add Zope packages in Windows binary distro to sys.path automagically """
import sys
import os
try:
sp = __file__
except:
sp = None
if sp:
dn = os.path.dirname
swhome = os.path.join(dn(dn(dn(dn(sp)))), 'lib', 'python')
if os.path.exists(swhome):
sys.path.insert(0, swhome)
[Setup]
AppName=ZEO <<VERSION>>
AppVerName=ZEO <<VERSION>>
AppPublisher=Zope Corporation
AppPublisherURL=http://www.zope.org
AppSupportURL=http://www.zope.org
AppUpdatesURL=http://www.zope.org
DefaultDirName={pf}\ZEO-<<VERSION>>
DefaultGroupName=ZEO <<VERSION>>
OutputBaseFilename=ZEO-<<VERSION>>-win32
WizardImageFile=<<MAKEFILEDIR>>\etc\zlogo_left.bmp
WizardSmallImageFile=<<MAKEFILEDIR>>\etc\zlogo_top.bmp
SourceDir=.
OutputDir=.
[Components]
Name: main; Description: "Main ZEO files"; Types: full compact custom; Flags: fixed
Name: instance; Description: "ZEO 'instance home' files (required to run ZEO immediately)"; Types: full compact custom; ExtraDiskSpaceRequired: 1453056
[Tasks]
Name: service; Description: "Run your ZEO instance as a Windows service (start ZEO automatically at system startup)"; MinVersion: 4.0,4.0; Components: instance; Check: IsAdministrator
[Files]
; Main ZEO files
Source:"bin\*.*"; DestDir: "{app}\bin"; Flags: ignoreversion recursesubdirs
Source:"doc\*.*"; DestDir: "{app}\doc"; Flags: ignoreversion recursesubdirs
Source:"lib\*.*"; DestDir: "{app}\lib"; Flags: ignoreversion recursesubdirs
Source:"skel\*.*"; DestDir: "{app}\skel"; Flags: ignoreversion recursesubdirs
; these are required to be put into the bin directory for proper function of NT services
Source:"bin\Lib\site-packages\PythonService.exe"; DestDir: "{app}\bin"; Flags: ignoreversion
Source:"bin\Lib\site-packages\PyWinTypes23.dll"; DestDir: "{app}\bin"; Flags: ignoreversion
[Icons]
Name: "{group}\Run ZEO In Console"; Filename: "{code:GetDataDir}\bin\runzeo.bat"; Check: DoInstanceHome
Name: "{group}\Uninstall ZEO"; Filename: "{uninstallexe}";
Name: "{group}\Make ZEO Instance"; Filename: "{app}\bin\python.exe"; Parameters: """{app}\bin\mkzeoinstance.py"""
[Run]
Filename: "{app}\bin\pythonw.exe"; Parameters: """{app}\bin\compilezpy.py"" ""{app}"" "; Description: "Byte-compiling Python files"; StatusMsg: "Byte-compiling Python files..."
Filename:"{app}\bin\pythonw.exe"; Parameters: """{app}\bin\mkzeoinstance.py"" ""--dir={code:GetDataDir}"" "; Description: "Creating default instance"; StatusMsg: "Creating default instance..."; Check: DoInstanceHome
Filename: "{app}\bin\pythonw.exe"; Parameters: """{code:GetDataDir}\bin\zeoservice.py"" --startup auto install"; Check: DoService
Filename: "{app}\bin\pythonw.exe"; Parameters: """{code:GetDataDir}\bin\zeoservice.py"" start"; Description: "Launch ZEO"; Flags: nowait postinstall skipifsilent; Check: DoService
Filename: "{code:GetDataDir}\bin\runzeo.bat"; Description: "Launch ZEO"; Flags: nowait postinstall skipifsilent; Check: DontDoService
[UninstallRun]
Filename: "{app}\bin\pythonw.exe"; Parameters: """{code:GetDataDir}\bin\zeoservice.py"" stop"; Check: DoService
Filename: "{app}\bin\pythonw.exe"; Parameters: """{code:GetDataDir}\bin\zeoservice.py"" remove"; Check: DoService
Filename: "{app}\bin\pythonw.exe"; Parameters: """{app}\bin\decompilezpy.py"" ""{app}"""
[Code]
var
PasswordPrompts, PasswordValues : array of String;
PasswordChars : array of char;
DataDirValues: array of String;
Password : string;
DataDir : String;
function InitializeSetup(): Boolean;
begin
{ set up password data structures }
SetArrayLength(PasswordPrompts, 1);
PasswordPrompts[0] := 'Password:';
SetArrayLength(PasswordValues, 1);
PasswordValues[0] := '';
SetArrayLength(PasswordChars, 1);
PasswordChars[0] := '*';
Password := '';
{ set up data dir data structures }
SetArrayLength(DataDirValues, 1);
DataDir := '';
Result := True;
end;
function CollectInstanceDir(): Boolean;
var
Next: Boolean;
DirOk: Boolean;
begin
DirOk := True;
ScriptDlgPageSetSubCaption1('Select where ZEO instance files should be installed');
ScriptDlgPageSetSubCaption2('Select the folder to which you would like Setup to install ZEO "instance" files, then click Next.');
if DataDir = '' then DataDir:= 'C:\ZEO-Instance';
if DataDirValues[0] <> '' then DataDirValues[0]:= '';
{ Ask for a dir until the user has approved one or clicked Back or Cancel }
Next:= InputDir(DataDirValues[0], DataDir);
if Next and FileOrDirExists(DataDir) then DirOk := False;
while Next and not DirOk do begin
if DataDir = '' then begin
DirOk := False;
MsgBox(SetupMessage(msgInvalidPath), mbError, MB_OK);
end;
if FileOrDirExists(DataDir) then begin
DirOk := MsgBox('Directory Exists' #13#13 'The directory ' + DataDir + ' already exists. Would you like to create instance files in that directory anyway?', mbConfirmation, MB_YESNO) = idYes;
end;
if not DirOk then Next := InputDir(DataDirValues[0], DataDir);
end;
Result:=Next;
end;
function DoInstanceHome():Boolean;
var
S : String;
begin
S := WizardSelectedComponents(False);
Result := Pos('instance', S) <> 0;
end;
function DoService(): Boolean;
var
S : String;
begin
S := WizardSelectedTasks(False);
Result := Pos('service', S) <> 0;
end;
function DontDoService(): Boolean;
begin
Result := not DoService();
end;
function ScriptDlgPages(CurPage: Integer; BackClicked: Boolean): Boolean;
var
Next : Boolean;
CurSubPage : Integer;
begin
Next:=True;
if ( (not BackClicked and (CurPage = wpSelectTasks)) or (BackClicked and (CurPage = wpReady)) )
and DoInstanceHome() then begin
ScriptDlgPageOpen();
ScriptDlgPageSetCaption('Instance Setup');
Next:=CollectInstanceDir();
if not BackClicked then
Result := Next
else
Result := not Next;
ScriptDlgPageClose(not Result);
end;
Result:=Next;
end;
function NextButtonClick(CurPage: Integer): Boolean;
begin
Result := ScriptDlgPages(CurPage, False);
end;
function BackButtonClick(CurPage: Integer): Boolean;
begin
Result := ScriptDlgPages(CurPage, True);
end;
function GetPassword(Default: String): String;
begin
Result := Password;
end;
function GetDataDir(Default : String):String;
begin
Result := DataDir;
end; { GetInstanceDir }
function IsAdministrator(): Boolean;
begin
Result := IsAdminLoggedOn();
end;
[Setup]
AppName=Zope <<VERSION>>
AppVerName=Zope <<VERSION>>
AppPublisher=Zope Corporation
AppPublisherURL=http://www.zope.org
AppSupportURL=http://www.zope.org
AppUpdatesURL=http://www.zope.org
DefaultDirName={pf}\Zope-<<VERSION>>
DefaultGroupName=Zope <<VERSION>>
OutputBaseFilename=Zope-<<VERSION>>-win32
WizardImageFile=<<MAKEFILEDIR>>\etc\zlogo_left.bmp
WizardSmallImageFile=<<MAKEFILEDIR>>\etc\zlogo_top.bmp
SourceDir=.
OutputDir=.
[Components]
Name: main; Description: "Main Zope files"; Types: full compact custom; Flags: fixed
Name: instance; Description: "Zope 'instance home' files (required to run Zope immediately)"; Types: full compact custom; ExtraDiskSpaceRequired: 1453056
[Tasks]
Name: service; Description: "Run your Zope instance as a Windows service (start Zope automatically at system startup)"; MinVersion: 4.0,4.0; Components: instance; Check: IsAdministrator
[Files]
; Main Zope files
Source: "<<MAKEFILEDIR>>\etc\README.html"; DestDir: "{app}"; Flags: ignoreversion
Source:"bin\*.*"; DestDir: "{app}\bin"; Flags: ignoreversion recursesubdirs
Source:"doc\*.*"; DestDir: "{app}\doc"; Flags: ignoreversion recursesubdirs
Source:"import\*.*"; DestDir: "{app}\import"; Flags: ignoreversion recursesubdirs
Source:"lib\*.*"; DestDir: "{app}\lib"; Flags: ignoreversion recursesubdirs
Source:"skel\*.*"; DestDir: "{app}\skel"; Flags: ignoreversion recursesubdirs
; these are required to be put into the bin directory for proper function of NT services
Source:"bin\Lib\site-packages\PythonService.exe"; DestDir: "{app}\bin"; Flags: ignoreversion
Source:"bin\Lib\site-packages\PyWinTypes23.dll"; DestDir: "{app}\bin"; Flags: ignoreversion
; This is a helper module for manging registry entries at uninstall time
Source: "<<MAKEFILEDIR>>\bin\fixreg.py"; DestDir: "{app}\bin"; Flags: ignoreversion
[Icons]
Name: "{group}\Run Zope In Console"; Filename: "{code:GetDataDir}\bin\runzope.bat"; Check: DoInstanceHome
Name: "{group}\Uninstall Zope"; Filename: "{uninstallexe}";
Name: "{group}\Make Zope Instance"; Filename: "{app}\bin\python.exe"; Parameters: """{app}\bin\mkzopeinstance.py"""
[Run]
Filename: "{app}\bin\pythonw.exe"; Parameters: """{app}\bin\compilezpy.py"" ""{app}"" "; Description: "Byte-compiling Python files"; StatusMsg: "Byte-compiling Python files..."
Filename:"{app}\bin\pythonw.exe"; Parameters: """{app}\bin\mkzopeinstance.py"" --user=""admin:{code:GetPassword}"" --dir=""{code:GetDataDir}"" "; Description: "Creating default instance"; StatusMsg: "Creating default instance..."; Check: DoInstanceHome
Filename: "{app}\bin\pythonw.exe"; Parameters: """{code:GetDataDir}\bin\zopeservice.py"" --startup auto install"; Check: DoService
Filename: "{app}\README.html"; Flags: shellexec skipifdoesntexist postinstall skipifsilent; Description: "View 'QuickStart' document in a web browser"
Filename: "{app}\bin\pythonw.exe"; Parameters: """{code:GetDataDir}\bin\zopeservice.py"" start"; Description: "Launch Zope"; Flags: nowait postinstall skipifsilent; Check: DoService
Filename: "{code:GetDataDir}\bin\runzope.bat"; Description: "Launch Zope"; Flags: nowait postinstall skipifsilent; Check: DontDoService
[UninstallRun]
Filename: "{app}\bin\pythonw.exe"; Parameters: """{code:GetDataDir}\bin\zopeservice.py"" stop"; Check: DoService
Filename: "{app}\bin\pythonw.exe"; Parameters: """{code:GetDataDir}\bin\zopeservice.py"" remove"; Check: DoService
Filename: "{app}\bin\pythonw.exe"; Parameters: """{app}\bin\decompilezpy.py"" ""{app}"""
Filename: "{app}\bin\pythonw.exe"; Parameters: """{app}\bin\fixreg.py"" ""<<VERSION>>"""
[Registry]
Root: HKLM; Subkey: "Software\Zope Corporation\Zope"; ValueType: string; ValueName: "PreviousVersion"; ValueData: "{reg:HKLM\Software\Zope Corporation\Zope,CurrentVersion|}"
Root: HKLM; Subkey: "Software\Zope Corporation\Zope"; Flags: uninsdeletekeyifempty; ValueType: string; ValueName: "CurrentVersion"; ValueData: "<<VERSION>>"
Root: HKLM; Subkey: "Software\Zope Corporation\Zope\<<VERSION>>"; Flags: uninsdeletekey; ValueType: string; ValueName: "Home"; ValueData: "{app}"
Root: HKLM; Subkey: "Software\Zope Corporation\Zope\<<VERSION>>"; Flags: uninsdeletekey; ValueType: string; ValueName: "Python"; ValueData: "{app}\bin\python.exe"
Root: HKLM; Subkey: "Software\Zope Corporation\Zope\<<VERSION>>"; Flags: uninsdeletekey; ValueType: string; ValueName: "Pythonw"; ValueData: "{app}\bin\pythonw.exe"
[Code]
var
PasswordPrompts, PasswordValues : array of String;
PasswordChars : array of char;
DataDirValues: array of String;
Password : string;
DataDir : String;
function InitializeSetup(): Boolean;
begin
{ set up password data structures }
SetArrayLength(PasswordPrompts, 1);
PasswordPrompts[0] := 'Password:';
SetArrayLength(PasswordValues, 1);
PasswordValues[0] := '';
SetArrayLength(PasswordChars, 1);
PasswordChars[0] := '*';
Password := '';
{ set up data dir data structures }
SetArrayLength(DataDirValues, 1);
DataDir := '';
Result := True;
end;
function CollectInstanceDir(): Boolean;
var
Next: Boolean;
DirOk: Boolean;
begin
DirOk := True;
ScriptDlgPageSetSubCaption1('Select where Zope instance files should be installed');
ScriptDlgPageSetSubCaption2('Select the folder to which you would like Setup to install Zope "instance" files, then click Next.');
if DataDir = '' then DataDir:= 'C:\Zope-Instance';
if DataDirValues[0] <> '' then DataDirValues[0]:= '';
{ Ask for a dir until the user has approved one or clicked Back or Cancel }
Next:= InputDir(DataDirValues[0], DataDir);
if Next and FileOrDirExists(DataDir) then DirOk := False;
while Next and not DirOk do begin
if DataDir = '' then begin
DirOk := False;
MsgBox(SetupMessage(msgInvalidPath), mbError, MB_OK);
end;
if FileOrDirExists(DataDir) then begin
DirOk := MsgBox('Directory Exists' #13#13 'The directory ' + DataDir + ' already exists. Would you like to create instance files in that directory anyway?', mbConfirmation, MB_YESNO) = idYes;
end;
if not DirOk then Next := InputDir(DataDirValues[0], DataDir);
end;
Result:=Next;
end;
function CollectPassword(): Boolean;
var
Next: Boolean;
begin
ScriptDlgPageSetSubCaption1('Specify adminisrator password');
ScriptDlgPageSetSubCaption2('The login name for your Zope administrator account is "admin". When you first connect to the Zope management interface, you will need to login using the "admin" username and the password you specify below.');
Next := InputQueryArrayEx(PasswordPrompts, PasswordChars, PasswordValues);
while Next and (PasswordValues[0] = '') do begin
MsgBox('You must enter an administrator password', mbError, MB_OK)
Next := InputQueryArrayEx(PasswordPrompts, PasswordChars, PasswordValues);
end;
Password := PasswordValues[0];
Result:=Next;
end;
function DoInstanceHome():Boolean;
var
S : String;
begin
S := WizardSelectedComponents(False);
Result := Pos('instance', S) <> 0;
end;
function DoService(): Boolean;
var
S : String;
begin
S := WizardSelectedTasks(False);
Result := Pos('service', S) <> 0;
end;
function DontDoService(): Boolean;
begin
Result := not DoService();
end;
function ScriptDlgPages(CurPage: Integer; BackClicked: Boolean): Boolean;
var
Next : Boolean;
CurSubPage : Integer;
begin
Next:=True;
if ( (not BackClicked and (CurPage = wpSelectTasks)) or (BackClicked and (CurPage = wpReady)) )
and DoInstanceHome() then begin
if not BackClicked then CurSubPage:=0 else CurSubPage:=1;
ScriptDlgPageOpen();
ScriptDlgPageSetCaption('Instance Setup');
while (CurSubPage >=0) and (CurSubPage <=1) and not Terminated do begin
case CurSubPage of
0: Next:=CollectInstanceDir();
1: Next:=CollectPassword();
end;
if Next then CurSubPage := CurSubPage +1 else CurSubPage := CurSubPage -1;
end;
if not BackClicked then
Result := Next
else
Result := not Next;
ScriptDlgPageClose(not Result);
end;
Result:=Next;
end;
function NextButtonClick(CurPage: Integer): Boolean;
begin
Result := ScriptDlgPages(CurPage, False);
end;
function BackButtonClick(CurPage: Integer): Boolean;
begin
Result := ScriptDlgPages(CurPage, True);
end;
function GetPassword(Default: String): String;
begin
Result := Password;
end;
function GetDataDir(Default : String):String;
begin
Result := DataDir;
end; { GetInstanceDir }
function IsAdministrator(): Boolean;
begin
Result := IsAdminLoggedOn();
end;
BASE_DIR=$(shell pwd)
WIN_BASE_DIR=$(shell cygpath -w $(BASE_DIR))
BUILD_DIR=$(BASE_DIR)/build
WIN_BUILD_DIR=$(shell cygpath -w $(BUILD_DIR))
SRC_DIR=$(BASE_DIR)/src
WIN_SRC_DIR=$(shell cygpath -w $(SRC_DIR))
TMP_DIR=$(BASE_DIR)/tmp
WIN_TMP_DIR=$(shell cygpath -w $(TMP_DIR))
WIN_MAKEFILEDIR=$(shell cygpath -w $(MAKEFILEDIR))
# Root of the Windows drive you're working on. The setting here is for
# the C: drive and using a default out-of-the-box Cygwin.
CYGROOT=/cygdrive/c
RM=rm -f
RMRF=rm -rf
CD=cd
XCOPY=xcopy /i /s /e /y
CPR=cp -r
CP=cp
MKDIR=mkdir -p
CVS="$(MAKEFILEDIR)/bin/cvs.exe"
TAR=tar
SED=sed
TOUCH=touch
NMAKE=nmake
CSCRIPT=cscript
ECHO=echo
ISS_DIR=$(CYGROOT)/Progra~1/Inno Setup 4
ISS_COMPILER=$(ISS_DIR)/Compil32.exe
$(REQUIRED_FILES):
if [ -z "$(BASE_DIR)/$@" ]; then echo. &echo. & echo \
You must download $(@F) and place it in "$(BASE_DIR)/tmp" &\
error 1; fi
PRODUCTS_DIR=build/instance/Products
PYLIBDIR=build/instance/lib/python
ZOPE_CVS_REPOSITORY=:pserver:anonymous@cvs.zope.org:/cvs-repository
CVS=/usr/bin/cvs -z7 -q
CVS_UPDATE=${CVS} update -dP
CVSROOT=:ext:korak.zope.com:/cvs-turbointranet
# Use COPY_AND_WINDOWIZE_LINEENDS like so:
#
# destination_path: source_path
# $(COPY_AND_WINDOWIZE_LINEENDS)
#
# Any directories needed to hold destination_path are created. The file
# is copied from source_path to there, and unix2dos is run on it in its
# new home. The paths must give file names, not directories; this reflects
# that renaming of files is often needed in these makefiles.
define COPY_AND_WINDOWIZE_LINEENDS
$(MKDIR) $(@D)
$(CP) $< $@
unix2dos $@
$(TOUCH) $@
endef
\ No newline at end of file
# The Python and win32all versions. For Python, both the source tarball
# and the Windows installer must be in tmp/. For win32all, the Windows
# installer must be in tmp/. Nothing beyond those is required to
# build Python, and you don't even need a compiler for this part.
PYVERSION=2.3.5
W32ALLVERSION=163
# CAUTION: Extracting files from Wise installers doesn't really do what
# you expect. While a Wise installer is a zip file, the zip file
# structure is flat (Wise reconstructs the intended directory structure
# from metadata stored in proprietary FILEnnnn.DAT files also in the
# zip file). Consequently, the package structure of Python packages is
# lost, and if there's more than one file with the same name, you only
# get "the last one" to be extracted (all files are extracted to the
# same directory).
#
# For Python, this doesn't matter, because we're only sucking out the
# precompiled .pyd and .exe files from the Python installer -- there
# are no name clashes in that set, and it's a pretty safe bet there never
# will be (else Python wouldn't be able to decide which to use!). We
# use the Python source tarball to get all the non-executable parts we
# need.
#
# For win32all, I'm not sure what all the consequences are. Zope has
# gotten away with it so far. Favoring it, Zope makes little use of
# win32all. Against it, there's (as of the time of this writing) little
# field experience with Windows Zope after Python 2.1. Python and
# win32all have both gotten hairier since then, and win32all has
# significant package structure with many instances of files with the
# same name in different subtrees. For now it's poke-and-hope.
PYDIRNAME=Python-$(PYVERSION)
W32ALLDIRNAME=win32all-$(W32ALLVERSION)
# The Python tarball is extracted to PYSRCDIR.
# The contents of the Python installer get extracted to PYEXTRACTDIR.
# The " " " win32all " " " " W32EXTRACTDIR.
PYSRCDIR=$(BASE_DIR)/src/$(PYDIRNAME)
PYEXTRACTDIR=$(BASE_DIR)/src/$(PYDIRNAME)-extract
W32EXTRACTDIR=$(BASE_DIR)/src/$(W32ALLDIRNAME)
WIN_PYSRCDIR=$(shell cygpath -w $(PYSRCDIR))
WIN_PYEXTRACTDIR=$(shell cygpath -w $(PYEXTRACTDIR))
WIN_W32EXTRACTDIR=$(shell cygpath -w $(W32EXTRACTDIR))
PYTHON_REQUIRED_FILES=tmp/$(W32ALLDIRNAME).exe \
tmp/$(PYDIRNAME).tgz \
tmp/$(PYDIRNAME).exe
# Arbitrary files from each of the installers and tarballs, to use as
# targets to force them to get unpacked.
ARB_PYSRCDIR=$(PYSRCDIR)/PCbuild/pcbuild.dsw
ARB_PYEXTRACTDIR=$(PYEXTRACTDIR)/zlib.pyd
ARB_W32EXTRACTDIR=$(W32EXTRACTDIR)/readme.txt
# Building Python just consists of extracting files.
build_python: $(ARB_PYSRCDIR) $(ARB_PYEXTRACTDIR) $(ARB_W32EXTRACTDIR)
# Installing Python consists of copying oodles of files into
# $(BUILD_DIR).
install_python: $(BUILD_DIR)/bin/python.exe
clean_python:
$(RMRF) $(PYSRCDIR)
$(RMRF) $(PYEXTRACTDIR)
clean_libs:
$(RMRF) $(W32EXTRACTDIR)
$(ARB_PYSRCDIR): tmp/$(PYDIRNAME).tgz
$(MKDIR) "$(SRC_DIR)"
$(CD) "$(SRC_DIR)" && $(TAR) xvzf ../tmp/$(PYDIRNAME).tgz
$(TOUCH) "$(ARB_PYSRCDIR)"
$(ARB_PYEXTRACTDIR): tmp/$(PYDIRNAME).exe
$(MKDIR) "$(PYEXTRACTDIR)"
"tmp/$(PYDIRNAME).exe" /S /X "$(WIN_PYEXTRACTDIR)"
$(TOUCH) "$(ARB_PYEXTRACTDIR)"
$(ARB_W32EXTRACTDIR): tmp/$(W32ALLDIRNAME).exe
$(MKDIR) "$(W32EXTRACTDIR)"
"tmp/$(W32ALLDIRNAME).exe" /S /X "$(WIN_W32EXTRACTDIR)"
$(TOUCH) "$(ARB_W32EXTRACTDIR)"
$(BUILD_DIR)/bin/python.exe:
$(MKDIR) "$(BUILD_DIR)"
$(MKDIR) "$(BUILD_DIR)/doc"
$(CP) "$(MAKEFILEDIR)/doc/ZC_PY_DIST_README.txt" "$(BUILD_DIR)/doc"
$(CP) "$(PYSRCDIR)/LICENSE" "$(BUILD_DIR)/doc/PYTHON_LICENSE.txt"
unix2dos "$(BUILD_DIR)/doc/PYTHON_LICENSE.txt"
$(CP) "$(SRC_DIR)/$(W32ALLDIRNAME)/License.txt" \
"$(BUILD_DIR)/doc/WIN32ALL_LICENSE.txt"
$(MKDIR) "$(BUILD_DIR)/bin/DLLs"
$(XCOPY) "$(WIN_PYEXTRACTDIR)\*.pyd" "$(WIN_BUILD_DIR)\bin\DLLs"
$(MKDIR) "$(BUILD_DIR)/bin/Lib"
$(XCOPY) "$(WIN_PYSRCDIR)\Lib\*.py" "$(WIN_BUILD_DIR)\bin\Lib"
$(MKDIR) "$(BUILD_DIR)/bin/Lib/site-packages"
$(CP) "$(PYSRCDIR)/Lib/site-packages/README" \
"$(BUILD_DIR)/bin/Lib/site-packages"
$(XCOPY) "$(WIN_W32EXTRACTDIR)\*.pyd" \
"$(WIN_BUILD_DIR)\bin\Lib\site-packages"
$(XCOPY) "$(WIN_W32EXTRACTDIR)\*.dll" \
"$(WIN_BUILD_DIR)\bin\Lib\site-packages"
$(XCOPY) "$(WIN_W32EXTRACTDIR)\*.exe" \
"$(WIN_BUILD_DIR)\bin\Lib\site-packages"
$(XCOPY) "$(WIN_W32EXTRACTDIR)\*.py" \
"$(WIN_BUILD_DIR)\bin\Lib\site-packages"
$(CP) "$(MAKEFILEDIR)/etc/sitecustomize.py" \
"$(BUILD_DIR)/bin/Lib/site-packages"
$(MKDIR) "$(BUILD_DIR)/bin/Include"
$(XCOPY) "$(WIN_PYSRCDIR)\Include\*.h" "$(WIN_BUILD_DIR)\bin\Include"
$(XCOPY) "$(WIN_PYSRCDIR)\PC\*.h" "$(WIN_BUILD_DIR)\bin\Include"
$(MKDIR) "$(BUILD_DIR)/bin/libs"
$(CP) "$(PYEXTRACTDIR)/python23.lib" "$(BUILD_DIR)/bin/libs"
$(MKDIR) "$(BUILD_DIR)/bin"
$(CP) "$(PYEXTRACTDIR)/pythonw.exe" "$(BUILD_DIR)/bin"
$(CP) "$(PYEXTRACTDIR)/w9xpopen.exe" "$(BUILD_DIR)/bin"
$(CP) "$(PYEXTRACTDIR)/python23.dll" "$(BUILD_DIR)/bin"
$(CP) "$(PYEXTRACTDIR)/python.exe" "$(BUILD_DIR)/bin"
$(TOUCH) "$(BUILD_DIR)/bin/python.exe"
# Justs repackages the Spread binaries.
# Puts binaries into build/bin, and some docs into build/doc.
# See README.txt for system requirements.
# Download the binary distribution of Spread, from http://www.spread.org/.
# Store it in tmp/. NOTE: May need to rename it to .tgz (depends on how
# it's downloaded). The name is of the form spread-bin-n.nn.n.tgz
SPREAD_VERSION=3.17.1
SPREAD_DIR=spread-bin-$(SPREAD_VERSION)
SPREAD_ARCHIVE=$(SPREAD_DIR).tgz
SPREAD_REQUIRED_FILES=tmp/$(SPREAD_ARCHIVE)
REQUIRED_FILES=$(SPREAD_REQUIRED_FILES)
# Unpack the tarball into src/.
build_spread: $(SRC_DIR)/$(SPREAD_DIR)/win/spread.exe
$(SRC_DIR)/$(SPREAD_DIR)/win/spread.exe : tmp/$(SPREAD_ARCHIVE)
$(MKDIR) "$(SRC_DIR)"
$(TAR) -C "$(SRC_DIR)" -xvzf tmp/$(SPREAD_ARCHIVE)
$(TOUCH) $@
# A dumb trick so we don't unpack the tarball multiple times.
$(SRC_DIR)/$(SPREAD_DIR)/license.txt \
$(SRC_DIR)/$(SPREAD_DIR)/Readme.txt \
$(SRC_DIR)/$(SPREAD_DIR)/sample.spread.conf \
: $(SRC_DIR)/$(SPREAD_DIR)/win/spread.exe
$(TOUCH) $@
# Copy the Windows stuff from src/ into build/bin/ and build/doc
install_spread: $(BUILD_DIR)/bin/spread.exe \
$(BUILD_DIR)/bin/sprecv.exe \
$(BUILD_DIR)/bin/spsend.exe \
$(BUILD_DIR)/bin/sptuser.exe \
$(BUILD_DIR)/bin/spflooder.exe \
$(BUILD_DIR)/doc/SPREAD_LICENSE.txt \
$(BUILD_DIR)/doc/SPREAD_README.txt \
$(BUILD_DIR)/doc/sample.spread.conf
$(BUILD_DIR)/bin/spread.exe \
$(BUILD_DIR)/bin/sprecv.exe \
$(BUILD_DIR)/bin/spsend.exe \
$(BUILD_DIR)/bin/sptuser.exe \
$(BUILD_DIR)/bin/spflooder.exe : $(BUILD_DIR)/bin/% : \
$(SRC_DIR)/$(SPREAD_DIR)/win/%
$(MKDIR) $(@D)
$(CP) $< $@
$(TOUCH) $@
$(BUILD_DIR)/doc/SPREAD_LICENSE.txt: $(SRC_DIR)/$(SPREAD_DIR)/license.txt
$(COPY_AND_WINDOWIZE_LINEENDS)
$(BUILD_DIR)/doc/SPREAD_README.txt: $(SRC_DIR)/$(SPREAD_DIR)/Readme.txt
$(COPY_AND_WINDOWIZE_LINEENDS)
$(BUILD_DIR)/doc/sample.spread.conf: $(SRC_DIR)/$(SPREAD_DIR)/sample.spread.conf
$(COPY_AND_WINDOWIZE_LINEENDS)
# Builds the Python Spread wrapper module.
# Puts:
# spread.pyd into build/lib/python/
# testspread.py into build/lib/python/SpreadTest/
# various text files (Windowsized and renamed) into build/doc
# Download the wrapper module tarball, from
# http://www.python.org/other/spread/.
# Store it in tmp/. NOTE: May need to rename it to .tgz (depends on how
# it's downloaded). The name is of the form SpreadModule-n.n.tgz
# XXX There's no natural way to clean up SPREADWRAPPER_TMPDIR here.
SPREADWRAPPER_VERSION=1.4
SPREADWRAPPER_DIR=SpreadModule-$(SPREADWRAPPER_VERSION)
SPREADWRAPPER_ARCHIVE=$(SPREADWRAPPER_DIR).tgz
SPREADWRAPPER_REQUIRED_FILES=tmp/$(SPREADWRAPPER_ARCHIVE)
REQUIRED_FILES=$(SPREADWRAPPER_REQUIRED_FILES)
SPREADWRAPPER_TMPDIR=src/tmp/spreadwrapper-install
# Unpack the tarball into src/.
build_spreadwrapper: $(SRC_DIR)/$(SPREADWRAPPER_DIR)/spreadmodule.c
# Copy the Windows stuff into the build tree.
install_spreadwrapper: $(BUILD_DIR)/lib/python/spread.pyd \
$(BUILD_DIR)/lib/python/SpreadTest/testspread.py \
$(BUILD_DIR)/doc/spreadwrapper_doc.txt \
$(BUILD_DIR)/doc/SPREADWRAPPER_LICENSE.txt \
$(BUILD_DIR)/doc/SPREADWRAPPER_README.txt
$(SRC_DIR)/$(SPREADWRAPPER_DIR)/spreadmodule.c: tmp/$(SPREADWRAPPER_ARCHIVE)
$(MKDIR) "$(SRC_DIR)"
$(TAR) -C "$(SRC_DIR)" -xvzf $<
$(TOUCH) $@
# A dumb trick so we don't unpack the tarball multiple times.
$(SRC_DIR)/$(SPREADWRAPPER_DIR)/doc.txt \
$(SRC_DIR)/$(SPREADWRAPPER_DIR)/LICENSE \
$(SRC_DIR)/$(SPREADWRAPPER_DIR)/README \
$(SRC_DIR)/$(SPREADWRAPPER_DIR)/testspread.py \
: $(SRC_DIR)/$(SPREADWRAPPER_DIR)/spreadmodule.c
$(TOUCH) $@
$(SPREADWRAPPER_TMPDIR)/Lib/site-packages/spread.pyd: $(SRC_DIR)/$(SPREADWRAPPER_DIR)/spreadmodule.c
$(CD) $(SRC_DIR)/$(SPREADWRAPPER_DIR); \
$(BUILD_DIR)/bin/python.exe setup.py install \
--prefix=../../$(SPREADWRAPPER_TMPDIR)
$(BUILD_DIR)/lib/python/spread.pyd: $(SPREADWRAPPER_TMPDIR)/Lib/site-packages/spread.pyd
$(MKDIR) $(@D)
$(CP) $< $@
$(TOUCH) $@
$(BUILD_DIR)/doc/spreadwrapper_doc.txt: $(SRC_DIR)/$(SPREADWRAPPER_DIR)/doc.txt
$(COPY_AND_WINDOWIZE_LINEENDS)
$(BUILD_DIR)/doc/SPREADWRAPPER_LICENSE.txt: $(SRC_DIR)/$(SPREADWRAPPER_DIR)/LICENSE
$(COPY_AND_WINDOWIZE_LINEENDS)
$(BUILD_DIR)/doc/SPREADWRAPPER_README.txt: $(SRC_DIR)/$(SPREADWRAPPER_DIR)/README
$(COPY_AND_WINDOWIZE_LINEENDS)
$(BUILD_DIR)/lib/python/SpreadTest/testspread.py: $(SRC_DIR)/$(SPREADWRAPPER_DIR)/testspread.py
$(COPY_AND_WINDOWIZE_LINEENDS)
ZODBVERSION=3.2
ZODBDIRNAME=ZODB3-$(ZODBVERSION)
ZEO_REQUIRED_FILES=tmp/$(ZODBDIRNAME).tar.gz
REQUIRED_FILES=$(ZEO_REQUIRED_FILES)\
$(PYTHON_REQUIRED_FILES)
# run the Zope tests
clean_zope:
$(RMRF) src/$(ZODBDIRNAME)
install_zeo: src/$(ZODBDIRNAME)/setup.py install_python \
$(BUILD_DIR)/lib/python/version.txt \
$(BUILD_DIR)/ZEO-$(ZODBDIRNAME)-win32.exe
ESCAPED=$(shell sh $(MAKEFILEDIR)/bin/escape.sh '$(WIN_MAKEFILEDIR)')
SEDSCRIPT="s@<<VERSION>>@$(ZODBVERSION)@g;s@<<MAKEFILEDIR>>@$(ESCAPED)@g"
$(BUILD_DIR)/ZEO-$(ZODBDIRNAME)-win32.exe: $(BUILD_DIR)/lib/python/version.txt
$(SED) $(SEDSCRIPT) < "$(MAKEFILEDIR)/etc/zeo.iss.in" | unix2dos > "$(BUILD_DIR)/zeo.iss"
# Remove CVS directories from the build tree.
find $(BUILD_DIR) -name CVS -type d -exec $(RMRF) {} \; -prune
# Convert text files to Windows line ends. unix2dos has the nice
# property that it leaves lines with \r\n alone, so it doesn't hurt
# to do this on files already converted to Windows convention.
find $(BUILD_DIR) -name "*.py" -o -name "*.txt" -o -name "*.bat" | \
xargs unix2dos
# Build the Inno installer.
$(CD) "$(BUILD_DIR)";"$(ISS_COMPILER)" /cc "$(WIN_BUILD_DIR)\zeo.iss"
$(BUILD_DIR)/lib/python/ExtensionClass.pyd: WIN_TMPDIR=tmp\zeotmp
$(BUILD_DIR)/lib/python/ExtensionClass.pyd: install_python
$(MKDIR) $(WIN_TMPDIR)
$(CD) $(SRC_DIR)/$(ZODBDIRNAME); \
$(BUILD_DIR)/bin/python.exe setup.py install \
--prefix="$(WIN_BASE_DIR)\$(WIN_TMPDIR)" --no-compile
$(MKDIR) $(@D)
$(XCOPY) "$(WIN_TMPDIR)\Lib\site-packages\*.py" "$(shell cygpath -w $(@D))"
$(XCOPY) "$(WIN_TMPDIR)\Lib\site-packages\*.pyd" "$(shell cygpath -w $(@D))"
$(XCOPY) "$(WIN_TMPDIR)\Lib\site-packages\*.txt" "$(shell cygpath -w $(@D))"
$(XCOPY) "$(WIN_TMPDIR)\Lib\site-packages\*.xml" "$(shell cygpath -w $(@D))"
$(XCOPY) "$(WIN_TMPDIR)\Lib\site-packages\*.conf" "$(shell cygpath -w $(@D))"
$(XCOPY) "$(WIN_TMPDIR)\Include\*.h" "$(WIN_BUILD_DIR)\bin\Include"
$(XCOPY) "$(WIN_TMPDIR)\Scripts\*.py" "$(WIN_BUILD_DIR)\bin"
$(RMRF) $(shell cygpath -u $(WIN_TMPDIR))
$(BUILD_DIR)/lib/python/nt_svcutils/__init__.py: CVS_REPOSITORY=$(ZOPE_CVS_REPOSITORY)
$(BUILD_DIR)/lib/python/nt_svcutils/__init__.py: CVS_MODULE=Zope/lib/python/nt_svcutils
$(BUILD_DIR)/lib/python/nt_svcutils/__init__.py: CVS_TAG=-r HEAD
$(BUILD_DIR)/lib/python/nt_svcutils/__init__.py:
${CD} ${BUILD_DIR}/lib/python && \
${CVS} -d ${CVS_REPOSITORY} export ${CVS_TAG} -d \
$(shell basename $(@D)) ${CVS_MODULE}
$(BUILD_DIR)/skel/README.txt:
$(MKDIR) "$(@D)"
$(CPR) $(MAKEFILEDIR)/zeo_addons/skel/* $(@D)
$(TOUCH) "$@"
$(BUILD_DIR)/bin/mkzeoinstance.py:
$(MKDIR) "$(@D)"
$(CPR) $(MAKEFILEDIR)/zeo_addons/utilities/* $(@D)
$(TOUCH) "$(@)"
$(BUILD_DIR)/lib/python/version.txt: $(BUILD_DIR)/lib/python/ExtensionClass.pyd $(BUILD_DIR)/lib/python/nt_svcutils/__init__.py $(BUILD_DIR)/skel/README.txt $(BUILD_DIR)/bin/mkzeoinstance.py
@echo ZEO $(ZODBVERSION) > "$(BUILD_DIR)/lib/python/version.txt"
$(TOUCH) $@
src/$(ZODBDIRNAME)/setup.py:
$(MKDIR) "$(SRC_DIR)"
$(CD) "$(SRC_DIR)" && $(TAR) xvzf ../tmp/$(ZODBDIRNAME).tar.gz
$(TOUCH) $@
ZOPE_REQUIRED_FILES=tmp/$(ZOPEDIRNAME).tgz
REQUIRED_FILES=$(PYTHON_REQUIRED_FILES)\
$(ZOPE_REQUIRED_FILES)
ZOPEVERSION=2.8.0-b1
ZOPEDIRNAME=Zope-$(ZOPEVERSION)
MAKEZOPE="$(MAKEFILEDIR)/bin/makezope.bat" "$(WIN_BUILD_DIR)"
# run the Zope tests
test_zope:
$(CD) "$(BASE_DIR)/src/Zope"
"$(PYPCBUILDDIR)/python.exe" utilities/testrunner.py -a
$(CD) "$(BASE_DIR)"
clean_zope:
$(RMRF) src/$(ZOPEDIRNAME)
install_zope: src/$(ZOPEDIRNAME)/inst/configure.py install_python \
$(BUILD_DIR)/Zope-$(ZOPEVERSION)-win32.exe
ESCAPED=$(shell sh $(MAKEFILEDIR)/bin/escape.sh '$(WIN_MAKEFILEDIR)')
SEDSCRIPT="s@<<VERSION>>@$(ZOPEVERSION)@g;s@<<MAKEFILEDIR>>@$(ESCAPED)@g"
$(BUILD_DIR)/Zope-$(ZOPEVERSION)-win32.exe: $(BUILD_DIR)/lib/python/version.txt
$(SED) $(SEDSCRIPT) < "$(MAKEFILEDIR)/etc/zope.iss.in" | unix2dos > "$(BUILD_DIR)/zope.iss"
# Remove CVS directories from the build tree.
find $(BUILD_DIR) -name CVS -type d -exec $(RMRF) {} \; -prune
# Convert text files to Windows line ends. unix2dos has the nice
# property that it leaves lines with \r\n alone, so it doesn't hurt
# to do this on files already converted to Windows convention.
find $(BUILD_DIR) -name "*.py" -o -name "*.txt" -o -name "*.bat" | \
xargs unix2dos
# Build the Inno installer.
$(CD) "$(BUILD_DIR)";"$(ISS_COMPILER)" /cc "$(WIN_BUILD_DIR)\zope.iss"
$(BUILD_DIR)/lib/python/Zope2/Startup/run.py:
$(CD) "$(BUILD_DIR)"; \
bin/python.exe \
"$(WIN_SRC_DIR)\$(ZOPEDIRNAME)\inst\configure.py" \
--prefix="$(WIN_BUILD_DIR)" --no-compile
$(MAKEZOPE)
$(TOUCH) "$(BUILD_DIR)/lib/python/Zope2/Startup/run.py"
$(BUILD_DIR)/lib/python/version.txt: $(BUILD_DIR)/lib/python/Zope2/Startup/run.py
@echo Zope $(ZOPEVERSION) > "$(BUILD_DIR)/lib/python/version.txt"
$(TOUCH) "$(BUILD_DIR)/lib/python/version.txt"
src/$(ZOPEDIRNAME)/inst/configure.py:
$(MKDIR) "$(SRC_DIR)"
$(CD) "$(SRC_DIR)" && $(TAR) xvzf ../tmp/$(ZOPEDIRNAME).tgz \
&& $(TOUCH) $(ZOPEDIRNAME)/inst/configure.py
This is an instance home for a ZEO server.
@set PYTHON=<<PYTHON>>
@set ZEO_HOME=<<ZEO_HOME>>
@set SOFTWARE_HOME=%ZEO_HOME%\lib\python
@set INSTANCE_HOME=<<INSTANCE_HOME>>
@set CONFIG_FILE=%INSTANCE_HOME%\etc\zeo.conf
@set PYTHONPATH=<<SOFTWARE_HOME>>
@set ZEO_RUN=%SOFTWARE_HOME%\ZEO\runzeo.py
"%PYTHON%" "%ZEO_RUN%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""
A Windows NT service frontend.
Usage:
Installation
The service should be installed by the Windows installer. You can
manually install, uninstall the service from the commandline.
ntservice.py [options] install|update|remove|start [...]
|stop|restart [...]|debug [...]
Options for 'install' and 'update' commands only:
--username domain\username : The Username the service is to run
under
--password password : The password for the username
--startup [manual|auto|disabled] : How the service starts,
default = manual
Commands
install : Installs the service
update : Updates the service, use this when you change
the service class implementation
remove : Removes the service
start : Starts the service, this can also be done from the
services control panel
stop : Stops the service, this can also be done from the
services control panel
restart : Restarts the service
debug : Runs the service in debug mode
You can view the usage options by running ntservice.py without any
arguments.
Note: you may have to register the Python service program first,
win32\PythonService.exe /register
Starting
Start the service by clicking the 'start' button in the services
control panel. You can set the service to automatically start at boot
time by choosing 'Auto' startup by clicking the 'statup' button.
Stopping
Stop the service by clicking the 'stop' button in the services
control panel.
Event logging
Events are logged to the NT application event log. Use the event
viewer to keep track of events.
Note: to successfully run this script, the software home needs to be
on the PYTHONPATH.
"""
import os.path
from os.path import dirname as dn
import sys
# these are replacements from mkzeoinstance
PYTHON = r'<<PYTHON>>'
SOFTWARE_HOME=r'<<SOFTWARE_HOME>>'
INSTANCE_HOME = r'<<INSTANCE_HOME>>'
ZEO_HOME = r'<<ZEO_HOME>>'
ZEO_RUN = r'%s\ZEO\runzeo.py' % SOFTWARE_HOME
CONFIG_FILE= os.path.join(INSTANCE_HOME, 'etc', 'zeo.conf')
PYTHONSERVICE_EXE=r'%s\bin\PythonService.exe' % ZEO_HOME
sys.path.insert(0, SOFTWARE_HOME)
from nt_svcutils import service
servicename = 'ZEO_%s' % str(hash(INSTANCE_HOME))
class InstanceService(service.Service):
start_cmd = '"%s" "%s" -C "%s"' % (PYTHON, ZEO_RUN, CONFIG_FILE)
_svc_name_ = servicename
_svc_display_name_ = 'ZEO instance at %s' % INSTANCE_HOME
_exe_name_ = PYTHONSERVICE_EXE
if __name__ == '__main__':
import win32serviceutil
win32serviceutil.HandleCommandLine(InstanceService)
# ZEO configuration file
%define INSTANCE_HOME <<INSTANCE_HOME>>
<zeo>
address 8100
read-only false
invalidation-queue-size 100
# monitor-address PORT
# transaction-timeout SECONDS
</zeo>
<filestorage 1>
path $INSTANCE_HOME\var\Data.fs
</filestorage>
<eventlog>
level info
<logfile>
path $INSTANCE_HOME\log\zeo.log
</logfile>
</eventlog>
# zeoctl configuration file
%define INSTANCE_HOME <<INSTANCE_HOME>>
%define SOFTWARE_HOME <<SOFTWARE_HOME>>
<runner>
program $INSTANCE_HOME/bin/runzeo
socket-name $INSTANCE_HOME/etc/zeo.zdsock
daemon true
forever false
backoff-limit 10
exit-codes 0, 2
directory $INSTANCE_HOME
default-to-interactive true
# user zope
python <<PYTHON>>
zdrun $SOFTWARE_HOME\ZEO\runzeo.py
# This logfile should match the one in the zeo.conf file.
# It is used by zdctl's logtail command, zdrun/zdctl doesn't write it.
logfile $INSTANCE_HOME\log\zeo.log
</runner>
<eventlog>
level info
<logfile>
path $INSTANCE_HOME\log\zeoctl.log
</logfile>
</eventlog>
This directory contains logfiles generated by a ZEO server.
This directory contains files related to a ZEO server instance such as database
files, lock files, and pid files.
#!/usr/bin/env python
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import compileall, os, sys
class Shutup:
def write(*args): pass # :)
class NoteErr:
wrote = 0
def write(self, *args):
self.wrote = 1
apply(stderr.write, args)
def compile_non_test(dir):
"""Byte-compile all modules except those in test directories."""
success = compileall.compile_dir(dir, maxlevels=0)
try:
names = os.listdir(dir)
except os.error:
print "Can't list", dir
names = []
names.sort()
for name in names:
fullname = os.path.join(dir, name)
if (name != os.curdir and name != os.pardir and
os.path.isdir(fullname) and not os.path.islink(fullname) and
name != 'test' and name != 'tests' and name != 'skins'):
success = success and compile_non_test(fullname)
return success
print
print '-'*78
print 'Compiling python modules'
stdout = sys.stdout
stderr = sys.stderr
try:
try:
success = 0
sys.stdout = Shutup()
sys.stderr = NoteErr()
success = compile_non_test(os.getcwd())
finally:
success = success and not sys.stderr.wrote
sys.stdout = stdout
sys.stderr = stderr
except:
success = 0
import traceback
traceback.print_exc()
if not success:
print
print '!' * 78
print 'There were errors during Python module compilation.'
print '!' * 78
print
sys.exit(1)
#! python
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""%(program)s: Create a target directory from a skeleton directory.
usage: %(program)s [options]
Options:
-h/--help -- print this help text
-s/--sourcedir -- the skeleton source directory
-t/--targetdir -- the directory to which the skeleton files will be copied
-u/--uid -- the username/uid of the user who will own the target files
-g/--gid -- the groupname/gid of the group who will own the target files
-r/--replace -- specify replacement value for .in file
This script may be used to install a custom Zope instance home
skeleton directory. It is most useful when used to install a skeleton
which does not follow the standard 'one-directory-as-instance-home'
paradigm used by the stock Zope source install.
The value of --targetdir should be the directory where you would like to copy
the skeleton hierarchy. For many packagers, this will be "/" or "/usr"
or "/usr/local".
The value of --sourcedir should be a directory which contains a custom skeleton
hierarchy. For many packagers, the skeleton source directory may contain
directories like "usr" and "bin" and these directories will contain files
and other directories, comprising an installation hierarchy suitable for your
platform.
The skeleton source hierarchy may contain any kind of file. Files
in the skeleton hierarchy that end with a ".in" extension will go through
textual substitution before they are placed in the target directory. When
they are placed in the target directory, the ".in" extension is removed.
Specify textual replacement values by passing one or more --replace= options
to the script. The value of each replace option needs to be
in the following format: --replace=key:value. 'key' is the value that
will be replaced (minus the "<<" and ">>" values expected by the
replacement). 'value' is the value that should be used for replacement.
Files which do not have an ".in" extension are copied without substitution.
All file mode bits from files/dirs in the skeleton source directory are copied
along with the file/directory itself. If the --uid and/or --gid flags are
used, all directories and files created by this script will be provided with
this owner and/or group. Otherwise, the uid and group owner of the files will
be the executing user's. Existing directory structures and files are left
unchanged. If a file already exists in the target directory, it is left
unchanged and the source file is not copied. If a directory already exists in
the target directory, its ownership information and mode bit settings are left
unchanged.
"""
import os
import shutil
import sys
import getopt
def main():
try:
opts, args = getopt.getopt(sys.argv[1:],
"hs:t:u:g:r:",
["help", "sourcedir=", "targetdir=", "uid=", "gid=",
"replace="]
)
except getopt.GetoptError, msg:
usage(sys.stderr, msg)
sys.exit(2)
script = os.path.abspath(sys.argv[0])
sourcedir = None
targetdir = None
uid = None
gid = None
replacements = {}
for opt, arg in opts:
if opt in ("-h", "--help"):
usage(sys.stdout)
sys.exit()
if opt in ("-s", "--sourcedir"):
sourcedir = os.path.abspath(os.path.expanduser(arg))
if not sourcedir:
usage(sys.stderr, "sourcedir must not be empty")
sys.exit(2)
if opt in ("-t", "--targetdir"):
targetdir = os.path.abspath(os.path.expanduser(arg))
if not targetdir:
usage(sys.stderr, "targetdir must not be empty")
sys.exit(2)
if opt in ("-u", "--uid"):
if not arg:
usage(sys.stderr, "uid must not be empty")
sys.exit(2)
try:
if os.getuid() != 0:
usage(sys.stderr, "You must be root to specify a uid")
sys.exit(2)
try:
uid = int(arg)
except:
try:
import pwd
uid = pwd.getpwnam(arg)[2]
if not gid:
gid = pwd.getpwnam(arg)[3]
except KeyError:
usage(sys.stderr,
"The user indicated by uid does not exist on "
"your system")
sys.exit(2)
except (ImportError, AttributeError):
usage(sys.stderr,
"Your system does not support the gid or uid options")
sys.exit(2)
if opt in ("-g", "--gid"):
if not arg:
usage(sys.stderr, "gid must not be empty")
sys.exit(2)
try:
if os.getuid() != 0:
usage(sys.stderr, "You must be root to specify a gid")
sys.exit(2)
try:
gid = int(arg)
except:
try:
import pwd
gid = pwd.getpwnam(arg)[3]
except KeyError:
usage(sys.stderr,
"The user indicated by gid does not exist on "
"your system")
sys.exit(2)
except (ImportError, AttributeError):
usage(sys.stderr,
"Your system does not support the gid or uid options")
sys.exit(2)
if opt in ("-r", "--replace"):
if not arg:
continue
k, v = arg.split(':', 1)
replacements[k] = v
if not sourcedir:
usage(sys.stderr, "Must specify sourcedir")
sys.exit(2)
if not targetdir:
usage(sys.stderr, "Must specify targetdir")
sys.exit(2)
copyskel(sourcedir, targetdir, uid, gid, **replacements)
def copyskel(sourcedir, targetdir, uid, gid, **replacements):
""" This is an independent function because we'd like to
import and call it from mkzopeinstance """
# Create the top of the instance:
if not os.path.exists(targetdir):
os.makedirs(targetdir)
# This is fairly ugly. The chdir() makes path manipulation in the
# walk() callback a little easier (less magical), so we'll live
# with it.
pwd = os.getcwd()
os.chdir(sourcedir)
try:
try:
os.path.walk(os.curdir, copydir,
(targetdir, replacements, uid, gid))
finally:
os.chdir(pwd)
except (IOError, OSError), msg:
print >>sys.stderr, msg
sys.exit(1)
CVS = os.path.normcase("CVS")
def copydir((targetdir, replacements, uid, gid), sourcedir, names):
# Don't recurse into CVS directories:
for name in names[:]:
if os.path.normcase(name) == CVS:
names.remove(name)
elif os.path.isfile(os.path.join(sourcedir, name)):
# Copy the file:
sn, ext = os.path.splitext(name)
if os.path.normcase(ext) == ".in":
dst = os.path.join(targetdir, sourcedir, sn)
if os.path.exists(dst):
continue
copyin(os.path.join(sourcedir, name), dst, replacements, uid,
gid)
if uid is not None:
os.chown(dst, uid, gid)
else:
src = os.path.join(sourcedir, name)
dst = os.path.join(targetdir, src)
if os.path.exists(dst):
continue
shutil.copyfile(src, dst)
shutil.copymode(src, dst)
if uid is not None:
os.chown(dst, uid, gid)
else:
# Directory:
dn = os.path.join(targetdir, sourcedir, name)
if not os.path.exists(dn):
os.mkdir(dn)
shutil.copymode(os.path.join(sourcedir, name), dn)
if uid is not None:
os.chown(dn, uid, gid)
def copyin(src, dst, replacements, uid, gid):
ifp = open(src)
text = ifp.read()
ifp.close()
for k in replacements:
text = text.replace("<<%s>>" % k, replacements[k])
ofp = open(dst, "w")
ofp.write(text)
ofp.close()
shutil.copymode(src, dst)
if uid is not None:
os.chown(dst, uid, gid)
def usage(stream, msg=None):
if msg:
print >>stream, msg
print >>stream
program = os.path.basename(sys.argv[0])
print >>stream, __doc__ % {"program": program}
if __name__ == '__main__':
main()
#!/usr/bin/env python
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import os
import sys
def main(dirname):
os.path.walk(dirname, rmpycs, None)
def rmpycs(arg, dirname, names):
for name in names:
path = os.path.join(dirname, name)
if ( name.endswith('.pyc') or name.endswith('.pyo') and
os.path.isfile(path) ):
os.unlink(path)
if __name__ == '__main__':
main(sys.argv[1])
#! python
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""%(program)s: Create a ZEO instance home.
usage: %(program)s [options]
Options:
-h/--help -- print this help text
-d/--dir -- the dir in which the instance home should be created
-u/--user NAME:PASSWORD -- set the user name and password of the initial user
-s/--skelsrc -- the dir from which skeleton files should be copied
When run without arguments, this script will ask for the information necessary
to create a ZEO instance home.
"""
import getopt
import os
import shutil
import sys
import copyskel
def main():
try:
opts, args = getopt.getopt(sys.argv[1:],
"hu:d:s:",
["help", "user=", "dir=", "skelsrc="]
)
except getopt.GetoptError, msg:
usage(sys.stderr, msg)
sys.exit(2)
script = os.path.abspath(sys.argv[0])
user = None
password = None
skeltarget = None
skelsrc = None
for opt, arg in opts:
if opt in ("-d", "--dir"):
skeltarget = os.path.abspath(os.path.expanduser(arg))
if not skeltarget:
usage(sys.stderr, "dir must not be empty")
sys.exit(2)
if opt in ("-s", "--skelsrc"):
skelsrc = os.path.abspath(os.path.expanduser(arg))
if not skelsrc:
usage(sys.stderr, "skelsrc must not be empty")
sys.exit(2)
if opt in ("-h", "--help"):
usage(sys.stdout)
sys.exit()
if not skeltarget:
# interactively ask for skeltarget and initial user name/passwd.
# cant set custom instancehome in interactive mode, we default
# to skeltarget.
skeltarget = instancehome = os.path.abspath(
os.path.expanduser(get_skeltarget())
)
instancehome = skeltarget
zeohome = os.path.dirname(os.path.dirname(script))
softwarehome = os.path.join(zeohome, "lib", "python")
if skelsrc is None:
# default to using stock ZEO skeleton source
skelsrc = os.path.join(zeohome, "skel")
inituser = os.path.join(instancehome, "inituser")
kw = {
"PYTHON": sys.executable,
"INSTANCE_HOME": instancehome,
"SOFTWARE_HOME": softwarehome,
"ZEO_HOME": zeohome,
}
copyskel.copyskel(skelsrc, skeltarget, None, None, **kw)
def usage(stream, msg=None):
if msg:
print >>stream, msg
print >>stream
program = os.path.basename(sys.argv[0])
print >>stream, __doc__ % {"program": program}
def get_skeltarget():
print 'Please choose a directory in which you\'d like to install'
print 'ZEO "instance home" files such as database files, configuration'
print 'files, etc.'
print
while 1:
skeltarget = raw_input("Directory: ").strip()
if skeltarget == '':
print 'You must specify a directory'
continue
else:
break
return skeltarget
if __name__ == "__main__":
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment