1
--- debian/bugzilla.templates 2004-11-29 15:44:23.000000000 +0100
2
+++ debian/bugzilla.templates 2004-11-30 17:49:37.000000000 +0100
4
Template: bugzilla/mysql_available
7
-_Description: Do you have a MySQL server somewhere on your network?
8
+_Description: Do you want to continue?
9
+ You need a mysql server installed on your local machine, or
10
+ accessable on your network.
12
The Bugzilla package does not declare a mandatory package dependency on
13
the MySQL server package, since Bugzilla can use a remote MySQL database.
14
To complete Bugzilla configuration, access to a MySQL server is required.
16
- Answering no to this question will make Bugzilla configuration fail and
17
- let you install a MySQL server.
18
+ Answering no to this question will stop the Bugzilla configuration.
21
Template: bugzilla/mysql_need_root
24
Template: bugzilla/bugzilla_admin_pwd
26
_Description: Enter the password for the Bugzilla administrator account.
28
+Template: bugzilla/bugzilla_installation_way_single
30
+Choices: Manual, Later
32
+_Description: Choose the way you want to configure bugzilla:
33
+ As you don't have a MySQL server installed locally, I can just provide
34
+ the automatic installation.
36
+ Manual installation will let you enter all the preferences for the MySQL
37
+ server you want to use (either present locally or on the network).
39
+ Later means that you don't have yet a MySQL server up for bugzilla,
40
+ choosing this will stop the installation.
42
+Template: bugzilla/bugzilla_installation_way
44
+Choices: Automatic, Manual, Later
46
+_Description: Choose the way you want to configure bugzilla:
47
+ Automatic installation will assume you have a locally installed MySQL
48
+ server and will try to use as many default values as possible.
50
+ Manual installation will let you enter all the preferences for the MySQL
51
+ server you want to use (either present locally or on the network).
53
+ Later means that you don't have yet a MySQL server up for bugzilla,
54
+ choosing this will stop the installation.
55
--- debian/bugzilla.config 2004-11-29 15:44:23.000000000 +0100
56
+++ debian/bugzilla.config 2004-11-30 18:09:57.000000000 +0100
58
while [ "$STATE" != 0 -a "$STATE" != 90 ]; do
61
- #give chance to make install fail if there no
62
- #mysql server available
63
- db_input high bugzilla/mysql_available || true
65
- db_get bugzilla/mysql_available || true
66
- if [ "$RET" = "true" ]; then
67
+ # First ask user which installation way he wants
68
+ # if the mysql default file doesn't exists, only Manual install is available.
69
+ if [ ! -f /etc/mysql/debian.cnf ]; then
70
+ db_input high bugzilla/bugzilla_installation_way_single || true
72
+ db_get bugzilla/bugzilla_installation_way_single || true
74
+ db_input high bugzilla/bugzilla_installation_way || true
76
+ db_get bugzilla/bugzilla_installation_way || true
80
+ # as bugzilla/bugzilla_installation_way
81
+ # is set to Automatic, postinst will try
82
+ # to do the stuff, but first we have to ask
83
+ # for bugziall admin name and so on :
89
+ # Let's do all what we did before.
100
+ # Here we just stop the process and postinst won't do
101
+ # anything. User will have to run dpkg-reconfigure
102
+ # when he is ready.
111
db_set bugzilla/pwd_check ""
115
+ # this is a split of the STATE #60.
116
+ # In this way, Automatic jump to here directly.
119
db_input high bugzilla/bugzilla_admin_name || true
120
db_input high bugzilla/bugzilla_admin_real_name || true
121
--- debian/changelog 2004-11-30 18:23:22.000000000 +0100
122
+++ debian/changelog 2004-11-30 18:23:13.000000000 +0100
124
+bugzilla (2.16.7-0.1.1) unstable; urgency=low
126
+ * Non-maintainer upload:
127
+ - post-inst won't fail anymore when no MySQL server is
128
+ available. Added an automatic way of setting up the MySQL server if
129
+ /etc/mysql/debian.cnf exists, will read values from it then.
132
+ -- Alexis Sukrieh <sukria@sukria.net> Tue, 30 Nov 2004 17:14:24 +0100
134
bugzilla (2.16.7-0.1) unstable; urgency=low
136
* NMU 0-days due to major security issues, solved upstream.
137
--- debian/bugzilla.postinst 2004-11-29 15:44:23.000000000 +0100
138
+++ debian/bugzilla.postinst 2004-11-30 18:25:58.000000000 +0100
140
use vars qw( $dsn $dbh
141
$mysql_host $mysql_port
142
$mysql_name $mysql_user $mysql_user_pwd
143
- $mysql_root_name $mysql_root_pwd );
144
+ $mysql_root_name $mysql_root_pwd $mysql_need_root);
146
use Debconf::Client::ConfModule ':all';
150
-if ( get('bugzilla/mysql_available') ne 'true' ) {
151
- print STDERR "You answer that there is no MySQL server "
152
- ."suitable to support the bugzilla database. "
153
- ."This makes bugzilla installation to failed\n";
154
+# according to installation way user choosed,
155
+# we'll do different things.
157
+my $default_file = '/etc/mysql/debian.cnf';
158
+if (-f $default_file) {
159
+ $install_way = get('bugzilla/bugzilla_installation_way');
162
+ $install_way = get('bugzilla/bugzilla_installation_way_single');
165
+# The Automatic way will read /etc/mysql/default.cnf
166
+# and will use the values found there.
167
+if ($install_way eq 'Automatic') {
168
+ $mysql_name = 'bugzilla';
169
+ $mysql_need_root = 'true';
170
+ $mysql_port = '3306';
172
+ # parsing default.cnf file to get host, user and password.
173
+ if (-f $default_file) {
174
+ if (open(MYSQL_DEFAULT_FILE, $default_file)) {
175
+ while (<MYSQL_DEFAULT_FILE>) {
177
+ next if /^#/ or /^\[\w*\]$/;
178
+ if (/(\S+)\s*=\s*(\S+)/) {
179
+ my ($key, $val) = ($1, $2);
180
+ if ($key eq 'host') {
181
+ $mysql_host = $val;
183
+ elsif($key eq 'user') {
184
+ $mysql_user = $val;
185
+ $mysql_root_name = $val;
187
+ elsif($key eq 'password') {
188
+ $mysql_user_pwd = $val;
189
+ $mysql_root_pwd = $val;
193
+ close MYSQL_DEFAULT_FILE;
196
+ print STDERR "Cannot read $default_file\n";
201
+ print STDERR "The file $default_file has disapeared.\n";
206
+# The Manual way is the same as before, everything
207
+# was asked with debconf and is used here.
208
+elsif ($install_way eq 'Manual') {
209
+ $mysql_host = get('bugzilla/mysql_host');
210
+ $mysql_port = get('bugzilla/mysql_port');
211
+ $mysql_name = get('bugzilla/mysql_name');
212
+ $mysql_user = get('bugzilla/mysql_user');
213
+ $mysql_user_pwd = get('bugzilla/mysql_user_pwd');
214
+ $mysql_need_root = get('bugzilla/mysql_need_root');
215
+ if ($mysql_need_root) {
216
+ $mysql_root_name = get('bugzilla/mysql_root_name');
217
+ $mysql_root_pwd = get('bugzilla/mysql_root_pwd');
221
-$mysql_host = get('bugzilla/mysql_host');
222
-$mysql_port = get('bugzilla/mysql_port');
223
-$mysql_name = get('bugzilla/mysql_name');
224
-$mysql_user = get('bugzilla/mysql_user');
225
-$mysql_user_pwd = get('bugzilla/mysql_user_pwd');
226
+# Later maeans that there is no MySQL server ready for
227
+# bugzilla now, user will come back later.
228
+elsif ($install_way eq 'Later') {
229
+ print STDERR "You answer that there is no MySQL server "
230
+ ."suitable to support the bugzilla database. "
231
+ ."Use 'dpkg-reconfigure bugzilla' when you have"
232
+ ." a MySQL server.\n";
236
-my $mysql_need_root = get('bugzilla/mysql_need_root');
237
+# Well, that should never happend...
239
+ print STDERR "Postinst error, unknown installation way : $install_way";
243
+# If we have to create the databse, let's do it (that will be
244
+# in automatic mode).
245
if ($mysql_need_root eq 'true') {
246
- $mysql_root_name = get('bugzilla/mysql_root_name');
247
- $mysql_root_pwd = get('bugzilla/mysql_root_pwd');
248
$dsn = "DBI:mysql:;$mysql_host;$mysql_port";
249
$dbh = DBI->connect($dsn, $mysql_root_name, $mysql_root_pwd)
250
or die "Can't connect as admin to the database";
252
+ if ($install_way eq 'Automatic' and exists_database()) {
253
+ print STDERR "The database $mysql_name already exists in your MySQL server, I cannot follow the automatic installation.\n";
259
$dbh = DBI->connect($dsn, $mysql_root_name, $mysql_root_pwd)
261
or die "checksetup.pl failed";
263
my $temp="set -e\nset -- @ARGV\n" . << 'EOF';
268
system ($temp) / 256 == 0
270
or die "Can't fix $path/* dirs perm : $!";
275
+ return grep /^$mysql_name$/, $dbh->func('_ListDBs');
278
sub create_database {
279
my @databases = $dbh->func('_ListDBs');
280
unless (grep /^$mysql_name$/, @databases) {
285
- $dbh->do("grant all on $mysql_name.* to $mysql_user\@$fqdn identified by '$mysql_user_pwd'")
286
+ my $sql = "grant all on $mysql_name.* to '$mysql_user'\@$fqdn identified by '$mysql_user_pwd'";
288
or die "Can't grant or create $mysql_user user";