~ubuntu-branches/ubuntu/wily/mysql-5.6/wily

« back to all changes in this revision

Viewing changes to packaging/deb-precise/patches/fix-mysql_install_db.patch

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2015-04-16 20:07:10 UTC
  • mto: (1.3.9 vivid-proposed)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20150416200710-pcrsa022082zj46k
Tags: upstream-5.6.24
Import upstream version 5.6.24

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
From: Terje Røsten <terje.rosten@oracle.com>
2
 
Description: Updates script to use existing my.cnf and not delete it if created from template
 
2
Description: Maintains the pending --skip-my-cnf option in mainline
3
3
Bug: <TODO>
4
4
 
5
5
diff --git a/scripts/mysql_install_db.pl.in b/scripts/mysql_install_db.pl.in
6
6
index 440a977..7d068fc 100644
7
7
--- a/scripts/mysql_install_db.pl.in
8
8
+++ b/scripts/mysql_install_db.pl.in
9
 
@@ -75,6 +97,8 @@ Usage: $0 [OPTIONS]
10
 
   --help               Display this help and exit.
11
 
   --ldata=path         The path to the MySQL data directory. Same as --datadir.
12
 
   --no-defaults        Don't read default options from any option file.
13
 
+  --keep-my-cnf        Don't try to create my.cnf based on template.
14
 
+                       Useful for systems with working, updated my.cnf.
15
 
 EOF1
