[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[6328] trunk



Revision: 6328
          http://sourceforge.net/p/ledger-smb/code/6328
Author:   ehuelsmann
Date:     2014-01-01 14:50:50 +0000 (Wed, 01 Jan 2014)
Log Message:
-----------
Refactor setup; eliminate PG_CONTRIB_DIR.

Modified Paths:
--------------
    trunk/LedgerSMB/Database.pm
    trunk/LedgerSMB/Scripts/setup.pm
    trunk/LedgerSMB/Sysconfig.pm
    trunk/README.tests
    trunk/install_interactive.pl
    trunk/ledgersmb.conf.default
    trunk/t/40-dbsetup.t
    trunk/t/89-dropdb.t
    trunk/tools/dbsetup.pl
    trunk/tools/prepare-company-database.pl

Modified: trunk/LedgerSMB/Database.pm
===================================================================
--- trunk/LedgerSMB/Database.pm	2014-01-01 14:37:08 UTC (rev 6327)
+++ trunk/LedgerSMB/Database.pm	2014-01-01 14:50:50 UTC (rev 6328)
@@ -79,6 +79,22 @@
     return $self;
 }
 
+=item dbh
+
+This routine returns a DBI database handle
+
+=cut
+
+sub dbh {
+    my ($self) = @_;
+    my $creds = LedgerSMB::Auth::get_credentials();
+    return DBI->connect(
+        "dbi:Pg:dbname=$self->{company_name}",
+	"$creds->{login}", "$creds->{password}",
+	{ AutoCommit => 0, PrintError => $logger->is_warn(), }
+    );
+}
+
 =item base_backup
 
 This routine connects to the database using pg_dumpall and returns a plain text,
@@ -100,8 +116,7 @@
 sub base_backup {
     my $self = shift @_;
 
-    my $old_pguser = $ENV{PGUSER};
-    my $old_pgpass = $ENV{PGPASSWORD};
+    local %ENV; # Make sure that - when leaving the scope - %ENV is restored
     $ENV{PGUSER} = $self->{username};
     $ENV{PGPASSWORD} = $self->{password};
 
@@ -122,9 +137,6 @@
         $logger->error("backup failed: non-zero exit code from pg_dumpall");
     }
 
-    $ENV{PGUSER} = $old_pguser;
-    $ENV{PGPASSWORD} = $old_pgpass;
-
     return $backupfile;
 }
 
@@ -147,8 +159,7 @@
 sub db_backup {
     my $self = shift @_;
 
-    my $old_pguser = $ENV{PGUSER};
-    my $old_pgpass = $ENV{PGPASSWORD};
+    local %ENV;
     $ENV{PGUSER} = $self->{username};
     $ENV{PGPASSWORD} = $self->{password};
 
@@ -169,9 +180,6 @@
         $logger->error("backup failed: non-zero exit code from pg_dump");
     }
 
-    $ENV{PGUSER} = $old_pguser;
-    $ENV{PGPASSWORD} = $old_pgpass;
-
     return $backupfile;
 }
 
@@ -445,7 +453,6 @@
 
 sub create {
     my ($self) = @_;
-    $logger->trace("trying to create db \$ENV{PG_CONTRIB_DIR}=$ENV{PG_CONTRIB_DIR}");
     # We have to use template0 because of issues that Debian has with database 
     # encoding.  Apparently that causes problems for us, so template0 must be
     # used. Hat tip:  irc user nwnw on #ledgersmb
@@ -468,22 +475,7 @@
     if (!$rc) {
         return $rc;
     }
-    my $rc2=0;
-    my @contrib_scripts = qw(pg_trgm tsearch2 tablefunc);
-    if($ENV{PG_CONTRIB_DIR})
-    { 
-     #postgres 9.1 this is done by create extension pg_trgm btree_gist ..
-     for my $contrib (@contrib_scripts){
-         $rc2=system("psql -f $ENV{PG_CONTRIB_DIR}/$contrib.sql >> $temp/dblog_stdout 2>>$temp/dblog_stderr");
-         $rc ||= $rc2
-     }
-    }
-    else
-    {
-     $logger->info("Skipping contrib_scripts @contrib_scripts");
-    }     
-    $rc2 = system("psql -f $self->{source_dir}sql/Pg-database.sql >> $temp/dblog_stdout 2>>$temp/dblog_stderr");
-    $rc ||= $rc2;
+    $rc ||= $self->load_base_schema();
 
      # TODO Add logging of errors/notices
 
@@ -509,6 +501,23 @@
     return $rc;
 }        
 
