Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Bricolage: commits

[8203] Fixed `make clone` to work properly with both databases.

 

 

Bricolage commits RSS feed   Index | Next | Previous | View Threaded


theory at bricolage

Apr 29, 2008, 5:08 PM

Post #1 of 1 (68 views)
Permalink
[8203] Fixed `make clone` to work properly with both databases.

Revision: 8203
Author: theory
Date: 2008-04-29 17:08:30 -0700 (Tue, 29 Apr 2008)
ViewCVS: http://viewsvn.bricolage.cc/?rev=8203&view=rev

Log Message:
-----------
Fixed `make clone` to work properly with both databases. It was broken for both!

Modified Paths:
--------------
bricolage/trunk/inst/clone_files.pl
bricolage/trunk/inst/clone_sql.pl
bricolage/trunk/inst/clone_sql_Pg.pl
bricolage/trunk/inst/clone_sql_mysql.pl
bricolage/trunk/inst/dbgrant.pl

Modified: bricolage/trunk/inst/clone_files.pl
===================================================================
--- bricolage/trunk/inst/clone_files.pl 2008-04-30 00:07:36 UTC (rev 8202)
+++ bricolage/trunk/inst/clone_files.pl 2008-04-30 00:08:30 UTC (rev 8203)
@@ -63,7 +63,7 @@
opendir(CUR, '.') or die $!;
my %exclude = map { $_ => 1 } qw(. .. dist comp data conf bin lib);
foreach my $d (readdir(CUR)) {
- next if $exclude{$d} or $d =~ /.db$/ or $d =~ /^bricolage-/;
+ next if $exclude{$d} or $d =~ /[.](?:db|sql)$/ or $d =~ /^bricolage-/;
system("cp -pR $d dist");
}
close(CUR);

Modified: bricolage/trunk/inst/clone_sql.pl
===================================================================
--- bricolage/trunk/inst/clone_sql.pl 2008-04-30 00:07:36 UTC (rev 8202)
+++ bricolage/trunk/inst/clone_sql.pl 2008-04-30 00:08:30 UTC (rev 8203)
@@ -2,8 +2,7 @@

=head1 NAME

-clone_sql.pl - installation script to clone an existing database by launching apropriate
-database clone script
+clone_sql.pl - installation script to clone an existing database by launching apropriate database clone script

=head1 DESCRIPTION

@@ -20,20 +19,9 @@

=cut

-
-use strict;
use FindBin;
-use lib "$FindBin::Bin/lib";
-use Bric::Inst qw(:all);
-use File::Spec::Functions qw(:ALL);
-use File::Find qw(find);
-use DBI;
+use strict;

-print "\n\n==> Cloning Bricolage Database <==\n\n";
-
-our $DB;
-do "./database.db" or die "Failed to read database.db: $!";
-
-do "./clone_sql_$DB->{db}.pl" or die "Failed to launch $DB->{db} clone script (./clone_sql_$DB->{db}.pl): $!";
-
-exit 0;
+my $DB = do './database.db' or die "Failed to read database.db: $!";
+my $script = "$FindBin::Bin/clone_sql_$DB->{db_type}.pl";
+system ( $^X, $script ) and exit 1;

Modified: bricolage/trunk/inst/clone_sql_Pg.pl
===================================================================
--- bricolage/trunk/inst/clone_sql_Pg.pl 2008-04-30 00:07:36 UTC (rev 8202)
+++ bricolage/trunk/inst/clone_sql_Pg.pl 2008-04-30 00:08:30 UTC (rev 8203)
@@ -20,44 +20,48 @@
=cut


-use strict;
use FindBin;
-use lib "$FindBin::Bin/lib";
-use Bric::Inst qw(:all);
use File::Spec::Functions qw(:ALL);
-use File::Find qw(find);
-use DBI;

+print "\n\n==> Cloning Bricolage Database <==\n\n";
+
our $DB;
do "./database.db" or die "Failed to read database.db: $!";

# Make sure that we don't overwrite the existing Pg.sql.
chdir 'dist';
+my $file = 'inst/Pg.sql';

