12 def __init__(self
, filename
):
13 self
.filename
= filename
14 f
= open(filename
, 'rb')
15 self
.content
= f
.read()
18 def modify(self
, key
, value
):
19 (self
.content
, count
) = re
.subn(
20 r
'(<parameter[^>]*\sname\s*=\s*"' + re
.escape(key
) + r
'"[^>]*\sdefault\s*=\s*")[^"]*',
26 f
= open(self
.filename
, 'w')
31 def pre_configure_hook(options
, bo
, env
):
32 location
= options
['location']
34 # TODO: double-check which one of these values must be set
35 # at instantiation time!
37 fm
= FileModifier('conf/Config.xml')
38 fm
.modify('apache_user', pwd
.getpwuid(os
.getuid())[0])
39 fm
.modify('apache_group', grp
.getgrgid(os
.getgid())[0])
40 mioga_base
= os
.path
.join(location
, 'var', 'lib', 'Mioga2')
41 fm
.modify('install_dir', mioga_base
)
42 fm
.modify('tmp_dir', os
.path
.join(mioga_base
, 'tmp'))
43 fm
.modify('search_tmp_dir', os
.path
.join(mioga_base
, 'mioga_search'))
44 fm
.modify('maildir', os
.path
.join(location
, 'var', 'spool', 'mioga', 'maildir'))
45 fm
.modify('maildirerror', os
.path
.join(location
, 'var', 'spool', 'mioga', 'error'))
46 fm
.modify('mailfifo', os
.path
.join(location
, 'var', 'spool', 'mioga', 'fifo'))
49 # TODO: mail settings are certainly wrong, what is the domain name?
51 # Correct shebangs to the right Perl
52 for root
, dirnames
, filenames
in os
.walk('.'):
53 for filename
in fnmatch
.filter(filenames
, '*.pl'):
54 with
open(os
.path
.join(root
, filename
), "r+") as f
:
56 (lines
[0], count
) = re
.subn(r
'^#!/usr/bin/perl',
57 '#!' + options
['perl-binary'],
62 print "Corrected interpreter for script "+filename
66 # def post_make_hook(options, buildout):
67 # location = options['location']
68 # print "Mioga - postmakehook"
69 # print "We are currently in", os.getcwd()
70 # shutil.move("var", location)