Commit 5d42da92 authored by Viktor Horvath's avatar Viktor Horvath

Makefiles partially working (createdb, dropdb, psql)

but no Perl DBI yet.
parent 85676999
......@@ -28,6 +28,7 @@
import os
import pprint
import re
import stat
import subprocess
from slapos.recipe.librecipe import GenericBaseRecipe
......@@ -62,35 +63,39 @@ class Recipe(GenericBaseRecipe):
fm.modify('dbi_passwd', self.options['db_password'])
fm.modify('db_host', self.options['db_host'])
fm.modify('db_port', self.options['db_port'])
# TODO: Mioga must be able to use an external Postgres server! IPv6 address!
# db_name, dbi_login are standard
fm.save()
os.remove("config.mk") # otherwise we don't see the values in the Makefiles
if os.path.isfile("config.mk"):
os.remove("config.mk") # otherwise we don't see the values in the Makefiles
environ = os.environ
environ['PATH'] = self.options['mioga_add_to_path'] + ':' + environ['PATH']
environ['PATH'] = ':'.join([self.options['perl_bin'], # priority!
self.options['mioga_add_to_path'],
self.options['postgres_bin'],
environ['PATH'] ])
# Write the Postgres password file
pgpassfilepath = os.path.join(self.options['instance_root'], '.pgpass')
pgpassfile = open(pgpassfilepath, 'w')
pgpassfile.write(':'.join([re.sub(r':', r'\:', self.options['db_host']),
self.options['db_port'],
'*', # could be self.options['db_dbname'] or 'postgres'
self.options['db_username'],
self.options['db_password'] ]) + "\n")
pgpassfile.close()
os.chmod(pgpassfilepath, stat.S_IRUSR | stat.S_IWUSR)
environ['PGPASSFILE'] = pgpassfilepath
# environ = self.options['mioga_compile_env']
print pprint.pformat(environ)
# We must call "make installall" in the SAME environment that
# "perl Makefile.PL" left!
cmd = subprocess.Popen(self.options['perl_binary'] + ' Makefile.PL'
cmd = subprocess.Popen(self.options['perl_bin'] + '/perl Makefile.PL'
+ ' && make installall',
env=environ, shell=True)
cmd.communicate()
# cmd_configure = subprocess.Popen([ self.options['perl_binary'],
# 'Makefile.PL' ],
# env=environ)
# cmd_configure.communicate()
# if cmd_configure.returncode == 0:
# # TODO: no "make" on SlapOS ?
# cmd_make = subprocess.Popen(['make', 'installall'],
# env=environ)
# cmd_make.communicate()
# else:
# print "Mioga instantiate.py::install: Configure failed."
os.chdir(former_directory)
print "Mioga instantiate.py::install finished!"
......
......@@ -75,7 +75,9 @@ mioga_compile_dir = ${template-apacheperl:compile-directory}
# mioga_compile_env = ${mioga:environment}
mioga_add_to_path = ${libxslt:location}/bin:${libxml2:location}/bin
var_directory = $${rootdirectory:var}
perl_binary = ${perl:location}/bin/perl
instance_root = $${buildout:directory}
perl_bin = ${perl:location}/bin
postgres_bin = ${postgresql:location}/bin
htdocs = $${apacheperl-instance:htdocs}
db_host = $${postgres-urlparse:host}
db_port = $${postgres-urlparse:port}
......
diff -r c0f4c1b8b448 Makefile.PL
--- a/Makefile.PL Sat Oct 06 16:15:43 2012 +0200
+++ b/Makefile.PL Tue Oct 09 16:40:31 2012 +0200
+++ b/Makefile.PL Wed Oct 10 01:19:50 2012 +0200
@@ -115,7 +115,7 @@
# ----------------------------------------------------------------------------
sub MY::processPL {
......@@ -24,7 +24,7 @@ diff -r c0f4c1b8b448 Makefile.PL
fi \
diff -r c0f4c1b8b448 conf/Config.xml
--- a/conf/Config.xml Sat Oct 06 16:15:43 2012 +0200
+++ b/conf/Config.xml Tue Oct 09 16:40:31 2012 +0200
+++ b/conf/Config.xml Wed Oct 10 01:19:50 2012 +0200
@@ -37,6 +37,12 @@
xpath="/authentication"/>
......@@ -40,7 +40,7 @@ diff -r c0f4c1b8b448 conf/Config.xml
xpath="/database/DBname"/>
diff -r c0f4c1b8b448 lib/MiogaConf.pm
--- a/lib/MiogaConf.pm Sat Oct 06 16:15:43 2012 +0200
+++ b/lib/MiogaConf.pm Tue Oct 09 16:40:31 2012 +0200
+++ b/lib/MiogaConf.pm Wed Oct 10 01:19:50 2012 +0200
@@ -811,6 +811,10 @@
my @missing;
my @missing_clib;
......@@ -62,12 +62,17 @@ diff -r c0f4c1b8b448 lib/MiogaConf.pm
my $version;
diff -r c0f4c1b8b448 sql/Makefile
--- a/sql/Makefile Sat Oct 06 16:15:43 2012 +0200
+++ b/sql/Makefile Tue Oct 09 16:40:31 2012 +0200
@@ -18,6 +18,7 @@
+++ b/sql/Makefile Wed Oct 10 01:19:50 2012 +0200
@@ -18,9 +18,9 @@
if [ $(INIT_SQL) = 'yes' ] ; \
then \
echo "Initialize database"; \
+ echo "Database server will be: $(DBI_LOGIN) on $(DB_HOST) : $(DB_PORT)" \
su - $(POSTGRES_USER) -c "dropdb $(DB_NAME)" ; \
su - $(POSTGRES_USER) -c "createdb --encoding UTF8 $(DB_NAME)" && \
su $(POSTGRES_USER) -c "psql $(DB_NAME) < create_lang.sql" && \
- su - $(POSTGRES_USER) -c "dropdb $(DB_NAME)" ; \
- su - $(POSTGRES_USER) -c "createdb --encoding UTF8 $(DB_NAME)" && \
- su $(POSTGRES_USER) -c "psql $(DB_NAME) < create_lang.sql" && \
+ dropdb -h $(DB_HOST) -p $(DB_PORT) -U $(DBI_LOGIN) $(DB_NAME) ; \
+ createdb --encoding UTF8 -h $(DB_HOST) -p $(DB_PORT) -U $(DBI_LOGIN) $(DB_NAME) && \
+ psql -h $(DB_HOST) -p $(DB_PORT) -U $(DBI_LOGIN) $(DB_NAME) < create_lang.sql && \
perl -w -I../lib initdb.pl ; \
elif [ $(INIT_SQL) != 'noupdate' ]; then \
echo "Update database"; \
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