diff options
Diffstat (limited to 'rt/tools')
-rw-r--r-- | rt/tools/cpan2rpm | 299 | ||||
-rw-r--r-- | rt/tools/initdb | 216 | ||||
-rwxr-xr-x | rt/tools/insertdata | 618 | ||||
-rw-r--r-- | rt/tools/testdeps | 115 |
4 files changed, 1248 insertions, 0 deletions
diff --git a/rt/tools/cpan2rpm b/rt/tools/cpan2rpm new file mode 100644 index 000000000..9b54cb912 --- /dev/null +++ b/rt/tools/cpan2rpm @@ -0,0 +1,299 @@ +#!/usr/bin/perl -w + + +# Take a perl tarball and make a specfile for it. Now with bundles. +# +# Copyright 2000,2001 Simon Wilkinson. All rights reserved. +# +# 10/18/2001 - <jesse@bestpractical.com> +# Added resolution of prereq_pm modules +# +# This program is free software; you can redistribute it +# and/or modify it under the same terms as Perl itself. +# + +use strict; + +use CPAN; +use POSIX; +use Sys::Hostname; +use File::Basename; +use Getopt::Long; + +use vars qw ($DEBUG $ARCH $builddir $seen @report); + +$ARCH = 'i386'; + +$DEBUG = 0; +# Icky globals + +my $release; +my $package; + +$seen = {}; + + +sub usage +{ + print STDERR <<EOM; + +Usage: cpan2rpm [--release <release>] [--builddir <rpm build dir>] <Perl::Module> + +Where: +<release> is the release number of the RPM you wish to produce +<Perl::Module> is the name of the module to build +EOM + exit(1); +} + + +my $ret=GetOptions("release" => \$release, + "builddir=s" => \$builddir); + +$package=$ARGV[0]; +usage() if !$package; +$release=1 if !$release; + + +$builddir=ExtractRpmMacro($ENV{HOME}."/.rpmmacros","_topdir") if !$builddir; +$builddir=ExtractRpmMacro("/etc/rpm/macros","_topdir") if !$builddir; +$builddir=getcwd() if !$builddir; + +die "Build directory $builddir doesn't look like an RPM build root\n" + if ((! -d "$builddir/SPECS") || (! -d "$builddir/SOURCES")); + +process($package,$release); + +print join("\n",@report)."\n"; + +sub process { + my ($infile,$release)=@_; + + + +# Convert our installation list into an unbundled one + unbundle($infile); + + print "Building $infile\n"; + + cpan2rpm($infile,$builddir,$release); + +} + +# Given a Module, try to split it into its required components - this +# currently only handles Bundles, but could also be extended to deal with +# prereqs as well. + +sub unbundle { + my ($item) = @_; + + if ($item=~/Bundle::/) { + my $obj=CPAN::Shell->expand('Bundle',$item); + + foreach my $kid ($obj->contains) { + process($kid,$release); + } + } +} + + +sub cpan2rpm($$$) { + my ($infile,$builddir,$release) = @_; + + my $ret; + + my $obj=CPAN::Shell->expand('Module',$infile); + + print "CPAN tells us the following about $infile:\n",$obj->as_string if ($DEBUG); + + $ret=fetch_source($obj,$builddir); + $ret=build_specfile($obj,$builddir,$release) if !$ret; + + return $ret; +} + +# FIXME: Some error handling in the function below wouldn't go amiss ... +sub fetch_source { + my ($obj,$builddir)=@_; + + # Minor Sanity checks + my $id=$obj->{ID}; + + return "Error: No file for $id\n" + if $obj->cpan_file eq "N/A"; + return "Error: $id says 'Contact Author'\n" + if $obj->cpan_file =~ /^Contact Author/; + return "Error: $id is contained within Perl itself!\n" + if ($obj->cpan_file =~/perl-5\.\d?\.\d?\.tar\.gz/xo); + + # We do this so we can take advantage of CPAN's object caching. This is + # pinched from the CPAN::Distribution::get method, which we can't use + # directly, as it untars the package as well - which we let RPM do. + + my $dist = $CPAN::META->instance('CPAN::Distribution',$obj->cpan_file); + + + my($local_wanted) = + MM->catfile($CPAN::Config->{keep_source_where}, + "authors", + "id", + split("/",$dist->{ID}) + ); + + my $local_file = CPAN::FTP->localize("authors/id/$dist->{ID}", $local_wanted); + + $dist->{localfile} = $local_file; + + $dist->verifyMD5 if ($CPAN::META->has_inst('MD5')); + + + # Find all the prereqs for this distribution, then build em. + # TODO this should be somewhere else + + $dist->make; + build_prereqs( $dist->prereq_pm()); + + + + my $infile=basename($obj->cpan_file); + + File::Copy::copy($local_file,"$builddir/SOURCES/$infile"); + + return undef; +} + + +sub build_prereqs($) { + my ($prereqs) = @_; + + foreach my $prereq (keys %{$prereqs}) { + process ($prereq, $release); + } +} +sub build_specfile($$$) { + my ($obj,$builddir,$release) = @_; + + my $source=basename($obj->cpan_file); + + # don't go through dependencies on something we've already dealt with + return() if ($seen->{$source}); + $seen->{$source} = 1; + +my ($name,$version)=($source=~/(.*)-(.*)\.tar\.gz/); + return "Couldn't get a name for $source\n" if !$name; + return "Couldn't get a version for $source\n" if !$version; + + my $summary="$name module for perl"; + my $description=$obj->{description}; + $description= $summary if !$description; + + open(SPEC, ">$builddir/SPECS/perl-$name.spec") + or die "Couldn't open perl-$name.spec for writing."; + print SPEC <<EOF; + +Summary: $summary +Name: perl-$name +Version: $version +Release: $release +Copyright: distributable +Group: Applications/CPAN +Source0: $source +Url: http://www.cpan.org +BuildRoot: /var/tmp/perl-${name}-buildroot/ +Requires: perl + +%description +This is a perl module, autogenerated by cpan2rpm. The original package's +description was: + +$description + +%prep +%setup -q -n $name-%{version} + +%build +CFLAGS="\$RPM_OPT_FLAGS" perl Makefile.PL +make + +%clean +rm -rf \$RPM_BUILD_ROOT + +%install +rm -rf \$RPM_BUILD_ROOT +eval `perl '-V:installarchlib'` +mkdir -p \$RPM_BUILD_ROOT/\$installarchlib +make PREFIX=\$RPM_BUILD_ROOT/usr install +/usr/lib/rpm/brp-compress +find \$RPM_BUILD_ROOT/usr -type f -print | sed "s\@^\$RPM_BUILD_ROOT\@\@g" | grep -v perllocal.pod > $name-$version-filelist + +%files -f ${name}-${version}-filelist +%defattr(-,root,root) + +%changelog +EOF + print SPEC "* ",POSIX::strftime("%a %b %d %Y",localtime()), " ",$ENV{USER}," <",$ENV{USER},"\@",hostname(),">\n"; + print SPEC "- Spec file automatically generated by cpan2rpm\n"; + + close(SPEC); + + system("rpm -ba $builddir/SPECS/perl-$name.spec >/dev/null") == 0 + or push (@report, "RPM of $source failed with : $!\n"); + + system("rpm -Uvh $builddir/RPMS/$ARCH/perl-$name-$version-$release.$ARCH.rpm") == 0 + or warn "RPM of $source could not be installed: $!\n"; + + push (@report, "Built perl-$name-$version-$release.$ARCH.rpm"); +} + +sub ExtractRpmMacro { + my ($file,$macro) = @_; + + my $handle=new IO::File; + + if (!$handle->open($file)) { + return undef; + } + + while(<$handle>) { + if (/\%$macro (.*)/) { + return $1; + } + } + + return undef; +} + +=head1 NAME + +cpan2rpm - fetch and convert CPAN packages to RPMs + +=head1 SYNOPSIS + +cpan2rpm --release <release> <package> + +=head1 DESCRIPTION + +cpan2rpm provides a quick way of creating RPM packages from perl modules +published on CPAN. It interfaces with the perl CPAN module to fetch the +file from the selected mirror, and then creates a spec file from the +information in CPAN, and invokes RPM on that spec file. + +Files are created in the users RPM build root. + +=head1 OPTIONS + +=over 4 + +=item release + +Sets the release number of the created RPMs. + +=back + +=head1 SEE ALSO + +rpm(1) + +=head1 AUTHOR + +Simon Wilkinson <sxw@sxw.org.uk> diff --git a/rt/tools/initdb b/rt/tools/initdb new file mode 100644 index 000000000..ffb1ae3b0 --- /dev/null +++ b/rt/tools/initdb @@ -0,0 +1,216 @@ +#!/usr/bin/perl -w +# $Header: /home/cvs/cvsroot/freeside/rt/tools/Attic/initdb,v 1.1 2002-08-12 06:17:08 ivan Exp $ + +use strict; +use vars qw($PROMPT $SCHEMA_FILE $SCHEMA_DIR + $ACTION $DEBUG $DB_TYPE $DB_HOME + $DB_HOST $DB_PORT $DB_DBA $DB_DATABASE $DB_DBA_PASSWORD); + +use DBI; +use DBIx::DataSource qw( create_database drop_database ); + + +$|=1; #unbuffer that output. + +$DEBUG=0; +$PROMPT = 1; #by default, should at least *ask* before nuking databases +$SCHEMA_DIR ="etc"; +$SCHEMA_FILE = "$SCHEMA_DIR/schema.pm"; #hmm + +($DB_TYPE, $DB_HOME, $DB_HOST, $DB_PORT, $DB_DBA, $DB_DATABASE, $ACTION) = @ARGV; + + +if ($DEBUG) { + print_config_params(); +} +my $dsn = "dbi:$DB_TYPE:"; + +if (($DB_TYPE eq 'Pg') or ($DB_TYPE eq 'mysql')) { + $dsn .= "dbname=$DB_DATABASE"; + if ($DB_HOST) { + $dsn .= ";host=$DB_HOST"; + } + if ($DB_PORT) { + $dsn .= ";port=$DB_PORT"; + } +} +elsif ($DB_TYPE eq 'Oracle') { + $dsn .= "$DB_DATABASE"; +} + + +if ($ACTION eq 'create') { + unless ($DB_TYPE eq 'Oracle') { + print "Now creating a database for RT.\n"; + prompt_for_dba_password(); + create_db(); + } +} +elsif ($ACTION eq 'drop' ) { + unless ($DB_TYPE eq 'Oracle') { + print "Now dropping the RT2 database.\n"; + prompt_for_dba_password(); + drop_db(); + } +} +elsif ($ACTION eq 'insert' ) { + print "Now populating database schema.\n"; + prompt_for_dba_password(); + insert_schema(); +} +elsif ($ACTION eq 'generate') { + prompt_for_dba_password(); + generate_schema(); +} +else { + print STDERR '$ACTION unspecified. Makefile error. It was '.$ACTION ; + exit(-1); +} + + +# {{{ sub prompt_for_dba_password + +sub prompt_for_dba_password { + print "Enter the $DB_TYPE password for $DB_DBA: "; + + system "stty -echo"; + $DB_DBA_PASSWORD = scalar(<STDIN>); #keep off commandline + system "stty echo"; + chomp $DB_DBA_PASSWORD; + +} +# }}} + +# {{{ sub print_config_params +sub print_config_params { + print <<END; +Database creation parameters: + +DB_TYPE = $DB_TYPE +DB_HOME = $DB_HOME +DB_HOST = $DB_HOST +DB_DBA = $DB_DBA +DB_DBA_PASSWORD = <hidden> +DB_DATABASE = $DB_DATABASE +END +} +# }}} + +# {{{ sub drop_db +sub drop_db { + + if ( $PROMPT ) { + print <<END; + +About to drop $DB_TYPE database $DB_DATABASE. +WARNING: This will erase all data in $DB_DATABASE. +If you have an existing RT 2.x installation, this will destroy all your data. +i +END + exit unless _yesno(); + + } + + + print "\nDropping $DB_TYPE database $DB_DATABASE.\n"; + drop_database( $dsn, $DB_DBA, $DB_DBA_PASSWORD ) + or warn $DBIx::DataSource::errstr; + + +} +# }}} + +# {{{ sub generate_schema +sub generate_schema { + my @schema = generate_schema_from_hash(); + print "Generating schema for $DB_TYPE..."; + + system('mv', "$SCHEMA_DIR/schema.$DB_TYPE", "$SCHEMA_DIR/schema.$DB_TYPE.bak") + if (-f "$SCHEMA_DIR/schema.$DB_TYPE"); + open(SCHEMA, ">$SCHEMA_DIR/schema.$DB_TYPE"); + foreach my $line (@schema) { + print SCHEMA "$line;\n"; + } + close(SCHEMA); + print "done.\n"; +} +# }}} + +# {{{ sub insert_schema +sub insert_schema { + my (@schema); + print "\nCreating database schema.\n"; + + my $dbh = DBI->connect( $dsn, $DB_DBA, $DB_DBA_PASSWORD ) or die $DBI::errstr; + + if ( -f "$SCHEMA_DIR/schema.$DB_TYPE") { + open (SCHEMA, "<$SCHEMA_DIR/schema.$DB_TYPE"); + my $statement = ""; + foreach my $line (<SCHEMA>) { + $statement .= $line; + if ($line =~ /;$/) { + $statement =~ s/;$//g; + push @schema, $statement; + $statement = ""; + } + } + } + + else { + @schema = generate_schema_from_hash(); + } + + foreach my $statement (@schema) { + print STDERR $statement if $DEBUG; + my $sth = $dbh->prepare($statement) or die $dbh->errstr; + unless ($sth->execute) { + print STDERR "Problem with statement:\n $statement\n"; + die $sth->errstr; + } + } + + + $dbh->disconnect; + print "schema sucessfully inserted\n"; + +} +# }}} + +# {{{ sub generate_schema_from_hash +sub generate_schema_from_hash { + my (@schema); + + require DBIx::DBSchema; + my $schema_href = do "$SCHEMA_FILE" or die $@ || $!; + my $schema = DBIx::DBSchema->pretty_read($schema_href); + + + foreach my $statement ( $schema->sql($dsn, $DB_DBA, $DB_DBA_PASSWORD ) ) { + print STDERR $statement if $DEBUG; + chomp $statement; + push @schema, $statement; + + } + return (@schema); + +} +# }}} + +# {{{ sub create_db +sub create_db { + + print "\nCreating $DB_TYPE database $DB_DATABASE.\n"; + create_database( $dsn, $DB_DBA, $DB_DBA_PASSWORD ) + or die $DBIx::DataSource::errstr; + +} +# }}} + +# {{{ sub _yesno +sub _yesno { + print "Proceed [y/N]:"; + my $x = scalar(<STDIN>); + $x =~ /^y/i; +} + +# }}} diff --git a/rt/tools/insertdata b/rt/tools/insertdata new file mode 100755 index 000000000..b3e76e623 --- /dev/null +++ b/rt/tools/insertdata @@ -0,0 +1,618 @@ +#!/usr/bin/perl -w +# +# $Header: /home/cvs/cvsroot/freeside/rt/tools/Attic/insertdata,v 1.1 2002-08-12 06:17:08 ivan Exp $ +# RT is (c) 1996-2002 Jesse Vincent (jesse@bestpractical.com); + +package RT; +use strict; +use vars qw($VERSION $Handle $Nobody $SystemUser $item); + +use lib "!!RT_LIB_PATH!!"; +use lib "!!RT_ETC_PATH!!"; + +#This drags in RT's config.pm +use config; +use Carp; + +use RT::Handle; +use RT::User; +use RT::CurrentUser; + +# +my $LastVersion = shift || undef; +my $LastMinorVersion = undef; + +#connect to the db +$RT::Handle = new RT::Handle($RT::DatabaseType); +$RT::Handle->Connect(); + +#Put together a current user object so we can create a User object +my $CurrentUser = new RT::CurrentUser(); + +if ($LastVersion) { + if ( $LastVersion =~ /^2.0.(\d+)$/ ) { + $LastMinorVersion = $1; + print "Looking for new objects to add to the database" + . " since $LastVersion\n\n"; + } + else { + print "This tool does not support upgrades from development releases " + . "or non 2.0.x versions"; + } +} +else { # this is a virgin install + 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 already run insertdata.\n" + . "Exiting, so as not to clobber your existing data. To ERASE your\n" + . "RT database and start over, type 'make dropdb; make install' in\n" + . "the RT installation directory. If you just meant to upgrade the\n" + . "content of your database, rerun this program as: \n", + " $0 <version>\n" + . "where <version> is the last RELEASED version of RT you installed\n" + . "for example, if you're upgrading from 2.0.4, you'd type:\n" + . " $0 2.0.4\n"; + exit(-1); + + } + else { + print "not found. This appears to be a new installation"; + } + + 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', + Privileged => '2', + Creator => '1' + ); + + if ($val) { + print "done.\n"; + } + else { + print "$msg\n"; + exit(1); + } + +} + +#now that we bootstrapped that little bit, we can use the standard RT cli +# helpers to do what we need + +use RT::Interface::CLI qw(CleanEnv LoadConfig DBConnect + GetCurrentUser GetMessageContent); + +#Clean out all the nasties from the environment +CleanEnv(); + +#Load etc/config.pm and drop privs +LoadConfig(); + +#Connect to the database and get RT::SystemUser and RT::Nobody loaded +DBConnect(); + +$CurrentUser->LoadByName('RT_System'); + +# {{{ Users + +my @users; + +unless ($LastVersion) { + @users = ( + { + Name => 'Nobody', + RealName => 'Nobody in particular', + Comments => 'Do not delete or modify this user. It is integral ' + . 'to RT\'s internal data structures', + Privileged => '2', + }, + + { + Name => 'root', + Gecos => 'root', + RealName => 'Enoch Root', + Password => 'password', + EmailAddress => "root\@localhost", + Comments => 'SuperUser', + Privileged => '1', + } + ); +} + +# }}} + +# {{{ Groups + +my @groups; +unless ($LastVersion) { + @groups = ( + { + Name => 'Everyone', + Description => 'Pseudogroup for internal use', + Pseudo => '1', + }, + { + Name => 'Owner', + Description => 'Pseudogroup for internal use', + Pseudo => '1', + }, + { + Name => 'Requestor', + Description => 'Pseudogroup for internal use', + Pseudo => '1', + }, + { + Name => 'Cc', + Description => 'Pseudogroup for internal use', + Pseudo => '1', + }, + { + Name => 'AdminCc', + Description => 'Pseudogroup for internal use', + Pseudo => '1', + }, + ); +} + +# }}} + +# {{{ ACL +my @acl; + +unless ($LastVersion) { + @acl = ( #TODO: make this actually take the serial # granted to root. + { + PrincipalId => '1', + PrincipalType => 'User', + RightName => 'SuperUser', + RightScope => 'System', + RightAppliesTo => '0' + }, + { + PrincipalId => '2', + PrincipalType => 'User', + RightName => 'SuperUser', + RightScope => 'System', + RightAppliesTo => '0' + }, + + { + PrincipalId => '3', + PrincipalType => 'User', + RightName => 'SuperUser', + RightScope => 'System', + RightAppliesTo => '0' + } + + ); +} + +# }}} + +# {{{ Queues + +my @queues; +unless ($LastVersion) { + @queues = ( + { + Name => 'general', + Description => 'The default queue', + CorrespondAddress => "rt\@localhost", + CommentAddress => "rt-comment\@localhost" + } + ); +} + +# }}} + +# {{{ ScripActions + +my @ScripActions; + +unless ($LastVersion) { + @ScripActions = ( + + { + Name => 'AutoreplyToRequestors', + Description => +'Always sends a message to the requestors independent of message sender', + ExecModule => 'Autoreply', + Argument => 'Requestor' + }, + { + Name => 'NotifyRequestors', + Description => 'Sends a message to the requestors', + ExecModule => 'Notify', + Argument => 'Requestor' + }, + { + Name => 'NotifyOwnerAsComment', + Description => 'Sends mail to the owner', + ExecModule => 'NotifyAsComment', + Argument => 'Owner' + }, + { + Name => 'NotifyOwner', + Description => 'Sends mail to the owner', + ExecModule => 'Notify', + Argument => 'Owner' + }, + { + Name => 'NotifyAdminCcsAsComment', + Description => 'Sends mail to the administrative Ccs as a comment', + ExecModule => 'NotifyAsComment', + Argument => 'AdminCc' + }, + { + Name => 'NotifyAdminCcs', + Description => 'Sends mail to the administrative Ccs', + ExecModule => 'Notify', + Argument => 'AdminCc' + }, + + { + Name => 'NotifyRequestorsAndCcsAsComment', + Description => 'Send mail to requestors and Ccs as a comment', + ExecModule => 'NotifyAsComment', + Argument => 'Requestor,Cc' + }, + + { + Name => 'NotifyRequestorsAndCcs', + Description => 'Send mail to requestors and Ccs', + ExecModule => 'Notify', + Argument => 'Requestor,Cc' + }, + + { + Name => 'NotifyAllWatchersAsComment', + Description => 'Send mail to all watchers', + ExecModule => 'NotifyAsComment', + Argument => 'All' + }, + { + Name => 'NotifyAllWatchers', + Description => 'Send mail to all watchers', + ExecModule => 'Notify', + Argument => 'All' + }, + ); +} + +if ( $LastMinorVersion < 12 ) { + push ( + @ScripActions, + { + Name => 'NotifyOtherRecipientsAsComment', + Description => 'Sends mail to explicitly listed Ccs and Bccs', + ExecModule => 'NotifyAsComment', + Argument => 'OtherRecipients' + }, + { + Name => 'NotifyOtherRecipients', + Description => 'Sends mail to explicitly listed Ccs and Bccs', + ExecModule => 'Notify', + Argument => 'OtherRecipients' + }, + ); +} + +# }}} + +# {{{ ScripConditions + +my @ScripConditions; +unless ($LastVersion) { + @ScripConditions = ( + { + Name => 'OnCreate', + Description => 'When a ticket is created', + ApplicableTransTypes => 'Create', + ExecModule => 'AnyTransaction', + }, + + { + Name => 'OnTransaction', + Description => 'When anything happens', + ApplicableTransTypes => 'Any', + ExecModule => 'AnyTransaction', + }, + { + + Name => 'OnCorrespond', + Description => 'Whenever correspondence comes in', + ApplicableTransTypes => 'Correspond', + ExecModule => 'AnyTransaction', + }, + + { + + Name => 'OnComment', + Description => 'Whenever comments come in', + ApplicableTransTypes => 'Comment', + ExecModule => 'AnyTransaction' + }, + { + + Name => 'OnStatus', + Description => 'Whenever a ticket\'s status changes', + ApplicableTransTypes => 'Status', + ExecModule => 'AnyTransaction', + + }, + { + Name => 'OnResolve', + Description => 'Whenever a ticket is resolved.', + ApplicableTransTypes => 'Status', + ExecModule => 'StatusChange', + Argument => 'resolved' + + }, + + ); +} + +# }}} + +# {{{ Templates +my @templates; + +unless ($LastVersion) { + @templates = ( + { + Queue => '0', + Name => 'Autoreply', + Description => 'Default Autoresponse Template', + Content => 'Subject: AutoReply: {$Ticket->Subject} + + +Greetings, + +This message has been automatically generated in response to the +creation of a trouble ticket regarding: + "{$Ticket->Subject()}", +a summary of which appears below. + +There is no need to reply to this message right now. Your ticket has been +assigned an ID of [{$rtname} #{$Ticket->id()}]. + +Please include the string: + + [{$rtname} #{$Ticket->id}] + +in the subject line of all future correspondence about this issue. To do so, +you may reply to this message. + + Thank you, + {$Ticket->QueueObj->CorrespondAddress()} + +------------------------------------------------------------------------- +{$Transaction->Content()} +' + }, + + { + + # id => 2, + Queue => '0', + Name => 'Transaction', + Description => 'Default transaction template', + Content => ' + + +{$Transaction->CreatedAsString}: Request {$Ticket->id} was acted upon. +Transaction: {$Transaction->Description} + Queue: {$Ticket->QueueObj->Name} + Subject: {$Transaction->Subject || $Ticket->Subject || "(No subject given)"} + Owner: {$Ticket->OwnerObj->Name} + Requestors: {$Ticket->Requestors->EmailsAsString()} + Status: {$Ticket->Status} + Ticket <URL: {$RT::WebURL}Ticket/Display.html?id={$Ticket->id} > +------------------------------------------------------------------------- +{$Transaction->Content()}' + }, + + { + + Queue => '0', + Name => 'AdminCorrespondence', + Description => 'Default admin correspondence template', + Content => ' + + +<URL: {$RT::WebURL}Ticket/Display.html?id={$Ticket->id} > + +{$Transaction->Content()}' + }, + + { + Queue => '0', + Name => 'Correspondence', + Description => 'Default correspondence template', + Content => ' + +{$Transaction->Content()}' + }, + + { + Queue => '0', + Name => 'AdminComment', + Description => 'Default admin comment template', + Content => +'Subject: [Comment] {my $s=($Transaction->Subject||$Ticket->Subject); $s =~ s/\\[Comment\\]//g; $comment =~ s/^Re//i; $s;} + + +{$RT::WebURL}Ticket/Display.html?id={$Ticket->id} +This is a comment. It is not sent to the Requestor(s): + +{$Transaction->Content()} +' + }, + + { + Queue => '0', + Name => 'StatusChange', + Description => 'Ticket status changed', + Content => 'Subject: Status Changed to: {$Transaction->NewValue} + + +{$RT::WebURL}Ticket/Display.html?id={$Ticket->id} + +{$Transaction->Content()} +' + }, + + { + + Queue => '0', + Name => 'Resolved', + Description => 'Ticket Resolved', + Content => 'Subject: Ticket Resolved + +According to our records, your request has been resolved. If you have any +further questions or concerns, please respond to this message. +' + } + ); +} + +# }}} + +# {{{ Scrips; + +my @scrips; +unless ($LastVersion) { + @scrips = ( + { Queue => 0, + ScripCondition => 'OnCreate', + ScripAction => 'AutoreplyToRequestors', + Template => 'Autoreply' + }, + { Queue => 0, + ScripCondition => 'OnCreate', + ScripAction => 'NotifyAdminCcs', + Template => 'Transaction', + }, + { Queue => 0, + ScripCondition => 'OnCorrespond', + ScripAction => 'NotifyAllWatchers', + Template => 'Correspondence', + }, + { Queue => 0, + ScripCondition => 'OnComment', + ScripAction => 'NotifyAdminCcsAsComment', + Template => 'AdminComment', + }, + ) +} +if ( $LastMinorVersion < 12 ) { + push ( + @scrips, + { Queue => 0, + ScripCondition => 'OnComment', + ScripAction => 'NotifyOtherRecipientsAsComment', + Template => 'Correspondence', + }, + { Queue => 0, + ScripCondition => 'OnCorrespond', + ScripAction => 'NotifyOtherRecipients', + Template => 'Correspondence', + }, + ); +} +# }}} + +print "Creating ACL..."; +use RT::ACE; +for $item (@acl) { + my $new_entry = new RT::ACE($CurrentUser); + + #Using an internal function. this should never be used outside of the bootstrap script + my $return = $new_entry->_BootstrapRight(%$item); + print $return. "."; +} +print "done.\n"; + +print "Creating users..."; +use RT::User; +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"; + +print "Creating groups..."; +use RT::Group; +foreach $item (@groups) { + my $new_entry = new RT::Group($CurrentUser); + my $return = $new_entry->Create(%$item); + print $return. "."; +} +print "done.\n"; + +print "Creating queues..."; +use RT::Queue; +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"; +print "Creating ScripActions..."; + +use RT::ScripAction; +for $item (@ScripActions) { + my $new_entry = new RT::ScripAction($CurrentUser); + my $return = $new_entry->Create(%$item); + print $return. "."; +} + +print "done.\n"; +print "Creating ScripConditions..."; + +use RT::ScripCondition; +for $item (@ScripConditions) { + my $new_entry = new RT::ScripCondition($CurrentUser); + my $return = $new_entry->Create(%$item); + print $return. "."; +} + +print "done.\n"; + +print "Creating templates..."; + +use RT::Template; +for $item (@templates) { + my $new_entry = new RT::Template($CurrentUser); + my $return = $new_entry->Create(%$item); + print $return. "."; +} +print "done.\n"; + +print "Creating Scrips..."; + +use RT::Scrip; +for $item (@scrips) { + my $new_entry = RT::Scrip->new($CurrentUser); + my ($return,$msg) = $new_entry->Create(%$item); + print "(Error: $msg)" unless ($return); + print $return."."; + +} +print "done.\n"; + +$RT::Handle->Disconnect(); + +1; + diff --git a/rt/tools/testdeps b/rt/tools/testdeps new file mode 100644 index 000000000..ddc338107 --- /dev/null +++ b/rt/tools/testdeps @@ -0,0 +1,115 @@ +#!/usr/bin/perl -w + +# $Header: /home/cvs/cvsroot/freeside/rt/tools/Attic/testdeps,v 1.1 2002-08-12 06:17:08 ivan Exp $ + +# Copyright 2000 Jesse Vincent <jesse@fsck.com> +# Distributed under the GNU General Public License +# + +# +# 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; + +use vars qw($mode $dbd $module @modules); + +$mode = shift || print_help(); +$dbd = shift || print_help(); + +@modules = qw( +Digest::MD5 +Storable +DBI 1.18 +DBIx::DataSource 0.02 +DBIx::SearchBuilder 0.48 +HTML::Entities +MLDBM +Net::Domain +Net::SMTP +Params::Validate 0.02 +HTML::Mason 1.02 +CGI::Cookie 1.20 +Apache::Cookie +Apache::Session 1.53 +Date::Parse +Date::Format +MIME::Entity 5.108 +Mail::Mailer 1.20 +Getopt::Long 2.24 +Tie::IxHash +Text::Wrapper +Text::Template +File::Spec 0.8 +Errno +FreezeThaw +File::Temp +Log::Dispatch 1.6 +); + + +if ($dbd =~ /mysql/i) { + push @modules, ('DBD::mysql','2.0416'); +} +elsif ($dbd =~ /oracle/i) { + push @modules, ('DBD::Oracle',''); +} +elsif ($dbd =~ /pg/i) { + push @modules, ('DBD::Pg',''); +} +use CPAN; + +while ($module= shift @modules) { + my $version = ""; + $version = " ". shift (@modules) . " " if ($modules[0] =~ /^([\d\.]*)$/); + print "Checking for $module$version"; + eval "use $module$version" ; + if ($@) { + &resolve_dependency($module, $version) + } + else { + print "...found\n"; + } +} + +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 CPAN to magically make everything better + +DBTYPE is one of: + oracle, pg, mysql + +EOF + +exit(0); +} + +sub resolve_dependency { + my $module = shift; + my $version = shift; + print "....$module$version not installed."; + if ($mode =~ /-f/) { + $module = "DBD::mysql::Install" if ($module =~ /DBD::mysql/); + + print "Installing with CPAN..."; + CPAN::install($module); + } + print "\n"; + exit(1) if ($mode =~ /-q/); +} + |