diff options
author | ivan <ivan> | 2005-10-15 09:11:20 +0000 |
---|---|---|
committer | ivan <ivan> | 2005-10-15 09:11:20 +0000 |
commit | d4d0590bef31071e8809ec046717444b95b3f30a (patch) | |
tree | ee1236da50578390d2642114f28eaed99a5efb18 /rt/sbin | |
parent | d39d52aac8f38ea9115628039f0df5aa3ac826de (diff) |
import rt 3.4.4
Diffstat (limited to 'rt/sbin')
-rw-r--r-- | rt/sbin/extract-message-catalog | 17 | ||||
-rw-r--r-- | rt/sbin/extract_pod_tests | 13 | ||||
-rw-r--r-- | rt/sbin/factory | 98 | ||||
-rw-r--r-- | rt/sbin/license_tag | 40 | ||||
-rw-r--r-- | rt/sbin/regression_harness | 6 | ||||
-rwxr-xr-x | rt/sbin/rt-dump-database.in | 168 | ||||
-rw-r--r-- | rt/sbin/rt-setup-database.in | 35 | ||||
-rw-r--r-- | rt/sbin/rt-test-dependencies.in | 232 |
8 files changed, 437 insertions, 172 deletions
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 # <jesse@bestpractical.com> # # (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 <autrijus@autrijus.org> 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 # <jesse@bestpractical.com> # # (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 <<EOF; +use Test::More qw/no_plan/; +use RT; +RT::LoadConfig(); +RT::Init(); + +EOF foreach my $test (@tests, @examples) { print $outfh "$test\n"; } diff --git a/rt/sbin/factory b/rt/sbin/factory index 882e4a826..743d8b90e 100644 --- a/rt/sbin/factory +++ b/rt/sbin/factory @@ -1,9 +1,9 @@ -#!/usr/bin/perl -# {{{ BEGIN BPS TAGGED BLOCK +#!/usr/bin/perl -w +# 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 # <jesse@bestpractical.com> # # (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 +# <jesse@bestpractical.com> # -# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com> +# (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 # <jesse@bestpractical.com> # # (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 <jesse@bestpractical.com> (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 # <jesse@bestpractical.com> # # (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 +# <jesse@bestpractical.com> +# +# (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 => '<?xml version="1.0" encoding="UTF-8"?>', +); 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 # <jesse@bestpractical.com> # # (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 <<END; @@ -241,6 +242,10 @@ END print "Dropping $RT::DatabaseType database $RT::DatabaseName.\n"; + if ( $RT::DatabaseType eq 'SQLite' ) { + unlink $RT::DatabaseName or warn $!; + return; + } $dbh->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 # <jesse@bestpractical.com> # # (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; |