1999-10-12 20:58:11 +04:00
|
|
|
#!/usr/bonsaitools/bin/perl -w
|
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
1999-11-02 02:33:56 +03:00
|
|
|
# The contents of this file are subject to the Mozilla Public
|
|
|
|
# License Version 1.1 (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.
|
|
|
|
#
|
|
|
|
# The Original Code is mozilla.org code.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Holger
|
|
|
|
# Schurig. Portions created by Holger Schurig are
|
|
|
|
# Copyright (C) 1999 Holger Schurig. All
|
|
|
|
# Rights Reserved.
|
1999-10-12 20:58:11 +04:00
|
|
|
#
|
|
|
|
# Contributor(s): Holger Schurig <holgerschurig@nikocity.de>
|
1999-11-02 02:33:56 +03:00
|
|
|
# Terry Weissman <terry@mozilla.org>
|
2000-03-29 01:31:24 +04:00
|
|
|
# Dan Mosedale <dmose@mozilla.org>
|
1999-10-12 20:58:11 +04:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# 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
|
2000-08-29 03:07:33 +04:00
|
|
|
# gets updated you SHOULD rerun it. Because then it may update your
|
1999-10-12 20:58:11 +04:00
|
|
|
# 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
|
1999-10-13 00:28:41 +04:00
|
|
|
# - put the first user into all groups so that the system can
|
|
|
|
# be administrated
|
1999-10-12 20:58:11 +04:00
|
|
|
# - 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
|
2000-08-29 03:07:33 +04:00
|
|
|
# this script. This is done by shifting the user settable stuff into
|
1999-10-12 20:58:11 +04:00
|
|
|
# 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
|
2000-01-22 19:33:33 +03:00
|
|
|
$db_host $db_port $db_name $db_user $db_pass $db_check
|
1999-10-13 00:28:41 +04:00
|
|
|
@severities @priorities @opsys @platforms
|
1999-10-12 20:58:11 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2000-01-21 00:31:22 +03:00
|
|
|
# Trim whitespace from front and back.
|
|
|
|
|
|
|
|
sub trim {
|
|
|
|
($_) = (@_);
|
|
|
|
s/^\s+//g;
|
|
|
|
s/\s+$//g;
|
|
|
|
return $_;
|
|
|
|
}
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
# 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",
|
1999-10-13 00:28:41 +04:00
|
|
|
" perl -MCPAN -eshell\n",
|
|
|
|
" install DBI\n";
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
unless (eval "require Data::Dumper") {
|
|
|
|
die "Please install the Data::Dumper module. You can do this by running (as root)\n\n",
|
1999-10-13 00:28:41 +04:00
|
|
|
" perl -MCPAN -eshell\n",
|
|
|
|
" install Data::Dumper\n";
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
unless (eval "require Mysql") {
|
|
|
|
die "Please install the Mysql database driver. You can do this by running (as root)\n\n",
|
1999-10-13 00:28:41 +04:00
|
|
|
" perl -MCPAN -eshell\n",
|
|
|
|
" install Msql-Mysql\n\n",
|
2000-08-14 22:44:54 +04:00
|
|
|
"Be sure to enable the Mysql emulation!\n";
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
unless (eval "require Date::Parse") {
|
|
|
|
die "Please install the Date::Parse module. You can do this by running (as root)\n\n",
|
1999-10-13 00:28:41 +04:00
|
|
|
" perl -MCPAN -eshell\n",
|
|
|
|
" install Date::Parse\n";
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# 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",
|
2000-03-11 00:44:42 +03:00
|
|
|
"the optional libgd and the Perl modules GD-1.19 and Chart::Base-0.99b, e.g. by\n",
|
1999-10-12 20:58:11 +04:00
|
|
|
"running (as root)\n\n",
|
|
|
|
" perl -MCPAN -eshell\n",
|
2000-03-11 00:44:42 +03:00
|
|
|
" install LDS/GD-1.19.tar.gz\n",
|
2000-06-29 17:33:10 +04:00
|
|
|
" install N/NI/NINJAZ/Chart-0.99b.tar.gz\n\n";
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
# Check and update local configuration
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
#
|
|
|
|
# This is quite tricky. But fun!
|
|
|
|
#
|
2000-01-22 19:33:33 +03:00
|
|
|
# First we read the file 'localconfig'. Then we check if the variables we
|
|
|
|
# need are defined. If not, localconfig will be amended by the new settings
|
|
|
|
# and the user informed to check this. The program then stops.
|
1999-10-12 20:58:11 +04:00
|
|
|
#
|
|
|
|
# Why do it this way around?
|
|
|
|
#
|
|
|
|
# Assume we will enhance Bugzilla and eventually more local configuration
|
|
|
|
# stuff arises on the horizon.
|
|
|
|
#
|
2000-01-22 19:33:33 +03:00
|
|
|
# But the file 'localconfig' is not in the Bugzilla CVS or tarfile. You
|
|
|
|
# know, we never want to overwrite your own version of 'localconfig', so
|
|
|
|
# we can't put it into the CVS/tarfile, can we?
|
|
|
|
#
|
1999-10-12 20:58:11 +04:00
|
|
|
# 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:
|
|
|
|
#
|
1999-10-13 00:28:41 +04:00
|
|
|
$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
|
1999-10-12 20:58:11 +04:00
|
|
|
');
|
2000-01-22 19:33:33 +03:00
|
|
|
LocalVar('$db_pass', '
|
|
|
|
#
|
|
|
|
# Some people actually use passwords with their MySQL database ...
|
|
|
|
#
|
|
|
|
$db_pass = "";
|
|
|
|
');
|
|
|
|
|
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
|
2000-01-22 19:33:33 +03:00
|
|
|
LocalVar('$db_check', '
|
|
|
|
#
|
|
|
|
# Should checksetup.pl try to check if your MySQL setup is correct?
|
|
|
|
# (with some combinations of MySQL/Msql-mysql/Perl/moonphase this doesn\'t work)
|
|
|
|
#
|
|
|
|
$db_check = 1;
|
|
|
|
');
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
|
|
|
|
LocalVar('@severities', '
|
|
|
|
#
|
|
|
|
# Which bug and feature-request severities do you want?
|
|
|
|
#
|
|
|
|
@severities = (
|
1999-10-13 00:28:41 +04:00
|
|
|
"blocker",
|
|
|
|
"critical",
|
|
|
|
"major",
|
|
|
|
"normal",
|
|
|
|
"minor",
|
|
|
|
"trivial",
|
|
|
|
"enhancement"
|
1999-10-12 20:58:11 +04:00
|
|
|
);
|
|
|
|
');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LocalVar('@priorities', '
|
|
|
|
#
|
|
|
|
# Which priorities do you want to assign to bugs and feature-request?
|
|
|
|
#
|
|
|
|
@priorities = (
|
1999-10-13 00:28:41 +04:00
|
|
|
"P1",
|
|
|
|
"P2",
|
|
|
|
"P3",
|
|
|
|
"P4",
|
|
|
|
"P5"
|
1999-10-12 20:58:11 +04:00
|
|
|
);
|
|
|
|
');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LocalVar('@opsys', '
|
|
|
|
#
|
|
|
|
# What operatings systems may your products run on?
|
|
|
|
#
|
|
|
|
@opsys = (
|
1999-10-13 00:28:41 +04:00
|
|
|
"All",
|
|
|
|
"Windows 3.1",
|
|
|
|
"Windows 95",
|
|
|
|
"Windows 98",
|
2000-07-11 03:01:26 +04:00
|
|
|
"Windows ME", # Millenium Edition (upgrade of 98)
|
2000-01-17 22:20:20 +03:00
|
|
|
"Windows 2000",
|
1999-10-13 00:28:41 +04:00
|
|
|
"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",
|
2000-01-17 22:20:20 +03:00
|
|
|
"Mac System 9.0",
|
2000-08-29 03:07:33 +04:00
|
|
|
"Linux",
|
1999-10-13 00:28:41 +04:00
|
|
|
"BSDI",
|
2000-08-29 03:07:33 +04:00
|
|
|
"FreeBSD",
|
|
|
|
"NetBSD",
|
|
|
|
"OpenBSD",
|
|
|
|
"AIX",
|
|
|
|
"BeOS",
|
1999-10-13 00:28:41 +04:00
|
|
|
"HP-UX",
|
|
|
|
"IRIX",
|
2000-08-29 03:07:33 +04:00
|
|
|
"Neutrino",
|
|
|
|
"OpenVMS",
|
|
|
|
"OS/2",
|
1999-10-13 00:28:41 +04:00
|
|
|
"OSF/1",
|
|
|
|
"Solaris",
|
|
|
|
"SunOS",
|
|
|
|
"other"
|
1999-10-12 20:58:11 +04:00
|
|
|
);
|
|
|
|
');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LocalVar('@platforms', '
|
|
|
|
#
|
|
|
|
# What hardware platforms may your products run on?
|
|
|
|
#
|
|
|
|
@platforms = (
|
1999-10-13 00:28:41 +04:00
|
|
|
"All",
|
|
|
|
"DEC",
|
|
|
|
"HP",
|
|
|
|
"Macintosh",
|
|
|
|
"PC",
|
|
|
|
"SGI",
|
|
|
|
"Sun",
|
|
|
|
"Other"
|
1999-10-12 20:58:11 +04:00
|
|
|
);
|
|
|
|
');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($newstuff ne "") {
|
2000-01-22 19:33:33 +03:00
|
|
|
print "\nThis version of Bugzilla contains some variables that you may \n",
|
1999-10-13 00:28:41 +04:00
|
|
|
"to change and adapt to your local settings. Please edit the file\n",
|
2000-01-17 14:38:41 +03:00
|
|
|
"'localconfig' and rerun checksetup.pl\n\n",
|
1999-10-13 00:28:41 +04:00
|
|
|
"The following variables are new to localconfig since you last ran\n",
|
2000-01-22 19:33:33 +03:00
|
|
|
"checksetup.pl: $newstuff\n\n";
|
1999-10-12 20:58:11 +04:00
|
|
|
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;
|
1999-10-13 00:28:41 +04:00
|
|
|
if ($webservergroup eq "") {
|
|
|
|
chmod 0777, 'data';
|
|
|
|
}
|
1999-10-12 20:58:11 +04:00
|
|
|
open FILE, '>>data/comments'; close FILE;
|
|
|
|
open FILE, '>>data/nomail'; close FILE;
|
|
|
|
open FILE, '>>data/mail'; close FILE;
|
1999-10-13 00:28:41 +04:00
|
|
|
chmod 0666, glob('data/*');
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
|
1999-10-13 00:28:41 +04:00
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
# 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?
|
|
|
|
#
|
2000-07-19 08:34:52 +04:00
|
|
|
# Changes 03/14/00 by SML
|
|
|
|
#
|
|
|
|
# This abstracts out what files are executable and what ones are not. It makes
|
|
|
|
# for slightly neater code and lets us do things like determine exactly which
|
|
|
|
# files are executable and which ones are not.
|
|
|
|
#
|
|
|
|
# Not all directories have permissions changed on them. i.e., changing ./CVS
|
|
|
|
# to be 0640 is bad.
|
|
|
|
#
|
|
|
|
# Fixed bug in chmod invokation. chmod (at least on my linux box running perl
|
|
|
|
# 5.005 needs a valid first argument, not 0.
|
|
|
|
#
|
|
|
|
# (end changes, 03/14/00 by SML)
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
# These are the files which need to be marked executable
|
|
|
|
my @executable_files = ('processmail', 'whineatnews.pl', 'collectstats.pl', 'checksetup.pl', 'syncshadowdb');
|
|
|
|
|
|
|
|
# tell me if a file is executable. All CGI files and those in @executable_files
|
|
|
|
# are executable
|
|
|
|
sub isExecutableFile {
|
|
|
|
my ($file) = @_;
|
|
|
|
if ($file =~ /\.cgi/) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $exec_file;
|
|
|
|
foreach $exec_file (@executable_files) {
|
|
|
|
if ($file eq $exec_file) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return undef;
|
|
|
|
}
|
1999-10-12 20:58:11 +04:00
|
|
|
|
1999-10-13 00:28:41 +04:00
|
|
|
if ($webservergroup) {
|
1999-10-15 02:32:44 +04:00
|
|
|
mkdir 'shadow', 0770 unless -d 'shadow';
|
1999-10-13 00:28:41 +04:00
|
|
|
# Funny! getgrname returns the GID if fed with NAME ...
|
|
|
|
my $webservergid = getgrnam($webservergroup);
|
2000-07-19 08:34:52 +04:00
|
|
|
# chmod needs to be called with a valid uid, not 0. $< returns the
|
|
|
|
# caller's uid. Maybe there should be a $bugzillauid, and call with that
|
|
|
|
# userid.
|
|
|
|
chown $<, $webservergid, glob('*');
|
|
|
|
my @files = glob('*');
|
|
|
|
my $file;
|
|
|
|
foreach $file (@files) {
|
|
|
|
# do not change permissions on directories here
|
|
|
|
if (!(-d $file)) {
|
|
|
|
# check if the file is executable.
|
|
|
|
if (isExecutableFile($file)) {
|
|
|
|
chmod 0750, $file;
|
|
|
|
} else {
|
|
|
|
chmod 0640, $file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-10-12 20:58:11 +04:00
|
|
|
|
2000-07-19 08:34:52 +04:00
|
|
|
# make sure that contrib keeps the permissions it had (don't touch it)
|
1999-10-15 02:32:44 +04:00
|
|
|
chmod 0770, 'data', 'shadow';
|
1999-10-13 00:28:41 +04:00
|
|
|
chmod 0666, glob('data/*');
|
2000-07-19 08:34:52 +04:00
|
|
|
chmod 0777, glob('data/*/'); # directories stay executable
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
# Check MySQL setup
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
#
|
|
|
|
# Check if we have access to --MYSQL--
|
|
|
|
#
|
|
|
|
|
1999-10-13 00:28:41 +04:00
|
|
|
# This settings are not yet changeable, because other code depends on
|
|
|
|
# the fact that we use MySQL and not, say, PostgreSQL.
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
my $db_base = 'mysql';
|
|
|
|
|
|
|
|
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";
|
|
|
|
|
2000-01-22 19:33:33 +03:00
|
|
|
if ($db_check) {
|
|
|
|
# Do we have the database itself?
|
2000-08-22 22:30:05 +04:00
|
|
|
my $dsn = "DBI:$db_base:$db_name;$db_host;$db_port";
|
|
|
|
my $dbh = DBI->connect($dsn, $db_user, $db_pass);
|
|
|
|
my @databases = $dbh->func('_ListDBs');
|
2000-01-22 19:33:33 +03:00
|
|
|
unless (grep /^$db_name$/, @databases) {
|
2000-08-22 22:30:05 +04:00
|
|
|
print "Creating database $db_name ...\n";
|
|
|
|
$drh->func('createdb', $db_name, "$db_host:$db_port", $db_user, $db_pass, 'admin')
|
2000-01-22 19:33:33 +03:00
|
|
|
or die <<"EOF"
|
|
|
|
|
|
|
|
The '$db_name' database is not accessible. This might have several reasons:
|
|
|
|
|
|
|
|
* MySQL is not running.
|
|
|
|
* MySQL is running, but the rights are not set correct. Go and read the
|
|
|
|
README file of Bugzilla and all parts of the MySQL documentation.
|
|
|
|
* There is an subtle problem with Perl, DBI, DBD::mysql and MySQL. Make
|
|
|
|
sure all settings in 'localconfig' are correct. If all else fails, set
|
|
|
|
'\$db_check' to zero.\n
|
|
|
|
EOF
|
|
|
|
}
|
2000-08-22 22:30:05 +04:00
|
|
|
$dbh->disconnect if $dbh;
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# 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",
|
1999-10-13 00:28:41 +04:00
|
|
|
"Have you read Bugzilla's README? Have you read the doc of '$db_name'?\n";
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
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,
|
2000-01-22 07:24:42 +03:00
|
|
|
fieldid mediumint not null,
|
1999-10-12 20:58:11 +04:00
|
|
|
oldvalue tinytext,
|
|
|
|
newvalue tinytext,
|
|
|
|
|
|
|
|
index (bug_id),
|
|
|
|
index (bug_when),
|
2000-01-22 07:24:42 +03:00
|
|
|
index (fieldid)';
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
|
|
|
|
$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)';
|
|
|
|
|
2000-09-15 05:00:56 +04:00
|
|
|
#
|
|
|
|
# Apostrophe's are not supportied in the enum types.
|
|
|
|
# See http://bugzilla.mozilla.org/show_bug.cgi?id=27309
|
|
|
|
#
|
1999-10-12 20:58:11 +04:00
|
|
|
$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,
|
2000-02-17 08:15:23 +03:00
|
|
|
bug_status enum("UNCONFIRMED", "NEW", "ASSIGNED", "REOPENED", "RESOLVED", "VERIFIED", "CLOSED") not null,
|
1999-10-12 20:58:11 +04:00
|
|
|
creation_ts datetime not null,
|
|
|
|
delta_ts timestamp,
|
|
|
|
short_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,
|
2000-07-14 01:38:15 +04:00
|
|
|
resolution enum("", "FIXED", "INVALID", "WONTFIX", "LATER", "REMIND", "DUPLICATE", "WORKSFORME", "MOVED") not null,
|
2000-03-23 03:04:08 +03:00
|
|
|
target_milestone varchar(20) not null default "---",
|
1999-10-12 20:58:11 +04:00
|
|
|
qa_contact mediumint not null,
|
|
|
|
status_whiteboard mediumtext not null,
|
|
|
|
votes mediumint not null,
|
2000-01-17 14:38:41 +03:00
|
|
|
keywords mediumtext not null, ' # Note: keywords field is only a cache;
|
|
|
|
# the real data comes from the keywords table.
|
|
|
|
. '
|
2000-01-22 07:24:42 +03:00
|
|
|
lastdiffed datetime not null,
|
2000-02-17 08:15:23 +03:00
|
|
|
everconfirmed tinyint not null,
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
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,
|
|
|
|
|
2000-03-29 01:31:24 +04:00
|
|
|
index(who),
|
|
|
|
unique(bug_id,who)';
|
|
|
|
|
|
|
|
$table{watch} =
|
|
|
|
'watcher mediumint not null,
|
|
|
|
watched mediumint not null,
|
|
|
|
|
|
|
|
index(watched),
|
|
|
|
unique(watcher,watched)';
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
|
2000-01-21 00:31:22 +03:00
|
|
|
$table{longdescs} =
|
|
|
|
'bug_id mediumint not null,
|
|
|
|
who mediumint not null,
|
|
|
|
bug_when datetime not null,
|
|
|
|
thetext mediumtext,
|
|
|
|
|
|
|
|
index(bug_id),
|
|
|
|
index(bug_when)';
|
|
|
|
|
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
$table{components} =
|
|
|
|
'value tinytext,
|
|
|
|
program varchar(64),
|
1999-10-13 00:28:41 +04:00
|
|
|
initialowner tinytext not null, # Should arguably be a mediumint!
|
1999-10-12 20:58:11 +04:00
|
|
|
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,
|
2000-02-17 08:15:23 +03:00
|
|
|
votesperuser smallint not null,
|
|
|
|
maxvotesperbug smallint not null default 10000,
|
2000-03-23 21:23:14 +03:00
|
|
|
votestoconfirm smallint not null,
|
|
|
|
defaultmilestone varchar(20) not null default "---"
|
2000-02-17 08:15:23 +03:00
|
|
|
';
|
1999-10-12 20:58:11 +04:00
|
|
|
|
1999-10-13 00:28:41 +04:00
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
$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",
|
2000-01-19 01:41:26 +03:00
|
|
|
disabledtext mediumtext not null,
|
2000-01-22 07:24:42 +03:00
|
|
|
newemailtech tinyint not null,
|
2000-01-25 10:54:57 +03:00
|
|
|
mybugslink tinyint not null default 1,
|
2000-02-17 08:15:23 +03:00
|
|
|
blessgroupset bigint not null,
|
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
|
2000-01-23 06:36:17 +03:00
|
|
|
unique(login_name)';
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
|
2000-02-17 08:15:23 +03:00
|
|
|
$table{profiles_activity} =
|
|
|
|
'userid mediumint not null,
|
|
|
|
who mediumint not null,
|
|
|
|
profiles_when datetime not null,
|
|
|
|
fieldid mediumint not null,
|
|
|
|
oldvalue tinytext,
|
|
|
|
newvalue tinytext,
|
|
|
|
|
|
|
|
index (userid),
|
|
|
|
index (profiles_when),
|
|
|
|
index (fieldid)';
|
|
|
|
|
|
|
|
|
2000-01-23 23:31:50 +03:00
|
|
|
$table{namedqueries} =
|
|
|
|
'userid mediumint not null,
|
|
|
|
name varchar(64) not null,
|
|
|
|
watchfordiffs tinyint not null,
|
2000-01-25 10:54:57 +03:00
|
|
|
linkinfooter tinyint not null,
|
2000-01-23 23:31:50 +03:00
|
|
|
query mediumtext not null,
|
|
|
|
|
|
|
|
unique(userid, name),
|
|
|
|
index(watchfordiffs)';
|
|
|
|
|
2000-01-22 07:24:42 +03:00
|
|
|
# This isn't quite cooked yet...
|
|
|
|
#
|
|
|
|
# $table{diffprefs} =
|
|
|
|
# 'userid mediumint not null,
|
|
|
|
# fieldid mediumint not null,
|
|
|
|
# mailhead tinyint not null,
|
|
|
|
# maildiffs tinyint not null,
|
|
|
|
#
|
|
|
|
# index(userid)';
|
|
|
|
|
|
|
|
$table{fielddefs} =
|
|
|
|
'fieldid mediumint not null auto_increment primary key,
|
|
|
|
name varchar(64) not null,
|
|
|
|
description mediumtext not null,
|
|
|
|
mailhead tinyint not null default 0,
|
|
|
|
sortkey smallint not null,
|
|
|
|
|
|
|
|
unique(name),
|
|
|
|
index(sortkey)';
|
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
$table{versions} =
|
|
|
|
'value tinytext,
|
2000-04-30 08:34:53 +04:00
|
|
|
program varchar(64) not null';
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
|
|
|
|
$table{votes} =
|
|
|
|
'who mediumint not null,
|
|
|
|
bug_id mediumint not null,
|
|
|
|
count smallint not null,
|
|
|
|
|
|
|
|
index(who),
|
|
|
|
index(bug_id)';
|
|
|
|
|
2000-01-07 00:16:15 +03:00
|
|
|
$table{keywords} =
|
|
|
|
'bug_id mediumint not null,
|
|
|
|
keywordid smallint not null,
|
1999-10-12 20:58:11 +04:00
|
|
|
|
2000-03-29 01:31:24 +04:00
|
|
|
index(keywordid),
|
|
|
|
unique(bug_id,keywordid)';
|
2000-01-07 00:16:15 +03:00
|
|
|
|
|
|
|
$table{keyworddefs} =
|
|
|
|
'id smallint not null primary key,
|
|
|
|
name varchar(64) not null,
|
|
|
|
description mediumtext,
|
|
|
|
|
|
|
|
unique(name)';
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
|
2000-03-21 19:47:06 +03:00
|
|
|
$table{milestones} =
|
2000-03-23 03:04:08 +03:00
|
|
|
'value varchar(20) not null,
|
2000-03-21 19:47:06 +03:00
|
|
|
product varchar(64) not null,
|
|
|
|
sortkey smallint not null,
|
|
|
|
unique (product, value)';
|
|
|
|
|
2000-02-18 00:41:39 +03:00
|
|
|
$table{shadowlog} =
|
|
|
|
'id int not null auto_increment primary key,
|
|
|
|
ts timestamp,
|
|
|
|
reflected tinyint not null,
|
|
|
|
command mediumtext not null,
|
|
|
|
|
|
|
|
index(reflected)';
|
|
|
|
|
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
# 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";
|
|
|
|
|
1999-10-13 00:28:41 +04:00
|
|
|
# add lines here if you add more --LOCAL-- config vars that end up in the enums:
|
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
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";
|
1999-10-13 00:28:41 +04:00
|
|
|
|
|
|
|
# add lines here if you add more --LOCAL-- config vars that end up in
|
|
|
|
# the enums:
|
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
$fielddef =~ s/\$severities/$severities/;
|
|
|
|
$fielddef =~ s/\$priorities/$priorities/;
|
|
|
|
$fielddef =~ s/\$opsys/$opsys/;
|
|
|
|
$fielddef =~ s/\$platforms/$platforms/;
|
|
|
|
|
|
|
|
$dbh->do("CREATE TABLE $tabname (\n$fielddef\n)")
|
1999-10-13 00:28:41 +04:00
|
|
|
or die "Could not create table '$tabname'. Please check your '$db_base' access.\n";
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
# Populate groups table
|
|
|
|
###########################################################################
|
|
|
|
|
2000-02-17 08:15:23 +03:00
|
|
|
sub GroupExists ($)
|
|
|
|
{
|
|
|
|
my ($name) = @_;
|
|
|
|
my $sth = $dbh->prepare("SELECT name FROM groups WHERE name='$name'");
|
|
|
|
$sth->execute;
|
|
|
|
if ($sth->rows) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
#
|
|
|
|
# This subroutine checks if a group exist. If not, it will be automatically
|
|
|
|
# created with the next available bit set
|
|
|
|
#
|
|
|
|
|
2000-02-17 08:15:23 +03:00
|
|
|
sub AddGroup {
|
|
|
|
my ($name, $desc, $userregexp) = @_;
|
|
|
|
$userregexp ||= "";
|
1999-10-12 20:58:11 +04:00
|
|
|
|
2000-02-17 08:15:23 +03:00
|
|
|
return if GroupExists($name);
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
# get highest bit number
|
2000-02-17 08:15:23 +03:00
|
|
|
my $sth = $dbh->prepare("SELECT bit FROM groups ORDER BY bit DESC");
|
1999-10-12 20:58:11 +04:00
|
|
|
$sth->execute;
|
|
|
|
my @row = $sth->fetchrow_array;
|
|
|
|
|
|
|
|
# normalize bits
|
|
|
|
my $bit;
|
|
|
|
if (defined $row[0]) {
|
1999-10-13 00:28:41 +04:00
|
|
|
$bit = $row[0] << 1;
|
1999-10-12 20:58:11 +04:00
|
|
|
} else {
|
1999-10-13 00:28:41 +04:00
|
|
|
$bit = 1;
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "Adding group $name ...\n";
|
|
|
|
$sth = $dbh->prepare('INSERT INTO groups
|
1999-10-13 00:28:41 +04:00
|
|
|
(bit, name, description, userregexp)
|
|
|
|
VALUES (?, ?, ?, ?)');
|
2000-02-17 08:15:23 +03:00
|
|
|
$sth->execute($bit, $name, $desc, $userregexp);
|
|
|
|
return $bit;
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#
|
2000-02-17 08:15:23 +03:00
|
|
|
# BugZilla uses --GROUPS-- to assign various rights to its users.
|
1999-10-12 20:58:11 +04:00
|
|
|
#
|
|
|
|
|
|
|
|
AddGroup 'tweakparams', 'Can tweak operating parameters';
|
2000-01-18 21:34:01 +03:00
|
|
|
AddGroup 'editusers', 'Can edit or disable users';
|
1999-10-12 20:58:11 +04:00
|
|
|
AddGroup 'creategroups', 'Can create and destroy groups.';
|
|
|
|
AddGroup 'editcomponents', 'Can create, destroy, and edit components.';
|
2000-01-07 00:16:15 +03:00
|
|
|
AddGroup 'editkeywords', 'Can create, destroy, and edit keywords.';
|
1999-10-13 00:28:41 +04:00
|
|
|
|
2000-09-27 21:51:36 +04:00
|
|
|
# Add the groupset field here because this code is run before the
|
|
|
|
# code that updates the database structure.
|
|
|
|
AddField('profiles', 'groupset', 'bigint not null');
|
|
|
|
|
2000-02-17 08:15:23 +03:00
|
|
|
if (!GroupExists("editbugs")) {
|
|
|
|
my $id = AddGroup('editbugs', 'Can edit all aspects of any bug.', ".*");
|
|
|
|
$dbh->do("UPDATE profiles SET groupset = groupset | $id");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!GroupExists("canconfirm")) {
|
|
|
|
my $id = AddGroup('canconfirm', 'Can confirm a bug.', ".*");
|
|
|
|
$dbh->do("UPDATE profiles SET groupset = groupset | $id");
|
|
|
|
}
|
|
|
|
|
1999-10-13 00:28:41 +04:00
|
|
|
|
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
# Create initial test product if there are no products present.
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
my $sth = $dbh->prepare("SELECT product FROM products");
|
|
|
|
$sth->execute;
|
1999-10-13 00:28:41 +04:00
|
|
|
unless ($sth->rows) {
|
1999-10-12 20:58:11 +04:00
|
|
|
print "Creating initial dummy product 'TestProduct' ...\n";
|
1999-10-13 00:28:41 +04:00
|
|
|
$dbh->do('INSERT INTO products(product, description) VALUES ("TestProduct",
|
1999-10-14 21:34:00 +04:00
|
|
|
"This is a test product. This ought to be blown away and ' .
|
|
|
|
'replaced with real stuff in a finished installation of ' .
|
|
|
|
'bugzilla.")');
|
1999-10-13 00:28:41 +04:00
|
|
|
$dbh->do('INSERT INTO versions (value, program) VALUES ("other", "TestProduct")');
|
1999-10-14 21:34:00 +04:00
|
|
|
$dbh->do('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.")');
|
2000-08-28 22:44:28 +04:00
|
|
|
$dbh->do('INSERT INTO milestones (product, value) VALUES ("TestProduct","---")');
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-22 07:24:42 +03:00
|
|
|
###########################################################################
|
|
|
|
# Populate the list of fields.
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
my $headernum = 1;
|
|
|
|
|
|
|
|
sub AddFDef ($$$) {
|
|
|
|
my ($name, $description, $mailhead) = (@_);
|
|
|
|
|
|
|
|
$name = $dbh->quote($name);
|
|
|
|
$description = $dbh->quote($description);
|
|
|
|
|
2000-01-23 00:43:30 +03:00
|
|
|
my $sth = $dbh->prepare("SELECT fieldid FROM fielddefs " .
|
|
|
|
"WHERE name = $name");
|
|
|
|
$sth->execute();
|
|
|
|
my ($fieldid) = ($sth->fetchrow_array());
|
|
|
|
if (!$fieldid) {
|
|
|
|
$fieldid = 'NULL';
|
|
|
|
}
|
|
|
|
|
2000-01-22 07:24:42 +03:00
|
|
|
$dbh->do("REPLACE INTO fielddefs " .
|
2000-01-23 00:43:30 +03:00
|
|
|
"(fieldid, name, description, mailhead, sortkey) VALUES " .
|
|
|
|
"($fieldid, $name, $description, $mailhead, $headernum)");
|
2000-01-22 07:24:42 +03:00
|
|
|
$headernum++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AddFDef("bug_id", "Bug \#", 1);
|
|
|
|
AddFDef("short_desc", "Summary", 1);
|
|
|
|
AddFDef("product", "Product", 1);
|
|
|
|
AddFDef("version", "Version", 1);
|
|
|
|
AddFDef("rep_platform", "Platform", 1);
|
2000-01-28 04:01:40 +03:00
|
|
|
AddFDef("bug_file_loc", "URL", 1);
|
2000-01-22 07:24:42 +03:00
|
|
|
AddFDef("op_sys", "OS/Version", 1);
|
|
|
|
AddFDef("bug_status", "Status", 1);
|
2000-01-28 04:01:40 +03:00
|
|
|
AddFDef("status_whiteboard", "Status Whiteboard", 1);
|
|
|
|
AddFDef("keywords", "Keywords", 1);
|
2000-01-22 07:24:42 +03:00
|
|
|
AddFDef("resolution", "Resolution", 1);
|
|
|
|
AddFDef("bug_severity", "Severity", 1);
|
|
|
|
AddFDef("priority", "Priority", 1);
|
|
|
|
AddFDef("component", "Component", 1);
|
|
|
|
AddFDef("assigned_to", "AssignedTo", 1);
|
|
|
|
AddFDef("reporter", "ReportedBy", 1);
|
2000-01-28 04:01:40 +03:00
|
|
|
AddFDef("votes", "Votes", 0);
|
2000-01-22 07:24:42 +03:00
|
|
|
AddFDef("qa_contact", "QAContact", 0);
|
|
|
|
AddFDef("cc", "CC", 0);
|
|
|
|
AddFDef("dependson", "BugsThisDependsOn", 0);
|
|
|
|
AddFDef("blocked", "OtherBugsDependingOnThis", 0);
|
2000-01-30 22:21:43 +03:00
|
|
|
AddFDef("attachments.description", "Attachment description", 0);
|
|
|
|
AddFDef("attachments.thedata", "Attachment data", 0);
|
|
|
|
AddFDef("attachments.mimetype", "Attachment mime type", 0);
|
|
|
|
AddFDef("attachments.ispatch", "Attachment is patch", 0);
|
2000-01-22 07:24:42 +03:00
|
|
|
AddFDef("target_milestone", "Target Milestone", 0);
|
2000-01-28 04:28:55 +03:00
|
|
|
AddFDef("delta_ts", "Last changed date", 0);
|
|
|
|
AddFDef("(to_days(now()) - to_days(bugs.delta_ts))", "Days since bug changed",
|
|
|
|
0);
|
2000-01-28 04:01:40 +03:00
|
|
|
AddFDef("longdesc", "Comment", 0);
|
2000-01-22 07:24:42 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
###########################################################################
|
|
|
|
# Detect changed local settings
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
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;
|
1999-10-13 00:28:41 +04:00
|
|
|
}
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
|
2000-01-23 06:36:17 +03:00
|
|
|
sub GetIndexDef ($$)
|
|
|
|
{
|
|
|
|
my ($table, $field) = @_;
|
|
|
|
my $sth = $dbh->prepare("SHOW INDEX FROM $table");
|
|
|
|
$sth->execute;
|
|
|
|
|
|
|
|
while (my $ref = $sth->fetchrow_arrayref) {
|
|
|
|
next if $$ref[2] ne $field;
|
|
|
|
return $ref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-29 01:31:24 +04:00
|
|
|
sub CountIndexes ($)
|
|
|
|
{
|
|
|
|
my ($table) = @_;
|
|
|
|
|
|
|
|
my $sth = $dbh->prepare("SHOW INDEX FROM $table");
|
|
|
|
$sth->execute;
|
|
|
|
|
|
|
|
if ( $sth->rows == -1 ) {
|
|
|
|
die ("Unexpected response while counting indexes in $table:" .
|
|
|
|
" \$sth->rows == -1");
|
|
|
|
}
|
|
|
|
|
|
|
|
return ($sth->rows);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub DropIndexes ($)
|
|
|
|
{
|
|
|
|
my ($table) = @_;
|
|
|
|
my %SEEN;
|
|
|
|
|
|
|
|
# get the list of indexes
|
|
|
|
#
|
|
|
|
my $sth = $dbh->prepare("SHOW INDEX FROM $table");
|
|
|
|
$sth->execute;
|
|
|
|
|
|
|
|
# drop each index
|
|
|
|
#
|
|
|
|
while ( my $ref = $sth->fetchrow_arrayref) {
|
|
|
|
|
|
|
|
# note that some indexes are described by multiple rows in the
|
|
|
|
# index table, so we may have already dropped the index described
|
|
|
|
# in the current row.
|
|
|
|
#
|
|
|
|
next if exists $SEEN{$$ref[2]};
|
|
|
|
|
|
|
|
my $dropSth = $dbh->prepare("ALTER TABLE $table DROP INDEX $$ref[2]");
|
|
|
|
$dropSth->execute;
|
|
|
|
$dropSth->finish;
|
|
|
|
$SEEN{$$ref[2]} = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2000-01-23 06:36:17 +03:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
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";
|
1999-10-13 00:28:41 +04:00
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
$_ = "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 $_");
|
2000-07-14 01:38:15 +04:00
|
|
|
$::regenerateshadow = 1;
|
1999-10-12 20:58:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# This code changes the enum types of some SQL tables whenever you change
|
2000-07-11 03:01:26 +04:00
|
|
|
# some --LOCAL-- variables. Once you have a running system, to add new
|
|
|
|
# severities, priorities, operating systems and platforms, add them to
|
|
|
|
# the localconfig file and then re-run checksetup.pl which will make the
|
|
|
|
# necessary changes to your database. Additions to these fields in
|
|
|
|
# checksetup.pl after the initial installation of bugzilla on a system
|
|
|
|
# are ignored.
|
1999-10-12 20:58:11 +04:00
|
|
|
#
|
|
|
|
|
|
|
|
CheckEnumField('bugs', 'bug_severity', @severities);
|
|
|
|
CheckEnumField('bugs', 'priority', @priorities);
|
|
|
|
CheckEnumField('bugs', 'op_sys', @opsys);
|
|
|
|
CheckEnumField('bugs', 'rep_platform', @platforms);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-10-13 00:28:41 +04:00
|
|
|
###########################################################################
|
|
|
|
# Promote first user into every group
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
#
|
|
|
|
# Assume you just logged in. Now how can you administrate the system? Just
|
|
|
|
# execute checksetup.pl again. If there is only 1 user in bugzilla, then
|
|
|
|
# this user is promoted into every group.
|
|
|
|
#
|
|
|
|
|
|
|
|
$sth = $dbh->prepare("SELECT login_name FROM profiles");
|
|
|
|
$sth->execute;
|
|
|
|
# when we have exactly one user ...
|
|
|
|
if ($sth->rows == 1) {
|
|
|
|
my @row = $sth->fetchrow_array;
|
|
|
|
print "Putting user $row[0] into every group ...\n";
|
|
|
|
# are this enought f's for now? :-)
|
|
|
|
$dbh->do("update profiles set groupset=0xffffffffffff");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
###########################################################################
|
|
|
|
# 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";
|
|
|
|
|
2000-03-23 21:23:14 +03:00
|
|
|
my $oldtype = $ref->[1];
|
|
|
|
if ($ref->[4]) {
|
|
|
|
$oldtype .= qq{ default "$ref->[4]"};
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($oldtype ne $newtype) {
|
1999-10-12 20:58:11 +04:00
|
|
|
print "Updating field type $field in table $table ...\n";
|
2000-03-23 21:23:14 +03:00
|
|
|
print "old: $oldtype\n";
|
|
|
|
print "new: $newtype\n";
|
1999-10-12 20:58:11 +04:00
|
|
|
$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);
|
1999-10-13 00:28:41 +04:00
|
|
|
return unless $ref; # already fixed?
|
1999-10-12 20:58:11 +04:00
|
|
|
#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");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-14 01:38:15 +04:00
|
|
|
$::regenerateshadow = 0;
|
2000-01-29 23:07:05 +03:00
|
|
|
|
|
|
|
|
2000-09-27 21:51:36 +04:00
|
|
|
# really old fields that were added before checksetup.pl existed
|
|
|
|
# but aren't in very old bugzilla's (like 2.1)
|
|
|
|
# Steve Stock (sstock@iconnect-inc.com)
|
|
|
|
AddField('bugs', 'target_milestone', 'varchar(20) not null default "---"');
|
|
|
|
AddField('bugs', 'groupset', 'bigint not null');
|
|
|
|
AddField('bugs', 'qa_contact', 'mediumint not null');
|
|
|
|
AddField('bugs', 'status_whiteboard', 'mediumtext not null');
|
|
|
|
AddField('products', 'disallownew', 'tinyint not null');
|
|
|
|
AddField('products', 'milestoneurl', 'tinytext not null');
|
|
|
|
AddField('components', 'initialqacontact', 'tinytext not null');
|
|
|
|
AddField('components', 'description', 'mediumtext not null');
|
|
|
|
ChangeFieldType('components', 'program', 'varchar(64)');
|
2000-01-29 23:07:05 +03:00
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
|
2000-01-17 14:38:41 +03:00
|
|
|
# 1999-05-12 Added a pref to control how much email you get. This needs a new
|
1999-10-12 20:58:11 +04:00
|
|
|
# column in the profiles table, so feed the following to mysql:
|
|
|
|
|
1999-10-13 00:28:41 +04:00
|
|
|
AddField('profiles', 'emailnotification', 'enum("ExcludeSelfChanges", "CConly",
|
|
|
|
"All") not null default "ExcludeSelfChanges"');
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-17 14:38:41 +03:00
|
|
|
# 1999-06-22 Added an entry to the attachments table to record who the
|
1999-10-12 20:58:11 +04:00
|
|
|
# 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 :-)
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-17 14:38:41 +03:00
|
|
|
# 1999-9-15 Apparently, newer alphas of MySQL won't allow you to have "when"
|
1999-10-12 20:58:11 +04:00
|
|
|
# as a column name. So, I have had to rename a column in the bugs_activity
|
1999-10-15 02:35:12 +04:00
|
|
|
# table.
|
1999-10-12 20:58:11 +04:00
|
|
|
|
1999-10-15 02:35:12 +04:00
|
|
|
RenameField ('bugs_activity', 'when', 'bug_when');
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-17 14:38:41 +03:00
|
|
|
# 1999-10-11 Restructured voting database to add a cached value in each bug
|
1999-10-12 20:58:11 +04:00
|
|
|
# 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.
|
2000-01-17 14:38:41 +03:00
|
|
|
# (P.S. All is not lost; it appears that the latest betas of MySQL support
|
|
|
|
# a new table format which will allow 32 indices.)
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
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)');
|
|
|
|
|
2000-01-17 14:38:41 +03:00
|
|
|
# 2000-01-16 Added a "keywords" field to the bugs table, which
|
|
|
|
# contains a string copy of the entries of the keywords table for this
|
|
|
|
# bug. This is so that I can easily sort and display a keywords
|
|
|
|
# column in bug lists.
|
|
|
|
|
|
|
|
if (!GetFieldDef('bugs', 'keywords')) {
|
|
|
|
AddField('bugs', 'keywords', 'mediumtext not null');
|
|
|
|
|
|
|
|
my @kwords;
|
|
|
|
print "Making sure 'keywords' field of table 'bugs' is empty ...\n";
|
|
|
|
$dbh->do("UPDATE bugs SET delta_ts = delta_ts, keywords = '' " .
|
|
|
|
"WHERE keywords != ''");
|
|
|
|
print "Repopulating 'keywords' field of table 'bugs' ...\n";
|
|
|
|
my $sth = $dbh->prepare("SELECT keywords.bug_id, keyworddefs.name " .
|
|
|
|
"FROM keywords, keyworddefs " .
|
|
|
|
"WHERE keyworddefs.id = keywords.keywordid " .
|
|
|
|
"ORDER BY keywords.bug_id, keyworddefs.name");
|
|
|
|
$sth->execute;
|
|
|
|
my @list;
|
|
|
|
my $bugid = 0;
|
|
|
|
my @row;
|
|
|
|
while (1) {
|
|
|
|
my ($b, $k) = ($sth->fetchrow_array());
|
|
|
|
if (!defined $b || $b ne $bugid) {
|
|
|
|
if (@list) {
|
|
|
|
$dbh->do("UPDATE bugs SET delta_ts = delta_ts, keywords = " .
|
|
|
|
$dbh->quote(join(', ', @list)) .
|
|
|
|
" WHERE bug_id = $bugid");
|
|
|
|
}
|
|
|
|
if (!$b) {
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
$bugid = $b;
|
|
|
|
@list = ();
|
|
|
|
}
|
|
|
|
push(@list, $k);
|
|
|
|
}
|
|
|
|
}
|
2000-01-19 01:41:26 +03:00
|
|
|
|
|
|
|
|
|
|
|
# 2000-01-18 Added a "disabledtext" field to the profiles table. If not
|
|
|
|
# empty, then this account has been disabled, and this field is to contain
|
|
|
|
# text describing why.
|
|
|
|
|
|
|
|
AddField('profiles', 'disabledtext', 'mediumtext not null');
|
2000-01-17 14:38:41 +03:00
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
|
|
|
|
|
2000-01-21 00:31:22 +03:00
|
|
|
# 2000-01-20 Added a new "longdescs" table, which is supposed to have all the
|
|
|
|
# long descriptions in it, replacing the old long_desc field in the bugs
|
|
|
|
# table. The below hideous code populates this new table with things from
|
|
|
|
# the old field, with ugly parsing and heuristics.
|
|
|
|
|
|
|
|
sub WriteOneDesc {
|
|
|
|
my ($id, $who, $when, $buffer) = (@_);
|
|
|
|
$buffer = trim($buffer);
|
|
|
|
if ($buffer eq '') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$dbh->do("INSERT INTO longdescs (bug_id, who, bug_when, thetext) VALUES " .
|
|
|
|
"($id, $who, " . time2str("'%Y/%m/%d %H:%M:%S'", $when) .
|
|
|
|
", " . $dbh->quote($buffer) . ")");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (GetFieldDef('bugs', 'long_desc')) {
|
|
|
|
eval("use Date::Parse");
|
|
|
|
eval("use Date::Format");
|
|
|
|
my $sth = $dbh->prepare("SELECT count(*) FROM bugs");
|
|
|
|
$sth->execute();
|
|
|
|
my ($total) = ($sth->fetchrow_array);
|
|
|
|
|
|
|
|
print "Populating new long_desc table. This is slow. There are $total\n";
|
|
|
|
print "bugs to process; a line of dots will be printed for each 50.\n\n";
|
|
|
|
$| = 1;
|
|
|
|
|
|
|
|
$dbh->do("LOCK TABLES bugs write, longdescs write, profiles write");
|
|
|
|
|
|
|
|
$dbh->do('DELETE FROM longdescs');
|
|
|
|
|
|
|
|
$sth = $dbh->prepare("SELECT bug_id, creation_ts, reporter, long_desc " .
|
|
|
|
"FROM bugs ORDER BY bug_id");
|
|
|
|
$sth->execute();
|
|
|
|
my $count = 0;
|
|
|
|
while (1) {
|
|
|
|
my ($id, $createtime, $reporterid, $desc) = ($sth->fetchrow_array());
|
|
|
|
if (!$id) {
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
print ".";
|
|
|
|
$count++;
|
|
|
|
if ($count % 10 == 0) {
|
|
|
|
print " ";
|
|
|
|
if ($count % 50 == 0) {
|
|
|
|
print "$count/$total (" . int($count * 100 / $total) . "%)\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$desc =~ s/\r//g;
|
|
|
|
my $who = $reporterid;
|
|
|
|
my $when = str2time($createtime);
|
|
|
|
my $buffer = "";
|
|
|
|
foreach my $line (split(/\n/, $desc)) {
|
|
|
|
$line =~ s/\s+$//g; # Trim trailing whitespace.
|
|
|
|
if ($line =~ /^------- Additional Comments From ([^\s]+)\s+(\d.+\d)\s+-------$/) {
|
|
|
|
my $name = $1;
|
|
|
|
my $date = str2time($2);
|
|
|
|
$date += 59; # Oy, what a hack. The creation time is
|
|
|
|
# accurate to the second. But we the long
|
|
|
|
# text only contains things accurate to the
|
|
|
|
# minute. And so, if someone makes a comment
|
|
|
|
# within a minute of the original bug creation,
|
|
|
|
# then the comment can come *before* the
|
|
|
|
# bug creation. So, we add 59 seconds to
|
|
|
|
# the time of all comments, so that they
|
|
|
|
# are always considered to have happened at
|
|
|
|
# the *end* of the given minute, not the
|
|
|
|
# beginning.
|
|
|
|
if ($date >= $when) {
|
|
|
|
WriteOneDesc($id, $who, $when, $buffer);
|
|
|
|
$buffer = "";
|
|
|
|
$when = $date;
|
|
|
|
my $s2 = $dbh->prepare("SELECT userid FROM profiles " .
|
|
|
|
"WHERE login_name = " .
|
|
|
|
$dbh->quote($name));
|
|
|
|
$s2->execute();
|
|
|
|
($who) = ($s2->fetchrow_array());
|
|
|
|
if (!$who) {
|
|
|
|
# This username doesn't exist. Try a special
|
|
|
|
# netscape-only hack (sorry about that, but I don't
|
|
|
|
# think it will hurt any other installations). We
|
|
|
|
# have many entries in the bugsystem from an ancient
|
|
|
|
# world where the "@netscape.com" part of the loginname
|
|
|
|
# was omitted. So, look up the user again with that
|
|
|
|
# appended, and use it if it's there.
|
|
|
|
if ($name !~ /\@/) {
|
|
|
|
my $nsname = $name . "\@netscape.com";
|
|
|
|
$s2 =
|
|
|
|
$dbh->prepare("SELECT userid FROM profiles " .
|
|
|
|
"WHERE login_name = " .
|
|
|
|
$dbh->quote($nsname));
|
|
|
|
$s2->execute();
|
|
|
|
($who) = ($s2->fetchrow_array());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$who) {
|
|
|
|
# This username doesn't exist. Maybe someone renamed
|
|
|
|
# him or something. Invent a new profile entry,
|
|
|
|
# disabled, just to represent him.
|
|
|
|
$dbh->do("INSERT INTO profiles " .
|
|
|
|
"(login_name, password, cryptpassword," .
|
|
|
|
" disabledtext) VALUES (" .
|
|
|
|
$dbh->quote($name) .
|
|
|
|
", 'okthen', encrypt('okthen'), " .
|
|
|
|
"'Account created only to maintain database integrity')");
|
|
|
|
$s2 = $dbh->prepare("SELECT LAST_INSERT_ID()");
|
|
|
|
$s2->execute();
|
|
|
|
($who) = ($s2->fetchrow_array());
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
} else {
|
|
|
|
# print "\nDecided this line of bug $id has a date of " .
|
|
|
|
# time2str("'%Y/%m/%d %H:%M:%S'", $date) .
|
|
|
|
# "\nwhich is less than previous line:\n$line\n\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
$buffer .= $line . "\n";
|
|
|
|
}
|
|
|
|
WriteOneDesc($id, $who, $when, $buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "\n\n";
|
|
|
|
|
|
|
|
DropField('bugs', 'long_desc');
|
|
|
|
|
|
|
|
$dbh->do("UNLOCK TABLES");
|
2000-07-14 01:38:15 +04:00
|
|
|
$::regenerateshadow = 1;
|
2000-01-21 00:31:22 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-22 07:24:42 +03:00
|
|
|
# 2000-01-18 Added a new table fielddefs that records information about the
|
|
|
|
# different fields we keep an activity log on. The bugs_activity table
|
|
|
|
# now has a pointer into that table instead of recording the name directly.
|
|
|
|
|
|
|
|
if (GetFieldDef('bugs_activity', 'field')) {
|
|
|
|
AddField('bugs_activity', 'fieldid',
|
|
|
|
'mediumint not null, ADD INDEX (fieldid)');
|
|
|
|
print "Populating new fieldid field ...\n";
|
|
|
|
|
|
|
|
$dbh->do("LOCK TABLES bugs_activity WRITE, fielddefs WRITE");
|
|
|
|
|
|
|
|
my $sth = $dbh->prepare('SELECT DISTINCT field FROM bugs_activity');
|
|
|
|
$sth->execute();
|
|
|
|
my %ids;
|
|
|
|
while (my ($f) = ($sth->fetchrow_array())) {
|
|
|
|
my $q = $dbh->quote($f);
|
|
|
|
my $s2 =
|
|
|
|
$dbh->prepare("SELECT fieldid FROM fielddefs WHERE name = $q");
|
|
|
|
$s2->execute();
|
|
|
|
my ($id) = ($s2->fetchrow_array());
|
|
|
|
if (!$id) {
|
|
|
|
$dbh->do("INSERT INTO fielddefs (name, description) VALUES " .
|
|
|
|
"($q, $q)");
|
|
|
|
$s2 = $dbh->prepare("SELECT LAST_INSERT_ID()");
|
|
|
|
$s2->execute();
|
|
|
|
($id) = ($s2->fetchrow_array());
|
|
|
|
}
|
|
|
|
$dbh->do("UPDATE bugs_activity SET fieldid = $id WHERE field = $q");
|
|
|
|
}
|
|
|
|
$dbh->do("UNLOCK TABLES");
|
|
|
|
|
|
|
|
DropField('bugs_activity', 'field');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# 2000-01-18 New email-notification scheme uses a new field in the bug to
|
|
|
|
# record when email notifications were last sent about this bug. Also,
|
|
|
|
# added a user pref whether a user wants to use the brand new experimental
|
|
|
|
# stuff.
|
|
|
|
|
|
|
|
if (!GetFieldDef('bugs', 'lastdiffed')) {
|
|
|
|
AddField('bugs', 'lastdiffed', 'datetime not null');
|
2000-01-27 00:17:36 +03:00
|
|
|
$dbh->do('UPDATE bugs SET lastdiffed = now(), delta_ts = delta_ts');
|
2000-01-22 07:24:42 +03:00
|
|
|
}
|
|
|
|
|
2000-01-23 06:36:17 +03:00
|
|
|
AddField('profiles', 'newemailtech', 'tinyint not null');
|
|
|
|
|
|
|
|
|
|
|
|
# 2000-01-22 The "login_name" field in the "profiles" table was not
|
|
|
|
# declared to be unique. Sure enough, somehow, I got 22 duplicated entries
|
|
|
|
# in my database. This code detects that, cleans up the duplicates, and
|
|
|
|
# then tweaks the table to declare the field to be unique. What a pain.
|
|
|
|
|
|
|
|
if (GetIndexDef('profiles', 'login_name')->[1]) {
|
|
|
|
print "Searching for duplicate entries in the profiles table ...\n";
|
|
|
|
while (1) {
|
|
|
|
# This code is weird in that it loops around and keeps doing this
|
|
|
|
# select again. That's because I'm paranoid about deleting entries
|
|
|
|
# out from under us in the profiles table. Things get weird if
|
|
|
|
# there are *three* or more entries for the same user...
|
|
|
|
$sth = $dbh->prepare("SELECT p1.userid, p2.userid, p1.login_name " .
|
|
|
|
"FROM profiles AS p1, profiles AS p2 " .
|
|
|
|
"WHERE p1.userid < p2.userid " .
|
|
|
|
"AND p1.login_name = p2.login_name " .
|
|
|
|
"ORDER BY p1.login_name");
|
|
|
|
$sth->execute();
|
|
|
|
my ($u1, $u2, $n) = ($sth->fetchrow_array);
|
|
|
|
if (!$u1) {
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
print "Both $u1 & $u2 are ids for $n! Merging $u2 into $u1 ...\n";
|
|
|
|
foreach my $i (["bugs", "reporter"],
|
|
|
|
["bugs", "assigned_to"],
|
|
|
|
["bugs", "qa_contact"],
|
|
|
|
["attachments", "submitter_id"],
|
|
|
|
["bugs_activity", "who"],
|
|
|
|
["cc", "who"],
|
|
|
|
["votes", "who"],
|
|
|
|
["longdescs", "who"]) {
|
|
|
|
my ($table, $field) = (@$i);
|
|
|
|
print " Updating $table.$field ...\n";
|
2000-01-23 06:57:11 +03:00
|
|
|
my $extra = "";
|
|
|
|
if ($table eq "bugs") {
|
|
|
|
$extra = ", delta_ts = delta_ts";
|
|
|
|
}
|
|
|
|
$dbh->do("UPDATE $table SET $field = $u1 $extra " .
|
|
|
|
"WHERE $field = $u2");
|
2000-01-23 06:36:17 +03:00
|
|
|
}
|
|
|
|
$dbh->do("DELETE FROM profiles WHERE userid = $u2");
|
|
|
|
}
|
|
|
|
print "OK, changing index type to prevent duplicates in the future ...\n";
|
|
|
|
|
|
|
|
$dbh->do("ALTER TABLE profiles DROP INDEX login_name");
|
|
|
|
$dbh->do("ALTER TABLE profiles ADD UNIQUE (login_name)");
|
2000-01-22 07:24:42 +03:00
|
|
|
|
2000-01-23 06:36:17 +03:00
|
|
|
}
|
2000-01-22 07:24:42 +03:00
|
|
|
|
|
|
|
|
2000-01-25 10:54:57 +03:00
|
|
|
# 2000-01-24 Added a new field to let people control whether the "My
|
|
|
|
# bugs" link appears at the bottom of each page. Also can control
|
|
|
|
# whether each named query should show up there.
|
|
|
|
|
|
|
|
AddField('profiles', 'mybugslink', 'tinyint not null default 1');
|
|
|
|
AddField('namedqueries', 'linkinfooter', 'tinyint not null');
|
|
|
|
|
2000-01-22 07:24:42 +03:00
|
|
|
|
2000-02-17 08:15:23 +03:00
|
|
|
# 2000-02-12 Added a new state to bugs, UNCONFIRMED. Added ability to confirm
|
|
|
|
# a vote via bugs. Added user bits to control which users can confirm bugs
|
|
|
|
# by themselves, and which users can edit bugs without their names on them.
|
|
|
|
# Added a user field which controls which groups a user can put other users
|
|
|
|
# into.
|
|
|
|
|
2000-07-14 01:38:15 +04:00
|
|
|
my @resolutions = ("", "FIXED", "INVALID", "WONTFIX", "LATER", "REMIND",
|
2000-07-14 04:03:48 +04:00
|
|
|
"DUPLICATE", "WORKSFORME", "MOVED");
|
2000-07-14 01:38:15 +04:00
|
|
|
CheckEnumField('bugs', 'resolution', @resolutions);
|
|
|
|
|
2000-02-17 08:15:23 +03:00
|
|
|
my @states = ("UNCONFIRMED", "NEW", "ASSIGNED", "REOPENED", "RESOLVED",
|
|
|
|
"VERIFIED", "CLOSED");
|
|
|
|
CheckEnumField('bugs', 'bug_status', @states);
|
2000-07-14 01:38:15 +04:00
|
|
|
|
2000-02-17 08:15:23 +03:00
|
|
|
if (!GetFieldDef('bugs', 'everconfirmed')) {
|
|
|
|
AddField('bugs', 'everconfirmed', 'tinyint not null');
|
2000-02-18 23:03:17 +03:00
|
|
|
$dbh->do("UPDATE bugs SET everconfirmed = 1, delta_ts = delta_ts");
|
2000-02-17 08:15:23 +03:00
|
|
|
}
|
|
|
|
AddField('products', 'maxvotesperbug', 'smallint not null default 10000');
|
|
|
|
AddField('products', 'votestoconfirm', 'smallint not null');
|
|
|
|
AddField('profiles', 'blessgroupset', 'bigint not null');
|
|
|
|
|
2000-03-21 19:47:06 +03:00
|
|
|
# 2000-03-21 Adding a table for target milestones to
|
|
|
|
# database - matthew@zeroknowledge.com
|
|
|
|
|
|
|
|
$sth = $dbh->prepare("SELECT count(*) from milestones");
|
|
|
|
$sth->execute();
|
|
|
|
if (!($sth->fetchrow_arrayref()->[0])) {
|
|
|
|
print "Replacing blank milestones...\n";
|
|
|
|
$dbh->do("UPDATE bugs SET target_milestone = '---', delta_ts=delta_ts WHERE target_milestone = ' '");
|
|
|
|
|
|
|
|
# Populate milestone table with all exisiting values in database
|
|
|
|
$sth = $dbh->prepare("SELECT DISTINCT target_milestone, product FROM bugs");
|
|
|
|
$sth->execute();
|
|
|
|
|
|
|
|
print "Populating milestones table...\n";
|
|
|
|
|
|
|
|
my $value;
|
|
|
|
my $product;
|
|
|
|
while(($value, $product) = $sth->fetchrow_array())
|
|
|
|
{
|
|
|
|
# check if the value already exists
|
|
|
|
my $sortkey = substr($value, 1);
|
|
|
|
if ($sortkey !~ /^\d+$/) {
|
|
|
|
$sortkey = 0;
|
|
|
|
} else {
|
|
|
|
$sortkey *= 10;
|
|
|
|
}
|
|
|
|
$value = $dbh->quote($value);
|
|
|
|
$product = $dbh->quote($product);
|
|
|
|
my $s2 = $dbh->prepare("SELECT value FROM milestones WHERE value = $value AND product = $product");
|
|
|
|
$s2->execute();
|
|
|
|
|
|
|
|
if(!$s2->fetchrow_array())
|
|
|
|
{
|
|
|
|
$dbh->do("INSERT INTO milestones(value, product, sortkey) VALUES($value, $product, $sortkey)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-23 03:04:08 +03:00
|
|
|
# 2000-03-22 Changed the default value for target_milestone to be "---"
|
|
|
|
# (which is still not quite correct, but much better than what it was
|
|
|
|
# doing), and made the size of the value field in the milestones table match
|
|
|
|
# the size of the target_milestone field in the bugs table.
|
|
|
|
|
|
|
|
ChangeFieldType('bugs', 'target_milestone',
|
2000-03-23 21:23:14 +03:00
|
|
|
'varchar(20) default "---"');
|
|
|
|
ChangeFieldType('milestones', 'value', 'varchar(20)');
|
|
|
|
|
|
|
|
|
|
|
|
# 2000-03-23 Added a defaultmilestone field to the products table, so that
|
|
|
|
# we know which milestone to initially assign bugs to.
|
|
|
|
|
|
|
|
if (!GetFieldDef('products', 'defaultmilestone')) {
|
|
|
|
AddField('products', 'defaultmilestone',
|
|
|
|
'varchar(20) not null default "---"');
|
|
|
|
$sth = $dbh->prepare("SELECT product, defaultmilestone FROM products");
|
|
|
|
$sth->execute();
|
|
|
|
while (my ($product, $defaultmilestone) = $sth->fetchrow_array()) {
|
|
|
|
$product = $dbh->quote($product);
|
|
|
|
$defaultmilestone = $dbh->quote($defaultmilestone);
|
|
|
|
my $s2 = $dbh->prepare("SELECT value FROM milestones " .
|
|
|
|
"WHERE value = $defaultmilestone " .
|
|
|
|
"AND product = $product");
|
|
|
|
$s2->execute();
|
|
|
|
if (!$s2->fetchrow_array()) {
|
|
|
|
$dbh->do("INSERT INTO milestones(value, product) " .
|
|
|
|
"VALUES ($defaultmilestone, $product)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-23 03:04:08 +03:00
|
|
|
|
2000-03-29 01:31:24 +04:00
|
|
|
# 2000-03-24 Added unique indexes into the cc and keyword tables. This
|
|
|
|
# prevents certain database inconsistencies, and, moreover, is required for
|
|
|
|
# new generalized list code to work.
|
|
|
|
|
|
|
|
if ( CountIndexes('cc') != 3 ) {
|
|
|
|
|
|
|
|
# XXX should eliminate duplicate entries before altering
|
|
|
|
#
|
|
|
|
print "Recreating indexes on cc table.\n";
|
|
|
|
DropIndexes('cc');
|
|
|
|
$dbh->do("ALTER TABLE cc ADD UNIQUE (bug_id,who)");
|
|
|
|
$dbh->do("ALTER TABLE cc ADD INDEX (who)");
|
2000-04-12 04:25:38 +04:00
|
|
|
|
2000-07-14 01:38:15 +04:00
|
|
|
$::regenerateshadow=1; # cc fields no longer have spaces in them
|
2000-03-29 01:31:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( CountIndexes('keywords') != 3 ) {
|
|
|
|
|
|
|
|
# XXX should eliminate duplicate entries before altering
|
|
|
|
#
|
|
|
|
print "Recreating indexes on keywords table.\n";
|
|
|
|
DropIndexes('keywords');
|
|
|
|
$dbh->do("ALTER TABLE keywords ADD INDEX (keywordid)");
|
|
|
|
$dbh->do("ALTER TABLE keywords ADD UNIQUE (bug_id,keywordid)");
|
2000-04-12 04:25:38 +04:00
|
|
|
|
2000-03-29 01:31:24 +04:00
|
|
|
}
|
2000-03-23 03:04:08 +03:00
|
|
|
|
1999-10-12 20:58:11 +04:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2000-01-29 23:07:05 +03:00
|
|
|
#
|
|
|
|
# Final checks...
|
2000-07-14 01:38:15 +04:00
|
|
|
if ($::regenerateshadow) {
|
2000-01-29 23:07:05 +03:00
|
|
|
print "Now regenerating the shadow database for all bugs.\n";
|
2000-05-18 01:29:33 +04:00
|
|
|
system("./processmail", "regenerate");
|
2000-01-29 23:07:05 +03:00
|
|
|
}
|
2000-03-29 01:31:24 +04:00
|
|
|
|
2000-03-23 21:23:14 +03:00
|
|
|
unlink "data/versioncache";
|
2000-03-29 01:31:24 +04:00
|
|
|
print "Reminder: Bugzilla now requires version 3.22.5 or later of MySQL.\n";
|
2000-04-12 04:25:38 +04:00
|
|
|
print "Reminder: Bugzilla now requires version 8.7 or later of sendmail.\n";
|