# Switch to postgres system user
-if (my $sys_user = $PG->{system_user}) {
+if (my $sys_user = $DB->{system_user}) {
print "Becoming $sys_user...\n";

# Make sure that the user can write out inst/Pg.sql.
- my $file = -e 'inst/Pg.sql' ? 'inst/Pg.sql' : 'inst';
- chown $PG->{system_user_uid}, -1, $file
- or die "Cannot chown $file to $PG->{system_user_uid} ($sys_user).\n";
+ my $to_chown = -e 'inst/Pg.sql' ? 'inst/Pg.sql' : 'inst';
+ chown $DB->{system_user_uid}, -1, $to_chown
+ or die "Cannot chown $to_chown to $DB->{system_user_uid} ($sys_user).\n";

# Become the user.
require Config;
- $> = $PG->{system_user_uid};
+ $> = $DB->{system_user_uid};
$< = $DB->{system_user_uid} if $Config::Config{d_setruid};
- die "Failed to switch EUID to $PG->{system_user_uid} ($sys_user).\n"
- unless $> == $PG->{system_user_uid};
+ die "Failed to switch EUID to $DB->{system_user_uid} ($sys_user).\n"
+ unless $> == $DB->{system_user_uid};
}

$ENV{PGHOST} = $DB->{host_name} if $DB->{host_name};
$ENV{PGPORT} = $DB->{host_port} if $DB->{host_port};

# dump out postgres database
-system(catfile($DB->{bin_dir}, 'pg_dump') .
- " -U$DB->{root_user} -O -x $DB->{db_name} > Pg.sql");
+my @pgdump = (
+ catfile($DB->{bin_dir}, 'pg_dump'),
+ '-U', $DB->{root_user},
+ '-f', $file,
+ '-O',
+ '-x',
+ $DB->{db_name},
+);

-printf "\n\n==> Finished cloning Bricolage Database <==\n\n";
-
-exit 0;
+# dump out postgres database
+system( @pgdump ) and die 'Error executing `' . join(' ', @pgdump), "`\n";
+print "\n\n==> Finished cloning Bricolage Database <==\n\n";

Modified: bricolage/trunk/inst/clone_sql_mysql.pl
===================================================================
--- bricolage/trunk/inst/clone_sql_mysql.pl 2008-04-30 00:07:36 UTC (rev 8202)
+++ bricolage/trunk/inst/clone_sql_mysql.pl 2008-04-30 00:08:30 UTC (rev 8203)
@@ -19,29 +19,28 @@

=cut

-
use strict;
-use FindBin;
-use lib "$FindBin::Bin/lib";
-use Bric::Inst qw(:all);
-use File::Spec::Functions qw(:ALL);
-use File::Find qw(find);
-use DBI;
+use File::Spec::Functions;

print "\n\n==> Cloning Bricolage Database <==\n\n";

-our $DB;
-do "./database.db" or die "Failed to read database.db: $!";
+my $DB = do './database.db' or die "Failed to read database.db: $!\n";

# Make sure that we don't overwrite the existing Pg.sql.
chdir 'dist';
+my $file = catfile qw( inst mysql.sql);

-my $dbclone;
-$dbclone = catfile($DB->{bin_dir}, 'mysqldump');
-$dbclone = " -h $DB->{host_name} " if $DB->{host_name};
-$dbclone = " -P $DB->{host_port} " if $DB->{host_port};
+my @dbclone = (catfile($DB->{bin_dir}, 'mysqldump'));
+push @dbclone, '-h', $DB->{host_name} if $DB->{host_name};
+push @dbclone, '-P', $DB->{host_port} if $DB->{host_port};
+push @dbclone, (
+ '-u', $DB->{root_user},
+ ( $DB->{root_pass} ? "-p$DB->{root_pass}" : ()),
+ '-r', $file,
+ $DB->{db_name},
+);

# dump out mysql database
-system($dbclone ." -u $DB->{root_user} -p$DB->{root_pass} -D $DB->{db_name} > mysql.sql");
-}
-exit 0;
+system( @dbclone ) and die 'Error executing `' . join(' ', @dbclone), "`\n";
+
+printf "\n\n==> Finished cloning Bricolage Database <==\n\n";

Modified: bricolage/trunk/inst/dbgrant.pl
===================================================================
--- bricolage/trunk/inst/dbgrant.pl 2008-04-30 00:07:36 UTC (rev 8202)
+++ bricolage/trunk/inst/dbgrant.pl 2008-04-30 00:08:30 UTC (rev 8203)
@@ -37,8 +37,7 @@
$DBCONF = './database.db';
do $DBCONF or die "Failed to read $DBCONF : $!";

-my $instdb;
-$instdb = "./inst/dbgrant_$DB->{db_type}.pl";
-do $instdb or die "Failed to launch $DB->{db_type} access granting script ($instdb)$!";
+my $instdb = "./inst/dbgrant_$DB->{db_type}.pl";
+do $instdb or die "Failed to launch $DB->{db_type} access granting script ($instdb): $!\n";

exit 0;

Bricolage commits RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.