From 945721f48f74d5cfffef7c7cf3a3d6bc2521f5dd Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 15 Jul 2003 13:16:32 +0000 Subject: import of rt 3.0.4 --- rt/sbin/extract-message-catalog | 246 +++++++++++++++++ rt/sbin/extract_pod_tests | 129 +++++++++ rt/sbin/factory | 427 +++++++++++++++++++++++++++++ rt/sbin/license_tag | 196 ++++++++++++++ rt/sbin/regression_harness | 33 +++ rt/sbin/rt-setup-database | 585 ++++++++++++++++++++++++++++++++++++++++ rt/sbin/rt-setup-database.in | 585 ++++++++++++++++++++++++++++++++++++++++ rt/sbin/rt-test-dependencies | 246 +++++++++++++++++ rt/sbin/rt-test-dependencies.in | 246 +++++++++++++++++ 9 files changed, 2693 insertions(+) create mode 100644 rt/sbin/extract-message-catalog create mode 100644 rt/sbin/extract_pod_tests create mode 100644 rt/sbin/factory create mode 100644 rt/sbin/license_tag create mode 100644 rt/sbin/regression_harness create mode 100644 rt/sbin/rt-setup-database create mode 100644 rt/sbin/rt-setup-database.in create mode 100644 rt/sbin/rt-test-dependencies create mode 100644 rt/sbin/rt-test-dependencies.in (limited to 'rt/sbin') diff --git a/rt/sbin/extract-message-catalog b/rt/sbin/extract-message-catalog new file mode 100644 index 000000000..af7b2c733 --- /dev/null +++ b/rt/sbin/extract-message-catalog @@ -0,0 +1,246 @@ +#!/usr/bin/perl -w +# BEGIN LICENSE BLOCK +# +# Copyright (c) 1996-2003 Jesse Vincent +# +# (Except where explictly superceded by other copyright notices) +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# Unless otherwise specified, all modifications, corrections or +# extensions to this work which alter its source code become the +# property of Best Practical Solutions, LLC when submitted for +# inclusion in the work. +# +# +# END LICENSE BLOCK + +# Portions Copyright 2002 Autrijus Tang + +use strict; + +use File::Find; +use File::Copy; +use Regexp::Common; +use Carp; + +use vars qw($DEBUG $FILECAT); + +$DEBUG = 1; + +@ARGV = unless @ARGV; + +$FILECAT = {}; + +# extract all strings and stuff them into $FILECAT +File::Find::find( { wanted => \&extract_strings_from_code, follow => 0 }, '.' ); + +# ensure proper escaping and [_1] => %1 transformation +foreach my $str ( sort keys %{$FILECAT} ) { + my $entry = $FILECAT->{$str}; + my $oldstr = $str; + + $str =~ s/\\/\\\\/g; + $str =~ s/\"/\\"/g; + $str =~ s/((?{$oldstr}; + $FILECAT->{$str} = $entry; +} + +# update all language dictionaries +foreach my $dict (@ARGV) { + $dict = "lib/RT/I18N/$dict.po" unless -f $dict or $dict =~ m!/!; + + my $lang = $dict; + $lang =~ s|.*/||; + $lang =~ s|\.po$||; + + update($lang, $dict); +} + + +# {{{ pull strings out of the code. + +sub extract_strings_from_code { + my $file = $_; + + local $/; + return if ( -d $_ ); + return if ( $File::Find::dir =~ 'lib/blib|lib/t/autogen|var|m4|local' ); + return if ( /\.po$|\.bak$|~|,D|,B$|extract-message-catalog$/ ); + return if ( /^[\.#]/ ); + return if ( -f "$_.in" ); + + print "Looking at $File::Find::name\n"; + my $filename = $File::Find::name; + $filename =~ s'^\./''; + $filename =~ s'\.in$''; + + unless (open _, $file) { + print "Cannot open $file for reading ($!), skipping.\n"; + return; + } + + $_ = <_>; + + # Mason filter: <&|/l>... + my $line = 1; + while (m!\G.*?<&\|/l(.*?)&>(.*?)!sg) { + my ( $vars, $str ) = ( $1, $2 ); + $line += ( () = ( $& =~ /\n/g ) ); # cryptocontext! + $str =~ s/\\'/\'/g; + #print "STR IS $str\n"; + push @{ $FILECAT->{$str} }, [ $filename, $line, $vars ]; + } + + # Localization function: loc(...) + $line = 1; + pos($_) = 0; + while (m/\G.*?\bloc$RE{balanced}{-parens=>'()'}{-keep}/sg) { + my $match = $1; + $line += ( () = ( $& =~ /\n/g ) ); # cryptocontext! + + my ( $vars, $str ); + if ( $match =~ + /\(\s*($RE{delimited}{-delim=>q{'"}}{-keep})(.*?)\s*\)$/ ) { + + $str = substr( $1, 1, -1 ); # $str comes before $vars now + $vars = $9; + } + else { + next; + } + + $vars =~ s/[\n\r]//g; + $str =~ s/\\'/\'/g; + + push @{ $FILECAT->{$str} }, [ $filename, $line, $vars ]; + } + + # Comment-based mark: "..." # loc + $line = 1; + pos($_) = 0; + while (m/\G.*?($RE{delimited}{-delim=>q{'"}}{-keep})[\}\)\],]*\s*\#\s*loc\s*$/smg) { + my $str = substr($1, 1, -1); + $line += ( () = ( $& =~ /\n/g ) ); # cryptocontext! + $str =~ s/\\'/\'/g; + push @{ $FILECAT->{$str} }, [ $filename, $line, '' ]; + } + + # Comment-based pair mark: "..." => "..." # loc_pair + $line = 1; + pos($_) = 0; + while (m/\G.*?(\w+)\s*=>\s*($RE{delimited}{-delim=>q{'"}}{-keep})[\}\)\],]*\s*\#\s*loc_pair\s*$/smg) { + my $key = $1; + my $val = substr($2, 1, -1); + $line += ( () = ( $& =~ /\n/g ) ); # cryptocontext! + $key =~ s/\\'/\'/g; + $val =~ s/\\'/\'/g; + push @{ $FILECAT->{$key} }, [ $filename, $line, '' ]; + push @{ $FILECAT->{$val} }, [ $filename, $line, '' ]; + } + + close (_); +} +# }}} extract from strings + +sub update { + my $lang = shift; + my $file = shift; + my ( %Lexicon, %Header); + my $out = ''; + + unless (!-e $file or -w $file) { + warn "Can't write to $lang, skipping...\n"; + return; + } + + print "Updating $lang...\n"; + + my @lines; + @lines = () if open (LEXICON, $file); + @lines = grep { !/^(#(:|\.)\s*|$)/ } @lines; + while (@lines) { + my $msghdr = ""; + $msghdr .= shift @lines while ( $lines[0] && $lines[0] !~ /^msgid/ ); + my $msgid = shift @lines; + my $msgstr = ""; + $msgstr .= shift @lines while ( $lines[0] && $lines[0] =~ /^(msgstr|")/ ); + + last unless $msgid; + + chomp $msgid; + chomp $msgstr; + $msgid =~ s/^msgid "(.*)"$/$1/ or warn $msgid; + $msgstr =~ s/^msgstr "(.*)"$/$1/ms or warn $msgstr; + + $Lexicon{$msgid} = $msgstr; + $Header{$msgid} = $msghdr; + } + + my $is_english = ( $lang =~ /^en(?:[^A-Za-z]|$)/ ); + + foreach my $str ( sort keys %{$FILECAT} ) { + $Lexicon{$str} ||= '';; + } + foreach ( sort keys %Lexicon ) { + my $f = join ( ' ', sort map $_->[0].":".$_->[1], @{ $FILECAT->{$_} } ); + my $nospace = $_; + $nospace =~ s/ +$//; + + if ( !$Lexicon{$_} and $Lexicon{$nospace} ) { + $Lexicon{$_} = + $Lexicon{$nospace} . ( ' ' x ( length($_) - length($nospace) ) ); + } + + next if !length( $Lexicon{$_} ) and $is_english; + + my %seen; + $out .= $Header{$_} if exists $Header{$_}; + if ( $f && $f !~ /^\s+$/ ) { + + $out .= "#: $f\n"; + } + elsif ($_) { + $out .= "#: NOT FOUND IN SOURCE\n"; + } + foreach my $entry ( grep { $_->[2] } @{ $FILECAT->{$_} } ) { + my ( $file, $line, $var ) = @{$entry}; + $var =~ s/^\s*,\s*//; + $var =~ s/\s*$//; + $out .= "#. ($var)\n" unless $seen{$var}++; + } + $out .= "msgid \"$_\"\nmsgstr \"$Lexicon{$_}\"\n\n"; + } + + open PO, ">$file" or die $!; + print PO $out; + close PO; + + return 1; +} + +sub escape { + my $text = shift; + $text =~ s/\b_(\d+)/%$1/; + return $text; +} + +__END__ +# Local variables: +# c-indentation-style: bsd +# c-basic-offset: 4 +# indent-tabs-mode: nil +# End: +# vim: expandtab shiftwidth=4: diff --git a/rt/sbin/extract_pod_tests b/rt/sbin/extract_pod_tests new file mode 100644 index 000000000..ed01c7dc2 --- /dev/null +++ b/rt/sbin/extract_pod_tests @@ -0,0 +1,129 @@ +#!/usr/bin/perl +# BEGIN LICENSE BLOCK +# +# Copyright (c) 1996-2003 Jesse Vincent +# +# (Except where explictly superceded by other copyright notices) +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# Unless otherwise specified, all modifications, corrections or +# extensions to this work which alter its source code become the +# property of Best Practical Solutions, LLC when submitted for +# inclusion in the work. +# +# +# END LICENSE BLOCK + +use strict; +use vars qw($VERSION); +$VERSION = '0.06'; + +use Pod::Tests; +use Symbol; + +=pod + +=head1 NAME + +extract_pod_tests - RT-specific variant of pod2tests + +=head1 SYNOPSIS + + pod2test [-Mmodule] [input [output]] + +=head1 DESCRIPTION + +B is a front-end for Test::Inline. It generates the +"Bodies" of MakeMaker style .t testing files from embedded tests and +code examples. + +If output is not specified, the resulting .t file will go to STDOUT. +Otherwise, it will go to the given output file. If input is not +given, it will draw from STDIN. + +If the given file contains no tests or code examples, no output will +be given and no output file will be created. + +=cut + +my($infile, $outfile) = @ARGV; +my($infh,$outfh); + + +if( defined $infile ) { + $infh = gensym; + open($infh, $infile) or + die "Can't open the POD file $infile: $!"; +} +else { + $infh = \*STDIN; +} + +unless ($outfile) { + ( my $test = $infile ) =~ s/\.(pm|pod)$//; + $test =~ s/^lib\W//; + $test =~ s/\W/-/; + $test =~ s/\//__/g; + + $outfile = "lib/t/autogen/autogen-$test.t"; +} + + +my $p = Pod::Tests->new; +$p->parse_fh($infh); + +# XXX Hack to put the filename into the #line directive +$p->{file} = $infile || ''; + +my @tests = $p->build_tests($p->tests); +my @examples = $p->build_examples($p->examples); + +exit unless @tests or @examples; + + +if( defined $outfile) { + $outfh = gensym; + open($outfh, ">$outfile") or + die "Can't open the test file $outfile: $!"; +} +else { + $outfh = \*STDOUT; +} + + + +foreach my $test (@tests, @examples) { + print $outfh "$test\n"; +} + +print $outfh "1;\n"; + +=pod + +=head1 BUGS and CAVEATS + +This is a very simple rough cut. It only does very rudimentary tests +on the examples. + +=head1 AUTHOR + + + +Based on pod2tests by Michael G Schwern + +=head1 SEE ALSO + +L + +=cut + +1; diff --git a/rt/sbin/factory b/rt/sbin/factory new file mode 100644 index 000000000..8abb1922f --- /dev/null +++ b/rt/sbin/factory @@ -0,0 +1,427 @@ +#!/usr/bin/perl +# BEGIN LICENSE BLOCK +# +# Copyright (c) 1996-2003 Jesse Vincent +# +# (Except where explictly superceded by other copyright notices) +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# Unless otherwise specified, all modifications, corrections or +# extensions to this work which alter its source code become the +# property of Best Practical Solutions, LLC when submitted for +# inclusion in the work. +# +# +# END LICENSE BLOCK + +use DBI; + +my $database = shift; +my $namespace = shift; + +my $CollectionBaseclass = 'RT::SearchBuilder'; +my $RecordBaseclass = 'RT::Record'; + +my $driver = 'mysql'; +my $hostname = 'localhost'; +my $user = 'root'; +my $password = ''; + + +my $LicenseBlock = << '.'; +# BEGIN LICENSE BLOCK +# +# Copyright (c) 1996-2003 Jesse Vincent +# +# (Except where explictly superceded by other copyright notices) +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# Unless otherwise specified, all modifications, corrections or +# extensions to this work which alter its source code become the +# property of Best Practical Solutions, LLC when submitted for +# inclusion in the work. +# +# +# END LICENSE BLOCK +. + +my $Attribution = << '.'; +# Autogenerated by DBIx::SearchBuilder factory (by ) +# WARNING: THIS FILE IS AUTOGENERATED. ALL CHANGES TO THIS FILE WILL BE LOST. +# +# !! DO NOT EDIT THIS FILE !! +# + +use strict; +. + +my $dsn = "DBI:$driver:database=$database;host=$hostname"; + +my $dbh = DBI->connect( $dsn, $user, $password ); + +#get all tables out of database +my @tables = $dbh->tables(); + +my ( %tablemap, $typemap, %modulemap ); + +foreach my $table (@tables) { + next if ($table eq 'sessions'); + $tablemap{$table} = $table; + $modulemap{$table} = $table; + if ( $table =~ /^(.*)s$/ ) { + $tablemap{$1} = $table; + $modulemap{$1} = $1; + } +} +$tablemap{'CreatedBy'} = 'User'; +$tablemap{'UpdatedBy'} = 'User'; + +$typemap{'id'} = 'ro'; +$typemap{'Creator'} = 'auto'; +$typemap{'Created'} = 'auto'; +$typemap{'Updated'} = 'auto'; +$typemap{'UpdatedBy'} = 'auto'; +$typemap{'LastUpdated'} = 'auto'; +$typemap{'LastUpdatedBy'} = 'auto'; + +foreach my $table (@tables) { + next if ($table eq 'sessions'); + my $tablesingle = $table; + $tablesingle =~ s/s$//; + my $tableplural = $tablesingle . "s"; + + if ( $tablesingle eq 'ACL' ) { + $tablesingle = "ACE"; + $tableplural = "ACL"; + } + + my %requirements; + + my $CollectionClassName = $namespace . "::" . $tableplural; + my $RecordClassName = $namespace . "::" . $tablesingle; + + my $path = $namespace; + $path =~ s/::/\//g; + + my $RecordClassPath = $path . "/" . $tablesingle . ".pm"; + my $CollectionClassPath = $path . "/" . $tableplural . ".pm"; + + #create a collection class + my $CreateInParams; + my $CreateOutParams; + my $ClassAccessible = ""; + my $FieldsPod = ""; + my $CreatePod = ""; + my %fields; + my $sth = $dbh->prepare("DESCRIBE $table"); + $sth->execute; + + while ( my $row = $sth->fetchrow_hashref() ) { + my $field = $row->{'Field'}; + my $type = $row->{'Type'}; + my $default = $row->{'Default'}; + $fields{$field} = 1; + + #generate the 'accessible' datastructure + + if ( $typemap{$field} eq 'auto' ) { + $ClassAccessible .= " $field => + {read => 1, auto => 1,"; + } + elsif ( $typemap{$field} eq 'ro' ) { + $ClassAccessible .= " $field => + {read => 1,"; + } + else { + $ClassAccessible .= " $field => + {read => 1, write => 1,"; + + } + + $ClassAccessible .= " type => '$type', default => '$default'},\n"; + + #generate pod for the accessible fields + $FieldsPod .= " +=head2 $field + +Returns the current value of $field. +(In the database, $field is stored as $type.) + +"; + + unless ( $typemap{$field} eq 'auto' || $typemap{$field} eq 'ro' ) { + $FieldsPod .= " + +=head2 Set$field VALUE + + +Set $field to VALUE. +Returns (1, 'Status message') on success and (0, 'Error Message') on failure. +(In the database, $field will be stored as a $type.) + +"; + } + + $FieldsPod .= " +=cut + +"; + + if ( $modulemap{$field} ) { + $FieldsPod .= " +=head2 ${field}Obj + +Returns the $modulemap{$field} Object which has the id returned by $field + + +=cut + +sub ${field}Obj { + my \$self = shift; + my \$$field = ${namespace}::$modulemap{$field}->new(\$self->CurrentUser); + \$$field->Load(\$self->__Value('$field')); + return(\$$field); +} +"; + $requirements{ $tablemap{$field} } = + "use ${namespace}::$modulemap{$field};"; + + } + + unless ( $typemap{$field} eq 'auto' || $field eq 'id' ) { + + #generate create statement + $CreateInParams .= " $field => '$default',\n"; + $CreateOutParams .= + " $field => \$args{'$field'},\n"; + + #gerenate pod for the create statement + $CreatePod .= " $type '$field'"; + $CreatePod .= " defaults to '$default'" if ($default); + $CreatePod .= ".\n"; + + } + + } + + $Create = " +sub Create { + my \$self = shift; + my \%args = ( +$CreateInParams + \@_); + \$self->SUPER::Create( +$CreateOutParams); + +} +"; + $CreatePod .= "\n=cut\n\n"; + + my $CollectionClass = $LicenseBlock . $Attribution . + + " + +=head1 NAME + + $CollectionClassName -- Class Description + +=head1 SYNOPSIS + + use $CollectionClassName + +=head1 DESCRIPTION + + +=head1 METHODS + +=cut + +package $CollectionClassName; + +use $CollectionBaseclass; +use $RecordClassName; + +use vars qw( \@ISA ); +\@ISA= qw($CollectionBaseclass); + + +sub _Init { + my \$self = shift; + \$self->{'table'} = '$table'; + \$self->{'primary_key'} = 'id'; + +"; + + if ( $fields{'SortOrder'} ) { + + $CollectionClass .= " + + # By default, order by name + \$self->OrderBy( ALIAS => 'main', + FIELD => 'SortOrder', + ORDER => 'ASC'); +"; + } + $CollectionClass .= " + return ( \$self->SUPER::_Init(\@_) ); +} + + +=head2 NewItem + +Returns an empty new $RecordClassName item + +=cut + +sub NewItem { + my \$self = shift; + return($RecordClassName->new(\$self->CurrentUser)); +} +" . MagicImport($CollectionClassName); + + my $RecordClassHeader = $Attribution . " + +=head1 NAME + +$RecordClassName + + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 METHODS + +=cut + +package $RecordClassName; +use $RecordBaseclass; +"; + + foreach my $key ( keys %requirements ) { + $RecordClassHeader .= $requirements{$key} . "\n"; + } + $RecordClassHeader .= " + +use vars qw( \@ISA ); +\@ISA= qw( $RecordBaseclass ); + +sub _Init { + my \$self = shift; + + \$self->Table('$table'); + \$self->SUPER::_Init(\@_); +} + +"; + + my $RecordClass = $LicenseBlock . $RecordClassHeader . " + +$RecordInit + +=head2 Create PARAMHASH + +Create takes a hash of values and creates a row in the database: + +$CreatePod + +$Create + +$FieldsPod + +sub _ClassAccessible { + { + +$ClassAccessible + } +}; + +" . MagicImport($RecordClassName); + + print "About to make $RecordClassPath, $CollectionClassPath\n"; + `mkdir -p $path`; + + open( RECORD, ">$RecordClassPath" ); + print RECORD $RecordClass; + close(RECORD); + + open( COL, ">$CollectionClassPath" ); + print COL $CollectionClass; + close($COL); + +} + +sub MagicImport { + my $class = shift; + + #if (exists \$warnings::{unimport}) { + # no warnings qw(redefine); + + my $path = $class; + $path =~ s#::#/#gi; + + + my $content = " + eval \"require @{[$class]}_Overlay\"; + if (\$@ && \$@ !~ qr{^Can't locate ".$path."_Overlay.pm}) { + die \$@; + }; + + eval \"require @{[$class]}_Vendor\"; + if (\$@ && \$@ !~ qr{^Can't locate ".$path."_Vendor.pm}) { + die \$@; + }; + + eval \"require @{[$class]}_Local\"; + if (\$@ && \$@ !~ qr{^Can't locate ".$path."_Local.pm}) { + die \$@; + }; + + + + +=head1 SEE ALSO + +This class allows \"overlay\" methods to be placed +into the following files _Overlay is for a System overlay by the original author, +_Vendor is for 3rd-party vendor add-ons, while _Local is for site-local customizations. + +These overlay files can contain new subs or subs to replace existing subs in this module. + +If you'll be working with perl 5.6.0 or greater, each of these files should begin with the line + + no warnings qw(redefine); + +so that perl does not kick and scream when you redefine a subroutine or variable in your overlay. + +@{[$class]}_Overlay, @{[$class]}_Vendor, @{[$class]}_Local + +=cut + + +1; +"; + + return $content; +} + +# }}} + diff --git a/rt/sbin/license_tag b/rt/sbin/license_tag new file mode 100644 index 000000000..33da2e026 --- /dev/null +++ b/rt/sbin/license_tag @@ -0,0 +1,196 @@ +#!/usr/bin/perl + + +# BEGIN LICENSE BLOCK +# +# Copyright (c) 1996-2003 Jesse Vincent +# +# (Except where explictly superceded by other copyright notices) +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# Unless otherwise specified, all modifications, corrections or +# extensions to this work which alter its source code become the +# property of Best Practical Solutions, LLC when submitted for +# inclusion in the work. +# +# +# END LICENSE BLOCK + +my $LICENSE = < + +(Except where explictly superceded by other copyright notices) + +This work is made available to you under the terms of Version 2 of +the GNU General Public License. A copy of that license should have +been provided with this software, but in any event can be snarfed +from www.gnu.org. + +This work is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +Unless otherwise specified, all modifications, corrections or +extensions to this work which alter its source code become the +property of Best Practical Solutions, LLC when submitted for +inclusion in the work. + + +EOL + +use File::Find; + +my @MAKE = qw(Makefile); + +File::Find::find({ no_chdir => 1, wanted => \&tag_pm}, 'lib'); +File::Find::find({ no_chdir => 1, wanted => \&tag_mason}, 'html'); +File::Find::find({ no_chdir => 1, wanted => \&tag_script}, 'sbin'); +File::Find::find({ no_chdir => 1, wanted => \&tag_script}, 'bin'); +tag_makefile ('Makefile'); +tag_makefile ('README'); + + +sub tag_mason { + my $pm = $_; + next unless (-f $pm); + next if ($pm =~ /images/); + open(FILE,"<$pm") || die "Failed to open $pm"; + my $file = (join "", ); + close (FILE); + my $pmlic = $LICENSE; + $pmlic =~ s/^/%# /mg; + + + print "$pm - "; + if ($file =~ /^%# BEGIN LICENSE BLOCK/ms) { + print "has license section"; + $file =~ s/^%# BEGIN LICENSE BLOCK(.*?)%# END LICENSE BLOCK/%# BEGIN LICENSE BLOCK\n$pmlic%# END LICENSE BLOCK/ms; + + + } else { + print "no license section"; + $file ="%# BEGIN LICENSE BLOCK\n$pmlic%# END LICENSE BLOCK\n". $file; + } + $file =~ s/%# END LICENSE BLOCK(\n+)/%# END LICENSE BLOCK\n/mg; + print "\n"; + + + + + open (FILE, ">$pm") || die "couldn't write new file"; + print FILE $file; + close FILE; + +} + + +sub tag_makefile { + my $pm = shift; + open(FILE,"<$pm") || die "Failed to open $pm"; + my $file = (join "", ); + close (FILE); + my $pmlic = $LICENSE; + $pmlic =~ s/^/# /mg; + + + print "$pm - "; + if ($file =~ /^# BEGIN LICENSE BLOCK/ms) { + print "has license section"; + $file =~ s/^# BEGIN LICENSE BLOCK(.*?)# END LICENSE BLOCK/# BEGIN LICENSE BLOCK\n$pmlic# END LICENSE BLOCK/ms; + + + } else { + print "no license section"; + $file ="# BEGIN LICENSE BLOCK\n$pmlic# END LICENSE BLOCK\n". $file; + } + $file =~ s/# END LICENSE BLOCK(\n+)/# END LICENSE BLOCK\n/mg; + print "\n"; + + + + + open (FILE, ">$pm") || die "couldn't write new file"; + print FILE $file; + close FILE; + +} + + +sub tag_pm { + my $pm = $_; + next unless $pm =~ /\.pm\z/s; + open(FILE,"<$pm") || die "Failed to open $pm"; + my $file = (join "", ); + close (FILE); + my $pmlic = $LICENSE; + $pmlic =~ s/^/# /mg; + + + print "$pm - "; + if ($file =~ /^# BEGIN LICENSE BLOCK/ms) { + print "has license section"; + $file =~ s/^# BEGIN LICENSE BLOCK(.*?)# END LICENSE BLOCK/# BEGIN LICENSE BLOCK\n$pmlic# END LICENSE BLOCK/ms; + + + } else { + print "no license section"; + $file ="# BEGIN LICENSE BLOCK\n$pmlic# END LICENSE BLOCK\n". $file; + } + $file =~ s/# END LICENSE BLOCK(\n+)/# END LICENSE BLOCK\n/mg; + print "\n"; + + + + + open (FILE, ">$pm") || die "couldn't write new file $pm"; + print FILE $file; + close FILE; + +} + + +sub tag_script { + my $pm = $_; + return unless (-f $pm); + open(FILE,"<$pm") || die "Failed to open $pm"; + my $file = (join "", ); + close (FILE); + my $pmlic = $LICENSE; + $pmlic =~ s/^/# /msg; + + print "$pm - "; + if ($file =~ /^# BEGIN LICENSE BLOCK/ms) { + print "has license section"; + $file =~ s/^# BEGIN LICENSE BLOCK(.*?)# END LICENSE BLOCK/# BEGIN LICENSE BLOCK\n$pmlic# END LICENSE BLOCK/ms; + + + } else { + print "no license section"; + if ($file =~ /^(#!.*?)\n/) { + + my $lic ="# BEGIN LICENSE BLOCK\n$pmlic# END LICENSE BLOCK\n"; + $file =~ s/^(#!.*?)\n/$1\n$lic/; + + } + } + $file =~ s/# END LICENSE BLOCK(\n+)/# END LICENSE BLOCK\n\n/mg; + print "\n"; + + + open (FILE, ">$pm") || die "couldn't write new file"; + print FILE $file; + close FILE; + +} + diff --git a/rt/sbin/regression_harness b/rt/sbin/regression_harness new file mode 100644 index 000000000..fc1e29304 --- /dev/null +++ b/rt/sbin/regression_harness @@ -0,0 +1,33 @@ +#!/usr/bin/perl +# BEGIN LICENSE BLOCK +# +# Copyright (c) 1996-2003 Jesse Vincent +# +# (Except where explictly superceded by other copyright notices) +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# Unless otherwise specified, all modifications, corrections or +# extensions to this work which alter its source code become the +# property of Best Practical Solutions, LLC when submitted for +# inclusion in the work. +# +# +# END LICENSE BLOCK + +open (FH,"make regression|"); + +my $skip_frontmatter = 1; +while () { + next if /^ok/; + $skip_frontmatter = 0 if (/autogen/); + print $_ unless ($skip_frontmatter); +} diff --git a/rt/sbin/rt-setup-database b/rt/sbin/rt-setup-database new file mode 100644 index 000000000..f84f290b7 --- /dev/null +++ b/rt/sbin/rt-setup-database @@ -0,0 +1,585 @@ +#!/usr/bin/perl -w +# BEGIN LICENSE BLOCK +# +# Copyright (c) 1996-2003 Jesse Vincent +# +# (Except where explictly superceded by other copyright notices) +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# Unless otherwise specified, all modifications, corrections or +# extensions to this work which alter its source code become the +# property of Best Practical Solutions, LLC when submitted for +# inclusion in the work. +# +# +# END LICENSE BLOCK + +use strict; +use vars qw($PROMPT $VERSION $Handle $Nobody $SystemUser $item); +use vars + qw(@Groups @Users @ACL @Queues @ScripActions @ScripConditions @Templates @CustomFields @Scrips); + +use lib "/opt/rt3/lib"; + +#This drags in RT's config.pm +# We do it in a begin block because RT::Handle needs to know the type to do its +# inheritance +use RT; +use Carp; +use RT::User; +use RT::CurrentUser; +use RT::Template; +use RT::ScripAction; +use RT::ACE; +use RT::Group; +use RT::User; +use RT::Queue; +use RT::ScripCondition; +use RT::CustomField; +use RT::Scrip; + +RT::LoadConfig(); +use Term::ReadKey; +use Getopt::Long; + +my %args; + +GetOptions( + \%args, + 'prompt-for-dba-password', 'force', 'debug', + 'action=s', 'dba=s', 'dba-password=s', 'datafile=s', + 'datadir=s' +); + +$| = 1; #unbuffer that output. + +require RT::Handle; +my $Handle = RT::Handle->new($RT::DatabaseType); +$Handle->BuildDSN; +my $dbh; + +if ( $args{'prompt-for-dba-password'} ) { + $args{'dba-password'} = get_dba_password(); + chomp( $args{'dba-password'} ); +} + +unless ( $args{'action'} ) { + help(); + die; +} +if ( $args{'action'} eq 'init' ) { + $dbh = DBI->connect( get_system_dsn(), $args{'dba'}, $args{'dba-password'} ) + || die "Failed to connect to " . get_system_dsn() . " as $args{'dba'}: $DBI::errstr"; + print "Now creating a database for RT.\n"; + create_db(); + + $dbh->disconnect; + $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) + || die $DBI::errstr; + + print "Now populating database schema.\n"; + insert_schema(); + print "Now inserting database ACLs\n"; + insert_acl(); + print "Now inserting RT core system objects\n"; + insert_initial_data(); + print "Now inserting RT data\n"; + insert_data( $RT::EtcPath . "/initialdata" ); +} +elsif ( $args{'action'} eq 'drop' ) { + unless ( $dbh = + DBI->connect( get_system_dsn(), $args{'dba'}, $args{'dba-password'} ) ) + { + warn $DBI::errstr; + warn "Database doesn't appear to exist. Aborting database drop."; + exit(0); + } + drop_db(); +} +elsif ( $args{'action'} eq 'insert' ) { + insert_data( $args{'datafile'} ); +} +elsif ($args{'action'} eq 'acl') { + $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) + || die "Failed to connect to " . get_system_dsn() . " as $args{'dba'}: $DBI::errstr"; + insert_acl($args{'datadir'}); +} +elsif ($args{'action'} eq 'schema') { + $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) + || die "Failed to connect to " . get_system_dsn() . " as $args{'dba'}: $DBI::errstr"; + insert_schema($args{'datadir'}); +} + +else { + print STDERR '$0 called with an invalid --action parameter'; + exit(-1); +} + +# {{{ sub insert_schema +sub insert_schema { + my $base_path = (shift || $RT::EtcPath); + my (@schema); + print "Creating database schema.\n"; + + if ( -f $base_path . "/schema." . $RT::DatabaseType ) { + no warnings 'unopened'; + + open( SCHEMA, "<" . $base_path . "/schema." . $RT::DatabaseType ); + open( SCHEMA_LOCAL, "<" . $RT::LocalEtcPath . "/schema." . $RT::DatabaseType ); + + my $statement = ""; + foreach my $line (, ) { + $line =~ s/\#.*//g; + $statement .= $line; + if ( $line =~ /;(\s*)$/ ) { + $statement =~ s/;(\s*)$//g; + push @schema, $statement; + $statement = ""; + } + } + + foreach my $statement (@schema) { + print STDERR $statement if $args{'debug'}; + my $sth = $dbh->prepare($statement) or die $dbh->errstr; + unless ( $sth->execute ) { + die "Problem with statement:\n $statement\n" . $sth->errstr; + } + } + + } + else { + die "Couldn't find schema file for " . $RT::DatabaseType . "\n"; + } + print "schema sucessfully inserted\n"; + +} + +# }}} + +# {{{ sub drop_db +sub drop_db { + return if ( $RT::DatabaseType eq 'SQLite' ); + unless ( $args{'force'} ) { + print <do("Drop DATABASE $RT::DatabaseName") or warn $DBI::errstr; +} + +# }}} + +# {{{ sub create_db +sub create_db { + print "Creating $RT::DatabaseType database $RT::DatabaseName.\n"; + if ( $RT::DatabaseType eq 'SQLite' ) { + return; + } + elsif ( $RT::DatabaseType eq 'Pg' ) { + $dbh->do("CREATE DATABASE $RT::DatabaseName WITH ENCODING='UNICODE'"); + if ($DBI::errstr) { + $dbh->do("CREATE DATABASE $RT::DatabaseName") || die $DBI::errstr; + } + } + else { + $dbh->do("CREATE DATABASE $RT::DatabaseName") or die $DBI::errstr; + } +} + +# }}} + +sub get_dba_password { + print +"In order to create a new database and grant RT access to that database,\n"; + print "this script needs to connect to your " + . $RT::DatabaseType + . " instance on " + . $RT::DatabaseHost . " as " + . $args{'dba'} . ".\n"; + print +"Please specify that user's database password below. If the user has no database\n"; + print "password, just press return.\n\n"; + print "Password: "; + ReadMode('noecho'); + my $password = ReadLine(0); + ReadMode('normal'); + return ($password); +} + +# {{{ sub _yesno +sub _yesno { + print "Proceed [y/N]:"; + my $x = scalar(); + $x =~ /^y/i; +} + +# }}} + +# {{{ insert_acls +sub insert_acl { + + my $base_path = (shift || $RT::EtcPath); + + if ( $RT::DatabaseType =~ /^oracle$/i ) { + do $base_path . "/acl.Oracle" + || die "Couldn't find ACLS for Oracle\n" . $@; + } + elsif ( $RT::DatabaseType =~ /^pg$/i ) { + do $base_path . "/acl.Pg" || die "Couldn't find ACLS for Pg\n" . $@; + } + elsif ( $RT::DatabaseType =~ /^mysql$/i ) { + do $base_path . "/acl.mysql" + || die "Couldn't find ACLS for mysql in " . $RT::EtcPath . "\n" . $@; + } + elsif ( $RT::DatabaseType =~ /^SQLite$/i ) { + return; + } + else { + die "Unknown RT database type"; + } + + my @acl = acl($dbh); + foreach my $statement (@acl) { + print STDERR $statement if $args{'debug'}; + my $sth = $dbh->prepare($statement) or die $dbh->errstr; + unless ( $sth->execute ) { + die "Problem with statement:\n $statement\n" . $sth->errstr; + } + } +} + +# }}} + +=head2 get_system_dsn + +Returns a dsn suitable for database creates and drops +and user creates and drops + +=cut + +sub get_system_dsn { + + my $dsn = $Handle->DSN; + + #with mysql, you want to connect sans database to funge things + if ( $RT::DatabaseType eq 'mysql' ) { + $dsn =~ s/dbname=$RT::DatabaseName//; + + # with postgres, you want to connect to database1 + } + elsif ( $RT::DatabaseType eq 'Pg' ) { + $dsn =~ s/dbname=$RT::DatabaseName/dbname=template1/; + } + return $dsn; +} + +sub insert_initial_data { + + RT::InitLogging(); + + #connect to the db, for actual RT work + require RT::Handle; + $RT::Handle = RT::Handle->new(); + $RT::Handle->Connect(); + + #Put together a current user object so we can create a User object + my $CurrentUser = new RT::CurrentUser(); + + print "Checking for existing system user..."; + my $test_user = RT::User->new($CurrentUser); + $test_user->Load('RT_System'); + if ( $test_user->id ) { + print "found!\n\nYou appear to have a functional RT database.\n" + . "Exiting, so as not to clobber your existing data.\n"; + exit(-1); + + } + else { + print "not found. This appears to be a new installation.\n"; + } + + print "Creating system user..."; + my $RT_System = new RT::User($CurrentUser); + + my ( $val, $msg ) = $RT_System->_BootstrapCreate( + Name => 'RT_System', + RealName => 'The RT System itself', + Comments => +'Do not delete or modify this user. It is integral to RT\'s internal database structures', + Creator => '1' ); + + unless ($val) { + print "$msg\n"; + exit(1); + } + print "done.\n"; + $RT::Handle->dbh->disconnect(); + +} + +# load some sort of data into the database + +sub insert_data { + my $datafile = shift; + + #Connect to the database and get RT::SystemUser and RT::Nobody loaded + RT::Init; + + my $CurrentUser = RT::CurrentUser->new(); + $CurrentUser->LoadByName('RT_System'); + + if ( $datafile eq $RT::EtcPath . "/initialdata" ) { + + print "Creating Superuser ACL..."; + + my $superuser_ace = RT::ACE->new($CurrentUser); + $superuser_ace->_BootstrapCreate( + PrincipalId => ACLEquivGroupId( $CurrentUser->Id ), + PrincipalType => 'Group', + RightName => 'SuperUser', + ObjectType => 'RT::System', + ObjectId => '1' ); + + } + + # Slurp in stuff to insert from the datafile. Possible things to go in here:- + # @groups, @users, @acl, @queues, @ScripActions, @ScripConditions, @templates + + require $datafile + || die "Couldn't find initial data for import\n" . $@; + + if (@Groups) { + print "Creating groups..."; + foreach $item (@Groups) { + my $new_entry = RT::Group->new($CurrentUser); + my ( $return, $msg ) = $new_entry->_Create(%$item); + print "(Error: $msg)" unless ($return); + print $return. "."; + } + print "done.\n"; + } + if (@Users) { + print "Creating users..."; + foreach $item (@Users) { + my $new_entry = new RT::User($CurrentUser); + my ( $return, $msg ) = $new_entry->Create(%$item); + print "(Error: $msg)" unless ($return); + print $return. "."; + } + print "done.\n"; + } + if (@Queues) { + print "Creating queues..."; + for $item (@Queues) { + my $new_entry = new RT::Queue($CurrentUser); + my ( $return, $msg ) = $new_entry->Create(%$item); + print "(Error: $msg)" unless ($return); + print $return. "."; + } + print "done.\n"; + } + if (@ACL) { + print "Creating ACL..."; + for my $item (@ACL) { + + my ($princ, $object); + + # Global rights or Queue rights? + if ($item->{'Queue'}) { + $object = RT::Queue->new($CurrentUser); + $object->Load( $item->{'Queue'} ); + } else { + $object = $RT::System; + } + + # Group rights or user rights? + if ($item->{'GroupDomain'}) { + $princ = RT::Group->new($CurrentUser); + if ($item->{'GroupDomain'} eq 'UserDefined') { + $princ->LoadUserDefinedGroup( $item->{'GroupId'} ); + } elsif ($item->{'GroupDomain'} eq 'SystemInternal') { + $princ->LoadSystemInternalGroup( $item->{'GroupType'} ); + } elsif ($item->{'GroupDomain'} eq 'RT::Queue-Role' && + $item->{'Queue'}) { + $princ->LoadQueueRoleGroup( Type => $item->{'GroupType'}, + Queue => $object->id); + } else { + $princ->Load( $item->{'GroupId'} ); + } + } else { + $princ = RT::User->new($CurrentUser); + $princ->Load( $item->{'UserId'} ); + } + + # Grant it + my ( $return, $msg ) = $princ->PrincipalObj->GrantRight( + Right => $item->{'Right'}, + Object => $object ); + + if ($return) { + print $return. "."; + } + else { + print $msg . "."; + + } + + } + print "done.\n"; + } + if (@CustomFields) { + print "Creating custom fields..."; + for $item (@CustomFields) { + my $new_entry = new RT::CustomField($CurrentUser); + my $values = $item->{'Values'}; + delete $item->{'Values'}; + my $q = $item->{'Queue'}; + my $q_obj = RT::Queue->new($CurrentUser); + $q_obj->Load($q); + if ( $q_obj->Id ) { + $item->{'Queue'} = $q_obj->Id; + } + elsif ( $q == 0 ) { + $item->{'Queue'} = 0; + } + else { + print "(Error: Could not find queue " . $q . ")\n" + unless ( $q_obj->Id ); + next; + } + my ( $return, $msg ) = $new_entry->Create(%$item); + + foreach my $value ( @{$values} ) { + my ( $eval, $emsg ) = $new_entry->AddValue(%$value); + print "(Error: $emsg)\n" unless ($eval); + } + + print "(Error: $msg)\n" unless ($return); + print $return. "."; + } + + print "done.\n"; + } + + if (@ScripActions) { + print "Creating ScripActions..."; + + for $item (@ScripActions) { + my $new_entry = RT::ScripAction->new($CurrentUser); + my $return = $new_entry->Create(%$item); + print $return. "."; + } + + print "done.\n"; + } + + if (@ScripConditions) { + print "Creating ScripConditions..."; + + for $item (@ScripConditions) { + my $new_entry = RT::ScripCondition->new($CurrentUser); + my $return = $new_entry->Create(%$item); + print $return. "."; + } + + print "done.\n"; + } + + if (@Templates) { + print "Creating templates..."; + + for $item (@Templates) { + my $new_entry = new RT::Template($CurrentUser); + my $return = $new_entry->Create(%$item); + print $return. "."; + } + print "done.\n"; + } + if (@Scrips) { + print "Creating scrips..."; + + for $item (@Scrips) { + my $new_entry = new RT::Scrip($CurrentUser); + my ( $return, $msg ) = $new_entry->Create(%$item); + if ($return) { + print $return. "."; + } + else { + print "(Error: $msg)\n"; + } + } + print "done.\n"; + } + $RT::Handle->Disconnect(); + +} + +=head2 ACLEquivGroupId + +Given a userid, return that user's acl equivalence group + +=cut + +sub ACLEquivGroupId { + my $username = shift; + my $user = RT::User->new($RT::SystemUser); + $user->Load($username); + my $equiv_group = RT::Group->new($RT::SystemUser); + $equiv_group->LoadACLEquivalenceGroup($user); + return ( $equiv_group->Id ); +} + +sub help { + + print < +# +# (Except where explictly superceded by other copyright notices) +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# Unless otherwise specified, all modifications, corrections or +# extensions to this work which alter its source code become the +# property of Best Practical Solutions, LLC when submitted for +# inclusion in the work. +# +# +# END LICENSE BLOCK + +use strict; +use vars qw($PROMPT $VERSION $Handle $Nobody $SystemUser $item); +use vars + qw(@Groups @Users @ACL @Queues @ScripActions @ScripConditions @Templates @CustomFields @Scrips); + +use lib "@RT_LIB_PATH@"; + +#This drags in RT's config.pm +# We do it in a begin block because RT::Handle needs to know the type to do its +# inheritance +use RT; +use Carp; +use RT::User; +use RT::CurrentUser; +use RT::Template; +use RT::ScripAction; +use RT::ACE; +use RT::Group; +use RT::User; +use RT::Queue; +use RT::ScripCondition; +use RT::CustomField; +use RT::Scrip; + +RT::LoadConfig(); +use Term::ReadKey; +use Getopt::Long; + +my %args; + +GetOptions( + \%args, + 'prompt-for-dba-password', 'force', 'debug', + 'action=s', 'dba=s', 'dba-password=s', 'datafile=s', + 'datadir=s' +); + +$| = 1; #unbuffer that output. + +require RT::Handle; +my $Handle = RT::Handle->new($RT::DatabaseType); +$Handle->BuildDSN; +my $dbh; + +if ( $args{'prompt-for-dba-password'} ) { + $args{'dba-password'} = get_dba_password(); + chomp( $args{'dba-password'} ); +} + +unless ( $args{'action'} ) { + help(); + die; +} +if ( $args{'action'} eq 'init' ) { + $dbh = DBI->connect( get_system_dsn(), $args{'dba'}, $args{'dba-password'} ) + || die "Failed to connect to " . get_system_dsn() . " as $args{'dba'}: $DBI::errstr"; + print "Now creating a database for RT.\n"; + create_db(); + + $dbh->disconnect; + $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) + || die $DBI::errstr; + + print "Now populating database schema.\n"; + insert_schema(); + print "Now inserting database ACLs\n"; + insert_acl(); + print "Now inserting RT core system objects\n"; + insert_initial_data(); + print "Now inserting RT data\n"; + insert_data( $RT::EtcPath . "/initialdata" ); +} +elsif ( $args{'action'} eq 'drop' ) { + unless ( $dbh = + DBI->connect( get_system_dsn(), $args{'dba'}, $args{'dba-password'} ) ) + { + warn $DBI::errstr; + warn "Database doesn't appear to exist. Aborting database drop."; + exit(0); + } + drop_db(); +} +elsif ( $args{'action'} eq 'insert' ) { + insert_data( $args{'datafile'} ); +} +elsif ($args{'action'} eq 'acl') { + $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) + || die "Failed to connect to " . get_system_dsn() . " as $args{'dba'}: $DBI::errstr"; + insert_acl($args{'datadir'}); +} +elsif ($args{'action'} eq 'schema') { + $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) + || die "Failed to connect to " . get_system_dsn() . " as $args{'dba'}: $DBI::errstr"; + insert_schema($args{'datadir'}); +} + +else { + print STDERR '$0 called with an invalid --action parameter'; + exit(-1); +} + +# {{{ sub insert_schema +sub insert_schema { + my $base_path = (shift || $RT::EtcPath); + my (@schema); + print "Creating database schema.\n"; + + if ( -f $base_path . "/schema." . $RT::DatabaseType ) { + no warnings 'unopened'; + + open( SCHEMA, "<" . $base_path . "/schema." . $RT::DatabaseType ); + open( SCHEMA_LOCAL, "<" . $RT::LocalEtcPath . "/schema." . $RT::DatabaseType ); + + my $statement = ""; + foreach my $line (, ) { + $line =~ s/\#.*//g; + $statement .= $line; + if ( $line =~ /;(\s*)$/ ) { + $statement =~ s/;(\s*)$//g; + push @schema, $statement; + $statement = ""; + } + } + + foreach my $statement (@schema) { + print STDERR $statement if $args{'debug'}; + my $sth = $dbh->prepare($statement) or die $dbh->errstr; + unless ( $sth->execute ) { + die "Problem with statement:\n $statement\n" . $sth->errstr; + } + } + + } + else { + die "Couldn't find schema file for " . $RT::DatabaseType . "\n"; + } + print "schema sucessfully inserted\n"; + +} + +# }}} + +# {{{ sub drop_db +sub drop_db { + return if ( $RT::DatabaseType eq 'SQLite' ); + unless ( $args{'force'} ) { + print <do("Drop DATABASE $RT::DatabaseName") or warn $DBI::errstr; +} + +# }}} + +# {{{ sub create_db +sub create_db { + print "Creating $RT::DatabaseType database $RT::DatabaseName.\n"; + if ( $RT::DatabaseType eq 'SQLite' ) { + return; + } + elsif ( $RT::DatabaseType eq 'Pg' ) { + $dbh->do("CREATE DATABASE $RT::DatabaseName WITH ENCODING='UNICODE'"); + if ($DBI::errstr) { + $dbh->do("CREATE DATABASE $RT::DatabaseName") || die $DBI::errstr; + } + } + else { + $dbh->do("CREATE DATABASE $RT::DatabaseName") or die $DBI::errstr; + } +} + +# }}} + +sub get_dba_password { + print +"In order to create a new database and grant RT access to that database,\n"; + print "this script needs to connect to your " + . $RT::DatabaseType + . " instance on " + . $RT::DatabaseHost . " as " + . $args{'dba'} . ".\n"; + print +"Please specify that user's database password below. If the user has no database\n"; + print "password, just press return.\n\n"; + print "Password: "; + ReadMode('noecho'); + my $password = ReadLine(0); + ReadMode('normal'); + return ($password); +} + +# {{{ sub _yesno +sub _yesno { + print "Proceed [y/N]:"; + my $x = scalar(); + $x =~ /^y/i; +} + +# }}} + +# {{{ insert_acls +sub insert_acl { + + my $base_path = (shift || $RT::EtcPath); + + if ( $RT::DatabaseType =~ /^oracle$/i ) { + do $base_path . "/acl.Oracle" + || die "Couldn't find ACLS for Oracle\n" . $@; + } + elsif ( $RT::DatabaseType =~ /^pg$/i ) { + do $base_path . "/acl.Pg" || die "Couldn't find ACLS for Pg\n" . $@; + } + elsif ( $RT::DatabaseType =~ /^mysql$/i ) { + do $base_path . "/acl.mysql" + || die "Couldn't find ACLS for mysql in " . $RT::EtcPath . "\n" . $@; + } + elsif ( $RT::DatabaseType =~ /^SQLite$/i ) { + return; + } + else { + die "Unknown RT database type"; + } + + my @acl = acl($dbh); + foreach my $statement (@acl) { + print STDERR $statement if $args{'debug'}; + my $sth = $dbh->prepare($statement) or die $dbh->errstr; + unless ( $sth->execute ) { + die "Problem with statement:\n $statement\n" . $sth->errstr; + } + } +} + +# }}} + +=head2 get_system_dsn + +Returns a dsn suitable for database creates and drops +and user creates and drops + +=cut + +sub get_system_dsn { + + my $dsn = $Handle->DSN; + + #with mysql, you want to connect sans database to funge things + if ( $RT::DatabaseType eq 'mysql' ) { + $dsn =~ s/dbname=$RT::DatabaseName//; + + # with postgres, you want to connect to database1 + } + elsif ( $RT::DatabaseType eq 'Pg' ) { + $dsn =~ s/dbname=$RT::DatabaseName/dbname=template1/; + } + return $dsn; +} + +sub insert_initial_data { + + RT::InitLogging(); + + #connect to the db, for actual RT work + require RT::Handle; + $RT::Handle = RT::Handle->new(); + $RT::Handle->Connect(); + + #Put together a current user object so we can create a User object + my $CurrentUser = new RT::CurrentUser(); + + print "Checking for existing system user..."; + my $test_user = RT::User->new($CurrentUser); + $test_user->Load('RT_System'); + if ( $test_user->id ) { + print "found!\n\nYou appear to have a functional RT database.\n" + . "Exiting, so as not to clobber your existing data.\n"; + exit(-1); + + } + else { + print "not found. This appears to be a new installation.\n"; + } + + print "Creating system user..."; + my $RT_System = new RT::User($CurrentUser); + + my ( $val, $msg ) = $RT_System->_BootstrapCreate( + Name => 'RT_System', + RealName => 'The RT System itself', + Comments => +'Do not delete or modify this user. It is integral to RT\'s internal database structures', + Creator => '1' ); + + unless ($val) { + print "$msg\n"; + exit(1); + } + print "done.\n"; + $RT::Handle->dbh->disconnect(); + +} + +# load some sort of data into the database + +sub insert_data { + my $datafile = shift; + + #Connect to the database and get RT::SystemUser and RT::Nobody loaded + RT::Init; + + my $CurrentUser = RT::CurrentUser->new(); + $CurrentUser->LoadByName('RT_System'); + + if ( $datafile eq $RT::EtcPath . "/initialdata" ) { + + print "Creating Superuser ACL..."; + + my $superuser_ace = RT::ACE->new($CurrentUser); + $superuser_ace->_BootstrapCreate( + PrincipalId => ACLEquivGroupId( $CurrentUser->Id ), + PrincipalType => 'Group', + RightName => 'SuperUser', + ObjectType => 'RT::System', + ObjectId => '1' ); + + } + + # Slurp in stuff to insert from the datafile. Possible things to go in here:- + # @groups, @users, @acl, @queues, @ScripActions, @ScripConditions, @templates + + require $datafile + || die "Couldn't find initial data for import\n" . $@; + + if (@Groups) { + print "Creating groups..."; + foreach $item (@Groups) { + my $new_entry = RT::Group->new($CurrentUser); + my ( $return, $msg ) = $new_entry->_Create(%$item); + print "(Error: $msg)" unless ($return); + print $return. "."; + } + print "done.\n"; + } + if (@Users) { + print "Creating users..."; + foreach $item (@Users) { + my $new_entry = new RT::User($CurrentUser); + my ( $return, $msg ) = $new_entry->Create(%$item); + print "(Error: $msg)" unless ($return); + print $return. "."; + } + print "done.\n"; + } + if (@Queues) { + print "Creating queues..."; + for $item (@Queues) { + my $new_entry = new RT::Queue($CurrentUser); + my ( $return, $msg ) = $new_entry->Create(%$item); + print "(Error: $msg)" unless ($return); + print $return. "."; + } + print "done.\n"; + } + if (@ACL) { + print "Creating ACL..."; + for my $item (@ACL) { + + my ($princ, $object); + + # Global rights or Queue rights? + if ($item->{'Queue'}) { + $object = RT::Queue->new($CurrentUser); + $object->Load( $item->{'Queue'} ); + } else { + $object = $RT::System; + } + + # Group rights or user rights? + if ($item->{'GroupDomain'}) { + $princ = RT::Group->new($CurrentUser); + if ($item->{'GroupDomain'} eq 'UserDefined') { + $princ->LoadUserDefinedGroup( $item->{'GroupId'} ); + } elsif ($item->{'GroupDomain'} eq 'SystemInternal') { + $princ->LoadSystemInternalGroup( $item->{'GroupType'} ); + } elsif ($item->{'GroupDomain'} eq 'RT::Queue-Role' && + $item->{'Queue'}) { + $princ->LoadQueueRoleGroup( Type => $item->{'GroupType'}, + Queue => $object->id); + } else { + $princ->Load( $item->{'GroupId'} ); + } + } else { + $princ = RT::User->new($CurrentUser); + $princ->Load( $item->{'UserId'} ); + } + + # Grant it + my ( $return, $msg ) = $princ->PrincipalObj->GrantRight( + Right => $item->{'Right'}, + Object => $object ); + + if ($return) { + print $return. "."; + } + else { + print $msg . "."; + + } + + } + print "done.\n"; + } + if (@CustomFields) { + print "Creating custom fields..."; + for $item (@CustomFields) { + my $new_entry = new RT::CustomField($CurrentUser); + my $values = $item->{'Values'}; + delete $item->{'Values'}; + my $q = $item->{'Queue'}; + my $q_obj = RT::Queue->new($CurrentUser); + $q_obj->Load($q); + if ( $q_obj->Id ) { + $item->{'Queue'} = $q_obj->Id; + } + elsif ( $q == 0 ) { + $item->{'Queue'} = 0; + } + else { + print "(Error: Could not find queue " . $q . ")\n" + unless ( $q_obj->Id ); + next; + } + my ( $return, $msg ) = $new_entry->Create(%$item); + + foreach my $value ( @{$values} ) { + my ( $eval, $emsg ) = $new_entry->AddValue(%$value); + print "(Error: $emsg)\n" unless ($eval); + } + + print "(Error: $msg)\n" unless ($return); + print $return. "."; + } + + print "done.\n"; + } + + if (@ScripActions) { + print "Creating ScripActions..."; + + for $item (@ScripActions) { + my $new_entry = RT::ScripAction->new($CurrentUser); + my $return = $new_entry->Create(%$item); + print $return. "."; + } + + print "done.\n"; + } + + if (@ScripConditions) { + print "Creating ScripConditions..."; + + for $item (@ScripConditions) { + my $new_entry = RT::ScripCondition->new($CurrentUser); + my $return = $new_entry->Create(%$item); + print $return. "."; + } + + print "done.\n"; + } + + if (@Templates) { + print "Creating templates..."; + + for $item (@Templates) { + my $new_entry = new RT::Template($CurrentUser); + my $return = $new_entry->Create(%$item); + print $return. "."; + } + print "done.\n"; + } + if (@Scrips) { + print "Creating scrips..."; + + for $item (@Scrips) { + my $new_entry = new RT::Scrip($CurrentUser); + my ( $return, $msg ) = $new_entry->Create(%$item); + if ($return) { + print $return. "."; + } + else { + print "(Error: $msg)\n"; + } + } + print "done.\n"; + } + $RT::Handle->Disconnect(); + +} + +=head2 ACLEquivGroupId + +Given a userid, return that user's acl equivalence group + +=cut + +sub ACLEquivGroupId { + my $username = shift; + my $user = RT::User->new($RT::SystemUser); + $user->Load($username); + my $equiv_group = RT::Group->new($RT::SystemUser); + $equiv_group->LoadACLEquivalenceGroup($user); + return ( $equiv_group->Id ); +} + +sub help { + + print < +# +# (Except where explictly superceded by other copyright notices) +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# Unless otherwise specified, all modifications, corrections or +# extensions to this work which alter its source code become the +# property of Best Practical Solutions, LLC when submitted for +# inclusion in the work. +# +# +# END LICENSE BLOCK + +# +# This is just a basic script that checks to make sure that all +# the modules needed by RT before you can install it. +# + +use strict; +no warnings qw(numeric redefine); +use Getopt::Long; +use CPAN; +my %args; +my %deps; +GetOptions(\%args,'install', 'with-MYSQL', 'with-POSTGRESQL|with-pg|with-pgsql', 'with-SQLITE', 'with-ORACLE', 'with-FASTCGI', 'with-SPEEDYCGI', 'with-MODPERL1', 'with-MODPERL2' ,'with-DEV'); + +if (!keys %args) { +help(); +exit(0); +} +$args{'with-MASON'} = 1; +$args{'with-CORE'} = 1; +$args{'with-DEV'} =1; +$args{'with-CLI'} =1; +$args{'with-MAILGATE'} =1; +if ($] < 5.007) { +$args{'with-I18N-COMPAT'} = 1; +} + + +sub help { + +print <<'.' + +By default, testdeps determine whether you have +installed all the perl modules RT needs to run. + + --install Install missing modules + +The following switches will tell the tool to check for specific dependencies + + --with-mysql Database interface for MySQL + --with-postgresql Database interface for PostgreSQL + --with-sqlite Database interface and driver for SQLite (unsupported) + --with-oracle Database interface for oracle (unsupported) + + --with-fastcgi Libraries needed to support the fastcgi handler + --with-speedycgi Libraries needed to support the speedycgi handler + --with-modperl1 Libraries needed to support the modperl 1 handler + --with-modperl2 Libraries needed to support the modperl 2 handler + + --with-dev Tools needed for RT development +. +} + + +sub _ { + map { /(\S+)\s*(\S*)/; $1 => ($2 ? $2 :'') } split ( /\n/, $_[0] ); +} + +$deps{'CORE'} = [ _( << '.') ]; +Digest::MD5 +DBI 1.18 +Test::Inline +Class::ReturnValue 0.40 +DBIx::SearchBuilder 0.86 +Text::Template +File::Spec 0.8 +HTML::Entities +Net::Domain +Log::Dispatch 2.0 +Locale::Maketext 1.04 +Locale::Maketext::Lexicon 0.25 +Locale::Maketext::Fuzzy +MIME::Entity 5.108 +Mail::Mailer 1.57 +Net::SMTP +Text::Wrapper +Time::ParseDate +File::Temp +Term::ReadKey +Text::Autoformat +Text::Quoted +. + +$deps{'MASON'} = [ _( << '.') ]; +Params::Validate 0.02 +Cache::Cache +Exception::Class +HTML::Mason 1.16 +MLDBM +Errno +FreezeThaw +Digest::MD5 +CGI::Cookie 1.20 +Storable +Apache::Session 1.53 +. + +$deps{'MAILGATE'} = [ _( << '.') ]; +HTML::TreeBuilder +HTML::FormatText +Getopt::Long +LWP::UserAgent +. + +$deps{'CLI'} = [ _( << '.') ]; +Getopt::Long 2.24 +. + +$deps{'DEV'} = [ _( << '.') ]; +Regexp::Common +Time::HiRes +Test::Inline +WWW::Mechanize +. + +$deps{'FASTCGI'} = [ _( << '.') ]; +CGI +FCGI +CGI::Fast +. + +$deps{'SPEEDYCGI'} = [ _( << '.') ]; +CGI +CGI::SpeedyCGI +. + + +$deps{'MODPERL1'} = [ _( << '.') ]; +CGI +Apache::Request +Apache::DBI +. + +$deps{'MODPERL2'} = [ _( << '.') ]; +CGI 2.89 +Apache::DBI +. + +$deps{'I18N-COMPAT'} = [ _( << '.') ]; +Text::Iconv +Encode::compat 0.04 +. + +$deps{'MYSQL'} = [ _( << '.') ]; +DBD::mysql 2.1018 +. +$deps{'ORACLE'} = [ _( << '.') ]; +DBD::Oracle +. +$deps{'POSTGRESQL'} = [ _( << '.') ]; +DBD::Pg +. + + +foreach my $type (keys %args) { +next unless ($type =~ /^with-(.*?)$/); +my $type = $1; +print "$type dependencies:\n"; + my @deps = (@{$deps{$type}}); + while (@deps) { + my $module = shift @deps; + my $version = shift @deps; +my $ret; + $ret =test_dep($module, $version); + +if ($args{'install'} && !$ret) { + resolve_dep($module); +} +} +} +sub test_dep { + my $module = shift; + my $version = shift; + + print "\t$module $version"; + eval "use $module $version" ; + if ($@) { + my $error = $@; + $error =~ s/\n(.*)$//s; + print "...MISSING\n"; + print "\t\t$error\n" if $error =~ /this is only/; + + return undef; + } else { + print "...found\n"; +return 1; + } +} + +sub resolve_dep { + my $module = shift; + use CPAN; + CPAN::Shell->install($module); + +} + + +sub print_help { + print << "EOF"; + +$0 FLAG DBTYPE + + +$0 is a tool for RT that will tell you if you've got all +the modules RT depends on properly installed. + +Flags: (only one flag is valid for a given run) + +-quiet will check to see if we've got everything we need + and will exit with a return code of (1) if we don't. + +-warn will tell you what isn't properly installed + +-fix will use CPANPLUS.pm or CPAN.pm to magically make everything better + +DBTYPE is one of: + oracle, pg, mysql + +EOF + + exit(0); +} diff --git a/rt/sbin/rt-test-dependencies.in b/rt/sbin/rt-test-dependencies.in new file mode 100644 index 000000000..6951290c4 --- /dev/null +++ b/rt/sbin/rt-test-dependencies.in @@ -0,0 +1,246 @@ +#!@PERL@ +# BEGIN LICENSE BLOCK +# +# Copyright (c) 1996-2003 Jesse Vincent +# +# (Except where explictly superceded by other copyright notices) +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# Unless otherwise specified, all modifications, corrections or +# extensions to this work which alter its source code become the +# property of Best Practical Solutions, LLC when submitted for +# inclusion in the work. +# +# +# END LICENSE BLOCK + +# +# This is just a basic script that checks to make sure that all +# the modules needed by RT before you can install it. +# + +use strict; +no warnings qw(numeric redefine); +use Getopt::Long; +use CPAN; +my %args; +my %deps; +GetOptions(\%args,'install', 'with-MYSQL', 'with-POSTGRESQL|with-pg|with-pgsql', 'with-SQLITE', 'with-ORACLE', 'with-FASTCGI', 'with-SPEEDYCGI', 'with-MODPERL1', 'with-MODPERL2' ,'with-DEV'); + +if (!keys %args) { +help(); +exit(0); +} +$args{'with-MASON'} = 1; +$args{'with-CORE'} = 1; +$args{'with-DEV'} =1; +$args{'with-CLI'} =1; +$args{'with-MAILGATE'} =1; +if ($] < 5.007) { +$args{'with-I18N-COMPAT'} = 1; +} + + +sub help { + +print <<'.' + +By default, testdeps determine whether you have +installed all the perl modules RT needs to run. + + --install Install missing modules + +The following switches will tell the tool to check for specific dependencies + + --with-mysql Database interface for MySQL + --with-postgresql Database interface for PostgreSQL + --with-sqlite Database interface and driver for SQLite (unsupported) + --with-oracle Database interface for oracle (unsupported) + + --with-fastcgi Libraries needed to support the fastcgi handler + --with-speedycgi Libraries needed to support the speedycgi handler + --with-modperl1 Libraries needed to support the modperl 1 handler + --with-modperl2 Libraries needed to support the modperl 2 handler + + --with-dev Tools needed for RT development +. +} + + +sub _ { + map { /(\S+)\s*(\S*)/; $1 => ($2 ? $2 :'') } split ( /\n/, $_[0] ); +} + +$deps{'CORE'} = [ _( << '.') ]; +Digest::MD5 +DBI 1.18 +Test::Inline +Class::ReturnValue 0.40 +DBIx::SearchBuilder 0.86 +Text::Template +File::Spec 0.8 +HTML::Entities +Net::Domain +Log::Dispatch 2.0 +Locale::Maketext 1.04 +Locale::Maketext::Lexicon 0.25 +Locale::Maketext::Fuzzy +MIME::Entity 5.108 +Mail::Mailer 1.57 +Net::SMTP +Text::Wrapper +Time::ParseDate +File::Temp +Term::ReadKey +Text::Autoformat +Text::Quoted +. + +$deps{'MASON'} = [ _( << '.') ]; +Params::Validate 0.02 +Cache::Cache +Exception::Class +HTML::Mason 1.16 +MLDBM +Errno +FreezeThaw +Digest::MD5 +CGI::Cookie 1.20 +Storable +Apache::Session 1.53 +. + +$deps{'MAILGATE'} = [ _( << '.') ]; +HTML::TreeBuilder +HTML::FormatText +Getopt::Long +LWP::UserAgent +. + +$deps{'CLI'} = [ _( << '.') ]; +Getopt::Long 2.24 +. + +$deps{'DEV'} = [ _( << '.') ]; +Regexp::Common +Time::HiRes +Test::Inline +WWW::Mechanize +. + +$deps{'FASTCGI'} = [ _( << '.') ]; +CGI +FCGI +CGI::Fast +. + +$deps{'SPEEDYCGI'} = [ _( << '.') ]; +CGI +CGI::SpeedyCGI +. + + +$deps{'MODPERL1'} = [ _( << '.') ]; +CGI +Apache::Request +Apache::DBI +. + +$deps{'MODPERL2'} = [ _( << '.') ]; +CGI 2.89 +Apache::DBI +. + +$deps{'I18N-COMPAT'} = [ _( << '.') ]; +Text::Iconv +Encode::compat 0.04 +. + +$deps{'MYSQL'} = [ _( << '.') ]; +DBD::mysql 2.1018 +. +$deps{'ORACLE'} = [ _( << '.') ]; +DBD::Oracle +. +$deps{'POSTGRESQL'} = [ _( << '.') ]; +DBD::Pg +. + + +foreach my $type (keys %args) { +next unless ($type =~ /^with-(.*?)$/); +my $type = $1; +print "$type dependencies:\n"; + my @deps = (@{$deps{$type}}); + while (@deps) { + my $module = shift @deps; + my $version = shift @deps; +my $ret; + $ret =test_dep($module, $version); + +if ($args{'install'} && !$ret) { + resolve_dep($module); +} +} +} +sub test_dep { + my $module = shift; + my $version = shift; + + print "\t$module $version"; + eval "use $module $version" ; + if ($@) { + my $error = $@; + $error =~ s/\n(.*)$//s; + print "...MISSING\n"; + print "\t\t$error\n" if $error =~ /this is only/; + + return undef; + } else { + print "...found\n"; +return 1; + } +} + +sub resolve_dep { + my $module = shift; + use CPAN; + CPAN::Shell->install($module); + +} + + +sub print_help { + print << "EOF"; + +$0 FLAG DBTYPE + + +$0 is a tool for RT that will tell you if you've got all +the modules RT depends on properly installed. + +Flags: (only one flag is valid for a given run) + +-quiet will check to see if we've got everything we need + and will exit with a return code of (1) if we don't. + +-warn will tell you what isn't properly installed + +-fix will use CPANPLUS.pm or CPAN.pm to magically make everything better + +DBTYPE is one of: + oracle, pg, mysql + +EOF + + exit(0); +} -- cgit v1.2.1 From 289340780927b5bac2c7604d7317c3063c6dd8cc Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 11 Mar 2004 02:05:38 +0000 Subject: import of rt 3.0.9 --- rt/sbin/extract-message-catalog | 2 +- rt/sbin/factory | 1 + rt/sbin/license_tag | 6 +-- rt/sbin/rt-setup-database | 46 +++++++++++++++++++--- rt/sbin/rt-setup-database.in | 46 +++++++++++++++++++--- rt/sbin/rt-test-dependencies | 84 ++++++++++++++++++++++++++++------------- rt/sbin/rt-test-dependencies.in | 84 ++++++++++++++++++++++++++++------------- 7 files changed, 201 insertions(+), 68 deletions(-) (limited to 'rt/sbin') diff --git a/rt/sbin/extract-message-catalog b/rt/sbin/extract-message-catalog index af7b2c733..a7ba6335c 100644 --- a/rt/sbin/extract-message-catalog +++ b/rt/sbin/extract-message-catalog @@ -41,7 +41,7 @@ $DEBUG = 1; $FILECAT = {}; # extract all strings and stuff them into $FILECAT -File::Find::find( { wanted => \&extract_strings_from_code, follow => 0 }, '.' ); +File::Find::find( { wanted => \&extract_strings_from_code, follow => 1 }, '.' ); # ensure proper escaping and [_1] => %1 transformation foreach my $str ( sort keys %{$FILECAT} ) { diff --git a/rt/sbin/factory b/rt/sbin/factory index 8abb1922f..64b0ae337 100644 --- a/rt/sbin/factory +++ b/rt/sbin/factory @@ -61,6 +61,7 @@ my $LicenseBlock = << '.'; # # # END LICENSE BLOCK + . my $Attribution = << '.'; diff --git a/rt/sbin/license_tag b/rt/sbin/license_tag index 33da2e026..689b246ef 100644 --- a/rt/sbin/license_tag +++ b/rt/sbin/license_tag @@ -5,7 +5,7 @@ # # Copyright (c) 1996-2003 Jesse Vincent # -# (Except where explictly superceded by other copyright notices) +# (Except where explicitly superseded by other copyright notices) # # This work is made available to you under the terms of Version 2 of # the GNU General Public License. A copy of that license should have @@ -29,7 +29,7 @@ my $LICENSE = < -(Except where explictly superceded by other copyright notices) +(Except where explicitly superseded by other copyright notices) This work is made available to you under the terms of Version 2 of the GNU General Public License. A copy of that license should have @@ -57,7 +57,7 @@ File::Find::find({ no_chdir => 1, wanted => \&tag_pm}, 'lib'); File::Find::find({ no_chdir => 1, wanted => \&tag_mason}, 'html'); File::Find::find({ no_chdir => 1, wanted => \&tag_script}, 'sbin'); File::Find::find({ no_chdir => 1, wanted => \&tag_script}, 'bin'); -tag_makefile ('Makefile'); +tag_makefile ('Makefile.in'); tag_makefile ('README'); diff --git a/rt/sbin/rt-setup-database b/rt/sbin/rt-setup-database index f84f290b7..58f882f6e 100644 --- a/rt/sbin/rt-setup-database +++ b/rt/sbin/rt-setup-database @@ -80,7 +80,12 @@ if ( $args{'action'} eq 'init' ) { $dbh = DBI->connect( get_system_dsn(), $args{'dba'}, $args{'dba-password'} ) || die "Failed to connect to " . get_system_dsn() . " as $args{'dba'}: $DBI::errstr"; print "Now creating a database for RT.\n"; + if ($RT::DatabaseType ne 'Oracle' || + $args{'dba'} ne $RT::DatabaseUser) { create_db(); + } else { + print "...skipped as ".$args{'dba'} ." is not " . $RT::DatabaseUser . " or we're working with Oracle.\n"; + } $dbh->disconnect; $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) @@ -89,7 +94,7 @@ if ( $args{'action'} eq 'init' ) { print "Now populating database schema.\n"; insert_schema(); print "Now inserting database ACLs\n"; - insert_acl(); + insert_acl() unless ($RT::DatabaseType eq 'Oracle'); print "Now inserting RT core system objects\n"; insert_initial_data(); print "Now inserting RT data\n"; @@ -137,8 +142,9 @@ sub insert_schema { open( SCHEMA_LOCAL, "<" . $RT::LocalEtcPath . "/schema." . $RT::DatabaseType ); my $statement = ""; - foreach my $line (, ) { + foreach my $line (, ($_ = ';;'), ) { $line =~ s/\#.*//g; + $line =~ s/--.*//g; $statement .= $line; if ( $line =~ /;(\s*)$/ ) { $statement =~ s/;(\s*)$//g; @@ -147,10 +153,13 @@ sub insert_schema { } } + local $SIG{__WARN__} = sub {}; + my $is_local = 0; # local/etc/schema needs to be nonfatal. foreach my $statement (@schema) { - print STDERR $statement if $args{'debug'}; + if ($statement =~ /^\s*;$/) { $is_local = 1; next; } + print STDERR "SQL: $statement\n" if defined $args{'debug'}; my $sth = $dbh->prepare($statement) or die $dbh->errstr; - unless ( $sth->execute ) { + unless ( $sth->execute or $is_local ) { die "Problem with statement:\n $statement\n" . $sth->errstr; } } @@ -168,6 +177,16 @@ sub insert_schema { # {{{ sub drop_db sub drop_db { return if ( $RT::DatabaseType eq 'SQLite' ); + if ( $RT::DatabaseType eq 'Oracle' ) { + print <do("CREATE DATABASE $RT::DatabaseName") || die $DBI::errstr; } } + elsif ($RT::DatabaseType eq 'Oracle') { + insert_acl(); + } + elsif ( $RT::DatabaseType eq 'Informix' ) { + $ENV{DB_LOCALE} = 'en_us.utf8'; + $dbh->do("CREATE DATABASE $RT::DatabaseName WITH BUFFERED LOG"); + } else { $dbh->do("CREATE DATABASE $RT::DatabaseName") or die $DBI::errstr; } @@ -248,6 +274,10 @@ sub insert_acl { do $base_path . "/acl.mysql" || die "Couldn't find ACLS for mysql in " . $RT::EtcPath . "\n" . $@; } + elsif ( $RT::DatabaseType =~ /^informix$/i ) { + do $base_path . "/acl.Informix" + || die "Couldn't find ACLS for Informix in " . $RT::EtcPath . "\n" . $@; + } elsif ( $RT::DatabaseType =~ /^SQLite$/i ) { return; } @@ -287,6 +317,10 @@ sub get_system_dsn { elsif ( $RT::DatabaseType eq 'Pg' ) { $dsn =~ s/dbname=$RT::DatabaseName/dbname=template1/; } + elsif ( $RT::DatabaseType eq 'Informix' ) { + # with Informix, you want to connect sans database: + $dsn =~ s/Informix:$RT::DatabaseName/Informix:/; + } return $dsn; } @@ -302,7 +336,7 @@ sub insert_initial_data { #Put together a current user object so we can create a User object my $CurrentUser = new RT::CurrentUser(); - print "Checking for existing system user..."; + print "Checking for existing system user ($CurrentUser)..."; my $test_user = RT::User->new($CurrentUser); $test_user->Load('RT_System'); if ( $test_user->id ) { @@ -330,7 +364,7 @@ sub insert_initial_data { exit(1); } print "done.\n"; - $RT::Handle->dbh->disconnect(); + $RT::Handle->Disconnect(); } diff --git a/rt/sbin/rt-setup-database.in b/rt/sbin/rt-setup-database.in index e49a32ed9..9e990e5b8 100644 --- a/rt/sbin/rt-setup-database.in +++ b/rt/sbin/rt-setup-database.in @@ -80,7 +80,12 @@ if ( $args{'action'} eq 'init' ) { $dbh = DBI->connect( get_system_dsn(), $args{'dba'}, $args{'dba-password'} ) || die "Failed to connect to " . get_system_dsn() . " as $args{'dba'}: $DBI::errstr"; print "Now creating a database for RT.\n"; + if ($RT::DatabaseType ne 'Oracle' || + $args{'dba'} ne $RT::DatabaseUser) { create_db(); + } else { + print "...skipped as ".$args{'dba'} ." is not " . $RT::DatabaseUser . " or we're working with Oracle.\n"; + } $dbh->disconnect; $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) @@ -89,7 +94,7 @@ if ( $args{'action'} eq 'init' ) { print "Now populating database schema.\n"; insert_schema(); print "Now inserting database ACLs\n"; - insert_acl(); + insert_acl() unless ($RT::DatabaseType eq 'Oracle'); print "Now inserting RT core system objects\n"; insert_initial_data(); print "Now inserting RT data\n"; @@ -137,8 +142,9 @@ sub insert_schema { open( SCHEMA_LOCAL, "<" . $RT::LocalEtcPath . "/schema." . $RT::DatabaseType ); my $statement = ""; - foreach my $line (, ) { + foreach my $line (, ($_ = ';;'), ) { $line =~ s/\#.*//g; + $line =~ s/--.*//g; $statement .= $line; if ( $line =~ /;(\s*)$/ ) { $statement =~ s/;(\s*)$//g; @@ -147,10 +153,13 @@ sub insert_schema { } } + local $SIG{__WARN__} = sub {}; + my $is_local = 0; # local/etc/schema needs to be nonfatal. foreach my $statement (@schema) { - print STDERR $statement if $args{'debug'}; + if ($statement =~ /^\s*;$/) { $is_local = 1; next; } + print STDERR "SQL: $statement\n" if defined $args{'debug'}; my $sth = $dbh->prepare($statement) or die $dbh->errstr; - unless ( $sth->execute ) { + unless ( $sth->execute or $is_local ) { die "Problem with statement:\n $statement\n" . $sth->errstr; } } @@ -168,6 +177,16 @@ sub insert_schema { # {{{ sub drop_db sub drop_db { return if ( $RT::DatabaseType eq 'SQLite' ); + if ( $RT::DatabaseType eq 'Oracle' ) { + print <do("CREATE DATABASE $RT::DatabaseName") || die $DBI::errstr; } } + elsif ($RT::DatabaseType eq 'Oracle') { + insert_acl(); + } + elsif ( $RT::DatabaseType eq 'Informix' ) { + $ENV{DB_LOCALE} = 'en_us.utf8'; + $dbh->do("CREATE DATABASE $RT::DatabaseName WITH BUFFERED LOG"); + } else { $dbh->do("CREATE DATABASE $RT::DatabaseName") or die $DBI::errstr; } @@ -248,6 +274,10 @@ sub insert_acl { do $base_path . "/acl.mysql" || die "Couldn't find ACLS for mysql in " . $RT::EtcPath . "\n" . $@; } + elsif ( $RT::DatabaseType =~ /^informix$/i ) { + do $base_path . "/acl.Informix" + || die "Couldn't find ACLS for Informix in " . $RT::EtcPath . "\n" . $@; + } elsif ( $RT::DatabaseType =~ /^SQLite$/i ) { return; } @@ -287,6 +317,10 @@ sub get_system_dsn { elsif ( $RT::DatabaseType eq 'Pg' ) { $dsn =~ s/dbname=$RT::DatabaseName/dbname=template1/; } + elsif ( $RT::DatabaseType eq 'Informix' ) { + # with Informix, you want to connect sans database: + $dsn =~ s/Informix:$RT::DatabaseName/Informix:/; + } return $dsn; } @@ -302,7 +336,7 @@ sub insert_initial_data { #Put together a current user object so we can create a User object my $CurrentUser = new RT::CurrentUser(); - print "Checking for existing system user..."; + print "Checking for existing system user ($CurrentUser)..."; my $test_user = RT::User->new($CurrentUser); $test_user->Load('RT_System'); if ( $test_user->id ) { @@ -330,7 +364,7 @@ sub insert_initial_data { exit(1); } print "done.\n"; - $RT::Handle->dbh->disconnect(); + $RT::Handle->Disconnect(); } diff --git a/rt/sbin/rt-test-dependencies b/rt/sbin/rt-test-dependencies index 637d33a32..c1591b189 100644 --- a/rt/sbin/rt-test-dependencies +++ b/rt/sbin/rt-test-dependencies @@ -36,10 +36,14 @@ my %args; my %deps; GetOptions(\%args,'install', 'with-MYSQL', 'with-POSTGRESQL|with-pg|with-pgsql', 'with-SQLITE', 'with-ORACLE', 'with-FASTCGI', 'with-SPEEDYCGI', 'with-MODPERL1', 'with-MODPERL2' ,'with-DEV'); -if (!keys %args) { -help(); -exit(0); +if (!keys %args) { + help(); + exit(0); +} +if ($args{'with-MODPERL2'}) { + warn_modperl2(); } + $args{'with-MASON'} = 1; $args{'with-CORE'} = 1; $args{'with-DEV'} =1; @@ -49,10 +53,20 @@ if ($] < 5.007) { $args{'with-I18N-COMPAT'} = 1; } +sub warn_modperl2 { + print <<'.'; + NOTE: mod_perl 2.0 isn't quite ready for prime_time just yet; + Best Practical Solutions strongly recommends that sites use + Apache 1.3 or FastCGI. If you MUST use mod_perl 2.0 (or 1.99), + please read the mailing list archives before asking for help. +. + sleep 5; +} + sub help { -print <<'.' + print <<'.'; By default, testdeps determine whether you have installed all the perl modules RT needs to run. @@ -81,18 +95,18 @@ sub _ { } $deps{'CORE'} = [ _( << '.') ]; -Digest::MD5 -DBI 1.18 +Digest::MD5 2.27 +DBI 1.37 Test::Inline Class::ReturnValue 0.40 -DBIx::SearchBuilder 0.86 +DBIx::SearchBuilder 0.97 Text::Template File::Spec 0.8 HTML::Entities Net::Domain Log::Dispatch 2.0 -Locale::Maketext 1.04 -Locale::Maketext::Lexicon 0.25 +Locale::Maketext 1.06 +Locale::Maketext::Lexicon 0.32 Locale::Maketext::Fuzzy MIME::Entity 5.108 Mail::Mailer 1.57 @@ -102,7 +116,8 @@ Time::ParseDate File::Temp Term::ReadKey Text::Autoformat -Text::Quoted +Text::Quoted 1.3 +Scalar::Util . $deps{'MASON'} = [ _( << '.') ]; @@ -113,9 +128,9 @@ HTML::Mason 1.16 MLDBM Errno FreezeThaw -Digest::MD5 +Digest::MD5 2.27 CGI::Cookie 1.20 -Storable +Storable 2.08 Apache::Session 1.53 . @@ -138,25 +153,25 @@ WWW::Mechanize . $deps{'FASTCGI'} = [ _( << '.') ]; -CGI +CGI 2.92 FCGI CGI::Fast . $deps{'SPEEDYCGI'} = [ _( << '.') ]; -CGI +CGI 2.92 CGI::SpeedyCGI . $deps{'MODPERL1'} = [ _( << '.') ]; -CGI +CGI 2.92 Apache::Request -Apache::DBI +Apache::DBI 0.92 . $deps{'MODPERL2'} = [ _( << '.') ]; -CGI 2.89 +CGI 2.92 Apache::DBI . @@ -175,6 +190,23 @@ $deps{'POSTGRESQL'} = [ _( << '.') ]; DBD::Pg . +print "perl:\n"; +print "\t5.8.0"; +eval {require 5.008}; +if ($@) { +print "...missing.\n"; + eval {require 5.006001}; + if ($@) { + print " RT is known to be non-functional on versions of perl older than 5.6.1. Please upgrade to 5.8.0 or newer"; + die; + } else { + print " RT is not supported on perl 5.6.1\n"; + } +} else { + print "...found\n"; + +} + foreach my $type (keys %args) { next unless ($type =~ /^with-(.*?)$/); @@ -196,17 +228,17 @@ sub test_dep { my $module = shift; my $version = shift; - print "\t$module $version"; - eval "use $module $version" ; - if ($@) { - my $error = $@; - $error =~ s/\n(.*)$//s; - print "...MISSING\n"; - print "\t\t$error\n" if $error =~ /this is only/; + print "\t$module $version"; + eval "use $module $version" ; + if ($@) { + my $error = $@; + $error =~ s/\n(.*)$//s; + print "...MISSING\n"; + print "\t\t$error\n" if $error =~ /this is only/; - return undef; + return undef; } else { - print "...found\n"; + print "...found\n"; return 1; } } diff --git a/rt/sbin/rt-test-dependencies.in b/rt/sbin/rt-test-dependencies.in index 6951290c4..7a1508010 100644 --- a/rt/sbin/rt-test-dependencies.in +++ b/rt/sbin/rt-test-dependencies.in @@ -36,10 +36,14 @@ my %args; my %deps; GetOptions(\%args,'install', 'with-MYSQL', 'with-POSTGRESQL|with-pg|with-pgsql', 'with-SQLITE', 'with-ORACLE', 'with-FASTCGI', 'with-SPEEDYCGI', 'with-MODPERL1', 'with-MODPERL2' ,'with-DEV'); -if (!keys %args) { -help(); -exit(0); +if (!keys %args) { + help(); + exit(0); +} +if ($args{'with-MODPERL2'}) { + warn_modperl2(); } + $args{'with-MASON'} = 1; $args{'with-CORE'} = 1; $args{'with-DEV'} =1; @@ -49,10 +53,20 @@ if ($] < 5.007) { $args{'with-I18N-COMPAT'} = 1; } +sub warn_modperl2 { + print <<'.'; + NOTE: mod_perl 2.0 isn't quite ready for prime_time just yet; + Best Practical Solutions strongly recommends that sites use + Apache 1.3 or FastCGI. If you MUST use mod_perl 2.0 (or 1.99), + please read the mailing list archives before asking for help. +. + sleep 5; +} + sub help { -print <<'.' + print <<'.'; By default, testdeps determine whether you have installed all the perl modules RT needs to run. @@ -81,18 +95,18 @@ sub _ { } $deps{'CORE'} = [ _( << '.') ]; -Digest::MD5 -DBI 1.18 +Digest::MD5 2.27 +DBI 1.37 Test::Inline Class::ReturnValue 0.40 -DBIx::SearchBuilder 0.86 +DBIx::SearchBuilder 0.97 Text::Template File::Spec 0.8 HTML::Entities Net::Domain Log::Dispatch 2.0 -Locale::Maketext 1.04 -Locale::Maketext::Lexicon 0.25 +Locale::Maketext 1.06 +Locale::Maketext::Lexicon 0.32 Locale::Maketext::Fuzzy MIME::Entity 5.108 Mail::Mailer 1.57 @@ -102,7 +116,8 @@ Time::ParseDate File::Temp Term::ReadKey Text::Autoformat -Text::Quoted +Text::Quoted 1.3 +Scalar::Util . $deps{'MASON'} = [ _( << '.') ]; @@ -113,9 +128,9 @@ HTML::Mason 1.16 MLDBM Errno FreezeThaw -Digest::MD5 +Digest::MD5 2.27 CGI::Cookie 1.20 -Storable +Storable 2.08 Apache::Session 1.53 . @@ -138,25 +153,25 @@ WWW::Mechanize . $deps{'FASTCGI'} = [ _( << '.') ]; -CGI +CGI 2.92 FCGI CGI::Fast . $deps{'SPEEDYCGI'} = [ _( << '.') ]; -CGI +CGI 2.92 CGI::SpeedyCGI . $deps{'MODPERL1'} = [ _( << '.') ]; -CGI +CGI 2.92 Apache::Request -Apache::DBI +Apache::DBI 0.92 . $deps{'MODPERL2'} = [ _( << '.') ]; -CGI 2.89 +CGI 2.92 Apache::DBI . @@ -175,6 +190,23 @@ $deps{'POSTGRESQL'} = [ _( << '.') ]; DBD::Pg . +print "perl:\n"; +print "\t5.8.0"; +eval {require 5.008}; +if ($@) { +print "...missing.\n"; + eval {require 5.006001}; + if ($@) { + print " RT is known to be non-functional on versions of perl older than 5.6.1. Please upgrade to 5.8.0 or newer"; + die; + } else { + print " RT is not supported on perl 5.6.1\n"; + } +} else { + print "...found\n"; + +} + foreach my $type (keys %args) { next unless ($type =~ /^with-(.*?)$/); @@ -196,17 +228,17 @@ sub test_dep { my $module = shift; my $version = shift; - print "\t$module $version"; - eval "use $module $version" ; - if ($@) { - my $error = $@; - $error =~ s/\n(.*)$//s; - print "...MISSING\n"; - print "\t\t$error\n" if $error =~ /this is only/; + print "\t$module $version"; + eval "use $module $version" ; + if ($@) { + my $error = $@; + $error =~ s/\n(.*)$//s; + print "...MISSING\n"; + print "\t\t$error\n" if $error =~ /this is only/; - return undef; + return undef; } else { - print "...found\n"; + print "...found\n"; return 1; } } -- cgit v1.2.1 From ae11d16db998c044e523030cc026b2d0c0bc981b Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Mar 2004 06:43:15 +0000 Subject: initial (hopefully rather unobtrusive) patch --- rt/sbin/rt-setup-database | 3 +++ 1 file changed, 3 insertions(+) (limited to 'rt/sbin') diff --git a/rt/sbin/rt-setup-database b/rt/sbin/rt-setup-database index 58f882f6e..83e08270a 100644 --- a/rt/sbin/rt-setup-database +++ b/rt/sbin/rt-setup-database @@ -110,6 +110,9 @@ elsif ( $args{'action'} eq 'drop' ) { } drop_db(); } +elsif ( $args{'action'} eq 'insert_initial' ) { + insert_initial_data(); +} elsif ( $args{'action'} eq 'insert' ) { insert_data( $args{'datafile'} ); } -- cgit v1.2.1 From ce41102169513f44c89a1e9bddfb250b29f239bb Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 8 Apr 2004 12:00:05 +0000 Subject: beginning of RT integration --- rt/sbin/rt-setup-database | 4 ++++ rt/sbin/rt-setup-database.in | 7 +++++++ 2 files changed, 11 insertions(+) (limited to 'rt/sbin') diff --git a/rt/sbin/rt-setup-database b/rt/sbin/rt-setup-database index 83e08270a..434e68671 100644 --- a/rt/sbin/rt-setup-database +++ b/rt/sbin/rt-setup-database @@ -592,6 +592,10 @@ $0: Set up RT's database --action init Initialize the database drop Drop the database. This will ERASE ALL YOUR DATA + insert_initial + Insert RT's core system objects + insert_initial + Insert RT's core system objects insert Insert data into RT's database. By default, will use RT's installation data. To use a local or supplementary datafile, specify it diff --git a/rt/sbin/rt-setup-database.in b/rt/sbin/rt-setup-database.in index 9e990e5b8..f37c69dc7 100644 --- a/rt/sbin/rt-setup-database.in +++ b/rt/sbin/rt-setup-database.in @@ -110,6 +110,9 @@ elsif ( $args{'action'} eq 'drop' ) { } drop_db(); } +elsif ( $args{'action'} eq 'insert_initial' ) { + insert_initial_data(); +} elsif ( $args{'action'} eq 'insert' ) { insert_data( $args{'datafile'} ); } @@ -589,6 +592,10 @@ $0: Set up RT's database --action init Initialize the database drop Drop the database. This will ERASE ALL YOUR DATA + insert_initial + Insert RT's core system objects + insert_initial + Insert RT's core system objects insert Insert data into RT's database. By default, will use RT's installation data. To use a local or supplementary datafile, specify it -- cgit v1.2.1 From b57bf99761751466c5b9a5d35df9e00b407c6f64 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 8 Apr 2004 12:05:04 +0000 Subject: remove accidentally doubled lines in usage inst --- rt/sbin/rt-setup-database | 2 -- rt/sbin/rt-setup-database.in | 2 -- 2 files changed, 4 deletions(-) (limited to 'rt/sbin') diff --git a/rt/sbin/rt-setup-database b/rt/sbin/rt-setup-database index 434e68671..17819886c 100644 --- a/rt/sbin/rt-setup-database +++ b/rt/sbin/rt-setup-database @@ -594,8 +594,6 @@ $0: Set up RT's database This will ERASE ALL YOUR DATA insert_initial Insert RT's core system objects - insert_initial - Insert RT's core system objects insert Insert data into RT's database. By default, will use RT's installation data. To use a local or supplementary datafile, specify it diff --git a/rt/sbin/rt-setup-database.in b/rt/sbin/rt-setup-database.in index f37c69dc7..56f4e8763 100644 --- a/rt/sbin/rt-setup-database.in +++ b/rt/sbin/rt-setup-database.in @@ -594,8 +594,6 @@ $0: Set up RT's database This will ERASE ALL YOUR DATA insert_initial Insert RT's core system objects - insert_initial - Insert RT's core system objects insert Insert data into RT's database. By default, will use RT's installation data. To use a local or supplementary datafile, specify it -- cgit v1.2.1 From c582e92888b4a5553e1b4e5214cf35217e4a0cf0 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 11 Nov 2004 12:13:50 +0000 Subject: import rt 3.0.12 --- rt/sbin/rt-setup-database.in | 2 ++ rt/sbin/rt-test-dependencies.in | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'rt/sbin') diff --git a/rt/sbin/rt-setup-database.in b/rt/sbin/rt-setup-database.in index 9e990e5b8..a7ee86d5d 100644 --- a/rt/sbin/rt-setup-database.in +++ b/rt/sbin/rt-setup-database.in @@ -450,6 +450,8 @@ sub insert_data { $princ->LoadUserDefinedGroup( $item->{'GroupId'} ); } elsif ($item->{'GroupDomain'} eq 'SystemInternal') { $princ->LoadSystemInternalGroup( $item->{'GroupType'} ); + } elsif ($item->{'GroupDomain'} eq 'RT::System-Role') { + $princ->LoadSystemRoleGroup( $item->{'GroupType'} ); } elsif ($item->{'GroupDomain'} eq 'RT::Queue-Role' && $item->{'Queue'}) { $princ->LoadQueueRoleGroup( Type => $item->{'GroupType'}, diff --git a/rt/sbin/rt-test-dependencies.in b/rt/sbin/rt-test-dependencies.in index 7a1508010..b4cb8c044 100644 --- a/rt/sbin/rt-test-dependencies.in +++ b/rt/sbin/rt-test-dependencies.in @@ -99,7 +99,7 @@ Digest::MD5 2.27 DBI 1.37 Test::Inline Class::ReturnValue 0.40 -DBIx::SearchBuilder 0.97 +DBIx::SearchBuilder 1.01 Text::Template File::Spec 0.8 HTML::Entities @@ -191,16 +191,19 @@ DBD::Pg . print "perl:\n"; -print "\t5.8.0"; -eval {require 5.008}; +print "\t5.8.3"; +eval {require 5.008003}; if ($@) { -print "...missing.\n"; - eval {require 5.006001}; +print "...MISSING.\n"; + eval {require 5.008000}; if ($@) { - print " RT is known to be non-functional on versions of perl older than 5.6.1. Please upgrade to 5.8.0 or newer"; + print "\nRT is known to be non-functional on versions of perl older than 5.8.3.\nPlease upgrade to 5.8.3 or newer\n\n"; die; - } else { - print " RT is not supported on perl 5.6.1\n"; + } + + eval {require 5.008003}; + if ($@) { + print "\nRT is known to be non-functional on versions of perl older than 5.8.3.\nPlease upgrade to 5.8.3 or newer\n\n"; } } else { print "...found\n"; -- cgit v1.2.1 From 70bfab976b302a8a407f7e921610983d9ac54ebd Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 11 Nov 2004 12:18:12 +0000 Subject: merge in changes to rt-setup-database --- rt/sbin/rt-setup-database.in | 2 ++ 1 file changed, 2 insertions(+) (limited to 'rt/sbin') diff --git a/rt/sbin/rt-setup-database.in b/rt/sbin/rt-setup-database.in index 56f4e8763..0b9a1071a 100644 --- a/rt/sbin/rt-setup-database.in +++ b/rt/sbin/rt-setup-database.in @@ -453,6 +453,8 @@ sub insert_data { $princ->LoadUserDefinedGroup( $item->{'GroupId'} ); } elsif ($item->{'GroupDomain'} eq 'SystemInternal') { $princ->LoadSystemInternalGroup( $item->{'GroupType'} ); + } elsif ($item->{'GroupDomain'} eq 'RT::System-Role') { + $princ->LoadSystemRoleGroup( $item->{'GroupType'} ); } elsif ($item->{'GroupDomain'} eq 'RT::Queue-Role' && $item->{'Queue'}) { $princ->LoadQueueRoleGroup( Type => $item->{'GroupType'}, -- cgit v1.2.1 From 232eb0de0d2b4dfa1c93a180b787126c3377ba02 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 3 Dec 2004 20:27:17 +0000 Subject: remove autogenerated file --- rt/sbin/rt-setup-database | 624 ------------------------------------------- rt/sbin/rt-test-dependencies | 19 +- 2 files changed, 11 insertions(+), 632 deletions(-) delete mode 100644 rt/sbin/rt-setup-database (limited to 'rt/sbin') diff --git a/rt/sbin/rt-setup-database b/rt/sbin/rt-setup-database deleted file mode 100644 index 17819886c..000000000 --- a/rt/sbin/rt-setup-database +++ /dev/null @@ -1,624 +0,0 @@ -#!/usr/bin/perl -w -# BEGIN LICENSE BLOCK -# -# Copyright (c) 1996-2003 Jesse Vincent -# -# (Except where explictly superceded by other copyright notices) -# -# This work is made available to you under the terms of Version 2 of -# the GNU General Public License. A copy of that license should have -# been provided with this software, but in any event can be snarfed -# from www.gnu.org. -# -# This work is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. -# -# -# END LICENSE BLOCK - -use strict; -use vars qw($PROMPT $VERSION $Handle $Nobody $SystemUser $item); -use vars - qw(@Groups @Users @ACL @Queues @ScripActions @ScripConditions @Templates @CustomFields @Scrips); - -use lib "/opt/rt3/lib"; - -#This drags in RT's config.pm -# We do it in a begin block because RT::Handle needs to know the type to do its -# inheritance -use RT; -use Carp; -use RT::User; -use RT::CurrentUser; -use RT::Template; -use RT::ScripAction; -use RT::ACE; -use RT::Group; -use RT::User; -use RT::Queue; -use RT::ScripCondition; -use RT::CustomField; -use RT::Scrip; - -RT::LoadConfig(); -use Term::ReadKey; -use Getopt::Long; - -my %args; - -GetOptions( - \%args, - 'prompt-for-dba-password', 'force', 'debug', - 'action=s', 'dba=s', 'dba-password=s', 'datafile=s', - 'datadir=s' -); - -$| = 1; #unbuffer that output. - -require RT::Handle; -my $Handle = RT::Handle->new($RT::DatabaseType); -$Handle->BuildDSN; -my $dbh; - -if ( $args{'prompt-for-dba-password'} ) { - $args{'dba-password'} = get_dba_password(); - chomp( $args{'dba-password'} ); -} - -unless ( $args{'action'} ) { - help(); - die; -} -if ( $args{'action'} eq 'init' ) { - $dbh = DBI->connect( get_system_dsn(), $args{'dba'}, $args{'dba-password'} ) - || die "Failed to connect to " . get_system_dsn() . " as $args{'dba'}: $DBI::errstr"; - print "Now creating a database for RT.\n"; - if ($RT::DatabaseType ne 'Oracle' || - $args{'dba'} ne $RT::DatabaseUser) { - create_db(); - } else { - print "...skipped as ".$args{'dba'} ." is not " . $RT::DatabaseUser . " or we're working with Oracle.\n"; - } - - $dbh->disconnect; - $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) - || die $DBI::errstr; - - print "Now populating database schema.\n"; - insert_schema(); - print "Now inserting database ACLs\n"; - insert_acl() unless ($RT::DatabaseType eq 'Oracle'); - print "Now inserting RT core system objects\n"; - insert_initial_data(); - print "Now inserting RT data\n"; - insert_data( $RT::EtcPath . "/initialdata" ); -} -elsif ( $args{'action'} eq 'drop' ) { - unless ( $dbh = - DBI->connect( get_system_dsn(), $args{'dba'}, $args{'dba-password'} ) ) - { - warn $DBI::errstr; - warn "Database doesn't appear to exist. Aborting database drop."; - exit(0); - } - drop_db(); -} -elsif ( $args{'action'} eq 'insert_initial' ) { - insert_initial_data(); -} -elsif ( $args{'action'} eq 'insert' ) { - insert_data( $args{'datafile'} ); -} -elsif ($args{'action'} eq 'acl') { - $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) - || die "Failed to connect to " . get_system_dsn() . " as $args{'dba'}: $DBI::errstr"; - insert_acl($args{'datadir'}); -} -elsif ($args{'action'} eq 'schema') { - $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) - || die "Failed to connect to " . get_system_dsn() . " as $args{'dba'}: $DBI::errstr"; - insert_schema($args{'datadir'}); -} - -else { - print STDERR '$0 called with an invalid --action parameter'; - exit(-1); -} - -# {{{ sub insert_schema -sub insert_schema { - my $base_path = (shift || $RT::EtcPath); - my (@schema); - print "Creating database schema.\n"; - - if ( -f $base_path . "/schema." . $RT::DatabaseType ) { - no warnings 'unopened'; - - open( SCHEMA, "<" . $base_path . "/schema." . $RT::DatabaseType ); - open( SCHEMA_LOCAL, "<" . $RT::LocalEtcPath . "/schema." . $RT::DatabaseType ); - - my $statement = ""; - foreach my $line (, ($_ = ';;'), ) { - $line =~ s/\#.*//g; - $line =~ s/--.*//g; - $statement .= $line; - if ( $line =~ /;(\s*)$/ ) { - $statement =~ s/;(\s*)$//g; - push @schema, $statement; - $statement = ""; - } - } - - local $SIG{__WARN__} = sub {}; - my $is_local = 0; # local/etc/schema needs to be nonfatal. - foreach my $statement (@schema) { - if ($statement =~ /^\s*;$/) { $is_local = 1; next; } - print STDERR "SQL: $statement\n" if defined $args{'debug'}; - my $sth = $dbh->prepare($statement) or die $dbh->errstr; - unless ( $sth->execute or $is_local ) { - die "Problem with statement:\n $statement\n" . $sth->errstr; - } - } - - } - else { - die "Couldn't find schema file for " . $RT::DatabaseType . "\n"; - } - print "schema sucessfully inserted\n"; - -} - -# }}} - -# {{{ sub drop_db -sub drop_db { - return if ( $RT::DatabaseType eq 'SQLite' ); - if ( $RT::DatabaseType eq 'Oracle' ) { - print <do("Drop DATABASE $RT::DatabaseName") or warn $DBI::errstr; -} - -# }}} - -# {{{ sub create_db -sub create_db { - print "Creating $RT::DatabaseType database $RT::DatabaseName.\n"; - if ( $RT::DatabaseType eq 'SQLite' ) { - return; - } - elsif ( $RT::DatabaseType eq 'Pg' ) { - $dbh->do("CREATE DATABASE $RT::DatabaseName WITH ENCODING='UNICODE'"); - if ($DBI::errstr) { - $dbh->do("CREATE DATABASE $RT::DatabaseName") || die $DBI::errstr; - } - } - elsif ($RT::DatabaseType eq 'Oracle') { - insert_acl(); - } - elsif ( $RT::DatabaseType eq 'Informix' ) { - $ENV{DB_LOCALE} = 'en_us.utf8'; - $dbh->do("CREATE DATABASE $RT::DatabaseName WITH BUFFERED LOG"); - } - else { - $dbh->do("CREATE DATABASE $RT::DatabaseName") or die $DBI::errstr; - } -} - -# }}} - -sub get_dba_password { - print -"In order to create a new database and grant RT access to that database,\n"; - print "this script needs to connect to your " - . $RT::DatabaseType - . " instance on " - . $RT::DatabaseHost . " as " - . $args{'dba'} . ".\n"; - print -"Please specify that user's database password below. If the user has no database\n"; - print "password, just press return.\n\n"; - print "Password: "; - ReadMode('noecho'); - my $password = ReadLine(0); - ReadMode('normal'); - return ($password); -} - -# {{{ sub _yesno -sub _yesno { - print "Proceed [y/N]:"; - my $x = scalar(); - $x =~ /^y/i; -} - -# }}} - -# {{{ insert_acls -sub insert_acl { - - my $base_path = (shift || $RT::EtcPath); - - if ( $RT::DatabaseType =~ /^oracle$/i ) { - do $base_path . "/acl.Oracle" - || die "Couldn't find ACLS for Oracle\n" . $@; - } - elsif ( $RT::DatabaseType =~ /^pg$/i ) { - do $base_path . "/acl.Pg" || die "Couldn't find ACLS for Pg\n" . $@; - } - elsif ( $RT::DatabaseType =~ /^mysql$/i ) { - do $base_path . "/acl.mysql" - || die "Couldn't find ACLS for mysql in " . $RT::EtcPath . "\n" . $@; - } - elsif ( $RT::DatabaseType =~ /^informix$/i ) { - do $base_path . "/acl.Informix" - || die "Couldn't find ACLS for Informix in " . $RT::EtcPath . "\n" . $@; - } - elsif ( $RT::DatabaseType =~ /^SQLite$/i ) { - return; - } - else { - die "Unknown RT database type"; - } - - my @acl = acl($dbh); - foreach my $statement (@acl) { - print STDERR $statement if $args{'debug'}; - my $sth = $dbh->prepare($statement) or die $dbh->errstr; - unless ( $sth->execute ) { - die "Problem with statement:\n $statement\n" . $sth->errstr; - } - } -} - -# }}} - -=head2 get_system_dsn - -Returns a dsn suitable for database creates and drops -and user creates and drops - -=cut - -sub get_system_dsn { - - my $dsn = $Handle->DSN; - - #with mysql, you want to connect sans database to funge things - if ( $RT::DatabaseType eq 'mysql' ) { - $dsn =~ s/dbname=$RT::DatabaseName//; - - # with postgres, you want to connect to database1 - } - elsif ( $RT::DatabaseType eq 'Pg' ) { - $dsn =~ s/dbname=$RT::DatabaseName/dbname=template1/; - } - elsif ( $RT::DatabaseType eq 'Informix' ) { - # with Informix, you want to connect sans database: - $dsn =~ s/Informix:$RT::DatabaseName/Informix:/; - } - return $dsn; -} - -sub insert_initial_data { - - RT::InitLogging(); - - #connect to the db, for actual RT work - require RT::Handle; - $RT::Handle = RT::Handle->new(); - $RT::Handle->Connect(); - - #Put together a current user object so we can create a User object - my $CurrentUser = new RT::CurrentUser(); - - print "Checking for existing system user ($CurrentUser)..."; - my $test_user = RT::User->new($CurrentUser); - $test_user->Load('RT_System'); - if ( $test_user->id ) { - print "found!\n\nYou appear to have a functional RT database.\n" - . "Exiting, so as not to clobber your existing data.\n"; - exit(-1); - - } - else { - print "not found. This appears to be a new installation.\n"; - } - - print "Creating system user..."; - my $RT_System = new RT::User($CurrentUser); - - my ( $val, $msg ) = $RT_System->_BootstrapCreate( - Name => 'RT_System', - RealName => 'The RT System itself', - Comments => -'Do not delete or modify this user. It is integral to RT\'s internal database structures', - Creator => '1' ); - - unless ($val) { - print "$msg\n"; - exit(1); - } - print "done.\n"; - $RT::Handle->Disconnect(); - -} - -# load some sort of data into the database - -sub insert_data { - my $datafile = shift; - - #Connect to the database and get RT::SystemUser and RT::Nobody loaded - RT::Init; - - my $CurrentUser = RT::CurrentUser->new(); - $CurrentUser->LoadByName('RT_System'); - - if ( $datafile eq $RT::EtcPath . "/initialdata" ) { - - print "Creating Superuser ACL..."; - - my $superuser_ace = RT::ACE->new($CurrentUser); - $superuser_ace->_BootstrapCreate( - PrincipalId => ACLEquivGroupId( $CurrentUser->Id ), - PrincipalType => 'Group', - RightName => 'SuperUser', - ObjectType => 'RT::System', - ObjectId => '1' ); - - } - - # Slurp in stuff to insert from the datafile. Possible things to go in here:- - # @groups, @users, @acl, @queues, @ScripActions, @ScripConditions, @templates - - require $datafile - || die "Couldn't find initial data for import\n" . $@; - - if (@Groups) { - print "Creating groups..."; - foreach $item (@Groups) { - my $new_entry = RT::Group->new($CurrentUser); - my ( $return, $msg ) = $new_entry->_Create(%$item); - print "(Error: $msg)" unless ($return); - print $return. "."; - } - print "done.\n"; - } - if (@Users) { - print "Creating users..."; - foreach $item (@Users) { - my $new_entry = new RT::User($CurrentUser); - my ( $return, $msg ) = $new_entry->Create(%$item); - print "(Error: $msg)" unless ($return); - print $return. "."; - } - print "done.\n"; - } - if (@Queues) { - print "Creating queues..."; - for $item (@Queues) { - my $new_entry = new RT::Queue($CurrentUser); - my ( $return, $msg ) = $new_entry->Create(%$item); - print "(Error: $msg)" unless ($return); - print $return. "."; - } - print "done.\n"; - } - if (@ACL) { - print "Creating ACL..."; - for my $item (@ACL) { - - my ($princ, $object); - - # Global rights or Queue rights? - if ($item->{'Queue'}) { - $object = RT::Queue->new($CurrentUser); - $object->Load( $item->{'Queue'} ); - } else { - $object = $RT::System; - } - - # Group rights or user rights? - if ($item->{'GroupDomain'}) { - $princ = RT::Group->new($CurrentUser); - if ($item->{'GroupDomain'} eq 'UserDefined') { - $princ->LoadUserDefinedGroup( $item->{'GroupId'} ); - } elsif ($item->{'GroupDomain'} eq 'SystemInternal') { - $princ->LoadSystemInternalGroup( $item->{'GroupType'} ); - } elsif ($item->{'GroupDomain'} eq 'RT::Queue-Role' && - $item->{'Queue'}) { - $princ->LoadQueueRoleGroup( Type => $item->{'GroupType'}, - Queue => $object->id); - } else { - $princ->Load( $item->{'GroupId'} ); - } - } else { - $princ = RT::User->new($CurrentUser); - $princ->Load( $item->{'UserId'} ); - } - - # Grant it - my ( $return, $msg ) = $princ->PrincipalObj->GrantRight( - Right => $item->{'Right'}, - Object => $object ); - - if ($return) { - print $return. "."; - } - else { - print $msg . "."; - - } - - } - print "done.\n"; - } - if (@CustomFields) { - print "Creating custom fields..."; - for $item (@CustomFields) { - my $new_entry = new RT::CustomField($CurrentUser); - my $values = $item->{'Values'}; - delete $item->{'Values'}; - my $q = $item->{'Queue'}; - my $q_obj = RT::Queue->new($CurrentUser); - $q_obj->Load($q); - if ( $q_obj->Id ) { - $item->{'Queue'} = $q_obj->Id; - } - elsif ( $q == 0 ) { - $item->{'Queue'} = 0; - } - else { - print "(Error: Could not find queue " . $q . ")\n" - unless ( $q_obj->Id ); - next; - } - my ( $return, $msg ) = $new_entry->Create(%$item); - - foreach my $value ( @{$values} ) { - my ( $eval, $emsg ) = $new_entry->AddValue(%$value); - print "(Error: $emsg)\n" unless ($eval); - } - - print "(Error: $msg)\n" unless ($return); - print $return. "."; - } - - print "done.\n"; - } - - if (@ScripActions) { - print "Creating ScripActions..."; - - for $item (@ScripActions) { - my $new_entry = RT::ScripAction->new($CurrentUser); - my $return = $new_entry->Create(%$item); - print $return. "."; - } - - print "done.\n"; - } - - if (@ScripConditions) { - print "Creating ScripConditions..."; - - for $item (@ScripConditions) { - my $new_entry = RT::ScripCondition->new($CurrentUser); - my $return = $new_entry->Create(%$item); - print $return. "."; - } - - print "done.\n"; - } - - if (@Templates) { - print "Creating templates..."; - - for $item (@Templates) { - my $new_entry = new RT::Template($CurrentUser); - my $return = $new_entry->Create(%$item); - print $return. "."; - } - print "done.\n"; - } - if (@Scrips) { - print "Creating scrips..."; - - for $item (@Scrips) { - my $new_entry = new RT::Scrip($CurrentUser); - my ( $return, $msg ) = $new_entry->Create(%$item); - if ($return) { - print $return. "."; - } - else { - print "(Error: $msg)\n"; - } - } - print "done.\n"; - } - $RT::Handle->Disconnect(); - -} - -=head2 ACLEquivGroupId - -Given a userid, return that user's acl equivalence group - -=cut - -sub ACLEquivGroupId { - my $username = shift; - my $user = RT::User->new($RT::SystemUser); - $user->Load($username); - my $equiv_group = RT::Group->new($RT::SystemUser); - $equiv_group->LoadACLEquivalenceGroup($user); - return ( $equiv_group->Id ); -} - -sub help { - - print < Date: Fri, 3 Dec 2004 20:27:33 +0000 Subject: remove autogenerated file --- rt/sbin/rt-test-dependencies | 281 ------------------------------------------- 1 file changed, 281 deletions(-) delete mode 100644 rt/sbin/rt-test-dependencies (limited to 'rt/sbin') diff --git a/rt/sbin/rt-test-dependencies b/rt/sbin/rt-test-dependencies deleted file mode 100644 index 1f9fa45b1..000000000 --- a/rt/sbin/rt-test-dependencies +++ /dev/null @@ -1,281 +0,0 @@ -#!/usr/bin/perl -# BEGIN LICENSE BLOCK -# -# Copyright (c) 1996-2003 Jesse Vincent -# -# (Except where explictly superceded by other copyright notices) -# -# This work is made available to you under the terms of Version 2 of -# the GNU General Public License. A copy of that license should have -# been provided with this software, but in any event can be snarfed -# from www.gnu.org. -# -# This work is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. -# -# -# END LICENSE BLOCK - -# -# This is just a basic script that checks to make sure that all -# the modules needed by RT before you can install it. -# - -use strict; -no warnings qw(numeric redefine); -use Getopt::Long; -use CPAN; -my %args; -my %deps; -GetOptions(\%args,'install', 'with-MYSQL', 'with-POSTGRESQL|with-pg|with-pgsql', 'with-SQLITE', 'with-ORACLE', 'with-FASTCGI', 'with-SPEEDYCGI', 'with-MODPERL1', 'with-MODPERL2' ,'with-DEV'); - -if (!keys %args) { - help(); - exit(0); -} -if ($args{'with-MODPERL2'}) { - warn_modperl2(); -} - -$args{'with-MASON'} = 1; -$args{'with-CORE'} = 1; -$args{'with-DEV'} =1; -$args{'with-CLI'} =1; -$args{'with-MAILGATE'} =1; -if ($] < 5.007) { -$args{'with-I18N-COMPAT'} = 1; -} - -sub warn_modperl2 { - print <<'.'; - NOTE: mod_perl 2.0 isn't quite ready for prime_time just yet; - Best Practical Solutions strongly recommends that sites use - Apache 1.3 or FastCGI. If you MUST use mod_perl 2.0 (or 1.99), - please read the mailing list archives before asking for help. -. - sleep 5; -} - - -sub help { - - print <<'.'; - -By default, testdeps determine whether you have -installed all the perl modules RT needs to run. - - --install Install missing modules - -The following switches will tell the tool to check for specific dependencies - - --with-mysql Database interface for MySQL - --with-postgresql Database interface for PostgreSQL - --with-sqlite Database interface and driver for SQLite (unsupported) - --with-oracle Database interface for oracle (unsupported) - - --with-fastcgi Libraries needed to support the fastcgi handler - --with-speedycgi Libraries needed to support the speedycgi handler - --with-modperl1 Libraries needed to support the modperl 1 handler - --with-modperl2 Libraries needed to support the modperl 2 handler - - --with-dev Tools needed for RT development -. -} - - -sub _ { - map { /(\S+)\s*(\S*)/; $1 => ($2 ? $2 :'') } split ( /\n/, $_[0] ); -} - -$deps{'CORE'} = [ _( << '.') ]; -Digest::MD5 2.27 -DBI 1.37 -Test::Inline -Class::ReturnValue 0.40 -DBIx::SearchBuilder 1.01 -Text::Template -File::Spec 0.8 -HTML::Entities -Net::Domain -Log::Dispatch 2.0 -Locale::Maketext 1.06 -Locale::Maketext::Lexicon 0.32 -Locale::Maketext::Fuzzy -MIME::Entity 5.108 -Mail::Mailer 1.57 -Net::SMTP -Text::Wrapper -Time::ParseDate -File::Temp -Term::ReadKey -Text::Autoformat -Text::Quoted 1.3 -Scalar::Util -. - -$deps{'MASON'} = [ _( << '.') ]; -Params::Validate 0.02 -Cache::Cache -Exception::Class -HTML::Mason 1.16 -MLDBM -Errno -FreezeThaw -Digest::MD5 2.27 -CGI::Cookie 1.20 -Storable 2.08 -Apache::Session 1.53 -. - -$deps{'MAILGATE'} = [ _( << '.') ]; -HTML::TreeBuilder -HTML::FormatText -Getopt::Long -LWP::UserAgent -. - -$deps{'CLI'} = [ _( << '.') ]; -Getopt::Long 2.24 -. - -$deps{'DEV'} = [ _( << '.') ]; -Regexp::Common -Time::HiRes -Test::Inline -WWW::Mechanize -. - -$deps{'FASTCGI'} = [ _( << '.') ]; -CGI 2.92 -FCGI -CGI::Fast -. - -$deps{'SPEEDYCGI'} = [ _( << '.') ]; -CGI 2.92 -CGI::SpeedyCGI -. - - -$deps{'MODPERL1'} = [ _( << '.') ]; -CGI 2.92 -Apache::Request -Apache::DBI 0.92 -. - -$deps{'MODPERL2'} = [ _( << '.') ]; -CGI 2.92 -Apache::DBI -. - -$deps{'I18N-COMPAT'} = [ _( << '.') ]; -Text::Iconv -Encode::compat 0.04 -. - -$deps{'MYSQL'} = [ _( << '.') ]; -DBD::mysql 2.1018 -. -$deps{'ORACLE'} = [ _( << '.') ]; -DBD::Oracle -. -$deps{'POSTGRESQL'} = [ _( << '.') ]; -DBD::Pg -. - -print "perl:\n"; -print "\t5.8.3"; -eval {require 5.008003}; -if ($@) { -print "...MISSING.\n"; - eval {require 5.008000}; - if ($@) { - print "\nRT is known to be non-functional on versions of perl older than 5.8.3.\nPlease upgrade to 5.8.3 or newer\n\n"; - die; - } - - eval {require 5.008003}; - if ($@) { - print "\nRT is known to be non-functional on versions of perl older than 5.8.3.\nPlease upgrade to 5.8.3 or newer\n\n"; - } -} else { - print "...found\n"; - -} - - -foreach my $type (keys %args) { -next unless ($type =~ /^with-(.*?)$/); -my $type = $1; -print "$type dependencies:\n"; - my @deps = (@{$deps{$type}}); - while (@deps) { - my $module = shift @deps; - my $version = shift @deps; -my $ret; - $ret =test_dep($module, $version); - -if ($args{'install'} && !$ret) { - resolve_dep($module); -} -} -} -sub test_dep { - my $module = shift; - my $version = shift; - - print "\t$module $version"; - eval "use $module $version" ; - if ($@) { - my $error = $@; - $error =~ s/\n(.*)$//s; - print "...MISSING\n"; - print "\t\t$error\n" if $error =~ /this is only/; - - return undef; - } else { - print "...found\n"; -return 1; - } -} - -sub resolve_dep { - my $module = shift; - use CPAN; - CPAN::Shell->install($module); - -} - - -sub print_help { - print << "EOF"; - -$0 FLAG DBTYPE - - -$0 is a tool for RT that will tell you if you've got all -the modules RT depends on properly installed. - -Flags: (only one flag is valid for a given run) - --quiet will check to see if we've got everything we need - and will exit with a return code of (1) if we don't. - --warn will tell you what isn't properly installed - --fix will use CPANPLUS.pm or CPAN.pm to magically make everything better - -DBTYPE is one of: - oracle, pg, mysql - -EOF - - exit(0); -} -- cgit v1.2.1 From d39d52aac8f38ea9115628039f0df5aa3ac826de Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 3 Dec 2004 20:40:48 +0000 Subject: import rt 3.2.2 --- rt/sbin/extract-message-catalog | 39 ++++++-- rt/sbin/extract_pod_tests | 39 ++++++-- rt/sbin/factory | 55 ++++++++--- rt/sbin/license_tag | 105 ++++++++++++++------ rt/sbin/regression_harness | 39 ++++++-- rt/sbin/rt-setup-database.in | 77 ++++++++++++--- rt/sbin/rt-test-dependencies.in | 210 +++++++++++++++++++++++++++------------- 7 files changed, 409 insertions(+), 155 deletions(-) (limited to 'rt/sbin') diff --git a/rt/sbin/extract-message-catalog b/rt/sbin/extract-message-catalog index a7ba6335c..c5d4d8953 100644 --- a/rt/sbin/extract-message-catalog +++ b/rt/sbin/extract-message-catalog @@ -1,9 +1,15 @@ #!/usr/bin/perl -w -# BEGIN LICENSE BLOCK +# {{{ BEGIN BPS TAGGED BLOCK # -# Copyright (c) 1996-2003 Jesse Vincent +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# # -# (Except where explictly superceded by other copyright notices) +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: # # This work is made available to you under the terms of Version 2 of # the GNU General Public License. A copy of that license should have @@ -15,14 +21,29 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # -# END LICENSE BLOCK - +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# }}} END BPS TAGGED BLOCK # Portions Copyright 2002 Autrijus Tang use strict; diff --git a/rt/sbin/extract_pod_tests b/rt/sbin/extract_pod_tests index ed01c7dc2..3987e90c7 100644 --- a/rt/sbin/extract_pod_tests +++ b/rt/sbin/extract_pod_tests @@ -1,9 +1,15 @@ #!/usr/bin/perl -# BEGIN LICENSE BLOCK +# {{{ BEGIN BPS TAGGED BLOCK # -# Copyright (c) 1996-2003 Jesse Vincent +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# # -# (Except where explictly superceded by other copyright notices) +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: # # This work is made available to you under the terms of Version 2 of # the GNU General Public License. A copy of that license should have @@ -15,14 +21,29 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # -# END LICENSE BLOCK - +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# }}} END BPS TAGGED BLOCK use strict; use vars qw($VERSION); $VERSION = '0.06'; diff --git a/rt/sbin/factory b/rt/sbin/factory index 64b0ae337..882e4a826 100644 --- a/rt/sbin/factory +++ b/rt/sbin/factory @@ -1,9 +1,15 @@ #!/usr/bin/perl -# BEGIN LICENSE BLOCK +# {{{ BEGIN BPS TAGGED BLOCK # -# Copyright (c) 1996-2003 Jesse Vincent +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# +# +# (Except where explicitly superseded by other copyright notices) # -# (Except where explictly superceded by other copyright notices) +# +# LICENSE: # # This work is made available to you under the terms of Version 2 of # the GNU General Public License. A copy of that license should have @@ -15,14 +21,29 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # -# END LICENSE BLOCK - +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# }}} END BPS TAGGED BLOCK use DBI; my $database = shift; @@ -38,7 +59,7 @@ my $password = ''; my $LicenseBlock = << '.'; -# BEGIN LICENSE BLOCK +# BEGIN BPS TAGGED BLOCK # # Copyright (c) 1996-2003 Jesse Vincent # @@ -60,7 +81,7 @@ my $LicenseBlock = << '.'; # inclusion in the work. # # -# END LICENSE BLOCK +# END BPS TAGGED BLOCK . @@ -84,7 +105,17 @@ my @tables = $dbh->tables(); my ( %tablemap, $typemap, %modulemap ); foreach my $table (@tables) { + $table =~ s/\`//g; next if ($table eq 'sessions'); + $table = ucfirst($table); + $table =~ s/field/Field/; + $table =~ s/group/Group/; + $table =~ s/custom/Custom/; + $table =~ s/member/Member/; + $table =~ s/Scripaction/ScripAction/g; + $table =~ s/condition/Condition/g; + $table =~ s/value/Value/; + $table =~ s/Acl/ACL/g; $tablemap{$table} = $table; $modulemap{$table} = $table; if ( $table =~ /^(.*)s$/ ) { @@ -348,7 +379,7 @@ $Create $FieldsPod -sub _ClassAccessible { +sub _CoreAccessible { { $ClassAccessible diff --git a/rt/sbin/license_tag b/rt/sbin/license_tag index 689b246ef..cd1a9716f 100644 --- a/rt/sbin/license_tag +++ b/rt/sbin/license_tag @@ -1,12 +1,18 @@ #!/usr/bin/perl -# BEGIN LICENSE BLOCK +# {{{ BEGIN BPS TAGGED BLOCK # -# Copyright (c) 1996-2003 Jesse Vincent +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# # # (Except where explicitly superseded by other copyright notices) # +# +# LICENSE: +# # This work is made available to you under the terms of Version 2 of # the GNU General Public License. A copy of that license should have # been provided with this software, but in any event can be snarfed @@ -17,20 +23,41 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # -# END LICENSE BLOCK - -my $LICENSE = < +COPYRIGHT: + +This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC + (Except where explicitly superseded by other copyright notices) + +LICENSE: + This work is made available to you under the terms of Version 2 of the GNU General Public License. A copy of that license should have been provided with this software, but in any event can be snarfed @@ -41,11 +68,27 @@ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -Unless otherwise specified, all modifications, corrections or -extensions to this work which alter its source code become the -property of Best Practical Solutions, LLC when submitted for -inclusion in the work. +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + +CONTRIBUTION SUBMISSION POLICY: + +(The following paragraph is not intended to limit the rights granted +to you to modify and distribute this software under the terms of +the GNU General Public License and is only of importance to you if +you choose to contribute your changes and enhancements to the +community by submitting them to Best Practical Solutions, LLC.) +By intentionally submitting any modifications, corrections or +derivatives to this work, or any other work intended for use with +Request Tracker, to Best Practical Solutions, LLC, you confirm that +you are the copyright holder for those contributions and you grant +Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +royalty-free, perpetual, license to use, copy, create derivative +works based on those contributions, and sublicense and distribute +those contributions and any derivatives thereof. EOL @@ -73,16 +116,16 @@ sub tag_mason { print "$pm - "; - if ($file =~ /^%# BEGIN LICENSE BLOCK/ms) { + if ($file =~ /^%# {{{ BEGIN BPS TAGGED BLOCK/ms) { print "has license section"; - $file =~ s/^%# BEGIN LICENSE BLOCK(.*?)%# END LICENSE BLOCK/%# BEGIN LICENSE BLOCK\n$pmlic%# END LICENSE BLOCK/ms; + $file =~ s/^%# {{{ BEGIN BPS TAGGED BLOCK(.*?)%# }}} END BPS TAGGED BLOCK/%# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic%# }}} END BPS TAGGED BLOCK/ms; } else { print "no license section"; - $file ="%# BEGIN LICENSE BLOCK\n$pmlic%# END LICENSE BLOCK\n". $file; + $file ="%# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic%# }}} END BPS TAGGED BLOCK\n". $file; } - $file =~ s/%# END LICENSE BLOCK(\n+)/%# END LICENSE BLOCK\n/mg; + $file =~ s/%# }}} END BPS TAGGED BLOCK(\n+)/%# }}} END BPS TAGGED BLOCK\n/mg; print "\n"; @@ -105,16 +148,16 @@ sub tag_makefile { print "$pm - "; - if ($file =~ /^# BEGIN LICENSE BLOCK/ms) { + if ($file =~ /^# {{{ BEGIN BPS TAGGED BLOCK/ms) { print "has license section"; - $file =~ s/^# BEGIN LICENSE BLOCK(.*?)# END LICENSE BLOCK/# BEGIN LICENSE BLOCK\n$pmlic# END LICENSE BLOCK/ms; + $file =~ s/^# {{{ BEGIN BPS TAGGED BLOCK(.*?)# }}} END BPS TAGGED BLOCK/# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic# }}} END BPS TAGGED BLOCK/ms; } else { print "no license section"; - $file ="# BEGIN LICENSE BLOCK\n$pmlic# END LICENSE BLOCK\n". $file; + $file ="# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic# }}} END BPS TAGGED BLOCK\n". $file; } - $file =~ s/# END LICENSE BLOCK(\n+)/# END LICENSE BLOCK\n/mg; + $file =~ s/# }}} END BPS TAGGED BLOCK(\n+)/# }}} END BPS TAGGED BLOCK\n/mg; print "\n"; @@ -129,7 +172,7 @@ sub tag_makefile { sub tag_pm { my $pm = $_; - next unless $pm =~ /\.pm\z/s; + next unless $pm =~ /\.pm/s; open(FILE,"<$pm") || die "Failed to open $pm"; my $file = (join "", ); close (FILE); @@ -138,16 +181,16 @@ sub tag_pm { print "$pm - "; - if ($file =~ /^# BEGIN LICENSE BLOCK/ms) { + if ($file =~ /^# {{{ BEGIN BPS TAGGED BLOCK/ms) { print "has license section"; - $file =~ s/^# BEGIN LICENSE BLOCK(.*?)# END LICENSE BLOCK/# BEGIN LICENSE BLOCK\n$pmlic# END LICENSE BLOCK/ms; + $file =~ s/^# {{{ BEGIN BPS TAGGED BLOCK(.*?)# }}} END BPS TAGGED BLOCK/# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic# }}} END BPS TAGGED BLOCK/ms; } else { print "no license section"; - $file ="# BEGIN LICENSE BLOCK\n$pmlic# END LICENSE BLOCK\n". $file; + $file ="# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic# }}} END BPS TAGGED BLOCK\n". $file; } - $file =~ s/# END LICENSE BLOCK(\n+)/# END LICENSE BLOCK\n/mg; + $file =~ s/# }}} END BPS TAGGED BLOCK(\n+)/# }}} END BPS TAGGED BLOCK\n/mg; print "\n"; @@ -170,21 +213,21 @@ sub tag_script { $pmlic =~ s/^/# /msg; print "$pm - "; - if ($file =~ /^# BEGIN LICENSE BLOCK/ms) { + if ($file =~ /^# {{{ BEGIN BPS TAGGED BLOCK/ms) { print "has license section"; - $file =~ s/^# BEGIN LICENSE BLOCK(.*?)# END LICENSE BLOCK/# BEGIN LICENSE BLOCK\n$pmlic# END LICENSE BLOCK/ms; + $file =~ s/^# {{{ BEGIN BPS TAGGED BLOCK(.*?)# }}} END BPS TAGGED BLOCK/# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic# }}} END BPS TAGGED BLOCK/ms; } else { print "no license section"; if ($file =~ /^(#!.*?)\n/) { - my $lic ="# BEGIN LICENSE BLOCK\n$pmlic# END LICENSE BLOCK\n"; + my $lic ="# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic# }}} END BPS TAGGED BLOCK\n"; $file =~ s/^(#!.*?)\n/$1\n$lic/; } } - $file =~ s/# END LICENSE BLOCK(\n+)/# END LICENSE BLOCK\n\n/mg; + $file =~ s/# }}} END BPS TAGGED BLOCK(\n+)/# }}} END BPS TAGGED BLOCK\n/mg; print "\n"; diff --git a/rt/sbin/regression_harness b/rt/sbin/regression_harness index fc1e29304..c10779614 100644 --- a/rt/sbin/regression_harness +++ b/rt/sbin/regression_harness @@ -1,9 +1,15 @@ #!/usr/bin/perl -# BEGIN LICENSE BLOCK +# {{{ BEGIN BPS TAGGED BLOCK # -# Copyright (c) 1996-2003 Jesse Vincent +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# # -# (Except where explictly superceded by other copyright notices) +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: # # This work is made available to you under the terms of Version 2 of # the GNU General Public License. A copy of that license should have @@ -15,14 +21,29 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # -# END LICENSE BLOCK - +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# }}} END BPS TAGGED BLOCK open (FH,"make regression|"); my $skip_frontmatter = 1; diff --git a/rt/sbin/rt-setup-database.in b/rt/sbin/rt-setup-database.in index a7ee86d5d..e83aa262b 100644 --- a/rt/sbin/rt-setup-database.in +++ b/rt/sbin/rt-setup-database.in @@ -1,9 +1,15 @@ #!@PERL@ -w -# BEGIN LICENSE BLOCK +# {{{ BEGIN BPS TAGGED BLOCK # -# Copyright (c) 1996-2003 Jesse Vincent +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# # -# (Except where explictly superceded by other copyright notices) +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: # # This work is made available to you under the terms of Version 2 of # the GNU General Public License. A copy of that license should have @@ -15,14 +21,29 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # -# END LICENSE BLOCK - +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# }}} END BPS TAGGED BLOCK use strict; use vars qw($PROMPT $VERSION $Handle $Nobody $SystemUser $item); use vars @@ -87,10 +108,30 @@ if ( $args{'action'} eq 'init' ) { print "...skipped as ".$args{'dba'} ." is not " . $RT::DatabaseUser . " or we're working with Oracle.\n"; } - $dbh->disconnect; - $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) - || die $DBI::errstr; + if ($RT::DatabaseType eq "mysql") { + # Check which version we're running + my ($version) = $dbh->selectrow_hashref("show variables like 'version'")->{Value} =~ /^(\d\.\d+)/; + print "*** Warning: RT is unsupported on MySQL versions before 4.0.x\n" if $version < 4; + + # MySQL must have InnoDB support + my $innodb = $dbh->selectrow_hashref("show variables like 'have_innodb'")->{Value}; + if ($innodb eq "NO") { + die "RT requires that MySQL be compiled with InnoDB table support.\n". + "See http://dev.mysql.com/doc/mysql/en/InnoDB.html\n"; + } elsif ($innodb eq "DISABLED") { + die "RT requires that MySQL InnoDB table support be enabled.\n". + ($version < 4 + ? "Add 'innodb_data_file_path=ibdata1:10M:autoextend' to the [mysqld] section of my.cnf\n" + : "Remove the 'skip-innodb' line from your my.cnf file, restart MySQL, and try again.\n"); + } + } + + # SQLite can't deal with the disconnect/reconnect + unless ($RT::DatabaseType eq 'SQLite') { + $dbh->disconnect; + $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) || die $DBI::errstr; + } print "Now populating database schema.\n"; insert_schema(); print "Now inserting database ACLs\n"; @@ -111,7 +152,7 @@ elsif ( $args{'action'} eq 'drop' ) { drop_db(); } elsif ( $args{'action'} eq 'insert' ) { - insert_data( $args{'datafile'} ); + insert_data( $args{'datafile'} || ($args{'datadir'}."/content")); } elsif ($args{'action'} eq 'acl') { $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) @@ -274,6 +315,10 @@ sub insert_acl { do $base_path . "/acl.mysql" || die "Couldn't find ACLS for mysql in " . $RT::EtcPath . "\n" . $@; } + elsif ( $RT::DatabaseType =~ /^Sybase$/i ) { + do $base_path . "/acl.Sybase" + || die "Couldn't find ACLS for Sybase in " . $RT::EtcPath . "\n" . $@; + } elsif ( $RT::DatabaseType =~ /^informix$/i ) { do $base_path . "/acl.Informix" || die "Couldn't find ACLS for Informix in " . $RT::EtcPath . "\n" . $@; @@ -336,7 +381,7 @@ sub insert_initial_data { #Put together a current user object so we can create a User object my $CurrentUser = new RT::CurrentUser(); - print "Checking for existing system user ($CurrentUser)..."; + print "Checking for existing system user..."; my $test_user = RT::User->new($CurrentUser); $test_user->Load('RT_System'); if ( $test_user->id ) { @@ -364,7 +409,7 @@ sub insert_initial_data { exit(1); } print "done.\n"; - $RT::Handle->Disconnect(); + $RT::Handle->Disconnect() unless ($RT::DatabaseType eq 'SQLite'); } @@ -563,7 +608,7 @@ sub insert_data { } print "done.\n"; } - $RT::Handle->Disconnect(); + $RT::Handle->Disconnect() unless ($RT::DatabaseType eq 'SQLite'); } diff --git a/rt/sbin/rt-test-dependencies.in b/rt/sbin/rt-test-dependencies.in index b4cb8c044..6eed51337 100644 --- a/rt/sbin/rt-test-dependencies.in +++ b/rt/sbin/rt-test-dependencies.in @@ -1,9 +1,15 @@ #!@PERL@ -# BEGIN LICENSE BLOCK +# {{{ BEGIN BPS TAGGED BLOCK # -# Copyright (c) 1996-2003 Jesse Vincent +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# # -# (Except where explictly superceded by other copyright notices) +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: # # This work is made available to you under the terms of Version 2 of # the GNU General Public License. A copy of that license should have @@ -15,14 +21,29 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # -# END LICENSE BLOCK - +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# }}} END BPS TAGGED BLOCK # # This is just a basic script that checks to make sure that all # the modules needed by RT before you can install it. @@ -34,7 +55,7 @@ use Getopt::Long; use CPAN; my %args; my %deps; -GetOptions(\%args,'install', 'with-MYSQL', 'with-POSTGRESQL|with-pg|with-pgsql', 'with-SQLITE', 'with-ORACLE', 'with-FASTCGI', 'with-SPEEDYCGI', 'with-MODPERL1', 'with-MODPERL2' ,'with-DEV'); +GetOptions(\%args, 'v|verbose', 'install', 'with-MYSQL', 'with-POSTGRESQL|with-pg|with-pgsql', 'with-SQLITE', 'with-ORACLE', 'with-FASTCGI', 'with-SPEEDYCGI', 'with-MODPERL1', 'with-MODPERL2' ,'with-DEV', 'download=s'); if (!keys %args) { help(); @@ -49,9 +70,6 @@ $args{'with-CORE'} = 1; $args{'with-DEV'} =1; $args{'with-CLI'} =1; $args{'with-MAILGATE'} =1; -if ($] < 5.007) { -$args{'with-I18N-COMPAT'} = 1; -} sub warn_modperl2 { print <<'.'; @@ -86,6 +104,9 @@ The following switches will tell the tool to check for specific dependencies --with-modperl2 Libraries needed to support the modperl 2 handler --with-dev Tools needed for RT development + +You can also specify -v or --verbose to list the status of all dependencies, +rather than just the missing ones. . } @@ -95,6 +116,7 @@ sub _ { } $deps{'CORE'} = [ _( << '.') ]; +Digest::base Digest::MD5 2.27 DBI 1.37 Test::Inline @@ -103,6 +125,7 @@ DBIx::SearchBuilder 1.01 Text::Template File::Spec 0.8 HTML::Entities +HTML::Scrubber 0.08 Net::Domain Log::Dispatch 2.0 Locale::Maketext 1.06 @@ -117,14 +140,16 @@ File::Temp Term::ReadKey Text::Autoformat Text::Quoted 1.3 +Tree::Simple 1.04 Scalar::Util +Module::Versions::Report . $deps{'MASON'} = [ _( << '.') ]; Params::Validate 0.02 Cache::Cache -Exception::Class -HTML::Mason 1.16 +Exception::Class 1.14 +HTML::Mason 1.23 MLDBM Errno FreezeThaw @@ -132,6 +157,7 @@ Digest::MD5 2.27 CGI::Cookie 1.20 Storable 2.08 Apache::Session 1.53 +XML::RSS . $deps{'MAILGATE'} = [ _( << '.') ]; @@ -149,6 +175,9 @@ $deps{'DEV'} = [ _( << '.') ]; Regexp::Common Time::HiRes Test::Inline +Apache::Test +HTML::Form +HTML::TokeParser WWW::Mechanize . @@ -175,11 +204,6 @@ CGI 2.92 Apache::DBI . -$deps{'I18N-COMPAT'} = [ _( << '.') ]; -Text::Iconv -Encode::compat 0.04 -. - $deps{'MYSQL'} = [ _( << '.') ]; DBD::mysql 2.1018 . @@ -190,67 +214,115 @@ $deps{'POSTGRESQL'} = [ _( << '.') ]; DBD::Pg . +$deps{'SQLITE'} = [ _( << '.') ]; +DBD::SQLite +. + +if ($args{'download'}) { + + my %modules; + + foreach my $key (keys %deps) { + my @deps = (@{$deps{$key}}); + while (@deps) { + my $mod = shift @deps; + my $ver = shift @deps; + next if ($mod =~ /^(DBD-|Apache-Request)/); + $modules{$mod} = $ver; + } + } + my @mods = keys %modules; + CPAN::get(); + my $moddir = $args{'download'}; + foreach my $mod (@mods) { + $CPAN::Config->{'build_dir'} = $moddir; + CPAN::get($mod); + } + + opendir(DIR, $moddir); + while ( my $dir = readdir(DIR)) { + print "Dir is $dir\n"; + next if ( $dir =~ /^\.\.?$/); + + if ($dir =~ /^(.*)-(.*?)$/) { + print "$1 -- $2\n"; + `svn_load_dirs.pl file:///Users/jesse/mod-repo $1 $moddir/$dir`; + `rm -rf $moddir/$dir`; + + } + + } + closedir(DIR); + exit; +} + + print "perl:\n"; print "\t5.8.3"; eval {require 5.008003}; if ($@) { -print "...MISSING.\n"; - eval {require 5.008000}; - if ($@) { - print "\nRT is known to be non-functional on versions of perl older than 5.8.3.\nPlease upgrade to 5.8.3 or newer\n\n"; - die; - } - - eval {require 5.008003}; - if ($@) { - print "\nRT is known to be non-functional on versions of perl older than 5.8.3.\nPlease upgrade to 5.8.3 or newer\n\n"; - } + print "...MISSING.\n"; + eval {require 5.008000}; + if ($@) { + print "\nRT is known to be non-functional on versions of perl older than 5.8.3.\nPlease upgrade to 5.8.3 or newer\n\n"; + die; + } + + eval {require 5.008003}; + if ($@) { + print "\nRT is known to be non-functional on versions of perl older than 5.8.3.\nPlease upgrade to 5.8.3 or newer\n\n"; + } } else { - print "...found\n"; - + print "...found\n" if $args{'v'}; } - -foreach my $type (keys %args) { -next unless ($type =~ /^with-(.*?)$/); -my $type = $1; -print "$type dependencies:\n"; - my @deps = (@{$deps{$type}}); - while (@deps) { - my $module = shift @deps; - my $version = shift @deps; -my $ret; - $ret =test_dep($module, $version); - -if ($args{'install'} && !$ret) { - resolve_dep($module); -} -} +print "users:\n"; +print "\trt group (@RTGROUP@)...", (defined getgrnam("@RTGROUP@") ? "found" : "MISSING"), "\n"; +print "\tbin owner (@BIN_OWNER@)...", (defined getpwnam("@BIN_OWNER@") ? "found" : "MISSING"), "\n"; +print "\tlibs owner (@LIBS_OWNER@)...", (defined getpwnam("@LIBS_OWNER@") ? "found" : "MISSING"), "\n"; +print "\tlibs group (@LIBS_GROUP@)...", (defined getgrnam("@LIBS_GROUP@") ? "found" : "MISSING"), "\n"; +print "\tweb owner (@WEB_USER@)...", (defined getpwnam("@WEB_USER@") ? "found" : "MISSING"), "\n"; +print "\tweb group (@WEB_GROUP@)...", (defined getgrnam("@WEB_GROUP@") ? "found" : "MISSING"), "\n"; + +foreach my $type (keys %args) { + next unless ($type =~ /^with-(.*?)$/); + my $type = $1; + print "$type dependencies:\n"; + my @deps = (@{$deps{$type}}); + while (@deps) { + my $module = shift @deps; + my $version = shift @deps; + my $ret = test_dep($module, $version); + + if ($args{'install'} && !$ret) { + resolve_dep($module); + } + } } + sub test_dep { - my $module = shift; - my $version = shift; - - print "\t$module $version"; - eval "use $module $version" ; - if ($@) { - my $error = $@; - $error =~ s/\n(.*)$//s; - print "...MISSING\n"; - print "\t\t$error\n" if $error =~ /this is only/; - - return undef; - } else { - print "...found\n"; -return 1; - } + my $module = shift; + my $version = shift; + + eval "use $module $version ()"; + if ($@) { + my $error = $@; + $error =~ s/\n(.*)$//s; + print "\t$module $version"; + print "...MISSING\n"; + print "\t\t$error\n" if $error =~ /this is only/; + + return undef; + } else { + print "\t$module $version...found\n" if $args{'v'}; + return 1; + } } sub resolve_dep { - my $module = shift; - use CPAN; - CPAN::Shell->install($module); - + my $module = shift; + use CPAN; + CPAN::Shell->install($module); } -- cgit v1.2.1 From e81cd66ea62231e89fbd30a95a0e5bdde2292eeb Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 3 Dec 2004 20:51:54 +0000 Subject: landing rt 3.2.2 --- rt/sbin/rt-setup-database.in | 77 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 16 deletions(-) (limited to 'rt/sbin') diff --git a/rt/sbin/rt-setup-database.in b/rt/sbin/rt-setup-database.in index 0b9a1071a..9d8fd2ee0 100644 --- a/rt/sbin/rt-setup-database.in +++ b/rt/sbin/rt-setup-database.in @@ -1,9 +1,15 @@ #!@PERL@ -w -# BEGIN LICENSE BLOCK +# {{{ BEGIN BPS TAGGED BLOCK # -# Copyright (c) 1996-2003 Jesse Vincent +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# # -# (Except where explictly superceded by other copyright notices) +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: # # This work is made available to you under the terms of Version 2 of # the GNU General Public License. A copy of that license should have @@ -15,14 +21,29 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # -# END LICENSE BLOCK - +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# }}} END BPS TAGGED BLOCK use strict; use vars qw($PROMPT $VERSION $Handle $Nobody $SystemUser $item); use vars @@ -87,10 +108,30 @@ if ( $args{'action'} eq 'init' ) { print "...skipped as ".$args{'dba'} ." is not " . $RT::DatabaseUser . " or we're working with Oracle.\n"; } - $dbh->disconnect; - $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) - || die $DBI::errstr; + if ($RT::DatabaseType eq "mysql") { + # Check which version we're running + my ($version) = $dbh->selectrow_hashref("show variables like 'version'")->{Value} =~ /^(\d\.\d+)/; + print "*** Warning: RT is unsupported on MySQL versions before 4.0.x\n" if $version < 4; + + # MySQL must have InnoDB support + my $innodb = $dbh->selectrow_hashref("show variables like 'have_innodb'")->{Value}; + if ($innodb eq "NO") { + die "RT requires that MySQL be compiled with InnoDB table support.\n". + "See http://dev.mysql.com/doc/mysql/en/InnoDB.html\n"; + } elsif ($innodb eq "DISABLED") { + die "RT requires that MySQL InnoDB table support be enabled.\n". + ($version < 4 + ? "Add 'innodb_data_file_path=ibdata1:10M:autoextend' to the [mysqld] section of my.cnf\n" + : "Remove the 'skip-innodb' line from your my.cnf file, restart MySQL, and try again.\n"); + } + } + + # SQLite can't deal with the disconnect/reconnect + unless ($RT::DatabaseType eq 'SQLite') { + $dbh->disconnect; + $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) || die $DBI::errstr; + } print "Now populating database schema.\n"; insert_schema(); print "Now inserting database ACLs\n"; @@ -114,7 +155,7 @@ elsif ( $args{'action'} eq 'insert_initial' ) { insert_initial_data(); } elsif ( $args{'action'} eq 'insert' ) { - insert_data( $args{'datafile'} ); + insert_data( $args{'datafile'} || ($args{'datadir'}."/content")); } elsif ($args{'action'} eq 'acl') { $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) @@ -277,6 +318,10 @@ sub insert_acl { do $base_path . "/acl.mysql" || die "Couldn't find ACLS for mysql in " . $RT::EtcPath . "\n" . $@; } + elsif ( $RT::DatabaseType =~ /^Sybase$/i ) { + do $base_path . "/acl.Sybase" + || die "Couldn't find ACLS for Sybase in " . $RT::EtcPath . "\n" . $@; + } elsif ( $RT::DatabaseType =~ /^informix$/i ) { do $base_path . "/acl.Informix" || die "Couldn't find ACLS for Informix in " . $RT::EtcPath . "\n" . $@; @@ -339,7 +384,7 @@ sub insert_initial_data { #Put together a current user object so we can create a User object my $CurrentUser = new RT::CurrentUser(); - print "Checking for existing system user ($CurrentUser)..."; + print "Checking for existing system user..."; my $test_user = RT::User->new($CurrentUser); $test_user->Load('RT_System'); if ( $test_user->id ) { @@ -367,7 +412,7 @@ sub insert_initial_data { exit(1); } print "done.\n"; - $RT::Handle->Disconnect(); + $RT::Handle->Disconnect() unless ($RT::DatabaseType eq 'SQLite'); } @@ -566,7 +611,7 @@ sub insert_data { } print "done.\n"; } - $RT::Handle->Disconnect(); + $RT::Handle->Disconnect() unless ($RT::DatabaseType eq 'SQLite'); } -- cgit v1.2.1 From d4d0590bef31071e8809ec046717444b95b3f30a Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 15 Oct 2005 09:11:20 +0000 Subject: import rt 3.4.4 --- rt/sbin/extract-message-catalog | 17 +-- rt/sbin/extract_pod_tests | 13 ++- rt/sbin/factory | 98 +++++++++++++---- rt/sbin/license_tag | 40 +++---- rt/sbin/regression_harness | 6 +- rt/sbin/rt-dump-database.in | 168 +++++++++++++++++++++++++++++ rt/sbin/rt-setup-database.in | 35 +++--- rt/sbin/rt-test-dependencies.in | 232 ++++++++++++++++++++++------------------ 8 files changed, 437 insertions(+), 172 deletions(-) create mode 100755 rt/sbin/rt-dump-database.in (limited to 'rt/sbin') diff --git a/rt/sbin/extract-message-catalog b/rt/sbin/extract-message-catalog index c5d4d8953..3552afb81 100644 --- a/rt/sbin/extract-message-catalog +++ b/rt/sbin/extract-message-catalog @@ -1,9 +1,9 @@ #!/usr/bin/perl -w -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -43,7 +43,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} # Portions Copyright 2002 Autrijus Tang use strict; @@ -98,7 +98,7 @@ sub extract_strings_from_code { local $/; return if ( -d $_ ); - return if ( $File::Find::dir =~ 'lib/blib|lib/t/autogen|var|m4|local' ); + return if ( $File::Find::dir =~ 'lib/blib|lib/t/autogen|var|m4|local|\.svn' ); return if ( /\.po$|\.bak$|~|,D|,B$|extract-message-catalog$/ ); return if ( /^[\.#]/ ); return if ( -f "$_.in" ); @@ -195,6 +195,7 @@ sub update { while (@lines) { my $msghdr = ""; $msghdr .= shift @lines while ( $lines[0] && $lines[0] !~ /^msgid/ ); + my $msgid = shift @lines; my $msgstr = ""; $msgstr .= shift @lines while ( $lines[0] && $lines[0] =~ /^(msgstr|")/ ); @@ -203,8 +204,8 @@ sub update { chomp $msgid; chomp $msgstr; - $msgid =~ s/^msgid "(.*)"$/$1/ or warn $msgid; - $msgstr =~ s/^msgstr "(.*)"$/$1/ms or warn $msgstr; + $msgid =~ s/^msgid "(.*)"\s*?$/$1/ms or warn "$msgid in $file"; + $msgstr =~ s/^msgstr "(.*)"\s*?$/$1/ms or warn "$msgstr in $file"; $Lexicon{$msgid} = $msgstr; $Header{$msgid} = $msghdr; @@ -229,6 +230,10 @@ sub update { my %seen; $out .= $Header{$_} if exists $Header{$_}; + + + + next if (!$f && $_ && !$Lexicon{$_}); if ( $f && $f !~ /^\s+$/ ) { $out .= "#: $f\n"; diff --git a/rt/sbin/extract_pod_tests b/rt/sbin/extract_pod_tests index 3987e90c7..4d9d7bd6c 100644 --- a/rt/sbin/extract_pod_tests +++ b/rt/sbin/extract_pod_tests @@ -1,9 +1,9 @@ #!/usr/bin/perl -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -43,7 +43,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} use strict; use vars qw($VERSION); $VERSION = '0.06'; @@ -121,7 +121,14 @@ else { } +print $outfh < # # (Except where explicitly superseded by other copyright notices) @@ -43,7 +43,8 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} +use strict; use DBI; my $database = shift; @@ -59,11 +60,17 @@ my $password = ''; my $LicenseBlock = << '.'; -# BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# # -# Copyright (c) 1996-2003 Jesse Vincent +# (Except where explicitly superseded by other copyright notices) # -# (Except where explictly superceded by other copyright notices) +# +# LICENSE: # # This work is made available to you under the terms of Version 2 of # the GNU General Public License. A copy of that license should have @@ -75,14 +82,29 @@ my $LicenseBlock = << '.'; # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # -# END BPS TAGGED BLOCK - +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} . my $Attribution = << '.'; @@ -126,6 +148,7 @@ foreach my $table (@tables) { $tablemap{'CreatedBy'} = 'User'; $tablemap{'UpdatedBy'} = 'User'; +my %typemap; $typemap{'id'} = 'ro'; $typemap{'Creator'} = 'auto'; $typemap{'Created'} = 'auto'; @@ -162,7 +185,27 @@ foreach my $table (@tables) { my $ClassAccessible = ""; my $FieldsPod = ""; my $CreatePod = ""; + my $RecordInit = ""; my %fields; + + + my $introspection = $dbh->prepare("SELECT * from $table where id is null"); + $introspection->execute(); + my @names =@{ $introspection->{'NAME'}}; + my @types = @{$introspection->{'TYPE'}}; + my @is_blob = @{$introspection->{'mysql_is_blob'}}; + my @is_num = @{$introspection->{'mysql_is_num'}}; + + my %blobness = (); + my %sqltypes = (); + my %numeric = (); + foreach my $name (@names) { + $sqltypes{$name} = shift @types; + $blobness{$name} = (shift @is_blob || "0"); + $numeric{$name} = (shift @is_num || "0"); + } + + my $sth = $dbh->prepare("DESCRIBE $table"); $sth->execute; @@ -170,10 +213,16 @@ foreach my $table (@tables) { my $field = $row->{'Field'}; my $type = $row->{'Type'}; my $default = $row->{'Default'}; + my $length = 0; + if ($type =~ /^(?:.*?)\((\d+)\)$/) { + $length = $1; + } $fields{$field} = 1; #generate the 'accessible' datastructure + no warnings 'uninitialized'; + if ( $typemap{$field} eq 'auto' ) { $ClassAccessible .= " $field => {read => 1, auto => 1,"; @@ -187,7 +236,7 @@ foreach my $table (@tables) { {read => 1, write => 1,"; } - + $ClassAccessible .= " sql_type => $sqltypes{$field}, length => $length, is_blob => $blobness{$field}, is_numeric => $numeric{$field}, "; $ClassAccessible .= " type => '$type', default => '$default'},\n"; #generate pod for the accessible fields @@ -199,7 +248,7 @@ Returns the current value of $field. "; - unless ( $typemap{$field} eq 'auto' || $typemap{$field} eq 'ro' ) { + unless ( exists $typemap{$field} && ( $typemap{$field} eq 'auto' || $typemap{$field} eq 'ro' )) { $FieldsPod .= " =head2 Set$field VALUE @@ -254,7 +303,7 @@ sub ${field}Obj { } - $Create = " + my $Create = " sub Create { my \$self = shift; my \%args = ( @@ -306,10 +355,15 @@ sub _Init { $CollectionClass .= " - # By default, order by name - \$self->OrderBy( ALIAS => 'main', - FIELD => 'SortOrder', - ORDER => 'ASC'); + # By default, order by SortOrder + \$self->OrderByCols( + { ALIAS => 'main', + FIELD => 'SortOrder', + ORDER => 'ASC' }, + { ALIAS => 'main', + FIELD => 'id', + ORDER => 'ASC' }, + ); "; } $CollectionClass .= " @@ -397,7 +451,7 @@ $ClassAccessible open( COL, ">$CollectionClassPath" ); print COL $CollectionClass; - close($COL); + close(COL); } @@ -438,7 +492,7 @@ _Vendor is for 3rd-party vendor add-ons, while _Local is for site-local customiz These overlay files can contain new subs or subs to replace existing subs in this module. -If you'll be working with perl 5.6.0 or greater, each of these files should begin with the line +Each of these files should begin with the line no warnings qw(redefine); diff --git a/rt/sbin/license_tag b/rt/sbin/license_tag index cd1a9716f..906d34924 100644 --- a/rt/sbin/license_tag +++ b/rt/sbin/license_tag @@ -1,11 +1,11 @@ #!/usr/bin/perl -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -45,12 +45,12 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} my $LICENSE = <<'EOL'; COPYRIGHT: -This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC (Except where explicitly superseded by other copyright notices) @@ -116,16 +116,16 @@ sub tag_mason { print "$pm - "; - if ($file =~ /^%# {{{ BEGIN BPS TAGGED BLOCK/ms) { + if ($file =~ /^%# BEGIN BPS TAGGED BLOCK {{{/ms) { print "has license section"; - $file =~ s/^%# {{{ BEGIN BPS TAGGED BLOCK(.*?)%# }}} END BPS TAGGED BLOCK/%# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic%# }}} END BPS TAGGED BLOCK/ms; + $file =~ s/^%# BEGIN BPS TAGGED BLOCK {{{(.*?)%# END BPS TAGGED BLOCK }}}/%# BEGIN BPS TAGGED BLOCK {{{\n$pmlic%# END BPS TAGGED BLOCK }}}/ms; } else { print "no license section"; - $file ="%# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic%# }}} END BPS TAGGED BLOCK\n". $file; + $file ="%# BEGIN BPS TAGGED BLOCK {{{\n$pmlic%# END BPS TAGGED BLOCK }}}\n". $file; } - $file =~ s/%# }}} END BPS TAGGED BLOCK(\n+)/%# }}} END BPS TAGGED BLOCK\n/mg; + $file =~ s/%# END BPS TAGGED BLOCK }}}(\n+)/%# END BPS TAGGED BLOCK }}}\n/mg; print "\n"; @@ -148,16 +148,16 @@ sub tag_makefile { print "$pm - "; - if ($file =~ /^# {{{ BEGIN BPS TAGGED BLOCK/ms) { + if ($file =~ /^# BEGIN BPS TAGGED BLOCK {{{/ms) { print "has license section"; - $file =~ s/^# {{{ BEGIN BPS TAGGED BLOCK(.*?)# }}} END BPS TAGGED BLOCK/# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic# }}} END BPS TAGGED BLOCK/ms; + $file =~ s/^# BEGIN BPS TAGGED BLOCK {{{(.*?)# END BPS TAGGED BLOCK }}}/# BEGIN BPS TAGGED BLOCK {{{\n$pmlic# END BPS TAGGED BLOCK }}}/ms; } else { print "no license section"; - $file ="# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic# }}} END BPS TAGGED BLOCK\n". $file; + $file ="# BEGIN BPS TAGGED BLOCK {{{\n$pmlic# END BPS TAGGED BLOCK }}}\n". $file; } - $file =~ s/# }}} END BPS TAGGED BLOCK(\n+)/# }}} END BPS TAGGED BLOCK\n/mg; + $file =~ s/# END BPS TAGGED BLOCK }}}(\n+)/# END BPS TAGGED BLOCK }}}\n/mg; print "\n"; @@ -181,16 +181,16 @@ sub tag_pm { print "$pm - "; - if ($file =~ /^# {{{ BEGIN BPS TAGGED BLOCK/ms) { + if ($file =~ /^# BEGIN BPS TAGGED BLOCK {{{/ms) { print "has license section"; - $file =~ s/^# {{{ BEGIN BPS TAGGED BLOCK(.*?)# }}} END BPS TAGGED BLOCK/# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic# }}} END BPS TAGGED BLOCK/ms; + $file =~ s/^# BEGIN BPS TAGGED BLOCK {{{(.*?)# END BPS TAGGED BLOCK }}}/# BEGIN BPS TAGGED BLOCK {{{\n$pmlic# END BPS TAGGED BLOCK }}}/ms; } else { print "no license section"; - $file ="# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic# }}} END BPS TAGGED BLOCK\n". $file; + $file ="# BEGIN BPS TAGGED BLOCK {{{\n$pmlic# END BPS TAGGED BLOCK }}}\n". $file; } - $file =~ s/# }}} END BPS TAGGED BLOCK(\n+)/# }}} END BPS TAGGED BLOCK\n/mg; + $file =~ s/# END BPS TAGGED BLOCK }}}(\n+)/# END BPS TAGGED BLOCK }}}\n/mg; print "\n"; @@ -213,21 +213,21 @@ sub tag_script { $pmlic =~ s/^/# /msg; print "$pm - "; - if ($file =~ /^# {{{ BEGIN BPS TAGGED BLOCK/ms) { + if ($file =~ /^# BEGIN BPS TAGGED BLOCK {{{/ms) { print "has license section"; - $file =~ s/^# {{{ BEGIN BPS TAGGED BLOCK(.*?)# }}} END BPS TAGGED BLOCK/# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic# }}} END BPS TAGGED BLOCK/ms; + $file =~ s/^# BEGIN BPS TAGGED BLOCK {{{(.*?)# END BPS TAGGED BLOCK }}}/# BEGIN BPS TAGGED BLOCK {{{\n$pmlic# END BPS TAGGED BLOCK }}}/ms; } else { print "no license section"; if ($file =~ /^(#!.*?)\n/) { - my $lic ="# {{{ BEGIN BPS TAGGED BLOCK\n$pmlic# }}} END BPS TAGGED BLOCK\n"; + my $lic ="# BEGIN BPS TAGGED BLOCK {{{\n$pmlic# END BPS TAGGED BLOCK }}}\n"; $file =~ s/^(#!.*?)\n/$1\n$lic/; } } - $file =~ s/# }}} END BPS TAGGED BLOCK(\n+)/# }}} END BPS TAGGED BLOCK\n/mg; + $file =~ s/# END BPS TAGGED BLOCK }}}(\n+)/# END BPS TAGGED BLOCK }}}\n/mg; print "\n"; diff --git a/rt/sbin/regression_harness b/rt/sbin/regression_harness index c10779614..d98e462c7 100644 --- a/rt/sbin/regression_harness +++ b/rt/sbin/regression_harness @@ -1,9 +1,9 @@ #!/usr/bin/perl -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -43,7 +43,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} open (FH,"make regression|"); my $skip_frontmatter = 1; diff --git a/rt/sbin/rt-dump-database.in b/rt/sbin/rt-dump-database.in new file mode 100755 index 000000000..bcc7bb713 --- /dev/null +++ b/rt/sbin/rt-dump-database.in @@ -0,0 +1,168 @@ +#!@PERL@ -w +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +# +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} +use strict; +use lib "@RT_LIB_PATH@"; +use RT; +use XML::Simple; + +RT::LoadConfig(); +RT::Init(); + +my $LocalOnly = @ARGV ? shift(@ARGV) : 1; + +my %RV; +my %Ignore = ( + All => [qw( + id Created Creator LastUpdated LastUpdatedBy + )], + Templates => [qw( + TranslationOf + )], +); + +my $SystemUserId = $RT::SystemUser->Id; +my @classes = qw( + Users Groups Queues ScripActions ScripConditions + Templates Scrips ACL CustomFields +); +foreach my $class (@classes) { + require "RT/$class.pm"; + my $objects = "RT::$class"->new($RT::SystemUser); + $objects->{find_disabled_rows} = 1; + $objects->UnLimit; + + if ($class eq 'CustomFields') { + $objects->OrderByCols( + { FIELD => 'LookupType' }, + { FIELD => 'SortOrder' }, + { FIELD => 'Id' }, + ); + } + else { + $objects->OrderBy( FIELD => 'Id' ); + } + + if ($LocalOnly) { + next if $class eq 'ACL'; # XXX - would go into infinite loop - XXX + $objects->Limit( FIELD => 'LastUpdatedBy', OPERATOR => '!=', VALUE => $SystemUserId ) + unless $class eq 'Groups'; + $objects->Limit( FIELD => 'Id', OPERATOR => '!=', VALUE => $SystemUserId ) + if $class eq 'Users'; + $objects->Limit( FIELD => 'Domain', OPERATOR => '=', VALUE => 'UserDefined' ) + if $class eq 'Groups'; + } + + my %fields; + while (my $obj = $objects->Next) { + next if $obj->can('LastUpdatedBy') and $obj->LastUpdatedBy == $SystemUserId; + + if (!%fields) { + %fields = map { $_ => 1 } keys %{$obj->_ClassAccessible}; + delete @fields{ + @{$Ignore{$class}||=[]}, + @{$Ignore{All}||=[]}, + }; + } + + my $rv; + # next if $obj-> # skip default names + foreach my $field (sort keys %fields) { + my $value = $obj->__Value($field); + $rv->{$field} = $value if length($value); + } + delete $rv->{Disabled} unless $rv->{Disabled}; + + foreach my $record (map { /ACL/ ? 'ACE' : substr($_, 0, -1) } @classes) { + foreach my $key (map "$record$_", ('', 'Id')) { + next unless exists $rv->{$key}; + my $id = $rv->{$key} or next; + my $obj = "RT::$record"->new($RT::SystemUser); + $obj->LoadByCols( Id => $id ) or next; + $rv->{$key} = $obj->__Value('Name') || 0; + } + } + + if ($class eq 'Users' and defined $obj->Privileged) { + $rv->{Privileged} = int($obj->Privileged); + } + elsif ($class eq 'CustomFields') { + my $values = $obj->Values; + while (my $value = $values->Next) { + push @{$rv->{Values}}, { + map { ($_ => $value->__Value($_)) } qw( + Name Description SortOrder + ), + }; + } + } + + if (eval { require RT::Attributes; 1 }) { + my $attributes = $obj->Attributes; + while (my $attribute = $attributes->Next) { + my $content = $attribute->Content; + $rv->{Attributes}{$attribute->Name} = $content if length($content); + } + } + + push @{$RV{$class}}, $rv; + } +} + +print(<< "."); +no strict; use XML::Simple; *_ = XMLin(do { local \$/; readline(DATA) }, ForceArray => [qw( + @classes Values +)], NoAttr => 1, SuppressEmpty => ''); *\$_ = (\$_{\$_} || []) for keys \%_; 1; # vim: ft=xml +__DATA__ +. + +print XMLout( + { map { ($_ => ($RV{$_} || [])) } @classes }, + RootName => 'InitialData', + NoAttr => 1, + SuppressEmpty => '', + XMLDecl => '', +); diff --git a/rt/sbin/rt-setup-database.in b/rt/sbin/rt-setup-database.in index e83aa262b..01c7b3cf1 100644 --- a/rt/sbin/rt-setup-database.in +++ b/rt/sbin/rt-setup-database.in @@ -1,9 +1,9 @@ #!@PERL@ -w -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -43,7 +43,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} use strict; use vars qw($PROMPT $VERSION $Handle $Nobody $SystemUser $item); use vars @@ -196,6 +196,7 @@ sub insert_schema { local $SIG{__WARN__} = sub {}; my $is_local = 0; # local/etc/schema needs to be nonfatal. + $dbh->begin_work or die $dbh->errstr; foreach my $statement (@schema) { if ($statement =~ /^\s*;$/) { $is_local = 1; next; } print STDERR "SQL: $statement\n" if defined $args{'debug'}; @@ -204,12 +205,13 @@ sub insert_schema { die "Problem with statement:\n $statement\n" . $sth->errstr; } } + $dbh->commit or die $dbh->errstr; } else { die "Couldn't find schema file for " . $RT::DatabaseType . "\n"; } - print "schema sucessfully inserted\n"; + print "Done setting up database schema.\n"; } @@ -217,7 +219,6 @@ sub insert_schema { # {{{ sub drop_db sub drop_db { - return if ( $RT::DatabaseType eq 'SQLite' ); if ( $RT::DatabaseType eq 'Oracle' ) { print <do("Drop DATABASE $RT::DatabaseName") or warn $DBI::errstr; } @@ -273,20 +278,19 @@ sub create_db { # }}} sub get_dba_password { - print -"In order to create a new database and grant RT access to that database,\n"; + print "In order to create or update your RT database,"; print "this script needs to connect to your " . $RT::DatabaseType . " instance on " . $RT::DatabaseHost . " as " . $args{'dba'} . ".\n"; - print -"Please specify that user's database password below. If the user has no database\n"; + print "Please specify that user's database password below. If the user has no database\n"; print "password, just press return.\n\n"; print "Password: "; ReadMode('noecho'); my $password = ReadLine(0); ReadMode('normal'); + print "\n"; return ($password); } @@ -313,15 +317,15 @@ sub insert_acl { } elsif ( $RT::DatabaseType =~ /^mysql$/i ) { do $base_path . "/acl.mysql" - || die "Couldn't find ACLS for mysql in " . $RT::EtcPath . "\n" . $@; + || die "Couldn't find ACLS for mysql in $base_path\n" . $@; } elsif ( $RT::DatabaseType =~ /^Sybase$/i ) { do $base_path . "/acl.Sybase" - || die "Couldn't find ACLS for Sybase in " . $RT::EtcPath . "\n" . $@; + || die "Couldn't find ACLS for Sybase in $base_path\n" . $@; } elsif ( $RT::DatabaseType =~ /^informix$/i ) { do $base_path . "/acl.Informix" - || die "Couldn't find ACLS for Informix in " . $RT::EtcPath . "\n" . $@; + || die "Couldn't find ACLS for Informix in $base_path\n" . $@; } elsif ( $RT::DatabaseType =~ /^SQLite$/i ) { return; @@ -338,6 +342,7 @@ sub insert_acl { die "Problem with statement:\n $statement\n" . $sth->errstr; } } + print "Done setting up database ACLs.\n"; } # }}} @@ -402,7 +407,8 @@ sub insert_initial_data { RealName => 'The RT System itself', Comments => 'Do not delete or modify this user. It is integral to RT\'s internal database structures', - Creator => '1' ); + Creator => '1', + LastUpdatedBy => '1' ); unless ($val) { print "$msg\n"; @@ -436,6 +442,7 @@ sub insert_data { ObjectType => 'RT::System', ObjectId => '1' ); + print "done.\n"; } # Slurp in stuff to insert from the datafile. Possible things to go in here:- @@ -609,7 +616,7 @@ sub insert_data { print "done.\n"; } $RT::Handle->Disconnect() unless ($RT::DatabaseType eq 'SQLite'); - + print "Done setting up database content.\n"; } =head2 ACLEquivGroupId diff --git a/rt/sbin/rt-test-dependencies.in b/rt/sbin/rt-test-dependencies.in index 6eed51337..f79e4e5c2 100644 --- a/rt/sbin/rt-test-dependencies.in +++ b/rt/sbin/rt-test-dependencies.in @@ -1,9 +1,9 @@ #!@PERL@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -43,7 +43,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} # # This is just a basic script that checks to make sure that all # the modules needed by RT before you can install it. @@ -52,36 +52,68 @@ use strict; no warnings qw(numeric redefine); use Getopt::Long; -use CPAN; my %args; my %deps; -GetOptions(\%args, 'v|verbose', 'install', 'with-MYSQL', 'with-POSTGRESQL|with-pg|with-pgsql', 'with-SQLITE', 'with-ORACLE', 'with-FASTCGI', 'with-SPEEDYCGI', 'with-MODPERL1', 'with-MODPERL2' ,'with-DEV', 'download=s'); - -if (!keys %args) { +GetOptions( + \%args, 'v|verbose', + 'install', 'with-MYSQL', + 'with-POSTGRESQL|with-pg|with-pgsql', 'with-SQLITE', + 'with-ORACLE', 'with-FASTCGI', + 'with-SPEEDYCGI', 'with-MODPERL1', + 'with-MODPERL2', 'with-DEV', + 'download=s', + 'repository=s' +); + +unless (keys %args) { help(); exit(0); } -if ($args{'with-MODPERL2'}) { - warn_modperl2(); -} +# Set up defaults $args{'with-MASON'} = 1; $args{'with-CORE'} = 1; $args{'with-DEV'} =1; $args{'with-CLI'} =1; $args{'with-MAILGATE'} =1; +{ + my $section; + my %always_show_sections = ( + perl => 1, + users => 1, + ); + + sub section { + my $s = shift; + $section = $s; + print "$s:\n"; + } + + my $any_missing = 0; + sub found { + my $msg = shift; + my $test = shift; + my $extra = shift; + + $any_missing = 1 unless $test; + if ($args{'v'} or not $test or $always_show_sections{$section}) { + print "\t$msg..."; + print $test ? "found" : "MISSING"; + print "\n"; + } + + print "\t\t$extra\n" if defined $extra; + } -sub warn_modperl2 { - print <<'.'; - NOTE: mod_perl 2.0 isn't quite ready for prime_time just yet; - Best Practical Solutions strongly recommends that sites use - Apache 1.3 or FastCGI. If you MUST use mod_perl 2.0 (or 1.99), - please read the mailing list archives before asking for help. -. - sleep 5; + sub conclude { + if ($any_missing) { + print "\nSOMETHING WAS MISSING!\n"; + } else { + print "\nEverything was found.\n"; + } + } } - sub help { print <<'.'; @@ -121,7 +153,7 @@ Digest::MD5 2.27 DBI 1.37 Test::Inline Class::ReturnValue 0.40 -DBIx::SearchBuilder 1.01 +DBIx::SearchBuilder 1.26 Text::Template File::Spec 0.8 HTML::Entities @@ -136,6 +168,7 @@ Mail::Mailer 1.57 Net::SMTP Text::Wrapper Time::ParseDate +Time::HiRes File::Temp Term::ReadKey Text::Autoformat @@ -143,6 +176,8 @@ Text::Quoted 1.3 Tree::Simple 1.04 Scalar::Util Module::Versions::Report +Cache::Simple::TimedExpiry +XML::Simple . $deps{'MASON'} = [ _( << '.') ]; @@ -157,7 +192,10 @@ Digest::MD5 2.27 CGI::Cookie 1.20 Storable 2.08 Apache::Session 1.53 -XML::RSS +XML::RSS 1.05 +HTTP::Server::Simple 0.07 +HTTP::Server::Simple::Mason 0.09 +Text::WikiFormat . $deps{'MAILGATE'} = [ _( << '.') ]; @@ -173,12 +211,13 @@ Getopt::Long 2.24 $deps{'DEV'} = [ _( << '.') ]; Regexp::Common -Time::HiRes Test::Inline Apache::Test HTML::Form HTML::TokeParser WWW::Mechanize +Test::WWW::Mechanize +Module::Refresh 0.03 . $deps{'FASTCGI'} = [ _( << '.') ]; @@ -202,6 +241,7 @@ Apache::DBI 0.92 $deps{'MODPERL2'} = [ _( << '.') ]; CGI 2.92 Apache::DBI +HTML::Mason 1.31 . $deps{'MYSQL'} = [ _( << '.') ]; @@ -211,7 +251,7 @@ $deps{'ORACLE'} = [ _( << '.') ]; DBD::Oracle . $deps{'POSTGRESQL'} = [ _( << '.') ]; -DBD::Pg +DBD::Pg 1.41 . $deps{'SQLITE'} = [ _( << '.') ]; @@ -220,74 +260,19 @@ DBD::SQLite if ($args{'download'}) { - my %modules; - - foreach my $key (keys %deps) { - my @deps = (@{$deps{$key}}); - while (@deps) { - my $mod = shift @deps; - my $ver = shift @deps; - next if ($mod =~ /^(DBD-|Apache-Request)/); - $modules{$mod} = $ver; - } - } - my @mods = keys %modules; - CPAN::get(); - my $moddir = $args{'download'}; - foreach my $mod (@mods) { - $CPAN::Config->{'build_dir'} = $moddir; - CPAN::get($mod); - } - - opendir(DIR, $moddir); - while ( my $dir = readdir(DIR)) { - print "Dir is $dir\n"; - next if ( $dir =~ /^\.\.?$/); - - if ($dir =~ /^(.*)-(.*?)$/) { - print "$1 -- $2\n"; - `svn_load_dirs.pl file:///Users/jesse/mod-repo $1 $moddir/$dir`; - `rm -rf $moddir/$dir`; - - } - - } - closedir(DIR); - exit; + download_mods(); } -print "perl:\n"; -print "\t5.8.3"; -eval {require 5.008003}; -if ($@) { - print "...MISSING.\n"; - eval {require 5.008000}; - if ($@) { - print "\nRT is known to be non-functional on versions of perl older than 5.8.3.\nPlease upgrade to 5.8.3 or newer\n\n"; - die; - } +check_perl_version(); - eval {require 5.008003}; - if ($@) { - print "\nRT is known to be non-functional on versions of perl older than 5.8.3.\nPlease upgrade to 5.8.3 or newer\n\n"; - } -} else { - print "...found\n" if $args{'v'}; -} +check_users(); -print "users:\n"; -print "\trt group (@RTGROUP@)...", (defined getgrnam("@RTGROUP@") ? "found" : "MISSING"), "\n"; -print "\tbin owner (@BIN_OWNER@)...", (defined getpwnam("@BIN_OWNER@") ? "found" : "MISSING"), "\n"; -print "\tlibs owner (@LIBS_OWNER@)...", (defined getpwnam("@LIBS_OWNER@") ? "found" : "MISSING"), "\n"; -print "\tlibs group (@LIBS_GROUP@)...", (defined getgrnam("@LIBS_GROUP@") ? "found" : "MISSING"), "\n"; -print "\tweb owner (@WEB_USER@)...", (defined getpwnam("@WEB_USER@") ? "found" : "MISSING"), "\n"; -print "\tweb group (@WEB_GROUP@)...", (defined getgrnam("@WEB_GROUP@") ? "found" : "MISSING"), "\n"; foreach my $type (keys %args) { next unless ($type =~ /^with-(.*?)$/); my $type = $1; - print "$type dependencies:\n"; + section("$type dependencies"); my @deps = (@{$deps{$type}}); while (@deps) { my $module = shift @deps; @@ -300,6 +285,8 @@ foreach my $type (keys %args) { } } +conclude(); + sub test_dep { my $module = shift; my $version = shift; @@ -308,46 +295,83 @@ sub test_dep { if ($@) { my $error = $@; $error =~ s/\n(.*)$//s; - print "\t$module $version"; - print "...MISSING\n"; - print "\t\t$error\n" if $error =~ /this is only/; + undef $error unless $error =~ /this is only/; + found("$module $version", 0, $error); return undef; } else { - print "\t$module $version...found\n" if $args{'v'}; + found("$module $version", 1); return 1; } } sub resolve_dep { my $module = shift; - use CPAN; - CPAN::Shell->install($module); + system( qq[@PERL@ -MCPAN -e'install("$module")'] ); } +sub download_mods { + my %modules; + use CPAN; + + foreach my $key (keys %deps) { + my @deps = (@{$deps{$key}}); + while (@deps) { + my $mod = shift @deps; + my $ver = shift @deps; + next if ($mod =~ /^(DBD-|Apache-Request)/); + $modules{$mod} = $ver; + } + } + my @mods = keys %modules; + CPAN::get(); + my $moddir = $args{'download'}; + foreach my $mod (@mods) { + $CPAN::Config->{'build_dir'} = $moddir; + CPAN::get($mod); + } -sub print_help { - print << "EOF"; - -$0 FLAG DBTYPE + opendir(DIR, $moddir); + while ( my $dir = readdir(DIR)) { + print "Dir is $dir\n"; + next if ( $dir =~ /^\.\.?$/); + # Skip things we've previously tagged + my $out = `svn ls $args{'repository'}/tags/$dir`; + next if ($out); -$0 is a tool for RT that will tell you if you've got all -the modules RT depends on properly installed. + if ($dir =~ /^(.*)-(.*?)$/) { + `svn_load_dirs -no_user_input -t tags/$dir -v $args{'repository'} dists/$1 $moddir/$dir`; + `rm -rf $moddir/$dir`; -Flags: (only one flag is valid for a given run) + } --quiet will check to see if we've got everything we need - and will exit with a return code of (1) if we don't. + } + closedir(DIR); + exit; +} --warn will tell you what isn't properly installed +sub check_perl_version { + section("perl"); + eval {require 5.008003}; + if ($@) { + found("5.8.3", 0, "RT is known to be non-functional on versions of perl older than 5.8.3. Please upgrade to 5.8.3 or newer."); + die; + } else { + found("5.8.3", 1); + } +} --fix will use CPANPLUS.pm or CPAN.pm to magically make everything better +sub check_users { + section("users"); + found("rt group (@RTGROUP@)", defined getgrnam("@RTGROUP@")); + found("bin owner (@BIN_OWNER@)", defined getpwnam("@BIN_OWNER@")); + found("libs owner (@LIBS_OWNER@)", defined getpwnam("@LIBS_OWNER@")); + found("libs group (@LIBS_GROUP@)", defined getgrnam("@LIBS_GROUP@")); + found("web owner (@WEB_USER@)", defined getpwnam("@WEB_USER@")); + found("web group (@WEB_GROUP@)", defined getgrnam("@WEB_GROUP@")); +} -DBTYPE is one of: - oracle, pg, mysql -EOF - exit(0); -} +1; -- cgit v1.2.1 From 6863b061a7740eed16903f01dae6b46521e9ca7b Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 15 Oct 2005 09:33:53 +0000 Subject: landing rt 3.4.4 on HEAD --- rt/sbin/rt-setup-database.in | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'rt/sbin') diff --git a/rt/sbin/rt-setup-database.in b/rt/sbin/rt-setup-database.in index 9d8fd2ee0..49feba845 100644 --- a/rt/sbin/rt-setup-database.in +++ b/rt/sbin/rt-setup-database.in @@ -1,9 +1,9 @@ #!@PERL@ -w -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -43,7 +43,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} use strict; use vars qw($PROMPT $VERSION $Handle $Nobody $SystemUser $item); use vars @@ -199,6 +199,7 @@ sub insert_schema { local $SIG{__WARN__} = sub {}; my $is_local = 0; # local/etc/schema needs to be nonfatal. + $dbh->begin_work or die $dbh->errstr; foreach my $statement (@schema) { if ($statement =~ /^\s*;$/) { $is_local = 1; next; } print STDERR "SQL: $statement\n" if defined $args{'debug'}; @@ -207,12 +208,13 @@ sub insert_schema { die "Problem with statement:\n $statement\n" . $sth->errstr; } } + $dbh->commit or die $dbh->errstr; } else { die "Couldn't find schema file for " . $RT::DatabaseType . "\n"; } - print "schema sucessfully inserted\n"; + print "Done setting up database schema.\n"; } @@ -220,7 +222,6 @@ sub insert_schema { # {{{ sub drop_db sub drop_db { - return if ( $RT::DatabaseType eq 'SQLite' ); if ( $RT::DatabaseType eq 'Oracle' ) { print <do("Drop DATABASE $RT::DatabaseName") or warn $DBI::errstr; } @@ -276,20 +281,19 @@ sub create_db { # }}} sub get_dba_password { - print -"In order to create a new database and grant RT access to that database,\n"; + print "In order to create or update your RT database,"; print "this script needs to connect to your " . $RT::DatabaseType . " instance on " . $RT::DatabaseHost . " as " . $args{'dba'} . ".\n"; - print -"Please specify that user's database password below. If the user has no database\n"; + print "Please specify that user's database password below. If the user has no database\n"; print "password, just press return.\n\n"; print "Password: "; ReadMode('noecho'); my $password = ReadLine(0); ReadMode('normal'); + print "\n"; return ($password); } @@ -316,15 +320,15 @@ sub insert_acl { } elsif ( $RT::DatabaseType =~ /^mysql$/i ) { do $base_path . "/acl.mysql" - || die "Couldn't find ACLS for mysql in " . $RT::EtcPath . "\n" . $@; + || die "Couldn't find ACLS for mysql in $base_path\n" . $@; } elsif ( $RT::DatabaseType =~ /^Sybase$/i ) { do $base_path . "/acl.Sybase" - || die "Couldn't find ACLS for Sybase in " . $RT::EtcPath . "\n" . $@; + || die "Couldn't find ACLS for Sybase in $base_path\n" . $@; } elsif ( $RT::DatabaseType =~ /^informix$/i ) { do $base_path . "/acl.Informix" - || die "Couldn't find ACLS for Informix in " . $RT::EtcPath . "\n" . $@; + || die "Couldn't find ACLS for Informix in $base_path\n" . $@; } elsif ( $RT::DatabaseType =~ /^SQLite$/i ) { return; @@ -341,6 +345,7 @@ sub insert_acl { die "Problem with statement:\n $statement\n" . $sth->errstr; } } + print "Done setting up database ACLs.\n"; } # }}} @@ -405,7 +410,8 @@ sub insert_initial_data { RealName => 'The RT System itself', Comments => 'Do not delete or modify this user. It is integral to RT\'s internal database structures', - Creator => '1' ); + Creator => '1', + LastUpdatedBy => '1' ); unless ($val) { print "$msg\n"; @@ -439,6 +445,7 @@ sub insert_data { ObjectType => 'RT::System', ObjectId => '1' ); + print "done.\n"; } # Slurp in stuff to insert from the datafile. Possible things to go in here:- @@ -612,7 +619,7 @@ sub insert_data { print "done.\n"; } $RT::Handle->Disconnect() unless ($RT::DatabaseType eq 'SQLite'); - + print "Done setting up database content.\n"; } =head2 ACLEquivGroupId -- cgit v1.2.1