1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
use strict;
use warnings;
use inc::Module::Install;
# Module::Install stuff
{
no_index directory => 't/lib';
no_index file => 'examples/friends_photos/FriendsPhotos.pm';
license ('perl');
# Graphics::Magick is recommended over Image::Magick, but isn't on CPAN
recommends
'Image::Magick' => 0;
# This could probably become a "test_requires"
requires 'Image::Size' => 0;
}
use Config ();
use Getopt::Long();
use Data::Dumper ();
my $TESTDB = "test";
use vars qw($opt);
$opt = {
"help" => \&Usage ,
testdsn => 'dbi:SQLite:dbname=t/test.db',
};
Getopt::Long::GetOptions($opt, "help", "testdsn=s", "testuser=s","testpassword=s");
my $source = {};
for my $key (qw/testdsn testuser testpassword/) {
Configure($opt, $source, $key);
}
print <<"MSG";
I will use the following settings for compiling and testing:
MSG
delete $opt->{'help'};
my $keylen = 0;
for my $key (keys %$opt) {
$keylen = length($key) if length($key) > $keylen;
}
my $slen = 0;
for my $val (values %$source) {
$slen = length($val) if length($val) > $slen;
}
for my $key (sort { $a cmp $b} keys %$opt) {
printf(" %-" . $keylen . "s (%-" . $slen . "s) = %s\n",
$key, $source->{$key}, $opt->{$key})
}
print <<"MSG";
To change these settings, see 'perl Makefile.PL --help'.
MSG
#sleep 5;
eval { require File::Spec };
my $fileName = $@ ?
"t/cgi-uploader.config" : File::Spec->catfile("t", "cgi-uploader.config");
die "Failed to determine location of $fileName" unless -f $fileName;
if (open(FILE, ">$fileName")) {
print FILE '$dsn = q!'.$opt->{testdsn}."!;\n";
print FILE '$user = q!'.$opt->{testuser}."!;\n";
print FILE '$password = q!'.$opt->{testpassword}."!;\n";
print FILE "1;\n";
close(FILE) or die "Failed to create $fileName: $!";
}
sub Configure {
my($opt, $source, $param) = @_;
if (exists($opt->{$param})) {
$source->{$param} = "Users choice";
return;
}
elsif ($param eq "testuser" || $param eq "testpassword" ||
$param eq "testdsn") {
$source->{$param} = "default";
$opt->{$param} = "";
} else {
die "Unknown configuration parameter: $param";
}
}
sub Usage {
print STDERR <<"USAGE";
Usage: perl $0 [options]
Possible options are:
--testdsn=<dsn> Use the DBI datasource <dsn> for running the test suite
Postgres Example:
dbi:Pg:dbname=\$db;host=\$host;username=\$user;password=\$pw
MySQL Example:
DBI:mysql:database=\$db;host=\$hostname
--testuser=<user>
--testpassword=<password>
--help Print this message and exit
Tables named "uploads" and "cgi_uploader_test" will be created and then
removed. If a table by that name already exists, the tests will be skipped.
USAGE
exit 1;
}
use 5.008;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'CGI::Uploader',
AUTHOR => 'Mark Stosberg <mark@summersault.com>',
'VERSION_FROM' => 'lib/CGI/Uploader.pm', # finds $VERSION
'PREREQ_PM' => {
'Carp::Assert' => 0,
'CGI::Carp' => 0,
'Digest::MD5' => 0,
'File::Copy' => 0,
'File::Spec' => 0,
'File::MMagic' => 1.22,
'File::Path' => 0,
'MIME::Type' => 0,
'MIME::Types' => 0,
'Params::Validate' => 0.77,
'SQL::Abstract' => 0,
'CGI' => 0,
'DBI' => 0,
'DBD::SQLite' => 1.1,
'File::Temp' => 0.15,
'Test::DatabaseRow' => 0,
'HTTP::BrowserDetect' => 0.98,
'Scalar::Util' => 0,
# For testing
'HTTP::Request::Common' => 0,
},
);
|