Bugzilla – Attachment 60918 Details for
Bug 18229
update_dbix_class_files.pl loads defaults from ~/.my.cnf
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18229 - update_dbix_class_files.pl loads defaults from ~/.my.cnf
Bug-18229---updatedbixclassfilespl-loads-defaults-.patch (text/plain), 3.15 KB, created by
Olli-Antti Kivilahti
on 2017-03-08 15:25:54 UTC
(
hide
)
Description:
Bug 18229 - update_dbix_class_files.pl loads defaults from ~/.my.cnf
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2017-03-08 15:25:54 UTC
Size:
3.15 KB
patch
obsolete
>From 21adcea040484a24ec39bfd7df939b4b368da56f Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Wed, 8 Mar 2017 17:10:22 +0200 >Subject: [PATCH] Bug 18229 - update_dbix_class_files.pl loads defaults from > ~/.my.cnf > >A) Put this to your ~/.my.cnf > >[client] > >host = 10.0.3.10 >port = 3306 >user = koha_ci >password = "Mr. senior plays with his junior" >database = koha_ci > >B) Then run update_dbix_class_files.pl > >perl misc/devel/update_dbix_class_files.pl --tablename issuingrules > >C) Update DBIx::Class files like a boss >--- > misc/devel/update_dbix_class_files.pl | 67 ++++++++++++++++++++++++----------- > 1 file changed, 46 insertions(+), 21 deletions(-) > >diff --git a/misc/devel/update_dbix_class_files.pl b/misc/devel/update_dbix_class_files.pl >index 033e676..12250f4 100755 >--- a/misc/devel/update_dbix_class_files.pl >+++ b/misc/devel/update_dbix_class_files.pl >@@ -25,15 +25,15 @@ use DBIx::Class::Schema::Loader qw/ make_schema_at /; > use Getopt::Long; > use Pod::Usage; > >-my $path = "./"; >-my $db_driver = 'mysql'; >-my $db_host = 'localhost'; >-my $db_port = '3306'; >-my $db_name; >-my $db_user; >-my $db_passwd; >-my $tablename; >-my $help; >+my ($path, $db_driver, $db_host, $db_port, $db_name, $db_user, $db_passwd, $tablename, $help); >+ >+#Get defaults if exists ~/.my.cnf >+defaultFromMyCnf(); >+ >+$path = "./" unless $path; >+$db_driver = 'mysql' unless $db_driver; >+$db_host = 'localhost' unless $db_host; >+$db_port = '3306' unless $db_port; > > GetOptions( > "path=s" => \$path, >@@ -53,17 +53,42 @@ pod2usage(1) if defined $help; > if (! defined $db_name ) { > print "Error: \'db_name\' parameter is mandatory.\n"; > pod2usage(1); >-} else { >- my $options = { debug => 1, dump_directory => $path, preserve_case => 1 }; >- if ($tablename) { >- $options->{constraint} = qr/\A$tablename\z/ >- } >- >- make_schema_at( >- "Koha::Schema", >- $options, >- ["DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",$db_user, $db_passwd ] >- ); >+} >+ >+ >+my $options = { debug => 1, dump_directory => $path, preserve_case => 1 }; >+if ($tablename) { >+ $options->{constraint} = qr/\A$tablename\z/ >+} >+ >+make_schema_at( >+ "Koha::Schema", >+ $options, >+ ["DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",$db_user, $db_passwd ] >+); >+ >+ >+ >+ >+ >+sub defaultFromMyCnf { >+ my $c = _parseMyCnf(); >+ return unless $c; >+ $db_user = $c->{'client.user'} unless $db_user; >+ $db_host = $c->{'client.host'} unless $db_host; >+ $db_port = $c->{'client.port'} unless $db_port; >+ $db_name = $c->{'client.database'} unless $db_name; >+ $db_passwd = $c->{'client.password'} unless $db_passwd; >+ $db_driver = 'mysql' unless $db_driver; >+} >+sub _parseMyCnf { >+ use Config::Simple; >+ my %c; >+ my $home = `echo ~`; >+ chomp $home; >+ return undef unless $home; >+ Config::Simple->import_from("$home/.my.cnf", \%c); >+ return \%c; > } > > 1; >@@ -117,4 +142,4 @@ path into which create the schema files. (defaults to './') > > prints this help text > >-=back >\ No newline at end of file >+=back >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18229
: 60918