Commit 2e28e98a authored by Alex Vandiver's avatar Alex Vandiver
Browse files

Version 1.00 releng

parent eb5a8c9b
1.00 2014-06-19
- Packaging updates; no code changes
0.08 2014-06-11
- Compatibility with RT 4.2
- Skip setting date if it is already the current value
......
......@@ -12,10 +12,12 @@ inc/Module/Install/Makefile.pm
inc/Module/Install/Metadata.pm
inc/Module/Install/ReadmeFromPod.pm
inc/Module/Install/RTx.pm
inc/Module/Install/RTx/Factory.pm
inc/Module/Install/RTx/Runtime.pm
inc/Module/Install/Substitute.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
inc/unicore/Name.pm
inc/YAML/Tiny.pm
lib/RT/Action/SLA.pm
lib/RT/Action/SLA_SetDefault.pm
lib/RT/Action/SLA_SetDue.pm
......
......@@ -22,7 +22,10 @@ no_index:
- t
requires:
Business::Hours: 0
perl: 5.8.0
perl: 5.8.3
resources:
license: http://opensource.org/licenses/gpl-2.0.php
version: '0.08'
version: '1.00'
x_module_install_rtx_version: 0.34_02
x_requires_rt: 4.0.0
x_rt_too_new: 4.4.0
......@@ -2,10 +2,12 @@ use inc::Module::Install;
abstract('Service Level Agreements for RT');
RTx ('RT-Extension-SLA');
all_from('lib/RT/Extension/SLA.pm');
readme_from('lib/RT/Extension/SLA.pm');
license('gpl2');
requires_rt '4.0.0';
rt_too_new '4.4.0';
build_requires('Test::More');
requires('Business::Hours');
......
......@@ -8,7 +8,7 @@ no warnings 'once';
use Module::Install::Base;
use base 'Module::Install::Base';
our $VERSION = '0.34';
our $VERSION = '0.34_02';
use FindBin;
use File::Glob ();
......@@ -20,98 +20,67 @@ my @INDEX_DIRS = qw(lib bin sbin);
sub RTx {
my ( $self, $name ) = @_;
my $original_name = $name;
my $RTx = 'RTx';
$RTx = $1 if $name =~ s/^(\w+)-//;
# Set up names
my $fname = $name;
$fname =~ s!-!/!g;
$self->name("$RTx-$name")
$self->name( $name )
unless $self->name;
$self->all_from( -e "$name.pm" ? "$name.pm" : "lib/$RTx/$fname.pm" )
$self->all_from( "lib/$fname.pm" )
unless $self->version;
$self->abstract("RT $name Extension")
$self->abstract("$name Extension")
unless $self->abstract;
my @prefixes = (qw(/opt /usr/local /home /usr /sw ));
my $prefix = $ENV{PREFIX};
@ARGV = grep { /PREFIX=(.*)/ ? ( ( $prefix = $1 ), 0 ) : 1 } @ARGV;
if ($prefix) {
$RT::LocalPath = $prefix;
$INC{'RT.pm'} = "$RT::LocalPath/lib/RT.pm";
} else {
local @INC = (
$ENV{RTHOME} ? ( $ENV{RTHOME}, "$ENV{RTHOME}/lib" ) : (),
@INC,
map { ( "$_/rt4/lib", "$_/lib/rt4", "$_/rt3/lib", "$_/lib/rt3", "$_/lib" )
} grep $_, @prefixes
);
until ( eval { require RT; $RT::LocalPath } ) {
warn
"Cannot find the location of RT.pm that defines \$RT::LocalPath in: @INC\n";
$_ = $self->prompt("Path to directory containing your RT.pm:") or exit;
$_ =~ s/\/RT\.pm$//;
push @INC, $_, "$_/rt3/lib", "$_/lib/rt3", "$_/lib";
}
$self->add_metadata("x_module_install_rtx_version", $VERSION );
# Try to find RT.pm
my @prefixes = qw( /opt /usr/local /home /usr /sw );
my @try = $ENV{RTHOME} ? ($ENV{RTHOME}, "$ENV{RTHOME}/lib") : ();
while (1) {
my @look = @INC;
unshift @look, grep {defined and -d $_} @try;
push @look, grep {defined and -d $_}
map { ( "$_/rt4/lib", "$_/lib/rt4", "$_/lib" ) } @prefixes;
last if eval {local @INC = @look; require RT; $RT::LocalLibPath};
warn
"Cannot find the location of RT.pm that defines \$RT::LocalPath in: @look\n";
$_ = $self->prompt("Path to directory containing your RT.pm:") or exit;
$_ =~ s{(/lib)?/RT\.pm$}{};
@try = ("$_/rt4/lib", "$_/lib/rt4", "$_/lib");
}
my $lib_path = File::Basename::dirname( $INC{'RT.pm'} );
my $local_lib_path = "$RT::LocalPath/lib";
print "Using RT configuration from $INC{'RT.pm'}:\n";
unshift @INC, "$RT::LocalPath/lib" if $RT::LocalPath;
my $local_lib_path = $RT::LocalLibPath;
unshift @INC, $local_lib_path;
my $lib_path = File::Basename::dirname( $INC{'RT.pm'} );
unshift @INC, $lib_path;
$RT::LocalVarPath ||= $RT::VarPath;
$RT::LocalPoPath ||= $RT::LocalLexiconPath;
$RT::LocalHtmlPath ||= $RT::MasonComponentRoot;
$RT::LocalStaticPath ||= $RT::StaticPath;
$RT::LocalLibPath ||= "$RT::LocalPath/lib";
my $with_subdirs = $ENV{WITH_SUBDIRS};
@ARGV = grep { /WITH_SUBDIRS=(.*)/ ? ( ( $with_subdirs = $1 ), 0 ) : 1 }
@ARGV;
my %subdirs;
%subdirs = map { $_ => 1 } split( /\s*,\s*/, $with_subdirs )
if defined $with_subdirs;
unless ( keys %subdirs ) {
$subdirs{$_} = 1 foreach grep -d "$FindBin::Bin/$_", @DIRS;
}
# Set a baseline minimum version
$self->requires_rt('4.0.0');
# If we're running on RT 3.8 with plugin support, we really wany
# to install libs, mason templates and po files into plugin specific
# directories
# Installation locations
my %path;
if ( $RT::LocalPluginPath ) {
die "Because of bugs in RT 3.8.0 this extension can not be installed.\n"
."Upgrade to RT 3.8.1 or newer.\n" if $RT::VERSION =~ /^3\.8\.0/;
$path{$_} = $RT::LocalPluginPath . "/$original_name/$_"
foreach @DIRS;
# Copy RT 4.2.0 static files into NoAuth; insufficient for
# images, but good enough for css and js.
$path{static} = "$path{html}/NoAuth/"
unless $RT::StaticPath;
} else {
foreach ( @DIRS ) {
no strict 'refs';
my $varname = "RT::Local" . ucfirst($_) . "Path";
$path{$_} = ${$varname} || "$RT::LocalPath/$_";
}
$path{$_} = $RT::LocalPluginPath . "/$name/$_"
foreach @DIRS;
$path{$_} .= "/$name" for grep $path{$_}, qw(etc po var);
}
# Copy RT 4.2.0 static files into NoAuth; insufficient for
# images, but good enough for css and js.
$path{static} = "$path{html}/NoAuth/"
unless $RT::StaticPath;
# Delete the ones we don't need
delete $path{$_} for grep {not -d "$FindBin::Bin/$_"} keys %path;
my %index = map { $_ => 1 } @INDEX_DIRS;
$self->no_index( directory => $_ ) foreach grep !$index{$_}, @DIRS;
my $args = join ', ', map "q($_)", map { ($_, $path{$_}) }
grep $subdirs{$_}, keys %path;
sort keys %path;
print "./$_\t=> $path{$_}\n" for sort keys %subdirs;
printf "%-10s => %s\n", $_, $path{$_} for sort keys %path;
if ( my @dirs = map { ( -D => $_ ) } grep $subdirs{$_}, qw(bin html sbin) ) {
if ( my @dirs = map { ( -D => $_ ) } grep $path{$_}, qw(bin html sbin etc) ) {
my @po = map { ( -o => $_ ) }
grep -f,
File::Glob::bsd_glob("po/*.po");
......@@ -121,12 +90,15 @@ lexicons ::
.
}
$self->load('RTxPlugin');
$self->include_deps( 'YAML::Tiny', 0 ) if $self->admin;
my $postamble = << ".";
install ::
\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxPlugin()"
\t\$(NOECHO) \$(PERL) -MExtUtils::Install -e \"install({$args})\"
.
if ( $subdirs{var} and -d $RT::MasonDataDir ) {
if ( $path{var} and -d $RT::MasonDataDir ) {
my ( $uid, $gid ) = ( stat($RT::MasonDataDir) )[ 4, 5 ];
$postamble .= << ".";
\t\$(NOECHO) chown -R $uid:$gid $path{var}
......@@ -146,11 +118,11 @@ install ::
}
$self->postamble("$postamble\n");
unless ( $subdirs{'lib'} ) {
$self->makemaker_args( PM => { "" => "" }, );
} else {
if ( $path{lib} ) {
$self->makemaker_args( INSTALLSITELIB => $path{'lib'} );
$self->makemaker_args( INSTALLARCHLIB => $path{'lib'} );
} else {
$self->makemaker_args( PM => { "" => "" }, );
}
$self->makemaker_args( INSTALLSITEMAN1DIR => "$RT::LocalPath/man/man1" );
......@@ -158,47 +130,97 @@ install ::
$self->makemaker_args( INSTALLSITEARCH => "$RT::LocalPath/man" );
if (%has_etc) {
$self->load('RTxInitDB');
$self->load('RTxDatabase');
print "For first-time installation, type 'make initdb'.\n";
my $initdb = '';
$initdb .= <<"." if $has_etc{schema};
\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(schema \$(NAME) \$(VERSION)))"
\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxDatabase(qw(schema \$(NAME) \$(VERSION)))"
.
$initdb .= <<"." if $has_etc{acl};
\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(acl \$(NAME) \$(VERSION)))"
\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxDatabase(qw(acl \$(NAME) \$(VERSION)))"
.
$initdb .= <<"." if $has_etc{initialdata};
\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(insert \$(NAME) \$(VERSION)))"
\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxDatabase(qw(insert \$(NAME) \$(VERSION)))"
.
$self->postamble("initdb ::\n$initdb\n");
$self->postamble("initialize-database ::\n$initdb\n");
if ($has_etc{upgrade}) {
print "To upgrade from a previous version of this extension, use 'make upgrade-database'\n";
my $upgradedb = qq|\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(upgrade \$(NAME) \$(VERSION)))"\n|;
my $upgradedb = qq|\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxDatabase(qw(upgrade \$(NAME) \$(VERSION)))"\n|;
$self->postamble("upgrade-database ::\n$upgradedb\n");
$self->postamble("upgradedb ::\n$upgradedb\n");
}
}
}
sub requires_rt {
my ($self,$version) = @_;
_load_rt_handle();
if ($self->is_admin) {
$self->add_metadata("x_requires_rt", $version);
my @sorted = sort RT::Handle::cmp_version $version,'4.0.0';
$self->perl_version('5.008003') if $sorted[0] eq '4.0.0'
and (not $self->perl_version or '5.008003' > $self->perl_version);
@sorted = sort RT::Handle::cmp_version $version,'4.2.0';
$self->perl_version('5.010001') if $sorted[0] eq '4.2.0'
and (not $self->perl_version or '5.010001' > $self->perl_version);
}
# if we're exactly the same version as what we want, silently return
return if ($version eq $RT::VERSION);
_load_rt_handle();
my @sorted = sort RT::Handle::cmp_version $version,$RT::VERSION;
if ($sorted[-1] eq $version) {
# should we die?
die "\nWarning: prerequisite RT $version not found. Your installed version of RT ($RT::VERSION) is too old.\n\n";
die <<"EOT";
**** Error: This extension requires RT $version. Your installed version
of RT ($RT::VERSION) is too old.
EOT
}
}
sub requires_rt_plugin {
my $self = shift;
my ( $plugin ) = @_;
if ($self->is_admin) {
my $plugins = $self->{values}{"x_requires_rt_plugins"} || [];
push @{$plugins}, $plugin;
$self->add_metadata("x_requires_rt_plugins", $plugins);
}
my $path = $plugin;
$path =~ s{\:\:}{-}g;
$path = "$RT::LocalPluginPath/$path/lib";
if ( -e $path ) {
unshift @INC, $path;
} else {
my $name = $self->name;
warn <<"EOT";
**** Warning: $name requires that the $plugin plugin be installed and
enabled; it does not appear to be installed.
EOT
}
$self->requires(@_);
}
sub rt_too_new {
my ($self,$version,$msg) = @_;
$msg ||= "Your version %s is too new, this extension requires a release of RT older than %s\n";
my $name = $self->name;
$msg ||= <<EOT;
**** Error: Your installed version of RT (%s) is too new; this extension
only works with versions older than %s.
EOT
$self->add_metadata("x_rt_too_new", $version) if $self->is_admin;
_load_rt_handle();
my @sorted = sort RT::Handle::cmp_version $version,$RT::VERSION;
......@@ -227,4 +249,4 @@ sub _load_rt_handle {
__END__
#line 367
#line 368
#line 1
package Module::Install::RTx::Factory;
package Module::Install::RTx::Runtime;
use Module::Install::Base; @ISA = qw(Module::Install::Base);
use strict;
use File::Basename ();
sub RTxInitDB {
my ($self, $action, $name, $version) = @_;
unshift @INC, substr(delete($INC{'RT.pm'}), 0, -5) if $INC{'RT.pm'};
sub _rt_runtime_load {
require RT;
unshift @INC, "$RT::LocalPath/lib" if $RT::LocalPath;
$RT::SbinPath ||= $RT::LocalPath;
$RT::SbinPath =~ s/local$/sbin/;
foreach my $file ($RT::CORE_CONFIG_FILE, $RT::SITE_CONFIG_FILE) {
next if !-e $file or -r $file;
die "No permission to read $file\n-- please re-run $0 with suitable privileges.\n";
eval { RT::LoadConfig(); };
if (my $err = $@) {
die $err unless $err =~ /^RT couldn't load RT config file/m;
my $warn = <<EOT;
This usually means that your current user cannot read the file. You
will likely need to run this installation step as root, or some user
with more permissions.
EOT
$err =~ s/This usually means.*/$warn/s;
die $err;
}
}
sub RTxDatabase {
my ($self, $action, $name, $version) = @_;
RT::LoadConfig();
$self->_rt_runtime_load;
require RT::System;
my $has_upgrade = RT::System->can('AddUpgradeHistory');
my $lib_path = File::Basename::dirname($INC{'RT.pm'});
my @args = ("-Ilib");
push @args, "-I$RT::LocalPath/lib" if $RT::LocalPath;
push @args, (
my @args = (
"-Ilib",
"-I$RT::LocalLibPath",
"-I$lib_path",
"$RT::SbinPath/rt-setup-database",
"--action" => $action,
......@@ -36,13 +40,12 @@ sub RTxInitDB {
(($action eq 'insert') ? ("--datafile" => "etc/initialdata") : ()),
"--dba" => $RT::DatabaseAdmin || $RT::DatabaseUser,
"--prompt-for-dba-password" => '',
(RT::System->can('AddUpgradeHistory') ? ("--package" => $name, "--ext-version" => $version) : ()),
($has_upgrade ? ("--package" => $name, "--ext-version" => $version) : ()),
);
# If we're upgrading against an RT which isn't at least 4.2 (has
# AddUpgradeHistory) then pass --package. Upgrades against later RT
# releases will pick up --package from AddUpgradeHistory.
if ($action eq 'upgrade' and
not RT::System->can('AddUpgradeHistory')) {
if ($action eq 'upgrade' and not $has_upgrade) {
push @args, "--package" => $name;
}
......@@ -50,4 +53,25 @@ sub RTxInitDB {
(system($^X, @args) == 0) or die "...returned with error: $?\n";
}
sub RTxPlugin {
my ($self, $name) = @_;
$self->_rt_runtime_load;
require YAML::Tiny;
my $data = YAML::Tiny::LoadFile('META.yml');
my $name = $data->{name};
my @enabled = RT->Config->Get('Plugins');
for my $required (@{$data->{x_requires_rt_plugins} || []}) {
next if grep {$required eq $_} @enabled;
warn <<"EOT";
**** Warning: $name requires that the $required plugin be installed and
enabled; it is not currently in \@Plugins.
EOT
}
}
1;
This diff is collapsed.
#line 1
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
# This file is machine-generated by lib/unicore/mktables from the Unicode
# database, Version 6.3.0. Any changes made here will be lost!
# !!!!!!! INTERNAL PERL USE ONLY !!!!!!!
# This file is for internal use by core Perl only. The format and even the
# name or existence of this file are subject to change without notice. Don't
# use it directly. Use Unicode::UCD to access the Unicode character data
# base.
package charnames;
# This module contains machine-generated tables and code for the
# algorithmically-determinable Unicode character names. The following
# routines can be used to translate between name and code point and vice versa
{ # Closure
# Matches legal code point. 4-6 hex numbers, If there are 6, the first
# two must be 10; if there are 5, the first must not be a 0. Written this
# way to decrease backtracking. The first regex allows the code point to
# be at the end of a word, but to work properly, the word shouldn't end
# with a valid hex character. The second one won't match a code point at
# the end of a word, and doesn't have the run-on issue
my $run_on_code_point_re = qr/(?^aax: (?: 10[0-9A-F]{4} | [1-9A-F][0-9A-F]{4} | [0-9A-F]{4} ) \b)/;
my $code_point_re = qr/(?^aa:\b(?^aax: (?: 10[0-9A-F]{4} | [1-9A-F][0-9A-F]{4} | [0-9A-F]{4} ) \b))/;
# In the following hash, the keys are the bases of names which include
# the code point in the name, like CJK UNIFIED IDEOGRAPH-4E01. The value
# of each key is another hash which is used to get the low and high ends
# for each range of code points that apply to the name.
my %names_ending_in_code_point = (
'CJK COMPATIBILITY IDEOGRAPH' =>
{
'high' =>
[
64109,
64217,
195101,
],
'low' =>
[
63744,
64112,
194560,
],
},
'CJK UNIFIED IDEOGRAPH' =>
{
'high' =>
[
19893,
40908,
173782,
177972,
178205,
],
'low' =>
[
13312,
19968,
131072,
173824,
177984,
],
},
);
# The following hash is a copy of the previous one, except is for loose
# matching, so each name has blanks and dashes squeezed out
my %loose_names_ending_in_code_point = (
'CJKCOMPATIBILITYIDEOGRAPH' =>
{
'high' =>
[
64109,
64217,
195101,
],
'low' =>
[
63744,
64112,
194560,
],
},
'CJKUNIFIEDIDEOGRAPH' =>
{
'high' =>
[
19893,
40908,
173782,
177972,
178205,
],
'low' =>
[
13312,
19968,
131072,
173824,
177984,
],
},
);
# And the following array gives the inverse mapping from code points to
# names. Lowest code points are first
my @code_points_ending_in_code_point = (
{
'high' => 19893,
'low' => 13312,
'name' => 'CJK UNIFIED IDEOGRAPH',
},
{
'high' => 40908,
'low' => 19968,
'name' => 'CJK UNIFIED IDEOGRAPH',
},
{
'high' => 64109,
'low' => 63744,
'name' => 'CJK COMPATIBILITY IDEOGRAPH',
},
{
'high' => 64217,
'low' => 64112,
'name' => 'CJK COMPATIBILITY IDEOGRAPH',
},
{
'high' => 173782,
'low' => 131072,
'name' => 'CJK UNIFIED IDEOGRAPH',
},
{
'high' => 177972,
'low' => 173824,
'name' => 'CJK UNIFIED IDEOGRAPH',
},
{
'high' => 178205,
'low' => 177984,
'name' => 'CJK UNIFIED IDEOGRAPH',
},
{
'high' => 195101,
'low' => 194560,
'name' => 'CJK COMPATIBILITY IDEOGRAPH',
},
,
);
# Convert from code point to Jamo short name for use in composing Hangul
# syllable names
my %Jamo = (
4352 => 'G',
4353 => 'GG',
4354 => 'N',
4355 => 'D',
4356 => 'DD',
4357 => 'R',
4358 => 'M',
4359 => 'B',
4360 => 'BB',
4361 => 'S',
4362 => 'SS',
4363 => '',