diff options
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, 172 insertions, 437 deletions
diff --git a/rt/sbin/extract-message-catalog b/rt/sbin/extract-message-catalog index 3552afb81..c5d4d8953 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-2005 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2004 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|\.svn' ); + 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" ); @@ -195,7 +195,6 @@ 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|")/ ); @@ -204,8 +203,8 @@ sub update { chomp $msgid; chomp $msgstr; - $msgid =~ s/^msgid "(.*)"\s*?$/$1/ms or warn "$msgid in $file"; - $msgstr =~ s/^msgstr "(.*)"\s*?$/$1/ms or warn "$msgstr in $file"; + $msgid =~ s/^msgid "(.*)"$/$1/ or warn $msgid; + $msgstr =~ s/^msgstr "(.*)"$/$1/ms or warn $msgstr; $Lexicon{$msgid} = $msgstr; $Header{$msgid} = $msghdr; @@ -230,10 +229,6 @@ 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 4d9d7bd6c..3987e90c7 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-2005 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2004 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,14 +121,7 @@ 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 743d8b90e..882e4a826 100644 --- a/rt/sbin/factory +++ b/rt/sbin/factory @@ -1,9 +1,9 @@ -#!/usr/bin/perl -w -# BEGIN BPS TAGGED BLOCK {{{ +#!/usr/bin/perl +# {{{ BEGIN BPS TAGGED BLOCK # # COPYRIGHT: # -# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -43,8 +43,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# END BPS TAGGED BLOCK }}} -use strict; +# }}} END BPS TAGGED BLOCK use DBI; my $database = shift; @@ -60,17 +59,11 @@ my $password = ''; my $LicenseBlock = << '.'; -# BEGIN BPS TAGGED BLOCK {{{ -# -# COPYRIGHT: -# -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC -# <jesse@bestpractical.com> +# BEGIN BPS TAGGED BLOCK # -# (Except where explicitly superseded by other copyright notices) +# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com> # -# -# 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 @@ -82,29 +75,14 @@ my $LicenseBlock = << '.'; # 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. +# 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. # # -# 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 }}} +# END BPS TAGGED BLOCK + . my $Attribution = << '.'; @@ -148,7 +126,6 @@ foreach my $table (@tables) { $tablemap{'CreatedBy'} = 'User'; $tablemap{'UpdatedBy'} = 'User'; -my %typemap; $typemap{'id'} = 'ro'; $typemap{'Creator'} = 'auto'; $typemap{'Created'} = 'auto'; @@ -185,27 +162,7 @@ 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; @@ -213,16 +170,10 @@ 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,"; @@ -236,7 +187,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 @@ -248,7 +199,7 @@ Returns the current value of $field. "; - unless ( exists $typemap{$field} && ( $typemap{$field} eq 'auto' || $typemap{$field} eq 'ro' )) { + unless ( $typemap{$field} eq 'auto' || $typemap{$field} eq 'ro' ) { $FieldsPod .= " =head2 Set$field VALUE @@ -303,7 +254,7 @@ sub ${field}Obj { } - my $Create = " + $Create = " sub Create { my \$self = shift; my \%args = ( @@ -355,15 +306,10 @@ sub _Init { $CollectionClass .= " - # By default, order by SortOrder - \$self->OrderByCols( - { ALIAS => 'main', - FIELD => 'SortOrder', - ORDER => 'ASC' }, - { ALIAS => 'main', - FIELD => 'id', - ORDER => 'ASC' }, - ); + # By default, order by name + \$self->OrderBy( ALIAS => 'main', + FIELD => 'SortOrder', + ORDER => 'ASC'); "; } $CollectionClass .= " @@ -451,7 +397,7 @@ $ClassAccessible open( COL, ">$CollectionClassPath" ); print COL $CollectionClass; - close(COL); + close($COL); } @@ -492,7 +438,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. -Each of these files should begin with the line +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); diff --git a/rt/sbin/license_tag b/rt/sbin/license_tag index 906d34924..cd1a9716f 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-2005 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2004 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-2005 Best Practical Solutions, LLC +This software is Copyright (c) 1996-2004 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 d98e462c7..c10779614 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-2005 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2004 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 deleted file mode 100755 index bcc7bb713..000000000 --- a/rt/sbin/rt-dump-database.in +++ /dev/null @@ -1,168 +0,0 @@ -#!@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 49feba845..9d8fd2ee0 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-2005 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2004 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 @@ -199,7 +199,6 @@ 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'}; @@ -208,13 +207,12 @@ 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 "Done setting up database schema.\n"; + print "schema sucessfully inserted\n"; } @@ -222,6 +220,7 @@ sub insert_schema { # {{{ sub drop_db sub drop_db { + return if ( $RT::DatabaseType eq 'SQLite' ); if ( $RT::DatabaseType eq 'Oracle' ) { print <<END; @@ -245,10 +244,6 @@ 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; } @@ -281,19 +276,20 @@ sub create_db { # }}} sub get_dba_password { - print "In order to create or update your RT database,"; + 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 +"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); } @@ -320,15 +316,15 @@ sub insert_acl { } elsif ( $RT::DatabaseType =~ /^mysql$/i ) { do $base_path . "/acl.mysql" - || die "Couldn't find ACLS for mysql in $base_path\n" . $@; + || 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 $base_path\n" . $@; + || 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 $base_path\n" . $@; + || die "Couldn't find ACLS for Informix in " . $RT::EtcPath . "\n" . $@; } elsif ( $RT::DatabaseType =~ /^SQLite$/i ) { return; @@ -345,7 +341,6 @@ sub insert_acl { die "Problem with statement:\n $statement\n" . $sth->errstr; } } - print "Done setting up database ACLs.\n"; } # }}} @@ -410,8 +405,7 @@ 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', - LastUpdatedBy => '1' ); + Creator => '1' ); unless ($val) { print "$msg\n"; @@ -445,7 +439,6 @@ 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:- @@ -619,7 +612,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 f79e4e5c2..6eed51337 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-2005 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2004 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,68 +52,36 @@ 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', - 'repository=s' -); - -unless (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'); + +if (!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 conclude { - if ($any_missing) { - print "\nSOMETHING WAS MISSING!\n"; - } else { - print "\nEverything was found.\n"; - } - } +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 <<'.'; @@ -153,7 +121,7 @@ Digest::MD5 2.27 DBI 1.37 Test::Inline Class::ReturnValue 0.40 -DBIx::SearchBuilder 1.26 +DBIx::SearchBuilder 1.01 Text::Template File::Spec 0.8 HTML::Entities @@ -168,7 +136,6 @@ Mail::Mailer 1.57 Net::SMTP Text::Wrapper Time::ParseDate -Time::HiRes File::Temp Term::ReadKey Text::Autoformat @@ -176,8 +143,6 @@ Text::Quoted 1.3 Tree::Simple 1.04 Scalar::Util Module::Versions::Report -Cache::Simple::TimedExpiry -XML::Simple . $deps{'MASON'} = [ _( << '.') ]; @@ -192,10 +157,7 @@ Digest::MD5 2.27 CGI::Cookie 1.20 Storable 2.08 Apache::Session 1.53 -XML::RSS 1.05 -HTTP::Server::Simple 0.07 -HTTP::Server::Simple::Mason 0.09 -Text::WikiFormat +XML::RSS . $deps{'MAILGATE'} = [ _( << '.') ]; @@ -211,13 +173,12 @@ 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'} = [ _( << '.') ]; @@ -241,7 +202,6 @@ Apache::DBI 0.92 $deps{'MODPERL2'} = [ _( << '.') ]; CGI 2.92 Apache::DBI -HTML::Mason 1.31 . $deps{'MYSQL'} = [ _( << '.') ]; @@ -251,7 +211,7 @@ $deps{'ORACLE'} = [ _( << '.') ]; DBD::Oracle . $deps{'POSTGRESQL'} = [ _( << '.') ]; -DBD::Pg 1.41 +DBD::Pg . $deps{'SQLITE'} = [ _( << '.') ]; @@ -260,19 +220,74 @@ DBD::SQLite if ($args{'download'}) { - download_mods(); + 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; } -check_perl_version(); +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_users(); + 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'}; +} +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; - section("$type dependencies"); + print "$type dependencies:\n"; my @deps = (@{$deps{$type}}); while (@deps) { my $module = shift @deps; @@ -285,8 +300,6 @@ foreach my $type (keys %args) { } } -conclude(); - sub test_dep { my $module = shift; my $version = shift; @@ -295,83 +308,46 @@ sub test_dep { if ($@) { my $error = $@; $error =~ s/\n(.*)$//s; - undef $error unless $error =~ /this is only/; - found("$module $version", 0, $error); + print "\t$module $version"; + print "...MISSING\n"; + print "\t\t$error\n" if $error =~ /this is only/; return undef; } else { - found("$module $version", 1); + print "\t$module $version...found\n" if $args{'v'}; return 1; } } sub resolve_dep { my $module = shift; - system( qq[@PERL@ -MCPAN -e'install("$module")'] ); + use CPAN; + CPAN::Shell->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); - } - opendir(DIR, $moddir); - while ( my $dir = readdir(DIR)) { - print "Dir is $dir\n"; - next if ( $dir =~ /^\.\.?$/); +sub print_help { + print << "EOF"; - # Skip things we've previously tagged - my $out = `svn ls $args{'repository'}/tags/$dir`; - next if ($out); +$0 FLAG DBTYPE - if ($dir =~ /^(.*)-(.*?)$/) { - `svn_load_dirs -no_user_input -t tags/$dir -v $args{'repository'} dists/$1 $moddir/$dir`; - `rm -rf $moddir/$dir`; - } +$0 is a tool for RT that will tell you if you've got all +the modules RT depends on properly installed. - } - closedir(DIR); - exit; -} +Flags: (only one flag is valid for a given run) -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); - } -} +-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. -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@")); -} +-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 -1; + exit(0); +} |