Commit 9278d2c2 authored by Viktor Horvath's avatar Viktor Horvath

Makefile separation : instantiation part (work in progress)

parent deabf912
...@@ -54,15 +54,14 @@ class Recipe(GenericBaseRecipe): ...@@ -54,15 +54,14 @@ class Recipe(GenericBaseRecipe):
self.instantiate(False) self.instantiate(False)
def instantiate(self, isNewInstall): def instantiate(self, isNewInstall):
print "This is the Mioga recipe" # Copy the build/ and var/lib/Mioga2 folders into the instance
print "Looking for compile folder:" mioga_location = self.options['mioga_location']
print self.options['mioga_compile_dir'] var_dir = self.options['var_directory']
if not os.path.exists(var_dir):
shutil.copytree(os.path.join(mioga_location, 'var'), var_dir, True)
# TODO: this will only work for a SINGLE instance in the Slaprunner.
# In a real environment we cannot mess around with the compile directory
# like that.
former_directory = os.getcwd() former_directory = os.getcwd()
os.chdir(self.options['mioga_compile_dir']) os.chdir(self.options['mioga_buildinst'])
vardir = self.options['var_directory'] vardir = self.options['var_directory']
mioga_base = os.path.join(vardir, 'lib', 'Mioga2') mioga_base = os.path.join(vardir, 'lib', 'Mioga2')
...@@ -91,12 +90,15 @@ class Recipe(GenericBaseRecipe): ...@@ -91,12 +90,15 @@ class Recipe(GenericBaseRecipe):
if os.path.isdir('web/conf/apache'): if os.path.isdir('web/conf/apache'):
shutil.rmtree('web/conf/apache') shutil.rmtree('web/conf/apache')
for key in self.options.keys():
print "Found option: "+key
environ = os.environ environ = os.environ
environ['PATH'] = ':'.join([self.options['perl_bin'], # priority! environ['PATH'] = ':'.join([self.options['perl_bin'], # priority!
# Mioga scripts in Makefiles and shell scripts # Mioga scripts in Makefiles and shell scripts
self.options['bin_dir'], self.options['bin_dir'],
self.options['mioga_add_to_path'], self.options['libxslt_bin'],
self.options['libxml2_bin'],
self.options['postgres_bin'], self.options['postgres_bin'],
environ['PATH'] ]) environ['PATH'] ])
...@@ -115,7 +117,7 @@ class Recipe(GenericBaseRecipe): ...@@ -115,7 +117,7 @@ class Recipe(GenericBaseRecipe):
# environ = self.options['mioga_compile_env'] # environ = self.options['mioga_compile_env']
print pprint.pformat(environ) print pprint.pformat(environ)
# We must call "make installall" in the SAME environment that # We must call "make" in the SAME environment that
# "perl Makefile.PL" left! # "perl Makefile.PL" left!
cmd = subprocess.Popen(self.options['perl_bin'] + '/perl Makefile.PL disable_check' cmd = subprocess.Popen(self.options['perl_bin'] + '/perl Makefile.PL disable_check'
...@@ -211,11 +213,12 @@ Include conf/extra/httpd-autoindex.conf ...@@ -211,11 +213,12 @@ Include conf/extra/httpd-autoindex.conf
else: else:
os.mkfifo(fifo, 0600) os.mkfifo(fifo, 0600)
site_perl_bin = os.path.join(self.options['site_perl'], 'bin')
mioga_conf_path = os.path.join(mioga_base, 'conf', 'Mioga.conf') mioga_conf_path = os.path.join(mioga_base, 'conf', 'Mioga.conf')
notifier_wrapper = self.createPythonScript( notifier_wrapper = self.createPythonScript(
os.path.join(services_dir, 'notifier'), os.path.join(services_dir, 'notifier'),
'slapos.recipe.librecipe.execute.execute', 'slapos.recipe.librecipe.execute.execute',
[ os.path.join(self.options['mioga_compile_dir'], 'bin', 'notifier', 'notifier.pl'), [ os.path.join(site_perl_bin, 'notifier.pl'),
mioga_conf_path ] mioga_conf_path ]
) )
path_list.append(notifier_wrapper) path_list.append(notifier_wrapper)
...@@ -223,18 +226,17 @@ Include conf/extra/httpd-autoindex.conf ...@@ -223,18 +226,17 @@ Include conf/extra/httpd-autoindex.conf
searchengine_wrapper = self.createPythonScript( searchengine_wrapper = self.createPythonScript(
os.path.join(services_dir, 'searchengine'), os.path.join(services_dir, 'searchengine'),
'slapos.recipe.librecipe.execute.execute', 'slapos.recipe.librecipe.execute.execute',
[ os.path.join(self.options['mioga_compile_dir'], 'bin', 'notifier', 'searchengine.pl'), [ os.path.join(site_perl_bin, 'searchengine.pl'),
mioga_conf_path ] mioga_conf_path ]
) )
path_list.append(searchengine_wrapper) path_list.append(searchengine_wrapper)
crawl_fm = FileModifier( crawl_fm = FileModifier( os.path.join('bin', 'search', 'crawl_sample.sh') )
os.path.join(self.options['mioga_compile_dir'], 'bin', 'search', 'crawl_sample.sh') )
# TODO: The crawl script will still call the shell command "date" # TODO: The crawl script will still call the shell command "date"
crawl_fm.modify(r'/var/tmp/crawl', self.options['log_dir'] + '/crawl') crawl_fm.modify(r'/var/tmp/crawl', self.options['log_dir'] + '/crawl')
crawl_fm.modify(r'/var/lib/Mioga2/conf', mioga_base + '/conf') crawl_fm.modify(r'/var/lib/Mioga2/conf', mioga_base + '/conf')
crawl_fm.modify(r'/usr/local/bin/(mioga2_(?:info|crawl|index).pl)', crawl_fm.modify(r'/usr/local/bin/(mioga2_(?:info|crawl|index).pl)',
self.options['site_perl'] + '/bin/' + r"\g<1>") site_perl_bin + r"/\g<1>")
crawl_path = os.path.join(self.options['bin_dir'], 'crawl.sh') crawl_path = os.path.join(self.options['bin_dir'], 'crawl.sh')
crawl_fm.save(crawl_path) crawl_fm.save(crawl_path)
os.chmod(crawl_path, stat.S_IRWXU) os.chmod(crawl_path, stat.S_IRWXU)
......
...@@ -16,7 +16,6 @@ bin = $${buildout:directory}/bin ...@@ -16,7 +16,6 @@ bin = $${buildout:directory}/bin
etc = $${buildout:directory}/etc etc = $${buildout:directory}/etc
srv = $${buildout:directory}/srv srv = $${buildout:directory}/srv
log = $${buildout:directory}/log log = $${buildout:directory}/log
var = $${buildout:directory}/var
[basedirectory] [basedirectory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
...@@ -80,11 +79,14 @@ symlink_base = ${postgresql:location}/bin ...@@ -80,11 +79,14 @@ symlink_base = ${postgresql:location}/bin
[mioga-instance] [mioga-instance]
recipe = slapos.cookbook:mioga.instantiate recipe = slapos.cookbook:mioga.instantiate
mioga_compile_dir = ${template-apacheperl:compile-directory} # mioga_compile_dir = ${template-apacheperl:compile-directory}
# Pity that the following line does not work. Or does it? # Pity that the following line does not work. Or does it?
# mioga_compile_env = ${mioga:environment} # mioga_compile_env = ${mioga:environment}
mioga_add_to_path = ${libxslt:location}/bin:${libxml2:location}/bin mioga_location = ${mioga:location}
var_directory = $${rootdirectory:var} mioga_buildinst = ${mioga:buildinst}
libxslt_bin = ${libxslt:location}/bin
libxml2_bin = ${libxml2:location}/bin
var_directory = $${buildout:directory}/var
instance_root = $${buildout:directory} instance_root = $${buildout:directory}
perl_bin = ${perl:location}/bin perl_bin = ${perl:location}/bin
postgres_bin = ${postgresql:location}/bin postgres_bin = ${postgresql:location}/bin
...@@ -103,7 +105,7 @@ htdocs = $${basedirectory:htdocs} ...@@ -103,7 +105,7 @@ htdocs = $${basedirectory:htdocs}
httpd_conf = $${rootdirectory:etc}/httpd.conf httpd_conf = $${rootdirectory:etc}/httpd.conf
pid_file = $${basedirectory:services}/apache.pid pid_file = $${basedirectory:services}/apache.pid
lock_file = $${basedirectory:services}/apache.lock lock_file = $${basedirectory:services}/apache.lock
dav_locks = $${rootdirectory:var}/dav_locks dav_locks = $${buildout:directory}/var/dav_locks
services_dir = $${basedirectory:services} services_dir = $${basedirectory:services}
error_log = $${rootdirectory:log}/error.log error_log = $${rootdirectory:log}/error.log
access_log = $${rootdirectory:log}/access.log access_log = $${rootdirectory:log}/access.log
......
...@@ -12,10 +12,36 @@ index ef0f369..b275a48 100644 ...@@ -12,10 +12,36 @@ index ef0f369..b275a48 100644
This script must be run by cron in a day basis with apache user (www-data for Debian) This script must be run by cron in a day basis with apache user (www-data for Debian)
diff --git a/Makefile.PL b/Makefile.PL diff --git a/Makefile.PL b/Makefile.PL
index 3582d20..0d9ef77 100644 index 3582d20..262e2c2 100644
--- a/Makefile.PL --- a/Makefile.PL
+++ b/Makefile.PL +++ b/Makefile.PL
@@ -115,7 +115,7 @@ my $docsubdirs = "docs"; @@ -22,6 +22,7 @@
use ExtUtils::MakeMaker;
use ExtUtils::MakeMaker::Config;
+use File::Find;
# ****************************************************************************
#
@@ -67,6 +68,7 @@ sub CheckPreDepends {
my $disable_check = grep {lc($_) eq 'disable_check'} @ARGV;
+if (! $disable_check) {
CheckPreDepends({ # 'Data::Dumper' => '2.101',
# 'DBI' => '1.13',
# 'DBD::Pg' => '1.01',
@@ -75,7 +77,8 @@ CheckPreDepends({ # 'Data::Dumper' => '2.101',
'Error' => '0.15',
# 'Net::LDAP' => '0.25',
# 'Unicode::String' => '2.06',
- });
+ })
+}
require MiogaConf;
@@ -115,7 +118,7 @@ my $docsubdirs = "docs";
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
sub MY::processPL { sub MY::processPL {
return ' return '
...@@ -24,7 +50,7 @@ index 3582d20..0d9ef77 100644 ...@@ -24,7 +50,7 @@ index 3582d20..0d9ef77 100644
# between "all" and next "tardist" # between "all" and next "tardist"
include config.mk include config.mk
@@ -124,10 +124,7 @@ tardist: doc @@ -124,10 +127,7 @@ tardist: doc
dist: doc dist: doc
install :: install ::
if test -e $(TMP_DIR) ; then \ if test -e $(TMP_DIR) ; then \
...@@ -36,7 +62,7 @@ index 3582d20..0d9ef77 100644 ...@@ -36,7 +62,7 @@ index 3582d20..0d9ef77 100644
echo "===> File $(TMP_DIR) exists but is not a directory ..." ; \ echo "===> File $(TMP_DIR) exists but is not a directory ..." ; \
exit 1 ; \ exit 1 ; \
fi \ fi \
@@ -156,6 +153,29 @@ install-all :: @@ -156,6 +156,31 @@ install-all ::
(cd web && $(MAKE) setperms) || exit 1; (cd web && $(MAKE) setperms) || exit 1;
...@@ -53,7 +79,9 @@ index 3582d20..0d9ef77 100644 ...@@ -53,7 +79,9 @@ index 3582d20..0d9ef77 100644
+ done + done
+ # copy a minimal build system into mioga/build + # copy a minimal build system into mioga/build
+ mkdir -p "$(MIOGA_BUILDINST)" + mkdir -p "$(MIOGA_BUILDINST)"
+ cp -R --parents Makefile.PL sql web/conf conf "$(MIOGA_BUILDINST)" + cp -R --parents \
+ Makefile.PL sql web/conf conf bin/search/crawl_sample.sh \
+ "$(MIOGA_BUILDINST)"
+ +
+slapos-instantiation :: +slapos-instantiation ::
+ for i in web/conf conf sql ; \ + for i in web/conf conf sql ; \
...@@ -66,6 +94,25 @@ index 3582d20..0d9ef77 100644 ...@@ -66,6 +94,25 @@ index 3582d20..0d9ef77 100644
doc: doc:
for i in ' . $docsubdirs . ' ; \ for i in ' . $docsubdirs . ' ; \
do \ do \
@@ -176,9 +201,17 @@ installall: install install-all
#
# ----------------------------------------------------------------------------
+my $Mioga2_pm = 'lib/Mioga2.pm';
+if ((not -e $lib_Mioga2_pm) and exists($ENV{MIOGA_SITEPERL})) {
+ my $findfile = sub {
+ $Mioga2_pm = $File::Find::name if $_ eq 'Mioga2.pm';
+ };
+ find($findfile, $ENV{MIOGA_SITEPERL});
+};
+
WriteMakefile(
'NAME' => 'Mioga',
'DIR' => ['bin', 'web', 'locales', 'docs', 'sql'],
- 'VERSION_FROM' => 'lib/Mioga2.pm',
+ 'VERSION_FROM' => $Mioga2_pm,
);
diff --git a/bin/mailinglist/miogamailinglist.pl b/bin/mailinglist/miogamailinglist.pl diff --git a/bin/mailinglist/miogamailinglist.pl b/bin/mailinglist/miogamailinglist.pl
index 80668e2..fa1603a 100755 index 80668e2..fa1603a 100755
--- a/bin/mailinglist/miogamailinglist.pl --- a/bin/mailinglist/miogamailinglist.pl
......
...@@ -102,6 +102,7 @@ environment = ...@@ -102,6 +102,7 @@ environment =
MIOGA_BASE=${mioga:location} MIOGA_BASE=${mioga:location}
MIOGA_BUILDINST=${mioga:buildinst} MIOGA_BUILDINST=${mioga:buildinst}
MIOGA_STATIC=${mioga:static} MIOGA_STATIC=${mioga:static}
MIOGA_SITEPERL=${perl:siteprefix}
PATH=${libxslt:location}/bin:${libxml2:location}/bin:${perl:location}/bin:${perl:siteprefix}/bin:%(PATH)s PATH=${libxslt:location}/bin:${libxml2:location}/bin:${perl:location}/bin:${perl:siteprefix}/bin:%(PATH)s
patch-options = -p1 patch-options = -p1
patches = patches =
......
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