Patch by Holger Schurig <holgerschurig@nikocity.de> -- replace all the
yicky old make*.sh files and the CHANGES file with a new, nifty checksetup.pl file that knows how to create a setup from scratch as well as upgrade an older setup to a new one. Very cool stuff!
This commit is contained in:
Родитель
d3f5ed29ce
Коммит
a7978eef56
|
@ -0,0 +1 @@
|
|||
localconfig
|
|
@ -1,392 +0,0 @@
|
|||
This file contains only important changes made to Bugzilla. If you
|
||||
are updating from an older verseion, make sure that you check this file!
|
||||
|
||||
For a more complete list of what has changed, use Bonsai
|
||||
(http://cvs-mirror.mozilla.org/webtools/bonsai/cvsqueryform.cgi) to
|
||||
query the CVS tree. For example,
|
||||
|
||||
http://cvs-mirror.mozilla.org/webtools/bonsai/cvsquery.cgi?module=all&branch=HEAD&branchtype=match&dir=mozilla%2Fwebtools%2Fbugzilla&file=&filetype=match&who=&whotype=match&sortby=Date&hours=2&date=week&mindate=&maxdate=&cvsroot=%2Fcvsroot
|
||||
|
||||
will tell you what has been changed in the last week.
|
||||
|
||||
|
||||
10/11/99 Restructured voting database to add a cached value in each
|
||||
bug recording how many total votes that bug has. While I'm at it, I
|
||||
removed the unused "area" field from the bugs database. It is
|
||||
distressing to realize that the bugs table has reached the maximum
|
||||
number of indices allowed by MySQL (16), which may make future
|
||||
enhancements awkward.
|
||||
|
||||
You must feed the following to MySQL:
|
||||
|
||||
alter table bugs drop column area;
|
||||
alter table bugs add column votes mediumint not null, add index (votes);
|
||||
|
||||
You then *must* delete the data/versioncache file when you make this
|
||||
change, as it contains references to the "area" field. Deleting it is safe,
|
||||
bugzilla will correctly regenerate it.
|
||||
|
||||
If you have been using the voting feature at all, then you will then
|
||||
need to update the voting cache. You can do this by visiting the
|
||||
sanitycheck.cgi page, and taking it up on its offer to rebuild the
|
||||
votes stuff.
|
||||
|
||||
|
||||
10/7/99 Added voting ability. You must run the new script
|
||||
"makevotestable.sh". You must also feed the following to mysql:
|
||||
|
||||
alter table products add column votesperuser smallint not null;
|
||||
|
||||
|
||||
|
||||
9/15/99 Apparently, newer alphas of MySQL won't allow you to have
|
||||
"when" as a column name. So, I have had to rename a column in the
|
||||
bugs_activity table. You must feed the below to mysql or you won't
|
||||
work at all.
|
||||
|
||||
alter table bugs_activity change column when bug_when datetime not null;
|
||||
|
||||
|
||||
8/16/99 Added "OpenVMS" to the list of OS's. Feed this to mysql:
|
||||
|
||||
alter table bugs change column op_sys op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.6.1", "Mac System 8.0", "Mac System 8.5", "Mac System 8.6", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "FreeBSD", "OSF/1", "Solaris", "SunOS", "Neutrino", "OS/2", "BeOS", "OpenVMS", "other") not null;
|
||||
|
||||
6/22/99 Added an entry to the attachments table to record who the submitter
|
||||
was. Nothing uses this yet, but it still should be recorded.
|
||||
|
||||
alter table attachments add column submitter_id mediumint not null;
|
||||
|
||||
You should also run this script to populate the new field:
|
||||
|
||||
#!/usr/bonsaitools/bin/perl -w
|
||||
use diagnostics;
|
||||
use strict;
|
||||
require "globals.pl";
|
||||
$|=1;
|
||||
ConnectToDatabase();
|
||||
SendSQL("select bug_id, attach_id from attachments order by bug_id");
|
||||
my @list;
|
||||
while (MoreSQLData()) {
|
||||
my @row = FetchSQLData();
|
||||
push(@list, \@row);
|
||||
}
|
||||
foreach my $ref (@list) {
|
||||
my ($bug, $attach) = (@$ref);
|
||||
SendSQL("select long_desc from bugs where bug_id = $bug");
|
||||
my $comment = FetchOneColumn() . "Created an attachment (id=$attach)";
|
||||
|
||||
if ($comment =~ m@-* Additional Comments From ([^ ]*)[- 0-9/:]*\nCreated an attachment \(id=$attach\)@) {
|
||||
print "Found $1\n";
|
||||
SendSQL("select userid from profiles where login_name=" .
|
||||
SqlQuote($1));
|
||||
my $userid = FetchOneColumn();
|
||||
if (defined $userid && $userid > 0) {
|
||||
SendSQL("update attachments set submitter_id=$userid where attach_id = $attach");
|
||||
}
|
||||
} else {
|
||||
print "Bug $bug can't find comment for attachment $attach\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
6/14/99 Added "BeOS" to the list of OS's. Feed this to mysql:
|
||||
|
||||
alter table bugs change column op_sys op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.6.1", "Mac System 8.0", "Mac System 8.5", "Mac System 8.6", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "FreeBSD", "OSF/1", "Solaris", "SunOS", "Neutrino", "OS/2", "BeOS", "other") not null;
|
||||
|
||||
|
||||
5/27/99 Added support for dependency information. You must run the new
|
||||
"makedependenciestable.sh" script. You can turn off dependencies with the new
|
||||
"usedependencies" param, but it defaults to being on. Also, read very
|
||||
carefully the description for the new "webdotbase" param; you will almost
|
||||
certainly need to tweak it.
|
||||
|
||||
|
||||
5/24/99 Added "Mac System 8.6" and "Neutrino" to the list of OS's.
|
||||
Feed this to mysql:
|
||||
|
||||
alter table bugs change column op_sys op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.6.1", "Mac System 8.0", "Mac System 8.5", "Mac System 8.6", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "FreeBSD", "OSF/1", "Solaris", "SunOS", "Neutrino", "OS/2", "other") not null;
|
||||
|
||||
|
||||
5/12/99 Added a pref to control how much email you get. This needs a new
|
||||
column in the profiles table, so feed the following to mysql:
|
||||
|
||||
alter table profiles add column emailnotification enum("ExcludeSelfChanges", "CConly", "All") not null default "ExcludeSelfChanges";
|
||||
|
||||
5/5/99 Added the ability to search by creation date. To make this perform
|
||||
well, you ought to do the following:
|
||||
|
||||
alter table bugs change column creation_ts creation_ts datetime not null, add index (creation_ts);
|
||||
|
||||
|
||||
4/30/99 Added a new severity, "blocker". To get this into your running
|
||||
Bugzilla, do the following:
|
||||
|
||||
alter table bugs change column bug_severity bug_severity enum("blocker", "critical", "major", "normal", "minor", "trivial", "enhancement") not null;
|
||||
|
||||
|
||||
4/22/99 There was a bug where the long descriptions of bugs had a variety of
|
||||
newline characters at the end, depending on the operating system of the browser
|
||||
that submitted the text. This bug has been fixed, so that no further changes
|
||||
like that will happen. But to fix problems that have already crept into your
|
||||
database, you can run the following perl script (which is slow and ugly, but
|
||||
does work:)
|
||||
#!/usr/bonsaitools/bin/perl -w
|
||||
use diagnostics;
|
||||
use strict;
|
||||
require "globals.pl";
|
||||
$|=1;
|
||||
ConnectToDatabase();
|
||||
SendSQL("select bug_id from bugs order by bug_id");
|
||||
my @list;
|
||||
while (MoreSQLData()) {
|
||||
push(@list, FetchOneColumn());
|
||||
}
|
||||
foreach my $id (@list) {
|
||||
if ($id % 50 == 0) {
|
||||
print "\n$id ";
|
||||
}
|
||||
SendSQL("select long_desc from bugs where bug_id = $id");
|
||||
my $comment = FetchOneColumn();
|
||||
my $orig = $comment;
|
||||
$comment =~ s/\r\n/\n/g; # Get rid of windows-style line endings.
|
||||
$comment =~ s/\r/\n/g; # Get rid of mac-style line endings.
|
||||
if ($comment ne $orig) {
|
||||
SendSQL("update bugs set long_desc = " . SqlQuote($comment) .
|
||||
" where bug_id = $id");
|
||||
print ".";
|
||||
} else {
|
||||
print "-";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
4/8/99 Added ability to store patches with bugs. This requires a new table
|
||||
to store the data, so you will need to run the "makeattachmenttable.sh" script.
|
||||
|
||||
3/25/99 Unfortunately, the HTML::FromText CPAN module had too many bugs, and
|
||||
so I had to roll my own. We no longer use the HTML::FromText CPAN module.
|
||||
|
||||
3/24/99 (This entry has been removed. It used to say that we required the
|
||||
HTML::FromText CPAN module, but that's no longer true.)
|
||||
|
||||
3/22/99 Added the ability to query by fields which have changed within a date
|
||||
range. To make this perform a bit better, we need a new index:
|
||||
|
||||
alter table bugs_activity add index (field);
|
||||
|
||||
3/10/99 Added 'groups' stuff, where we have different group bits that we can
|
||||
put on a person or on a bug. Some of the group bits control access to bugzilla
|
||||
features. And a person can't access a bug unless he has every group bit set
|
||||
that is also set on the bug. See the comments in makegroupstable.sh for a bit
|
||||
more info.
|
||||
|
||||
The 'maintainer' param is now used only as an email address for people to send
|
||||
complaints to. The groups table is what is now used to determine permissions.
|
||||
|
||||
You will need to run the new script "makegroupstable.sh". And then you need to
|
||||
feed the following lines to MySQL (replace XXX with the login name of the
|
||||
maintainer, the person you wish to be all-powerful).
|
||||
|
||||
alter table bugs add column groupset bigint not null;
|
||||
alter table profiles add column groupset bigint not null;
|
||||
update profiles set groupset=0x7fffffffffffffff where login_name = XXX;
|
||||
|
||||
|
||||
|
||||
3/8/99 Added params to control how priorities are set in a new bug. You can
|
||||
now choose whether to let submitters of new bugs choose a priority, or whether
|
||||
they should just accept the default priority (which is now no longer hardcoded
|
||||
to "P2", but is instead a param.) The default value of the params will cause
|
||||
the same behavior as before.
|
||||
|
||||
3/3/99 Added a "disallownew" field to the products table. If non-zero, then
|
||||
don't let people file new bugs against this product. (This is for when a
|
||||
product is retired, but you want to keep the bug reports around for posterity.)
|
||||
Feed this to MySQL:
|
||||
|
||||
alter table products add column disallownew tinyint not null;
|
||||
|
||||
|
||||
2/8/99 Added FreeBSD to the list of OS's. Feed this to MySQL:
|
||||
|
||||
alter table bugs change column op_sys op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.6.1", "Mac System 8.0", "Mac System 8.5", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "FreeBSD", "OSF/1", "Solaris", "SunOS", "OS/2", "other") not null;
|
||||
|
||||
|
||||
2/4/99 Added a new column "description" to the components table, and added
|
||||
links to a new page which will use this to describe the components of a
|
||||
given product. Feed this to MySQL:
|
||||
|
||||
alter table components add column description mediumtext not null;
|
||||
|
||||
|
||||
2/3/99 Added a new column "initialqacontact" to the components table that gives
|
||||
an initial QA contact field. It may be empty if you wish the initial qa
|
||||
contact to be empty. If you're not using the QA contact field, you don't need
|
||||
to add this column, but you might as well be safe and add it anyway:
|
||||
|
||||
alter table components add column initialqacontact tinytext not null;
|
||||
|
||||
|
||||
2/2/99 Added a new column "milestoneurl" to the products table that gives a URL
|
||||
which is to describe the currently defined milestones for a product. If you
|
||||
don't use target milestone, you might be able to get away without adding this
|
||||
column, but you might as well be safe and add it anyway:
|
||||
|
||||
alter table products add column milestoneurl tinytext not null;
|
||||
|
||||
|
||||
1/29/99 Whoops; had a mispelled op_sys. It was "Mac System 7.1.6"; it should
|
||||
be "Mac System 7.6.1". It turns out I had no bugs with this value set, so I
|
||||
could just do the below simple command. If you have bugs with this value, you
|
||||
may need to do something more complicated.
|
||||
|
||||
alter table bugs change column op_sys op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.6.1", "Mac System 8.0", "Mac System 8.5", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "OSF/1", "Solaris", "SunOS", "OS/2", "other") not null;
|
||||
|
||||
|
||||
|
||||
1/20/99 Added new fields: Target Milestone, QA Contact, and Status Whiteboard.
|
||||
These fields are all optional in the UI; there are parameters to turn them on.
|
||||
However, whether or not you use them, the fields need to be in the DB. There
|
||||
is some code that needs them, even if you don't.
|
||||
|
||||
To update your DB to have these fields, send the following to MySQL:
|
||||
|
||||
alter table bugs add column target_milestone varchar(20) not null,
|
||||
add column qa_contact mediumint not null,
|
||||
add column status_whiteboard mediumtext not null,
|
||||
add index (target_milestone), add index (qa_contact);
|
||||
|
||||
|
||||
|
||||
1/18/99 You can now query by CC. To make this perform reasonably, the CC table
|
||||
needs some indices. The following MySQL does the necessary stuff:
|
||||
|
||||
alter table cc add index (bug_id), add index (who);
|
||||
|
||||
|
||||
1/15/99 The op_sys field can now be queried by (and more easily tweaked).
|
||||
To make this perform reasonably, it needs an index. The following MySQL
|
||||
command will create the necessary index:
|
||||
|
||||
alter table bugs add index (op_sys);
|
||||
|
||||
|
||||
12/2/98 The op_sys and rep_platform fields have been tweaked. op_sys
|
||||
is now an enum, rather than having the legal values all hard-coded in
|
||||
perl. rep_platform now no longer allows a value of "X-Windows".
|
||||
|
||||
Here's how I ported to the new world. This ought to work for you too.
|
||||
Actually, it's probably overkill. I had a lot of illegal values for op_sys
|
||||
in my tables, from importing bugs from strange places. If you haven't done
|
||||
anything funky, then much of the below will be a no-op.
|
||||
|
||||
First, send the following commands to MySQL to make sure all your values for
|
||||
rep_platform and op_sys are legal in the new world..
|
||||
|
||||
update bugs set rep_platform="Sun" where rep_platform="X-Windows" and op_sys like "Solaris%";
|
||||
update bugs set rep_platform="SGI" where rep_platform="X-Windows" and op_sys = "IRIX";
|
||||
update bugs set rep_platform="SGI" where rep_platform="X-Windows" and op_sys = "HP-UX";
|
||||
update bugs set rep_platform="DEC" where rep_platform="X-Windows" and op_sys = "OSF/1";
|
||||
update bugs set rep_platform="PC" where rep_platform="X-Windows" and op_sys = "Linux";
|
||||
update bugs set rep_platform="other" where rep_platform="X-Windows";
|
||||
update bugs set rep_platform="other" where rep_platform="";
|
||||
update bugs set op_sys="Mac System 7" where op_sys="System 7";
|
||||
update bugs set op_sys="Mac System 7.5" where op_sys="System 7.5";
|
||||
update bugs set op_sys="Mac System 8.0" where op_sys="8.0";
|
||||
update bugs set op_sys="OSF/1" where op_sys="Digital Unix 4.0";
|
||||
update bugs set op_sys="IRIX" where op_sys like "IRIX %";
|
||||
update bugs set op_sys="HP-UX" where op_sys like "HP-UX %";
|
||||
update bugs set op_sys="Windows NT" where op_sys like "NT %";
|
||||
update bugs set op_sys="OSF/1" where op_sys like "OSF/1 %";
|
||||
update bugs set op_sys="Solaris" where op_sys like "Solaris %";
|
||||
update bugs set op_sys="SunOS" where op_sys like "SunOS%";
|
||||
update bugs set op_sys="other" where op_sys = "Motif";
|
||||
update bugs set op_sys="other" where op_sys = "Other";
|
||||
|
||||
Next, send the following commands to make sure you now have only legal
|
||||
entries in your table. If either of the queries do not come up empty, then
|
||||
you have to do more stuff like the above.
|
||||
|
||||
select bug_id,op_sys,rep_platform from bugs where rep_platform not regexp "^(All|DEC|HP|Macintosh|PC|SGI|Sun|X-Windows|Other)$";
|
||||
select bug_id,op_sys,rep_platform from bugs where op_sys not regexp "^(All|Windows 3.1|Windows 95|Windows 98|Windows NT|Mac System 7|Mac System 7.5|Mac System 7.1.6|Mac System 8.0|AIX|BSDI|HP-UX|IRIX|Linux|OSF/1|Solaris|SunOS|other)$";
|
||||
|
||||
Finally, once that's all clear, alter the table to make enforce the new legal
|
||||
entries:
|
||||
|
||||
alter table bugs change column op_sys op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.1.6", "Mac System 8.0", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "OSF/1", "Solaris", "SunOS", "other") not null, change column rep_platform rep_platform enum("All", "DEC", "HP", "Macintosh", "PC", "SGI", "Sun", "Other");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
11/20/98 Added searching of CC field. To better support this, added
|
||||
some indexes to the CC table. You probably want to execute the following
|
||||
mysql commands:
|
||||
|
||||
alter table cc add index (bug_id);
|
||||
alter table cc add index (who);
|
||||
|
||||
|
||||
10/27/98 security check for legal products in place. bug charts are not
|
||||
available as an option if collectstats.pl has never been run. all products
|
||||
get daily stats collected now. README updated: Chart::Base is listed as
|
||||
a requirement, instructions for using collectstats.pl included as
|
||||
an optional step. also got silly and added optional quips to bug
|
||||
reports.
|
||||
|
||||
10/17/98 modified README installation instructions slightly.
|
||||
|
||||
10/7/98 Added a new table called "products". Right now, this is used
|
||||
only to have a description for each product, and that description is
|
||||
only used when initially adding a new bug. Anyway, you *must* create
|
||||
the new table (which you can do by running the new makeproducttable.sh
|
||||
script). If you just leave it empty, things will work much as they
|
||||
did before, or you can add descriptions for some or all of your
|
||||
products.
|
||||
|
||||
|
||||
9/15/98 Everything has been ported to Perl. NO MORE TCL. This
|
||||
transition should be relatively painless, except for the "params"
|
||||
file. This is the file that contains parameters you've set up on the
|
||||
editparams.cgi page. Before changing to Perl, this was a tcl-syntax
|
||||
file, stored in the same directory as the code; after the change to
|
||||
Perl, it becomes a perl-syntax file, stored in a subdirectory named
|
||||
"data". See the README file for more details on what version of Perl
|
||||
you need.
|
||||
|
||||
So, if updating from an older version of Bugzilla, you will need to
|
||||
edit data/param, change the email address listed for
|
||||
$::param{'maintainer'}, and then go revisit the editparams.cgi page
|
||||
and reset all the parameters to your taste. Fortunately, your old
|
||||
params file will still be around, and so you ought to be able to
|
||||
cut&paste important bits from there.
|
||||
|
||||
Also, note that the "whineatnews" script has changed name (it now has
|
||||
an extension of .pl instead of .tcl), so you'll need to change your
|
||||
cron job.
|
||||
|
||||
And the "comments" file has been moved to the data directory. Just do
|
||||
"cat comments >> data/comments" to restore any old comments that may
|
||||
have been lost.
|
||||
|
||||
|
||||
|
||||
9/2/98 Changed the way password validation works. We now keep a
|
||||
crypt'd version of the password in the database, and check against
|
||||
that. (This is silly, because we're also keeping the plaintext
|
||||
version there, but I have plans...) Stop passing the plaintext
|
||||
password around as a cookie; instead, we have a cookie that references
|
||||
a record in a new database table, logincookies.
|
||||
|
||||
IMPORTANT: if updating from an older version of Bugzilla, you must run
|
||||
the following commands to keep things working:
|
||||
|
||||
./makelogincookiestable.sh
|
||||
echo "alter table profiles add column cryptpassword varchar(64);" | mysql bugs
|
||||
echo "update profiles set cryptpassword = encrypt(password,substring(rand(),3, 4));" | mysql bugs
|
||||
|
|
@ -201,17 +201,8 @@ you can get at the files in that directory through your web server.
|
|||
|
||||
Once all the files are in a web accessible directory, make that
|
||||
directory writable by your webserver's user (which may require just
|
||||
making it world writable). Inside this main bugzilla directory issue the
|
||||
following commands:
|
||||
|
||||
mkdir data
|
||||
cd data
|
||||
touch comments
|
||||
touch nomail
|
||||
touch mail
|
||||
making it world writable).
|
||||
|
||||
Make sure the data directory and files are writable by the webserver.
|
||||
|
||||
Lastly, you'll need to set up a symbolic link from /usr/bonsaitools/bin
|
||||
to the correct location of your perl executable (probably /usr/bin/perl). Or,
|
||||
you'll have to hack all the .cgi files to change where they look for perl.
|
||||
|
@ -249,54 +240,19 @@ For much more information about MySQL permissions, see the MySQL documentation.
|
|||
After you've tweaked the permissions, run "mysqladmin reload" to make sure that
|
||||
the database server knows to look at your new permission list.
|
||||
|
||||
Next we'll create the bugs database in MySQL. This is done using the
|
||||
'mysql' command line client. This client allows one to funnel SQL
|
||||
statements into the MySQL server directly. It's usage summary is
|
||||
available by running:
|
||||
Next, you can just run the magic checksetup.pl script. (Many thanks to Holger
|
||||
Schurig <holgerschurig@nikocity.de> for writing this script!) It will make
|
||||
sure things have reasonable permissions, set up the "data" directory, and
|
||||
create all the MySQL tables. Just run:
|
||||
|
||||
mysql --help
|
||||
./checksetup.pl
|
||||
|
||||
from the command line.
|
||||
|
||||
Once you've begun mysql you'll see a 'mysql>' prompt. At the prompt you
|
||||
should enter:
|
||||
|
||||
create database bugs;
|
||||
quit
|
||||
The first time you run it, it will create a file called "localconfig" which you
|
||||
should examine and perhaps tweak a bit. Then re-run checksetup.pl and it will
|
||||
do the real work.
|
||||
|
||||
|
||||
To create the tables necessary for bug tracking and to minimally
|
||||
populate the bug tracking system you'll need to run the eight shell
|
||||
scripts found in your bugzilla directory that begin with 'make'. These
|
||||
scripts load data into the database by piping input into the mysql
|
||||
command. Order does not matter, but this one is fine:
|
||||
|
||||
./makeactivitytable.sh
|
||||
./makeattachmenttable.sh
|
||||
./makebugtable.sh
|
||||
./makecctable.sh
|
||||
./makecomponenttable.sh
|
||||
./makedependenciestable.sh
|
||||
./makegroupstable.sh
|
||||
./makelogincookiestable.sh
|
||||
./makeproducttable.sh
|
||||
./makeprofilestable.sh
|
||||
./makeversiontable.sh
|
||||
./makevotestable.sh
|
||||
|
||||
You may want to edit the scripts; once bugs are entered it gets very hard to
|
||||
make changes. Think carefully about how you want database users to describe bugs. Here's one
|
||||
suggested alternative:
|
||||
|
||||
priority enum("P1", "P2", "P3", "P4", "defer") not null,
|
||||
bug_severity enum("critical", "normal", "low", "---",
|
||||
"enhancement", "requirement", "polish") not null,
|
||||
op_sys enum("Unspecified", "Windows 3.1", "Windows 95", "Windows 98",
|
||||
"Windows NT", "Mac System 7", "Mac System 8", "Linux",
|
||||
"Solaris", "FreeBSD", "Other Unix", "other") not null,
|
||||
rep_platform enum("Unspecified", "Apple", "PC Clone", "Sun", "other"),
|
||||
|
||||
After running the scripts you've got a nearly empty copy of the bug tracking setup.
|
||||
At ths point, you should have a nearly empty copy of the bug tracking setup.
|
||||
|
||||
4. Tweaking the Bugzilla->MySQL Connection Data
|
||||
|
||||
|
@ -336,7 +292,7 @@ effectively make you 'superuser'. The SQL to type is:
|
|||
|
||||
update profiles set groupset=0x7fffffffffffffff where login_name = 'XXX';
|
||||
|
||||
replacing XXX with your BugZilla email address.
|
||||
replacing XXX with your Bugzilla email address.
|
||||
|
||||
Now, if you go to the query page (off of the bugzilla main menu) where you'll
|
||||
now find a 'edit parameters' option which is filled with editable treats.
|
||||
|
@ -468,19 +424,13 @@ hour old, so Bugzilla will eventually notice your changes by itself, but
|
|||
generally you want it to notice right away, so that you can test things.
|
||||
|
||||
|
||||
Appendix C. Upgrading from previous versions of BugZilla
|
||||
Appendix C. Upgrading from previous versions of Bugzilla
|
||||
|
||||
The developers of BugZilla are constantly adding new tables, columns and fields.
|
||||
You'll get SQL errors if you just update the code. The strategy to update is
|
||||
to read the CHANGES file backwards, and apply all of the instructions given,
|
||||
typically things like:
|
||||
|
||||
./makeattachmenttable.sh
|
||||
./makegroupstable.sh
|
||||
alter table products add column disallownew tinyint not null;
|
||||
|
||||
Someday someone should write a script that queries the existing database
|
||||
for all the required columns, and if any are missing, adds them.
|
||||
The developers of Bugzilla are constantly adding new tables, columns and
|
||||
fields. You'll get SQL errors if you just update the code. The strategy to
|
||||
update is to simply always run the checksetup.pl script whenever you upgrade
|
||||
your installation of Bugzilla. If you want to see what has changed, you can
|
||||
read the comments in that file, starting from the end.
|
||||
|
||||
|
||||
Appendix D. History
|
||||
|
|
|
@ -0,0 +1,931 @@
|
|||
#!/usr/bonsaitools/bin/perl -w
|
||||
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License
|
||||
# Version 1.0 (the "License"); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS"
|
||||
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing rights and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Contributor(s): Holger Schurig <holgerschurig@nikocity.de>
|
||||
# Terry Weissman <terry@mozilla.org>
|
||||
#
|
||||
#
|
||||
# Direct any questions on this source code to
|
||||
#
|
||||
# Holger Schurig <holgerschurig@nikocity.de>
|
||||
#
|
||||
#
|
||||
#
|
||||
# Hey, what's this?
|
||||
#
|
||||
# 'checksetup.pl' is a script that is supposed to run during installation
|
||||
# time and also after every upgrade.
|
||||
#
|
||||
# The goal of this script is to make the installation even more easy.
|
||||
# It does so by doing things for you as well as testing for problems
|
||||
# early.
|
||||
#
|
||||
# And you can re-run it whenever you want. Especially after Bugzilla
|
||||
# get's updated you SHOULD rerun it. Because then it may update your
|
||||
# SQL table definitions so that they are again in sync with the code.
|
||||
#
|
||||
# So, currently this module does:
|
||||
#
|
||||
# - check for required perl modules
|
||||
# - set defaults for local configuration variables
|
||||
# - create and populate the data directory after installation
|
||||
# - set the proper rights for the *.cgi, *.html ... etc files
|
||||
# - check if the code can access MySQL
|
||||
# - creates the database 'bugs' if the database does not exist
|
||||
# - creates the tables inside the database if they don't exist
|
||||
# - automatically changes the table definitions of older BugZilla
|
||||
# installations
|
||||
# - populates the groups
|
||||
# - changes already existing SQL tables if you change your local
|
||||
# settings, e.g. when you add a new platform
|
||||
#
|
||||
# People that install this module locally are not supposed to modify
|
||||
# this script. This is done by shifting the user settable stuff intp
|
||||
# a local configuration file 'localconfig'. When this file get's
|
||||
# changed and 'checkconfig.pl' will be re-run, then the user changes
|
||||
# will be reflected back into the database.
|
||||
#
|
||||
# Developers however have to modify this file at various places. To
|
||||
# make this easier, I have added some special comments that one can
|
||||
# search for.
|
||||
#
|
||||
# To Search for
|
||||
#
|
||||
# add/delete local configuration variables --LOCAL--
|
||||
# check for more prerequired modules --MODULES--
|
||||
# change the defaults for local configuration vars --LOCAL--
|
||||
# update the assigned file permissions --CHMOD--
|
||||
# add more MySQL-related checks --MYSQL--
|
||||
# change table definitions --TABLE--
|
||||
# add more groups --GROUPS--
|
||||
#
|
||||
# Note: sometimes those special comments occur more then once. For
|
||||
# example, --LOCAL-- is at least 3 times in this code! --TABLE--
|
||||
# also is used more than once. So search for every occurence!
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Global definitions
|
||||
###########################################################################
|
||||
|
||||
use diagnostics;
|
||||
use strict;
|
||||
|
||||
|
||||
|
||||
#
|
||||
# This are the --LOCAL-- variables defined in 'localconfig'
|
||||
#
|
||||
|
||||
use vars qw(
|
||||
$webservergroup
|
||||
$db_host $db_port $db_name $db_user
|
||||
@severities @priorities @opsys @platforms
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Check required module
|
||||
###########################################################################
|
||||
|
||||
#
|
||||
# Here we check for --MODULES--
|
||||
#
|
||||
|
||||
print "Checking perl modules ...\n";
|
||||
unless (eval "require 5.004") {
|
||||
die "Sorry, you need at least Perl 5.004\n";
|
||||
}
|
||||
|
||||
unless (eval "require DBI") {
|
||||
die "Please install the DBI module. You can do this by running (as root)\n\n",
|
||||
" perl -MCPAN -eshell\n",
|
||||
" install DBI\n";
|
||||
}
|
||||
|
||||
unless (eval "require Data::Dumper") {
|
||||
die "Please install the Data::Dumper module. You can do this by running (as root)\n\n",
|
||||
" perl -MCPAN -eshell\n",
|
||||
" install Data::Dumper\n";
|
||||
}
|
||||
|
||||
unless (eval "require Mysql") {
|
||||
die "Please install the Mysql database driver. You can do this by running (as root)\n\n",
|
||||
" perl -MCPAN -eshell\n",
|
||||
" install Msql-Mysql\n\n",
|
||||
"Be sure to enable the Mysql emulation!";
|
||||
}
|
||||
|
||||
unless (eval "require Date::Parse") {
|
||||
die "Please install the Date::Parse module. You can do this by running (as root)\n\n",
|
||||
" perl -MCPAN -eshell\n",
|
||||
" install Date::Parse\n";
|
||||
}
|
||||
|
||||
# The following two modules are optional:
|
||||
my $charts = 0;
|
||||
$charts++ if eval "require GD";
|
||||
$charts++ if eval "require Chart::Base";
|
||||
if ($charts != 2) {
|
||||
print "If you you want to see graphical bug dependency charts, you may install\n",
|
||||
"the optional libgd and the Perl modules GD and Chart::Base, e.g. by\n",
|
||||
"running (as root)\n\n",
|
||||
" perl -MCPAN -eshell\n",
|
||||
" install GD\n",
|
||||
" install Chart::Base\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Check and update local configuration
|
||||
###########################################################################
|
||||
|
||||
#
|
||||
# This is quite tricky. But fun!
|
||||
#
|
||||
# First we read the file 'localconfig'. And then we check if the variables
|
||||
# we need to be defined are defined. If not, localconfig will be amended by
|
||||
# the new settings and the user informed to check this. The program then
|
||||
# stops.
|
||||
#
|
||||
# Why do it this way around?
|
||||
#
|
||||
# Assume we will enhance Bugzilla and eventually more local configuration
|
||||
# stuff arises on the horizon.
|
||||
#
|
||||
# But the file 'localconfig' is not in the Bugzilla CVS or tarfile. It should
|
||||
# not be there so that we never overwrite user's local setups accidentally.
|
||||
# Now, we need a new variable. We simply add the necessary stuff to checksetup.
|
||||
# The user get's the new version of Bugzilla from the CVS, runs checksetup
|
||||
# and checksetup finds out "Oh, there is something new". Then it adds some
|
||||
# default value to the user's local setup and informs the user to check that
|
||||
# to see if that is what the user wants.
|
||||
#
|
||||
# Cute, ey?
|
||||
#
|
||||
|
||||
print "Checking user setup ...\n";
|
||||
do 'localconfig';
|
||||
my $newstuff = "";
|
||||
sub LocalVar ($$)
|
||||
{
|
||||
my ($name, $definition) = @_;
|
||||
|
||||
# Is there a cleaner way to test if the variable defined in scalar $name
|
||||
# is defined or not?
|
||||
my $defined = 0;
|
||||
$_ = "\$defined = 1 if defined $name;";
|
||||
eval $_;
|
||||
return if $defined;
|
||||
|
||||
$newstuff .= " " . $name;
|
||||
open FILE, '>>localconfig';
|
||||
print FILE $definition, "\n\n";
|
||||
close FILE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Set up the defaults for the --LOCAL-- variables below:
|
||||
#
|
||||
|
||||
|
||||
LocalVar('$webservergroup', '
|
||||
#
|
||||
# This is the group your web server runs on.
|
||||
# If you have a windows box, ignore this setting.
|
||||
# If you do not wish for checksetup to adjust the permissions of anything,
|
||||
# set this to "".
|
||||
# If you set this to anything besides "", you will need to run checksetup.pl
|
||||
# as root.
|
||||
$webservergroup = "nobody";
|
||||
');
|
||||
|
||||
|
||||
|
||||
LocalVar('$db_host', '
|
||||
#
|
||||
# How to access the SQL database:
|
||||
#
|
||||
$db_host = "localhost"; # where is the database?
|
||||
$db_port = 3306; # which port to use
|
||||
$db_name = "bugs"; # name of the MySQL database
|
||||
$db_user = "bugs"; # user to attach to the MySQL database
|
||||
');
|
||||
|
||||
|
||||
|
||||
LocalVar('@severities', '
|
||||
#
|
||||
# Which bug and feature-request severities do you want?
|
||||
#
|
||||
@severities = (
|
||||
"blocker",
|
||||
"critical",
|
||||
"major",
|
||||
"normal",
|
||||
"minor",
|
||||
"trivial",
|
||||
"enhancement"
|
||||
);
|
||||
');
|
||||
|
||||
|
||||
|
||||
LocalVar('@priorities', '
|
||||
#
|
||||
# Which priorities do you want to assign to bugs and feature-request?
|
||||
#
|
||||
@priorities = (
|
||||
"P1",
|
||||
"P2",
|
||||
"P3",
|
||||
"P4",
|
||||
"P5"
|
||||
);
|
||||
');
|
||||
|
||||
|
||||
|
||||
LocalVar('@opsys', '
|
||||
#
|
||||
# What operatings systems may your products run on?
|
||||
#
|
||||
@opsys = (
|
||||
"All",
|
||||
"Windows 3.1",
|
||||
"Windows 95",
|
||||
"Windows 98",
|
||||
"Windows NT",
|
||||
"Mac System 7",
|
||||
"Mac System 7.5",
|
||||
"Mac System 7.6.1",
|
||||
"Mac System 8.0",
|
||||
"Mac System 8.5",
|
||||
"Mac System 8.6",
|
||||
"AIX",
|
||||
"BSDI",
|
||||
"HP-UX",
|
||||
"IRIX",
|
||||
"Linux",
|
||||
"FreeBSD",
|
||||
"OSF/1",
|
||||
"Solaris",
|
||||
"SunOS",
|
||||
"Neutrino",
|
||||
"OS/2",
|
||||
"BeOS",
|
||||
"OpenVMS",
|
||||
"other"
|
||||
);
|
||||
');
|
||||
|
||||
|
||||
|
||||
LocalVar('@platforms', '
|
||||
#
|
||||
# What hardware platforms may your products run on?
|
||||
#
|
||||
@platforms = (
|
||||
"All",
|
||||
"DEC",
|
||||
"HP",
|
||||
"Macintosh",
|
||||
"PC",
|
||||
"SGI",
|
||||
"Sun",
|
||||
"Other"
|
||||
);
|
||||
');
|
||||
|
||||
|
||||
|
||||
|
||||
if ($newstuff ne "") {
|
||||
print "This version of Bugzilla contains some variables that you may \n",
|
||||
"to change and adapt to your local settings. Please edit the file\n",
|
||||
"'localconfig' and return checksetup.pl\n\n",
|
||||
"The following variables are new to localconfig since you last ran\n",
|
||||
"checksetup.pl: $newstuff\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Check data directory
|
||||
###########################################################################
|
||||
|
||||
#
|
||||
# Create initial --DATA-- directory and make the initial empty files there:
|
||||
#
|
||||
|
||||
unless (-d 'data') {
|
||||
print "Creating data directory ...\n";
|
||||
mkdir 'data', 0770;
|
||||
if ($webservergroup eq "") {
|
||||
chmod 0777, 'data';
|
||||
}
|
||||
open FILE, '>>data/comments'; close FILE;
|
||||
open FILE, '>>data/nomail'; close FILE;
|
||||
open FILE, '>>data/mail'; close FILE;
|
||||
chmod 0666, glob('data/*');
|
||||
}
|
||||
|
||||
# Just to be sure ...
|
||||
unlink "data/versioncache";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Set proper rights
|
||||
###########################################################################
|
||||
|
||||
#
|
||||
# Here we use --CHMOD-- and friends to set the file permissions
|
||||
#
|
||||
# The rationale is that the web server generally runs as nobody and so the cgi
|
||||
# scripts should not be writable for nobody, otherwise someone may be possible
|
||||
# to change the cgi's when exploiting some security flaw somewhere (not
|
||||
# necessarily in Bugzilla!)
|
||||
#
|
||||
# Also, some *.pl files are executable, some are not.
|
||||
#
|
||||
# +++ Can anybody tell me what a Windows Perl would do with this code?
|
||||
#
|
||||
|
||||
|
||||
# Funny! getgrname returns the GID if fed with NAME ...
|
||||
|
||||
if ($webservergroup ne "") {
|
||||
my $webservergid = getgrnam($webservergroup);
|
||||
chown 0, $webservergid, glob('*');
|
||||
chmod 0640, glob('*');
|
||||
|
||||
chmod 0750, glob('*.cgi'),
|
||||
'processmail',
|
||||
'whineatnews.pl',
|
||||
'collectstats.pl',
|
||||
'checksetup.pl';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Check MySQL setup
|
||||
###########################################################################
|
||||
|
||||
#
|
||||
# Check if we have access to --MYSQL--
|
||||
#
|
||||
|
||||
# This settings are not yet changeable, because other code depends on it:
|
||||
|
||||
my $db_base = 'mysql';
|
||||
my $db_pass = ''; # Password to attach to the MySQL database
|
||||
|
||||
use DBI;
|
||||
|
||||
# get a handle to the low-level DBD driver
|
||||
my $drh = DBI->install_driver($db_base)
|
||||
or die "Can't connect to the $db_base. Is the database installed and up and running?\n";
|
||||
|
||||
# Do we have the database itself?
|
||||
my @databases = $drh->func($db_host, $db_port, '_ListDBs');
|
||||
unless (grep /^$db_name$/, @databases) {
|
||||
print "Creating database $db_name ...\n";
|
||||
$drh->func('createdb', $db_name, 'admin')
|
||||
or die "The '$db_name' database does not exist. I tried to create the database,\n",
|
||||
"but that didn't work, probably because of access rigths. Read the README\n",
|
||||
"file and the documentation of $db_base to make sure that everything is\n",
|
||||
"set up correctly.\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
# now get a handle to the database:
|
||||
my $connectstring = "dbi:$db_base:$db_name:host=$db_host:port=$db_port";
|
||||
my $dbh = DBI->connect($connectstring, $db_user, $db_pass)
|
||||
or die "Can't connect to the table '$connectstring'.\n",
|
||||
"Have you read Bugzilla's README? Have you read the doc of '$db_name'?\n";
|
||||
|
||||
END { $dbh->disconnect if $dbh }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Table definitions
|
||||
###########################################################################
|
||||
|
||||
#
|
||||
# The following hash stores all --TABLE-- definitions. This will be used
|
||||
# to automatically create those tables that don't exist. The code is
|
||||
# safer than the make*.sh shell scripts used to be, because they won't
|
||||
# delete existing tables.
|
||||
#
|
||||
# If you want intentionally do this, yon can always drop a table and re-run
|
||||
# checksetup, e.g. like this:
|
||||
#
|
||||
# $ mysql bugs
|
||||
# mysql> drop table votes;
|
||||
# mysql> exit;
|
||||
# $ ./checksetup.pl
|
||||
#
|
||||
# If you change one of those field definitions, then also go below to the
|
||||
# next occurence of the string --TABLE-- (near the end of this file) to
|
||||
# add the code that updates older installations automatically.
|
||||
#
|
||||
|
||||
|
||||
my %table;
|
||||
|
||||
$table{bugs_activity} =
|
||||
'bug_id mediumint not null,
|
||||
who mediumint not null,
|
||||
bug_when datetime not null,
|
||||
field varchar(64) not null,
|
||||
oldvalue tinytext,
|
||||
newvalue tinytext,
|
||||
|
||||
index (bug_id),
|
||||
index (bug_when),
|
||||
index (field)';
|
||||
|
||||
|
||||
$table{attachments} =
|
||||
'attach_id mediumint not null auto_increment primary key,
|
||||
bug_id mediumint not null,
|
||||
creation_ts timestamp,
|
||||
description mediumtext not null,
|
||||
mimetype mediumtext not null,
|
||||
ispatch tinyint,
|
||||
filename mediumtext not null,
|
||||
thedata longblob not null,
|
||||
submitter_id mediumint not null,
|
||||
|
||||
index(bug_id),
|
||||
index(creation_ts)';
|
||||
|
||||
|
||||
$table{bugs} =
|
||||
'bug_id mediumint not null auto_increment primary key,
|
||||
groupset bigint not null,
|
||||
assigned_to mediumint not null, # This is a comment.
|
||||
bug_file_loc text,
|
||||
bug_severity enum($severities) not null,
|
||||
bug_status enum("NEW", "ASSIGNED", "REOPENED", "RESOLVED", "VERIFIED", "CLOSED") not null,
|
||||
creation_ts datetime not null,
|
||||
delta_ts timestamp,
|
||||
short_desc mediumtext,
|
||||
long_desc mediumtext,
|
||||
op_sys enum($opsys) not null,
|
||||
priority enum($priorities) not null,
|
||||
product varchar(64) not null,
|
||||
rep_platform enum($platforms),
|
||||
reporter mediumint not null,
|
||||
version varchar(16) not null,
|
||||
component varchar(50) not null,
|
||||
resolution enum("", "FIXED", "INVALID", "WONTFIX", "LATER", "REMIND", "DUPLICATE", "WORKSFORME") not null,
|
||||
target_milestone varchar(20) not null,
|
||||
qa_contact mediumint not null,
|
||||
status_whiteboard mediumtext not null,
|
||||
votes mediumint not null,
|
||||
|
||||
index (assigned_to),
|
||||
index (creation_ts),
|
||||
index (delta_ts),
|
||||
index (bug_severity),
|
||||
index (bug_status),
|
||||
index (op_sys),
|
||||
index (priority),
|
||||
index (product),
|
||||
index (reporter),
|
||||
index (version),
|
||||
index (component),
|
||||
index (resolution),
|
||||
index (target_milestone),
|
||||
index (qa_contact),
|
||||
index (votes)';
|
||||
|
||||
|
||||
$table{cc} =
|
||||
'bug_id mediumint not null,
|
||||
who mediumint not null,
|
||||
|
||||
index(bug_id),
|
||||
index(who)';
|
||||
|
||||
|
||||
$table{components} =
|
||||
'value tinytext,
|
||||
program varchar(64),
|
||||
initialowner tinytext not null, # Should arguably be a mediumint!
|
||||
initialqacontact tinytext not null, # Should arguably be a mediumint!
|
||||
description mediumtext not null';
|
||||
|
||||
|
||||
$table{dependencies} =
|
||||
'blocked mediumint not null,
|
||||
dependson mediumint not null,
|
||||
|
||||
index(blocked),
|
||||
index(dependson)';
|
||||
|
||||
|
||||
# Group bits must be a power of two. Groups are identified by a bit; sets of
|
||||
# groups are indicated by or-ing these values together.
|
||||
#
|
||||
# isbuggroup is nonzero if this is a group that controls access to a set
|
||||
# of bugs. In otherword, the groupset field in the bugs table should only
|
||||
# have this group's bit set if isbuggroup is nonzero.
|
||||
#
|
||||
# User regexp is which email addresses are initially put into this group.
|
||||
# This is only used when an email account is created; otherwise, profiles
|
||||
# may be individually tweaked to add them in and out of groups.
|
||||
|
||||
$table{groups} =
|
||||
'bit bigint not null,
|
||||
name varchar(255) not null,
|
||||
description text not null,
|
||||
isbuggroup tinyint not null,
|
||||
userregexp tinytext not null,
|
||||
|
||||
unique(bit),
|
||||
unique(name)';
|
||||
|
||||
|
||||
$table{logincookies} =
|
||||
'cookie mediumint not null auto_increment primary key,
|
||||
userid mediumint not null,
|
||||
cryptpassword varchar(64),
|
||||
hostname varchar(128),
|
||||
lastused timestamp,
|
||||
|
||||
index(lastused)';
|
||||
|
||||
|
||||
$table{products} =
|
||||
'product varchar(64),
|
||||
description mediumtext,
|
||||
milestoneurl tinytext not null,
|
||||
disallownew tinyint not null,
|
||||
votesperuser smallint not null';
|
||||
|
||||
$table{profiles} =
|
||||
'userid mediumint not null auto_increment primary key,
|
||||
login_name varchar(255) not null,
|
||||
password varchar(16),
|
||||
cryptpassword varchar(64),
|
||||
realname varchar(255),
|
||||
groupset bigint not null,
|
||||
emailnotification enum("ExcludeSelfChanges", "CConly", "All") not null default "ExcludeSelfChanges",
|
||||
|
||||
index(login_name)';
|
||||
|
||||
|
||||
$table{versions} =
|
||||
'value tinytext,
|
||||
program varchar(64)';
|
||||
|
||||
|
||||
$table{votes} =
|
||||
'who mediumint not null,
|
||||
bug_id mediumint not null,
|
||||
count smallint not null,
|
||||
|
||||
index(who),
|
||||
index(bug_id)';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Create tables
|
||||
###########################################################################
|
||||
|
||||
# The current DBI::mysql tells me to use this:
|
||||
#my @tables = map { $_ =~ s/.*\.//; $_ } $dbh->tables();
|
||||
# but that doesn't work on a freshly created database, so I still use
|
||||
my @tables = $dbh->func('_ListTables');
|
||||
#print 'Tables: ', join " ", @tables, "\n";
|
||||
|
||||
my $severities = '"' . join('", "', @severities) . '"';
|
||||
my $priorities = '"' . join('", "', @priorities) . '"';
|
||||
my $opsys = '"' . join('", "', @opsys) . '"';
|
||||
my $platforms = '"' . join('", "', @platforms) . '"';
|
||||
|
||||
# go throught our %table hash and create missing tables
|
||||
while (my ($tabname, $fielddef) = each %table) {
|
||||
next if grep /^$tabname$/, @tables;
|
||||
print "Creating table $tabname ...\n";
|
||||
$fielddef =~ s/\$severities/$severities/;
|
||||
$fielddef =~ s/\$priorities/$priorities/;
|
||||
$fielddef =~ s/\$opsys/$opsys/;
|
||||
$fielddef =~ s/\$platforms/$platforms/;
|
||||
|
||||
$dbh->do("CREATE TABLE $tabname (\n$fielddef\n)")
|
||||
or die "Could not create table '$tabname'. Please check your '$db_base' access.\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Populate groups table
|
||||
###########################################################################
|
||||
|
||||
#
|
||||
# This subroutine checks if a group exist. If not, it will be automatically
|
||||
# created with the next available bit set
|
||||
#
|
||||
|
||||
sub AddGroup ($$)
|
||||
{
|
||||
my ($name, $desc) = @_;
|
||||
|
||||
# does the group exist?
|
||||
my $sth = $dbh->prepare("SELECT name FROM groups WHERE name='$name'");
|
||||
$sth->execute;
|
||||
return if $sth->rows;
|
||||
|
||||
# get highest bit number
|
||||
$sth = $dbh->prepare("SELECT bit FROM groups ORDER BY bit DESC");
|
||||
$sth->execute;
|
||||
my @row = $sth->fetchrow_array;
|
||||
|
||||
# normalize bits
|
||||
my $bit;
|
||||
if (defined $row[0]) {
|
||||
$bit = $row[0] << 1;
|
||||
} else {
|
||||
$bit = 1;
|
||||
}
|
||||
|
||||
|
||||
print "Adding group $name ...\n";
|
||||
$sth = $dbh->prepare('INSERT INTO groups
|
||||
(bit, name, description, userregexp)
|
||||
VALUES (?, ?, ?, ?)');
|
||||
$sth->execute($bit, $name, $desc, "");
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# BugZilla uses --GROUPS-- to assign various rights to it's users.
|
||||
#
|
||||
|
||||
AddGroup 'tweakparams', 'Can tweak operating parameters';
|
||||
AddGroup 'editgroupmembers', 'Can put people in and out of groups that they are members of.';
|
||||
AddGroup 'creategroups', 'Can create and destroy groups.';
|
||||
AddGroup 'editcomponents', 'Can create, destroy, and edit components.';
|
||||
#AddGroup 'editproducts', 'Can create, destroy, and edit products.';
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Create initial test product if there are no products present.
|
||||
###########################################################################
|
||||
|
||||
my $sth = $dbh->prepare("SELECT product FROM products");
|
||||
$sth->execute;
|
||||
if ($sth->rows == 0) {
|
||||
print "Creating initial dummy product 'TestProduct' ...\n";
|
||||
$sth = $dbh->prepare('INSERT INTO products(product, description) VALUES ("TestProduct", "This is a test product. This ought to be blown away and replaced with real stuff in a finished installation of bugzilla.")');
|
||||
$sth->execute();
|
||||
$sth = $dbh->prepare('INSERT INTO versions (value, program) VALUES ("other", "TestProduct")');
|
||||
$sth->execute();
|
||||
$sth = $dbh->prepare('INSERT INTO components (value, program, description) VALUES ("TestComponent", "TestProduct", "This is a test component in the test product database. This ought to be blown away and replaced with real stuff in a finished installation of bugzilla.")');
|
||||
$sth->execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Detect changed local settings
|
||||
###########################################################################
|
||||
|
||||
#
|
||||
# Check if the enums in the bugs table return the same values that are defined
|
||||
# in the various locally changeable variables. If this is true, then alter the
|
||||
# table definition.
|
||||
#
|
||||
|
||||
sub GetFieldDef ($$)
|
||||
{
|
||||
my ($table, $field) = @_;
|
||||
my $sth = $dbh->prepare("SHOW COLUMNS FROM $table");
|
||||
$sth->execute;
|
||||
|
||||
while (my $ref = $sth->fetchrow_arrayref) {
|
||||
next if $$ref[0] ne $field;
|
||||
return $ref;
|
||||
}
|
||||
}
|
||||
|
||||
sub CheckEnumField ($$@)
|
||||
{
|
||||
my ($table, $field, @against) = @_;
|
||||
|
||||
my $ref = GetFieldDef($table, $field);
|
||||
#print "0: $$ref[0] 1: $$ref[1] 2: $$ref[2] 3: $$ref[3] 4: $$ref[4]\n";
|
||||
|
||||
$_ = "enum('" . join("','", @against) . "')";
|
||||
if ($$ref[1] ne $_) {
|
||||
print "Updating field $field in table $table ...\n";
|
||||
$_ .= " NOT NULL" if $$ref[3];
|
||||
$dbh->do("ALTER TABLE $table
|
||||
CHANGE $field
|
||||
$field $_");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#
|
||||
# This code changes the enum types of some SQL tables whenever you change
|
||||
# some --LOCAL-- variables
|
||||
#
|
||||
|
||||
CheckEnumField('bugs', 'bug_severity', @severities);
|
||||
CheckEnumField('bugs', 'priority', @priorities);
|
||||
CheckEnumField('bugs', 'op_sys', @opsys);
|
||||
CheckEnumField('bugs', 'rep_platform', @platforms);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Update the tables to the current definition
|
||||
###########################################################################
|
||||
|
||||
#
|
||||
# As time passes, fields in tables get deleted, added, changed and so on.
|
||||
# So we need some helper subroutines to make this possible:
|
||||
#
|
||||
|
||||
sub ChangeFieldType ($$$)
|
||||
{
|
||||
my ($table, $field, $newtype) = @_;
|
||||
|
||||
my $ref = GetFieldDef($table, $field);
|
||||
#print "0: $$ref[0] 1: $$ref[1] 2: $$ref[2] 3: $$ref[3] 4: $$ref[4]\n";
|
||||
|
||||
if ($$ref[1] ne $newtype) {
|
||||
print "Updating field type $field in table $table ...\n";
|
||||
$newtype .= " NOT NULL" if $$ref[3];
|
||||
$dbh->do("ALTER TABLE $table
|
||||
CHANGE $field
|
||||
$field $newtype");
|
||||
}
|
||||
}
|
||||
|
||||
sub RenameField ($$$)
|
||||
{
|
||||
my ($table, $field, $newname) = @_;
|
||||
|
||||
my $ref = GetFieldDef($table, $field);
|
||||
return unless $ref; # already fixed?
|
||||
#print "0: $$ref[0] 1: $$ref[1] 2: $$ref[2] 3: $$ref[3] 4: $$ref[4]\n";
|
||||
|
||||
if ($$ref[1] ne $newname) {
|
||||
print "Updating field $field in table $table ...\n";
|
||||
my $type = $$ref[1];
|
||||
$type .= " NOT NULL" if $$ref[3];
|
||||
$dbh->do("ALTER TABLE $table
|
||||
CHANGE $field
|
||||
$newname $type");
|
||||
}
|
||||
}
|
||||
|
||||
sub AddField ($$$)
|
||||
{
|
||||
my ($table, $field, $definition) = @_;
|
||||
|
||||
my $ref = GetFieldDef($table, $field);
|
||||
return if $ref; # already added?
|
||||
|
||||
print "Adding new field $field to table $table ...\n";
|
||||
$dbh->do("ALTER TABLE $table
|
||||
ADD COLUMN $field $definition");
|
||||
}
|
||||
|
||||
sub DropField ($$)
|
||||
{
|
||||
my ($table, $field) = @_;
|
||||
|
||||
my $ref = GetFieldDef($table, $field);
|
||||
return unless $ref; # already dropped?
|
||||
|
||||
print "Deleting unused field $field from table $table ...\n";
|
||||
$dbh->do("ALTER TABLE $table
|
||||
DROP COLUMN $field");
|
||||
}
|
||||
|
||||
|
||||
|
||||
# 5/12/99 Added a pref to control how much email you get. This needs a new
|
||||
# column in the profiles table, so feed the following to mysql:
|
||||
|
||||
AddField('profiles', 'emailnotification', 'enum("ExcludeSelfChanges", "CConly", "All") not null default "ExcludeSelfChanges"');
|
||||
|
||||
|
||||
|
||||
# 6/22/99 Added an entry to the attachments table to record who the
|
||||
# submitter was. Nothing uses this yet, but it still should be recorded.
|
||||
|
||||
AddField('attachments', 'submitter_id', 'mediumint not null');
|
||||
|
||||
#
|
||||
# One could even populate this field automatically, e.g. with
|
||||
#
|
||||
# unless (GetField('attachments', 'submitter_id') {
|
||||
# AddField ...
|
||||
# populate
|
||||
# }
|
||||
#
|
||||
# For now I was too lazy, so you should read the README :-)
|
||||
|
||||
|
||||
|
||||
# 9/15/99 Apparently, newer alphas of MySQL won't allow you to have "when"
|
||||
# as a column name. So, I have had to rename a column in the bugs_activity
|
||||
# table. You must feed the below to mysql or you won't work at all.
|
||||
|
||||
RenameField ('bugs', 'when', 'bug_when');
|
||||
|
||||
|
||||
|
||||
# 10/11/99 Restructured voting database to add a cached value in each bug
|
||||
# recording how many total votes that bug has. While I'm at it, I removed
|
||||
# the unused "area" field from the bugs database. It is distressing to
|
||||
# realize that the bugs table has reached the maximum number of indices
|
||||
# allowed by MySQL (16), which may make future enhancements awkward.
|
||||
|
||||
DropField('bugs', 'area');
|
||||
AddField('bugs', 'votes', 'mediumint not null, add index (votes)');
|
||||
AddField('products', 'votesperuser', 'mediumint not null');
|
||||
|
||||
|
||||
|
||||
# The product name used to be very different in various tables.
|
||||
#
|
||||
# It was varchar(16) in bugs
|
||||
# tinytext in components
|
||||
# tinytext in products
|
||||
# tinytext in versions
|
||||
#
|
||||
# tinytext is equivalent to varchar(255), which is quite huge, so I change
|
||||
# them all to varchar(64).
|
||||
|
||||
ChangeFieldType ('bugs', 'product', 'varchar(64)');
|
||||
ChangeFieldType ('components', 'program', 'varchar(64)');
|
||||
ChangeFieldType ('products', 'product', 'varchar(64)');
|
||||
ChangeFieldType ('versions', 'program', 'varchar(64)');
|
||||
|
||||
|
||||
|
||||
#
|
||||
# If you had to change the --TABLE-- definition in any way, then add your
|
||||
# differential change code *** A B O V E *** this comment.
|
||||
#
|
||||
# That is: if you add a new field, you first search for the first occurence
|
||||
# of --TABLE-- and add your field to into the table hash. This new setting
|
||||
# would be honored for every new installation. Then add your
|
||||
# AddField/DropField/ChangeFieldType/RenameField code above. This would then
|
||||
# be honored by everyone who updates his Bugzilla installation.
|
||||
#
|
Загрузка…
Ссылка в новой задаче