+=item $db->load_base_schema()
+
+Loads the base schema definition file Pg-database.sql.
+
+=cut
+
+sub load_base_schema {
+    my ($self) = @_;
+
+    return $self->exec_script({
+	script => "$self->{source_dir}sql/Pg-database.sql",
+	log => "$temp/dblog_stdout",
+	errlog => "$temp/dblog_stderr"
+			      });
+}
+
+
 =item $db->load_modules($loadorder)
 
 Loads or reloads sql modules from $loadorder
@@ -528,10 +537,11 @@
                             log    => "$temp/dblog"});
 
     }
-    close (LOADORDER);
+    close (LOADORDER); // ### return failure to execute the script?
 }
 
-=item $db->exec_script({script => 'path/to/file', logfile => 'path/to/log'})
+=item $db->exec_script({script => 'path/to/file', log => 'path/to/log',
+    errlog => 'path/to/stderr_output' })
 
 Executes the script.  Returns 0 if successful, 1 if there are errors suggesting
 that types are already created, and 2 if there are other errors.
@@ -540,8 +550,20 @@
 
 sub exec_script {
     my ($self, $args) = @_;
+
+
+    local %ENV;
+
+    $ENV{PGUSER} = $self->{user};
+    $ENV{PGPASSWORD} = $self->{password};
+    $ENV{PGDATABASE} = $self->{company_name};
+
     open (LOG, '>>', $args->{log});
-    open (PSQL, '-|', "psql -f $args->{script} 2>&1");
+    if ($args->{errlog}) {
+	open (PSQL, '-|', "psql -f $args->{script} 2>>$args->{errlog}");
+    } else {
+	open (PSQL, '-|', "psql -f $args->{script} 2>&1");
+    }
     my $test = 0;
     while (my $line = <PSQL>){
         if ($line =~ /ERROR/){
@@ -554,6 +576,10 @@
         print LOG $line;
     }
     close(PSQL);
+    if ($? != 0) {  # command return value non-zero indicates 'other error'
+	$test = 2;
+    }
+
     close(LOG);
     return $test;
 }

Modified: trunk/LedgerSMB/Scripts/setup.pm
===================================================================
--- trunk/LedgerSMB/Scripts/setup.pm	2014-01-01 14:37:08 UTC (rev 6327)
+++ trunk/LedgerSMB/Scripts/setup.pm	2014-01-01 14:50:50 UTC (rev 6328)
@@ -27,11 +27,6 @@
 
 my $logger = Log::Log4perl->get_logger('LedgerSMB::Scripts::setup');
 
-sub _set_dbh {
-    my ($dbh) = @_;
-    $LedgerSMB::App_State::DBH=$dbh;
-}
-
 sub __default {
 
     my ($request) = @_;
@@ -43,6 +38,27 @@
     $template->render($request);
 }
 
+sub _get_database {
+    my ($request) = @_;
+    my $creds = LedgerSMB::Auth::get_credentials('setup');
+
+    return LedgerSMB::Database->new(
+               {username => $creds->{login},
+            company_name => $request->{database},
+                password => $creds->{password}}
+    );
+}
+
+
+sub _init_db {
+    my ($request) = @_;
+    my $database = _get_database($request);
+    $request->{dbh} = $database->dbh();
+    $LedgerSMB::App_State::DBH = $request->{dbh};
+
+    return $database;
+}
+
 =over
 
 =item login
@@ -56,16 +72,11 @@
     use LedgerSMB::Locale;
     my ($request) = @_;
     $logger->trace("\$request=$request \$request->{dbh}=$request->{dbh} request=".Data::Dumper::Dumper(\$request));
-    my $creds = LedgerSMB::Auth::get_credentials('setup');
     if (!$request->{database}){
         list_databases($request);
         return;
     }
-    my $database = LedgerSMB::Database->new(
-               {username => $creds->{login},
-            company_name => $request->{database},
-                password => $creds->{password}}
-    );
+    my $database = _get_database($request);
     my $server_info = $database->server_version;
     
     my $version_info = $database->get_info();
@@ -158,12 +169,7 @@
 
 sub list_databases {
     my ($request) = @_;
-    my $creds = LedgerSMB::Auth::get_credentials('setup');
-    my $database = LedgerSMB::Database->new(
-               {username => $creds->{login},
-            company_name => $request->{database},
-                password => $creds->{password}}
-    );
+    my $database = _get_database($request);
     my @results = $database->list;
     $request->{dbs} = [];
     for my $r (@results){
@@ -185,12 +191,7 @@
 
 sub copy_db {
     my ($request) = @_;
-    my $creds = LedgerSMB::Auth::get_credentials('setup');
-    my $database = LedgerSMB::Database->new(
-               {username => $creds->{login},
-            company_name => $request->{database},
-                password => $creds->{password}}
-    );
+    my $database = _get_database($request);
     my $rc = $database->copy($request->{new_name}) 
            || die 'An error occurred. Please check your database logs.' ;
     my $template = LedgerSMB::Template->new(
@@ -247,15 +248,9 @@
 sub run_backup {
     use LedgerSMB::Company_Config;
 
-    my $creds = LedgerSMB::Auth::get_credentials('setup');
     my $request = shift @_;
+    my $database = _get_database($request);
 
-    my $database = LedgerSMB::Database->new(
-               {username => $creds->{login},
-            company_name => $request->{database},
-                password => $creds->{password}}
-    );
-
     my $backupfile;
     my $mimetype;
 
@@ -283,8 +278,7 @@
             mimetype => $mimetype,
             filename => $backupfile,
             file     => $backupfile,
-	);
-        $mail->send;
+	);        $mail->send;
         unlink $backupfile;
         my $template = LedgerSMB::Template->new(
             path => 'UI/setup',
@@ -324,38 +318,16 @@
 sub migrate_sl{
     my ($request) = @_;
     my $creds = LedgerSMB::Auth::get_credentials('setup');
-    my $database = LedgerSMB::Database->new(
-               {username => $creds->{login},
-            company_name => $request->{database},
-                password => $creds->{password}}
-    );
+    my $database = _init_db($request);
+    my $rc = 0;
+    my $temp = $LedgerSMB::Sysconfig::tempdir;
 
-    # ENVIRONMENT NECESSARY
-    $ENV{PGUSER} = $creds->{login};
-    $ENV{PGPASSWORD} = $creds->{password};
-    $ENV{PGDATABASE} = $request->{database};
-
-    # Credentials set above via environment variables --CT
-    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
     my $dbh = $request->{dbh};
-    _set_dbh($dbh);
     $dbh->do('ALTER SCHEMA public RENAME TO sl28');
     $dbh->do('CREATE SCHEMA PUBLIC');
-    # Copying contrib script loading for now
-    my $rc = 0;
-    my $temp = $LedgerSMB::Sysconfig::tempdir;
-     my @contrib_scripts = qw(tsearch2 tablefunc);
 
-     for my $contrib (@contrib_scripts){
-         my $rc2;
-         $rc2=system("psql -f $ENV{PG_CONTRIB_DIR}/$contrib.sql >> $temp/dblog_stdout 2>>$temp/dblog_stderr");
-         $rc ||= $rc2
-     }
-     my $rc2 = system("psql -f sql/Pg-database.sql >> $temp/dblog_stdout 2>>$temp/dblog_stderr");
-     
-     $rc ||= $rc2;
-
-    $database->load_modules('LOADORDER');
+    $rc ||= $database->load_base_schema();
+    $rc ||= $database->load_modules('LOADORDER');
     my $dbtemplate = LedgerSMB::Template->new(
         user => {}, 
         path => 'sql/upgrade',
@@ -365,11 +337,12 @@
         output_file => 'sl2.8-1.3-upgrade',
         format => 'TXT' );
     $dbtemplate->render($request);
-    $rc2 = system("psql -f $temp/sl2.8-1.3-upgrade.sql >> $temp/dblog_stdout 2>>$temp/dblog_stderr");
-    $rc ||= $rc2;
 
-    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
-    _set_dbh($request->{dbh});
+    $database->exec_script(
+        { script => "$temp/sl2.8-1.3-upgrade.sql",
+          log => "$temp/dblog_stdout",
+          errlog => "temp/dblog_stderr"
+        });
 
    @{$request->{salutations}} 
     = $request->call_procedure(procname => 'person__list_salutations' ); 
@@ -429,21 +402,9 @@
 sub upgrade{
     my ($request) = @_;
     my $creds = LedgerSMB::Auth::get_credentials('setup');
-    my $database = LedgerSMB::Database->new(
-               {username => $creds->{login},
-            company_name => $request->{database},
-                password => $creds->{password}}
-    );
+    my $database = _init_db($request);
     my $dbinfo = $database->get_info();
 
-    # ENVIRONMENT NECESSARY
-    $ENV{PGUSER} = $creds->{login};
-    $ENV{PGPASSWORD} = $creds->{password};
-    $ENV{PGDATABASE} = $request->{database};
-
-    # Credentials set above via environment variables --CT
-    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
-    _set_dbh($request->{dbh});
     $request->{dbh}->{AutoCommit} = 0;
     my $locale = $request->{_locale};
 
@@ -545,15 +506,8 @@
 
 sub fix_tests{
     my ($request) = @_;
-    my $creds = LedgerSMB::Auth::get_credentials('setup');
-    # ENVIRONMENT NECESSARY
-    $ENV{PGUSER} = $creds->{login};
-    $ENV{PGPASSWORD} = $creds->{password};
-    $ENV{PGDATABASE} = $request->{database};
 
-    # Credentials set above via environment variables --CT
-    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
-    _set_dbh($request->{dbh});
+    _init_db($request);
     $request->{dbh}->{AutoCommit} = 0;
     my $locale = $request->{_locale};
 
@@ -585,17 +539,7 @@
     my $creds = LedgerSMB::Auth::get_credentials('setup');
     my $rc=0;
 
-
-    # ENVIRONMENT NECESSARY
-    $ENV{PGUSER} = $creds->{login};
-    $ENV{PGPASSWORD} = $creds->{password};
-    $ENV{PGDATABASE} = $request->{database};
-
-    my $database = LedgerSMB::Database->new(
-               {username => $creds->{login},
-            company_name => $request->{database},
-                password => $creds->{password}}
-    );
+    my $database = _get_database($request):
     $rc=$database->create_and_load();#TODO what if createdb fails?
     $logger->info("create_and_load rc=$rc");
 
@@ -614,8 +558,7 @@
             template => 'select_coa',
 	    format => 'HTML',
     );
-    $template->render($request);
-    
+    $template->render($request);    
 }
 
 =item select_coa
@@ -704,18 +647,8 @@
     # here in order to avoid creating objects just to get argument
     # mapping going. --CT
 
-    my $creds = LedgerSMB::Auth::get_credentials('setup');
-    
-    # ENVIRONMENT NECESSARY
-    $ENV{PGUSER} = $creds->{login};
-    $ENV{PGPASSWORD} = $creds->{password};
-    $ENV{PGDATABASE} = $request->{database};
 
-
-
-
-    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
-    _set_dbh($request->{dbh});
+    _init_db($request);
     $request->{dbh}->{AutoCommit} = 0;
 
     @{$request->{salutations}} 
@@ -759,13 +692,10 @@
     use LedgerSMB::Entity::Person::Employee;
     use LedgerSMB::Entity::User;
     use LedgerSMB::PGDate;
-    my $creds = LedgerSMB::Auth::get_credentials('setup');
-    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}",
-                                   $creds->{login},
-                                   $creds->{password});
-    _set_dbh($request->{dbh});
+
+    _init_db($request);
     $request->{dbh}->{AutoCommit} = 0;
-    $LedgerSMB::App_State::DBH = $request->{dbh};
+
     $request->{control_code} = $request->{employeenumber};
     $request->{dob} = LedgerSMB::PGDate->from_input($request->{dob});
     my $emp = LedgerSMB::Entity::Person::Employee->new(%$request);
@@ -831,32 +761,19 @@
 
 sub run_upgrade {
     my ($request) = @_;
-    my $creds = LedgerSMB::Auth::get_credentials('setup');
-    my $database = LedgerSMB::Database->new(
-               {username => $creds->{login},
-            company_name => $request->{database},
-                password => $creds->{password}}
-    );
+    my $database = _init_db($request);
+
     my $rc;
-    my $rc2;
     my $temp = $LedgerSMB::Sysconfig::tempdir;
 
-    # ENVIRONMENT NECESSARY
-    $ENV{PGUSER} = $creds->{login};
-    $ENV{PGPASSWORD} = $creds->{password};
-    $ENV{PGDATABASE} = $request->{database};
-
-    # Credentials set above via environment variables --CT
-    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
-    _set_dbh($request->{dbh});
     my $dbh = $request->{dbh};
     my $dbinfo = $database->get_info();
     my $v = $dbinfo->{version};
     $v =~ s/\.//;
     $dbh->do("ALTER SCHEMA public RENAME TO lsmb$v");
     $dbh->do('CREATE SCHEMA PUBLIC');
-    $database->exec_script({script => "$database->{source_dir}sql/Pg-database.sql",
-                            log    => "$temp/dblog"});
+
+    $database->load_base_schema();
     $database->load_modules('LOADORDER');
     my $dbtemplate = LedgerSMB::Template->new(
         user => {}, 
@@ -867,12 +784,12 @@
         output_file => 'to_1.4-upgrade',
         format => 'TXT' );
     $dbtemplate->render($request);
-    $rc2 = system("psql -f $temp/to_1.4-upgrade.sql >> $temp/dblog_stdout 2>>$temp/dblog_stderr");
-    $rc ||= $rc2;
+    $rc ||= $database->exec_script(
+        { script => "$temp/to_1.4-upgrade.sql",
+          log => "$temp/dblog_stdout",
+          errlog => "temp/dblog_stderr"
+        });
 
-    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
-    _set_dbh($request->{dbh});
-
    @{$request->{salutations}} 
     = $request->call_procedure(procname => 'person__list_salutations' ); 
           
@@ -917,23 +834,12 @@
 sub rebuild_modules {
     my ($request) = @_;
     my $creds = LedgerSMB::Auth::get_credentials('setup');
-    my $database = LedgerSMB::Database->new(
-               {username => $creds->{login},
-            company_name => $request->{database},
-                password => $creds->{password}}
-    );
+    my $database = _init_db($request);
+    $request->{dbh}->{AutoCommit} = 0;
 
-    # ENVIRONMENT NECESSARY
-    $ENV{PGUSER} = $creds->{login};
-    $ENV{PGPASSWORD} = $creds->{password};
-    $ENV{PGDATABASE} = $request->{database};
-    
     $database->load_modules('LOADORDER');
     $request->{lsmb_info} = $database->lsmb_info();
-    # Credentials set above via environment variables --CT
-    #avoid msg commit ineffective with AutoCommit enabled
-    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}",$creds->{login},$creds->{password},{AutoCommit=>0});
-    _set_dbh($request->{dbh});
+
     my $dbh = $request->{dbh};
     my $sth = $dbh->prepare(
           'UPDATE defaults SET value = ? WHERE setting_key = ?'

Modified: trunk/LedgerSMB/Sysconfig.pm
===================================================================
--- trunk/LedgerSMB/Sysconfig.pm	2014-01-01 14:37:08 UTC (rev 6327)
+++ trunk/LedgerSMB/Sysconfig.pm	2014-01-01 14:50:50 UTC (rev 6328)
@@ -194,7 +194,6 @@
 our $db_namespace = $cfg->val('database', 'db_namespace') || 'public';
 $ENV{PGSSLMODE} = $cfg->val('database', 'sslmode') 
     if $cfg->val('database', 'sslmode');
-$ENV{PG_CONTRIB_DIR} = $cfg->val('database', 'contrib_dir');
 
 $ENV{HOME} = $tempdir;
 

Modified: trunk/README.tests
===================================================================
--- trunk/README.tests	2014-01-01 14:37:08 UTC (rev 6327)
+++ trunk/README.tests	2014-01-01 14:50:50 UTC (rev 6328)
@@ -49,12 +49,10 @@
 LSMB_BASE_URL directs LWP tests to the main LSMB instance being tested. 
 
 If you wish to make a new db for tests, you must set the following environment 
-variables:
+variable:
 
    LSMB_NEW_DB is the name of the new db.  If this database cannot be created, 
                the tests will bail out.
-PG_CONTRIB_DIR is the address of the directory where Pg contrib scripts are 
-               located.  You can find it by searching for tablefunc.sql.
 
 Additionally, if LSMB_INSTALL_DB is set, the database will NOT be removed after
 test cases are run.  This can be a useful way of installing the for production

Modified: trunk/install_interactive.pl
===================================================================
--- trunk/install_interactive.pl	2014-01-01 14:37:08 UTC (rev 6327)
+++ trunk/install_interactive.pl	2014-01-01 14:50:50 UTC (rev 6328)
@@ -10,9 +10,6 @@
 chomp($ENV{LSMB_NEW_DB} = <STDIN>);
 
 
-print "Please enter the directory where I can find PostgreSQL contrib modules:\n";
-chomp($ENV{PG_CONTRIB_DIR} = <STDIN>);
-
 print "\n\nPostgreSQL superuser's username: ";
 chomp($ENV{PGUSER} = <STDIN>);
 

Modified: trunk/ledgersmb.conf.default
===================================================================
--- trunk/ledgersmb.conf.default	2014-01-01 14:37:08 UTC (rev 6327)
+++ trunk/ledgersmb.conf.default	2014-01-01 14:50:50 UTC (rev 6328)
@@ -101,9 +101,6 @@
 default_db = lsmb13
 host = localhost
 db_namespace = public
-#contrib_dir PG_CONTRIB_DIR 
-#with postgresql-9.1 this stuff is in /usr/share/postgresql/9.1/extension and is injected in database with create extension pg_trgm,btree_gist...
-contrib_dir = /usr/share/pgsql/contrib/
 # sslmode can be require, allow, prefer, or disable.  Defaults to prefer.
 sslmode = prefer
 

Modified: trunk/t/40-dbsetup.t
===================================================================
--- trunk/t/40-dbsetup.t	2014-01-01 14:37:08 UTC (rev 6327)
+++ trunk/t/40-dbsetup.t	2014-01-01 14:50:50 UTC (rev 6328)
@@ -19,7 +19,7 @@
 for my $log (qw(dblog dblog_stderr dblog_stdout)){
     unlink "$LedgerSMB::Sysconfig::tempdir/$log";
 }
-for my $evar (qw(LSMB_NEW_DB LSMB_TEST_DB PG_CONTRIB_DIR)){
+for my $evar (qw(LSMB_NEW_DB LSMB_TEST_DB)){
   if (!defined $ENV{$evar}){
       $run_tests = 0;
       plan skip_all => "$evar not set";
@@ -38,7 +38,6 @@
          company_name => $ENV{LSMB_NEW_DB},
          username     => $ENV{PGUSER},
          password     => $ENV{PGPASSWORD},
-         contrib_dir  => $ENV{PG_CONTRIB_DIR},
          source_dir   => $ENV{LSMB_SOURCE_DIR}
 });
 

Modified: trunk/t/89-dropdb.t
===================================================================
--- trunk/t/89-dropdb.t	2014-01-01 14:37:08 UTC (rev 6327)
+++ trunk/t/89-dropdb.t	2014-01-01 14:50:50 UTC (rev 6328)
@@ -4,7 +4,7 @@
     
 my $temp = $ENV{TEMP} || '/tmp/';
 my $run_tests = 6;
-for my $evar (qw(LSMB_NEW_DB LSMB_TEST_DB PG_CONTRIB_DIR)){
+for my $evar (qw(LSMB_NEW_DB LSMB_TEST_DB)){
   if (!defined $ENV{$evar}){
       $run_tests = 0;
       plan skip_all => "$evar not set";

Modified: trunk/tools/dbsetup.pl
===================================================================
--- trunk/tools/dbsetup.pl	2014-01-01 14:37:08 UTC (rev 6327)
+++ trunk/tools/dbsetup.pl	2014-01-01 14:50:50 UTC (rev 6328)
@@ -181,16 +181,6 @@
 if ($progress) {
 	print "$$is_v9_1plus_aref[0]\n";
 }
-unless ($$is_v9_1plus_aref[0] =~ /PostgreSQL 9\.[1-9]/) {
-	unless ($pgsql_contrib_dir) {
-		print "\n\nYou must specify a contrib directory!\n\n";
-		exit;
-	}
-	$ENV{PG_CONTRIB_DIR} = $pgsql_contrib_dir;
-	if ($progress) {
-		print "PostgreSQL < 9.1.x\n";
-	}
-}
 my $admin_user_ok = $dbh->do("CREATE ROLE $creds->{login} WITH SUPERUSER LOGIN NOINHERIT ENCRYPTED PASSWORD '$creds->{password}';");
 my $database = LedgerSMB::Database->new(
 					{username => $creds->{login},

Modified: trunk/tools/prepare-company-database.pl
===================================================================
--- trunk/tools/prepare-company-database.pl	2014-01-01 14:37:08 UTC (rev 6327)
+++ trunk/tools/prepare-company-database.pl	2014-01-01 14:50:50 UTC (rev 6328)
@@ -63,7 +63,6 @@
 my $cc = 'us';
 my $coa="$srcdir/sql/coa/us/chart/General.sql";
 my $gifi=undef;
-my $pgsql_contrib_dir='ignore';
 my $progress=0;
 my $help=0;
 
@@ -97,8 +96,6 @@
 		from the webserver [$dstdir]
  --host		The PostgreSQL host to connect to (see 'man psql') [$host]
  --port		The PostgreSQL port to connect to (see 'man psql') [$port]
- --pgsql-contrib The directory where the tsearch2.sql, pg_trgm.sql and
-                tablefunc.sql PostgeSQL are located [$pgsql_contrib_dir] [*]
  --company	The name of the database to be created for the company [*]
  --owner	The name of the superuser which is to become owner of the
 		company's database [$owner]
@@ -118,7 +115,6 @@
    'dstdir=s'        => \$dstdir,
    'port=s'          => \$port,
    'host=s'          => \$host,
-   'pgsql-contrib=s' => \$pgsql_contrib_dir,
    'company=s'       => \$company,
    'owner=s'         => \$owner,
    'password=s'      => \$pass,
@@ -132,10 +128,9 @@
 
 # Setting up the environment here in case at some point we want to expand to
 # call libpq programs directly.  It also makes the script more future proof in
-# other ways.  Note that PG_CONTRIB_DIR is not really needed in Pg 9.1 and later
+# other ways.
 # and is a LedgerSMB-ism.
 #
-$ENV{PG_CONTRIB_DIR} = $pgsql_contrib_dir if $pgsql_contrib_dir;
 $ENV{PGUSER} = $owner if $owner;
 $ENV{PGPASS} = $pass if $pass;
 $ENV{PGDATABASE} = $company if $company;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits