Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
slapos
Commits
345114c0
Commit
345114c0
authored
Dec 07, 2012
by
Viktor Horvath
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Makefile separation: fix errors when an empty database "mioga2" exists (with or without tables).
parent
a0000542
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
30 deletions
+87
-30
software/mioga/mioga-patch
software/mioga/mioga-patch
+87
-30
No files found.
software/mioga/mioga-patch
View file @
345114c0
...
@@ -12,7 +12,7 @@ index ef0f369..b275a48 100644
...
@@ -12,7 +12,7 @@ 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..
80ea444
100644
index 3582d20..
c24e217
100644
--- a/Makefile.PL
--- a/Makefile.PL
+++ b/Makefile.PL
+++ b/Makefile.PL
@@ -20,8 +20,10 @@
@@ -20,8 +20,10 @@
...
@@ -83,16 +83,16 @@ index 3582d20..80ea444 100644
...
@@ -83,16 +83,16 @@ index 3582d20..80ea444 100644
+ # 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 \
+ cp -R --parents \
+ Makefile.PL sql web/conf conf bin/search/crawl_sample.sh \
+ Makefile.PL sql web/conf
web/skel
conf bin/search/crawl_sample.sh \
+ "$(MIOGA_BUILDINST)"
+ "$(MIOGA_BUILDINST)"
+
+
+slapos-instantiation ::
+slapos-instantiation ::
+ rm -Rf web/conf/apache; (cd web/conf && $(MAKE) apache)
+
+ for i in web/conf conf web/skel sql ; \
+ for i in web/conf conf web/skel sql ; \
+ do \
+ do \
+ (cd $$i && $(MAKE) install) || exit 1;\
+ (cd $$i && $(MAKE) install) || exit 1;\
+ done
+ done
+
+ (cd web && $(MAKE) setperms) || exit 1;
+
+
doc:
doc:
for i in ' . $docsubdirs . ' ; \
for i in ' . $docsubdirs . ' ; \
...
@@ -320,21 +320,44 @@ index 4afa54b..ca8368c 100644
...
@@ -320,21 +320,44 @@ index 4afa54b..ca8368c 100644
$self->{dbh} = DBI->connect($datasource, $dbiUser, $dbiPassword);
$self->{dbh} = DBI->connect($datasource, $dbiUser, $dbiPassword);
diff --git a/lib/Mioga2/Exception/DB.pm b/lib/Mioga2/Exception/DB.pm
diff --git a/lib/Mioga2/Exception/DB.pm b/lib/Mioga2/Exception/DB.pm
index 7ce5020..
bee00ca
100644
index 7ce5020..
dd29d83
100644
--- a/lib/Mioga2/Exception/DB.pm
--- a/lib/Mioga2/Exception/DB.pm
+++ b/lib/Mioga2/Exception/DB.pm
+++ b/lib/Mioga2/Exception/DB.pm
@@ -76,6 +76,17 @@
sub as_string
@@ -1,3 +1,4 @@
+
# ============================================================================
# Mioga2 Project (C) 2003-2007 The Mioga2 Project
#
@@ -53,6 +54,7 @@
sub new {
my($class, $function, $errDB, $errStr, $sql) = @_;
my $self = $class->SUPER::new(-text => "$errStr : $errDB");
$self->{errDB} = $errDB;
+ $self->{errStr} = $errStr;
$self->{sql} = $sql;
$self->{function} = $function;
return $self;
@@ -76,6 +78,27 @@
sub as_string
return $string;
return $string;
}
}
+# ----------------------------------------------------------------------------
+# ----------------------------------------------------------------------------
+=head2 getDBerror ()
+=head2 getDBerr ()
+Return the error as sent by the database connector.
+Return the error code as sent by the database connector.
+=cut
+# ----------------------------------------------------------------------------
+sub getDBerr {
+ my ($self) = @_;
+ return $self->{errDB};
+}
+
+# ----------------------------------------------------------------------------
+=head2 getDBerrstr ()
+Return the error string as sent by the database connector.
+=cut
+=cut
+# ----------------------------------------------------------------------------
+# ----------------------------------------------------------------------------
+sub getDBerr
o
r {
+sub getDBerr
st
r {
+ my ($self) = @_;
+ my ($self) = @_;
+ return $self->{err
DB}
+ return $self->{err
Str};
+}
+}
+
+
+
+
...
@@ -514,21 +537,17 @@ index 0870174..bbcc80a 100644
...
@@ -514,21 +537,17 @@ index 0870174..bbcc80a 100644
foreach my $dep (@{$self->{CONFIG}->{dependencies}->[0]->{clib}}) {
foreach my $dep (@{$self->{CONFIG}->{dependencies}->[0]->{clib}}) {
my $version;
my $version;
diff --git a/sql/Makefile b/sql/Makefile
diff --git a/sql/Makefile b/sql/Makefile
index 07b26f5..
f6b6c0f
100644
index 07b26f5..
63b7d0c
100644
--- a/sql/Makefile
--- a/sql/Makefile
+++ b/sql/Makefile
+++ b/sql/Makefile
@@ -1,4 +1,5 @@
@@ -15,19 +15,22 @@
install:
include ../config.mk
+DB_STATE=`perl -w testdb.pl`
all:
@@ -15,19 +16,20 @@
install:
cp upgradeMiogletDesc.pl $(DESTDIR)$(INSTALL_DIR)/conf/Config.hook.d
cp upgradeMiogletDesc.pl $(DESTDIR)$(INSTALL_DIR)/conf/Config.hook.d
chmod a+x $(DESTDIR)$(INSTALL_DIR)/conf/Config.hook.d/upgradeMiogletDesc.pl
chmod a+x $(DESTDIR)$(INSTALL_DIR)/conf/Config.hook.d/upgradeMiogletDesc.pl
- if [ $(INIT_SQL) = 'yes' ] ; \
- if [ $(INIT_SQL) = 'yes' ] ; \
+ if [ $(DB_STATE) = 'nodb' ] ; \
+ DB_STATE=`perl -w testdb.pl`; \
+ echo "VHH DEBUG: Makefile got DB_STATE '$$DB_STATE'"; \
+ if [ "$$DB_STATE" = "nodb" -o "$$DB_STATE" = "empty" ] ; \
then \
then \
echo "Initialize database"; \
echo "Initialize database"; \
- su - $(POSTGRES_USER) -c "dropdb $(DB_NAME)" ; \
- su - $(POSTGRES_USER) -c "dropdb $(DB_NAME)" ; \
...
@@ -540,10 +559,10 @@ index 07b26f5..f6b6c0f 100644
...
@@ -540,10 +559,10 @@ index 07b26f5..f6b6c0f 100644
+ createdb --encoding UTF8 -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 && \
+ psql -h $(DB_HOST) -p $(DB_PORT) -U $(DBI_LOGIN) $(DB_NAME) < create_lang.sql && \
+ perl -w -I../lib initdb.pl force_init_sql=1; \
+ perl -w -I../lib initdb.pl force_init_sql=1; \
+ elif [
$(DB_STATE) = 'present'
]; then \
+ elif [
"$$DB_STATE" = "present"
]; then \
echo "Update database"; \
echo "Update database"; \
perl -w -I../lib updatedb.pl configxml=$(DESTDIR)$(INSTALL_DIR)/conf/Config.xml; \
perl -w -I../lib updatedb.pl configxml=$(DESTDIR)$(INSTALL_DIR)/conf/Config.xml; \
+ elif [
$(DB_STATE) = 'noserver'
]; then \
+ elif [
"$$DB_STATE" = "noserver"
]; then \
+ echo "ERROR: Cannot connect to the database server!"; \
+ echo "ERROR: Cannot connect to the database server!"; \
fi
fi
...
@@ -579,15 +598,16 @@ index b7d8cc2..88d5e2d 100644
...
@@ -579,15 +598,16 @@ index b7d8cc2..88d5e2d 100644
-- Add referencial integrity on default_profile_id in m_group_base
-- Add referencial integrity on default_profile_id in m_group_base
diff --git a/sql/testdb.pl b/sql/testdb.pl
diff --git a/sql/testdb.pl b/sql/testdb.pl
new file mode 100755
new file mode 100755
index 0000000..
2fa3fe7
index 0000000..
cfbff33
--- /dev/null
--- /dev/null
+++ b/sql/testdb.pl
+++ b/sql/testdb.pl
@@ -0,0 +1,
37
@@
@@ -0,0 +1,
75
@@
+#!/usr/bin/perl -w
+#!/usr/bin/perl -w
+
+
+# Tests the availability of the Mioga2 database.
+# Tests the availability of the Mioga2 database.
+# Returns on stdout one of:
+# Returns on stdout one of:
+# 'present' - The Mioga2 database has been found.
+# 'present' - The Mioga2 database has been found and contains data.
+# 'empty' - The Mioga2 database exists but the table "m_mioga" is empty or nonexistent.
+# 'nodb' - There is no Mioga2 database but the database server is working fine
+# 'nodb' - There is no Mioga2 database but the database server is working fine
+# (i.e. one can try to create the database)
+# (i.e. one can try to create the database)
+# 'noserver' - Connection to the database server failed.
+# 'noserver' - Connection to the database server failed.
...
@@ -599,6 +619,7 @@ index 0000000..2fa3fe7
...
@@ -599,6 +619,7 @@ index 0000000..2fa3fe7
+use lib "../lib";
+use lib "../lib";
+
+
+use Data::Dumper;
+use Data::Dumper;
+use DBI;
+use Error qw(:try);
+use Error qw(:try);
+use Mioga2::Exception::DB;
+use Mioga2::Exception::DB;
+use Mioga2::MiogaConf;
+use Mioga2::MiogaConf;
...
@@ -607,19 +628,55 @@ index 0000000..2fa3fe7
...
@@ -607,19 +628,55 @@ index 0000000..2fa3fe7
+# my $configxml = "../conf/Config.xml";
+# my $configxml = "../conf/Config.xml";
+my $miogaconf = "../web/conf/Mioga.conf";
+my $miogaconf = "../web/conf/Mioga.conf";
+
+
+print STDERR "VHH DEBUG: Starting testdb.pl\n";
+my $result = 'undefined';
+try {
+try {
+ print STDERR "VHH DEBUG: creating MiogaConf object...\n";
+ my $config = new Mioga2::MiogaConf($miogaconf);
+ my $config = new Mioga2::MiogaConf($miogaconf);
+ print 'present';
+ print STDERR "VHH DEBUG: created MiogaConf\n";
+ my $dbh = $config->GetDBH();
+ print STDERR "VHH DEBUG: got dbh\n";
+ my $sql = 'SELECT COUNT(*) FROM m_mioga';
+ my $sth = $dbh->prepare($sql);
+ print STDERR "VHH DEBUG: prepared statement\n";
+ my $exec_result = $sth->execute();
+ print STDERR "VHH DEBUG: executed statement\n";
+ if (not defined($exec_result)) {
+ throw Mioga2::Exception::DB("testdb.pl 0", $sth->err, $sth->errstr, $sql);
+ }
+ my $res = $sth->fetchrow_arrayref();
+ if (not defined($res)) {
+ throw Mioga2::Exception::DB("testdb.pl 1", $sth->err, $sth->errstr, $sql);
+ }
+ my $count = $res->[0];
+ print STDERR "VHH DEBUG: got count\n";
+ if (not defined($count)) {
+ throw Mioga2::Exception::DB("testdb.pl 2", $sth->err, $sth->errstr, $sql);
+ } elsif ($count == 0) {
+ $result = 'empty';
+ } else {
+ $result = 'present';
+ }
+} catch Mioga2::Exception::DB with {
+} catch Mioga2::Exception::DB with {
+ my $err = shift;
+ my $err = shift;
+ if ($err->getDBerror() =~ m#database "mioga2" does not exist#) {
+ my $errstr = $err->getDBerrstr();
+ print 'nodb';
+ print STDERR "VHH DEBUG: got exception...\n";
+ print STDERR "VHH DEBUG: got error string: ".$err->as_string()."\n";
+ if ($errstr =~ m#database "mioga2" does not exist#) {
+ $result = 'nodb';
+ } elsif ($errstr =~ m#relation "m_mioga" does not exist#) {
+ $result = 'empty';
+ } else {
+ } else {
+
print
'noserver';
+
$result =
'noserver';
+ }
+ }
+} otherwise {
+} otherwise {
+ print 'noserver';
+ my $err = shift;
+}
+ print STDERR "VHH DEBUG: got other exception: $err\n";
+ $result = 'noserver';
+};
+
+print $result;
+print STDERR "VHH DEBUG: result = ".$result."\n";
diff --git a/web/Makefile b/web/Makefile
diff --git a/web/Makefile b/web/Makefile
index 66af45f..9649a02 100644
index 66af45f..9649a02 100644
--- a/web/Makefile
--- a/web/Makefile
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment