-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patherrep.perl
98 lines (68 loc) · 2.13 KB
/
errep.perl
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
#!perl -w
use strict;
use Config;
my @precommands=('uname -a','perl -V');
my @manpages=('dlopen','shl_load','dlsym','dlclose');
my @postcommands=map { "man $_ | col -bf | cat -s" } @manpages;
print <<EOF;
This script will gather information about your system in order to
help debugging the problem compiling or testing Imager on your
system.
Make sure that you are in the same directory as errep.perl is when
running the script. Also make sure that the environment variables
are the same as when running perl Makefile.PL
It issues: uname -a, perl -V and gets the %Config hash from the
build of the perl binary. Then it tries to build and test the
module (but not install it). It dumps out the test logs if there
are any. It ends by dumping out some manpages.
All the results are saved to the file 'report.txt'
Continue [Y/n]?
EOF
my $a=<STDIN>;
chomp($a);
die "Aborted!\n" if $a =~ /^n/i;
print "Generating info about system\n";
open OSTD, '>&STDOUT' or die $!;
open STDOUT, '>report.txt' or die $!;
open STDERR, '>&STDOUT' or die $!;
rcomm('rm testout/*');
rcomm(@precommands);
my $make = $Config{make};
rcomm("$^X Makefile.PL --verbose") || rcomm("$make") || rcomm("$make test TEST_VERBOSE=1");
head("Logfiles from run");
dumplogs();
pconf();
rcomm(@postcommands);
sub pconf {
head("perl Config parameters");
for(sort keys %Config) { print $_,"=>",(defined $Config{$_} ? $Config{$_} : '(undef)'),"\n"; }
print "\n";
}
sub rcomm {
my @commands=@_;
my ($comm,$R);
for $comm(@commands) {
print "Executing '$comm'\n";
print OSTD "Executing '$comm'\n";
$R=system($comm);
print "warning - rc=$R\n" if $R;
print "=====================\n\n";
}
return $R;
}
sub head {
my $h=shift;
print "=========================\n";
print $h;
print "\n=========================\n";
}
sub dumplogs {
opendir(DH,"testout") || die "Cannot open dir testout: $!\n";
my @fl=sort grep(/\.log$/,readdir(DH));
for my $f (@fl) {
print "::::::::::::::\ntestout/$f\n::::::::::::::\n";
open(FH,"testout/$f") || warn "Cannot open testout/$f: $!\n";
print while(<FH>);
close(FH);
}
}