16
 
   if ( $^O !~ m/^(MSWin32|cygwin)$/ ) {
17
 
     print <<EOF2;
18
 
@@ -86,6 +110,7 @@ EOF2
 
9
@@ -113,6 +113,7 @@ EOF2
19
10
   print <<EOF3;
20
11
   --rpm                For internal use.  This option is used by RPM files
21
12
                        during the MySQL installation process.
23
14
   --skip-name-resolve  Use IP addresses rather than hostnames when creating
24
15
                        grant table entries.  This option can be useful if
25
16
                        your DNS does not work.
26
 
@@ -149,6 +174,7 @@ sub parse_arguments
27
 
 
28
 
              "skip-name-resolve",
29
 
              "verbose",
30
 
+             "keep-my-cnf",
31
 
              "rpm",
32
 
              "help",
33
 
              "random-passwords",
34
 
@@ -356,13 +382,19 @@ sub tell_root_password {
35
 
 ##############################################################################
36
 
 
37
 
 sub generate_random_password {
38
 
-  # On (at least) Linux and Solaris, a "random" device is available, use it:
39
 
-  # cat /dev/urandom | LC_ALL=C tr -dc "[:alnum:]" | fold -w 8  | head -1
40
 
-  # Without LC_ALL, "tr" may not know the "alnum" character class -
41
 
-  # and there are user profiles which do not have this set.
42
 
-  #
43
 
-  my $password = `cat /dev/urandom | LC_ALL=C tr -dc "[:alnum:]" | fold -w 8  | head -1`;
44
 
-  chomp ($password);
45
 
+  # On Linux, Solaris, Max OS X and FreeBSD we have a random device available.
46
 
+  my $randfile = "/dev/urandom";
47
 
+  open(FD, $randfile) || die "Can't open $randfile for reading: $!";
48
 
+  my $password = "";
49
 
+  my $pass_len = 16;
50
 
+  my $c;
51
 
+  while (length($password) < $pass_len) {
52
 
+    $c = getc(FD);
53
 
+    if ($c =~ /\w/) {
54
 
+      $password .= $c;
55
 
+    }
56
 
+  }
57
 
+  close(FD);
58
 
   return $password;
59
 
 }
60
 
 
61
 
@@ -399,11 +431,16 @@ $basedir= "@prefix@" if ! $basedir;               # Default
62
 
 # ----------------------------------------------------------------------
63
 
 
64
 
 my $print_defaults;
65
 
+my $keep_my_cnf = 0;
66
 
 
67
 
 if ( $opt->{srcdir} and $opt->{basedir} )
 
17
@@ -439,7 +440,7 @@ if ( $opt->{srcdir} and $opt->{basedir} )
68
18
 {
69
19
   error($opt,"Specify either --basedir or --srcdir, not both");
70
20
 }
 
21
-if ( $opt->{'keep-my-cnf'} )
71
22
+if ( $opt->{rpm} || $opt->{'keep-my-cnf'} )
72
 
+{
73
 
+  $keep_my_cnf = 1;
74
 
+}
75
 
 if ( $opt->{srcdir} )
76
23
 {
77
 
   $opt->{builddir} = $opt->{srcdir} unless $opt->{builddir};
78
 
@@ -425,7 +462,7 @@ my $config_file;
79
 
 my $copy_cfg_file;
80
 
 
81
 
 # ----------------------------------------------------------------------
82
 
-# This will be the default config file
83
 
+# This will be the default config file (unless creation is unwanted)
84
 
 # ----------------------------------------------------------------------
85
 
 
86
 
 my $cnfext = ( $^O =~ m/^(MSWin32|cygwin)$/ ) ? "ini" : "cnf";
87
 
@@ -434,6 +471,11 @@ $config_file= "$basedir/my.$cnfext";
88
 
 
89
 
 my $cfg_template= find_in_basedir($opt,"file","my-default.$cnfext",
90
 
                                  ".", "share","share/mysql","support-files");
91
 
+# Distros might move files
92
 
+if ((! -r $cfg_template) && (-r "@pkgdatadir@/my-default.cnf")) {
93
 
+  $cfg_template = "@pkgdatadir@/my-default.cnf";
94
 
+}
95
 
+
96
 
 -e $cfg_template or cannot_find_file("my-default.$cnfext");
97
 
 
98
 
 $copy_cfg_file= $config_file;
99
 
@@ -443,22 +485,21 @@ if (-e $copy_cfg_file)
100
 
   $copy_cfg_file =~ s/my.$cnfext/my-new.$cnfext/;
101
 
   # Too early to print warning here, the user may not notice
102
 
 }
103
 
-open (TEMPL, $cfg_template) or error($opt, "Could not open config template $cfg_template");
104
 
-if (open (CFG, "> $copy_cfg_file"))
105
 
-{
106
 
-  while (<TEMPL>)
107
 
-  {
108
 
-    # Remove lines beginning with # *** which are template comments
109
 
-    print CFG $_ unless /^# \*\*\*/;
110
 
+
111
 
+if ( ! $keep_my_cnf ) {
112
 
+  open (TEMPL, $cfg_template) or error($opt, "Could not open config template $cfg_template");
113
 
+  if (open (CFG, "> $copy_cfg_file")) {
114
 
+    while (<TEMPL>) {
115
 
+      # Remove lines beginning with # *** which are template comments
116
 
+      print CFG $_ unless /^# \*\*\*/;
117
 
+    }
118
 
+    close CFG;
119
 
+  } else {
120
 
+    warning($opt,"Could not write to config file $copy_cfg_file: $!");
121
 
+    $failed_write_cfg= 1;
122
 
   }
123
 
-  close CFG;
124
 
+  close TEMPL;
125
 
 }
126
 
-else
127
 
-{
128
 
-  warning($opt,"Could not write to config file $copy_cfg_file: $!");
129
 
-  $failed_write_cfg= 1;
130
 
-}
131
 
-close TEMPL;
132
 
 
133
 
 # ----------------------------------------------------------------------
134
 
 # Now we can get arguments from the groups [mysqld] and [mysql_install_db]
135
 
@@ -621,7 +662,7 @@ if ( $opt->{'skip-name-resolve'} and $resolved and $resolved =~ /\s/ )
 
24
   $keep_my_cnf = 1;
 
25
 }
 
26
@@ -664,7 +665,7 @@ if ( $opt->{'skip-name-resolve'} and $resolved and $resolved =~ /\s/ )
136
27
 }
137
28
 
138
29
 # ----------------------------------------------------------------------
141
32
 # ----------------------------------------------------------------------
142
33
 
143
34
 # FIXME The shell variant uses "mkdir -p":
144
 
@@ -654,7 +695,7 @@ if ($opt_user)
 
35
@@ -697,7 +698,7 @@ if ($opt_user)
145
36
   }
146
37
 }
147
38
 
150
41
 {
151
42
   mkdir($dir, 0700) unless -d $dir;
152
43
   if ($opt_user and -w "/")
153
 
@@ -848,7 +889,13 @@ if ( open(PIPE, "| $mysqld_install_cmd_line") )
154
 
            "",
155
 
            "Support MySQL by buying support/licenses at http://shop.mysql.com");
156
 
 
157
 
-    if ($copy_cfg_file eq $config_file and !$failed_write_cfg)
158
 
+    if ($keep_my_cnf)
159
 
+    {
160
 
+      report($opt,
161
 
+            "Note: new default config file not created.",
162
 
+            "Please make sure your config file is current");
163
 
+    }
164
 
+    elsif ($copy_cfg_file eq $config_file and !$failed_write_cfg)
165
 
     {
166
 
       report($opt,
167
 
                "New default config file was created as $config_file and",