line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Build::Custom; |
2
|
1
|
|
|
1
|
|
3884
|
use Module::Build; |
|
1
|
|
|
|
|
124542
|
|
|
1
|
|
|
|
|
818
|
|
3
|
|
|
|
|
|
|
@ISA = qw(Module::Build); |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub ACTION_distdir { |
6
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
7
|
0
|
|
|
|
|
|
$self->SUPER::ACTION_distdir; |
8
|
|
|
|
|
|
|
|
9
|
0
|
|
|
|
|
|
$self->depends_on("buildagent"); |
10
|
0
|
|
|
|
|
|
my @agents = (); |
11
|
|
|
|
|
|
|
find( |
12
|
|
|
|
|
|
|
{ |
13
|
|
|
|
|
|
|
wanted => sub { |
14
|
0
|
0
|
|
0
|
|
|
push @agents,$_ if /osgish-(core|bundle).*\.jar/; |
15
|
|
|
|
|
|
|
}, |
16
|
0
|
|
|
|
|
|
no_chdir => 1 |
17
|
|
|
|
|
|
|
},"agent"); |
18
|
0
|
0
|
|
|
|
|
die "No agent jars found" unless @agents; |
19
|
0
|
|
|
|
|
|
for my $agent (@agents) { |
20
|
0
|
0
|
|
|
|
|
my $file = $1 . ".jar" if $agent =~ m{/(osgish-(core|bundle))}; |
21
|
0
|
0
|
|
|
|
|
File::Copy::copy($agent,$self->dist_dir . "/$file") || die "Cannot copy $agent to ",$self->dist_dir,"/$file : $!"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub ACTION_clean { |
26
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
27
|
0
|
0
|
|
|
|
|
print "No mvn installed, skipping ...\n" unless $self->do_system(qw(mvn -f agent/pom.xml clean)); |
28
|
0
|
|
|
|
|
|
$self->SUPER::ACTION_clean; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub ACTION_get_agent { |
32
|
0
|
|
|
0
|
0
|
|
&_download("osgish-core","jar"); |
33
|
0
|
|
|
|
|
|
&_download("osgish-bundle","jar"); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _download { |
37
|
0
|
|
|
0
|
|
|
my ($name,$type) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
eval { |
40
|
0
|
|
|
|
|
|
require LWP; |
41
|
|
|
|
|
|
|
}; |
42
|
0
|
0
|
|
|
|
|
if ($@) { |
43
|
0
|
|
|
|
|
|
print "No LWP installed\n"; |
44
|
0
|
|
|
|
|
|
exit 1; |
45
|
|
|
|
|
|
|
} |
46
|
0
|
|
|
|
|
|
my $BASE_URL = "http://labs.consol.de/maven/repository/org/jolokia/osgish"; |
47
|
0
|
|
|
|
|
|
my $version = &_extract_version(); |
48
|
0
|
|
|
|
|
|
my $file = "$name-${version}.$type"; |
49
|
0
|
|
|
|
|
|
my $url = $BASE_URL . "/$name/$version/$file"; |
50
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
51
|
0
|
|
|
|
|
|
my $res = $ua->request(new HTTP::Request(GET => $url)); |
52
|
0
|
|
|
|
|
|
my $content = $res->content; |
53
|
0
|
0
|
|
|
|
|
if ($res->is_success) { |
54
|
0
|
0
|
|
|
|
|
open(F,">$file") || die "Cannot open $file: $!\n"; |
55
|
0
|
|
|
|
|
|
print F $content; |
56
|
0
|
|
|
|
|
|
close F; |
57
|
0
|
|
|
|
|
|
print "Downloaded $file into local directory\n"; |
58
|
|
|
|
|
|
|
} else { |
59
|
0
|
|
|
|
|
|
print "Error fetching $url\n"; |
60
|
0
|
|
|
|
|
|
print $res->status_line,"\n"; |
61
|
0
|
|
|
|
|
|
exit 1; |
62
|
|
|
|
|
|
|
} |
63
|
0
|
|
|
|
|
|
eval { |
64
|
0
|
|
|
|
|
|
require Digest::SHA1; |
65
|
|
|
|
|
|
|
}; |
66
|
0
|
0
|
|
|
|
|
if ($@) { |
67
|
0
|
|
|
|
|
|
print "No Digest::SHA1 installed. Skipping checksum test\n"; |
68
|
0
|
|
|
|
|
|
return; |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
|
|
|
$res = $ua->request(new HTTP::Request(GET => $url . ".sha1")); |
71
|
0
|
0
|
|
|
|
|
if ($res->is_success) { |
72
|
0
|
|
|
|
|
|
my $r_sha1 = $res->content; |
73
|
0
|
|
|
|
|
|
chomp $r_sha1; |
74
|
0
|
|
|
|
|
|
my $sha1 = new Digest::SHA1; |
75
|
0
|
|
|
|
|
|
$sha1->add($content); |
76
|
0
|
0
|
|
|
|
|
if ($r_sha1 ne $sha1->hexdigest) { |
77
|
0
|
|
|
|
|
|
print "CHECKSUM Error:\nRemote SHA1: $r_sha1\nLocal SHA1: ",$sha1->hexdigest,"\n"; |
78
|
0
|
|
|
|
|
|
exit 1; |
79
|
|
|
|
|
|
|
} else { |
80
|
0
|
|
|
|
|
|
print "SHA1 Checksum $r_sha1 verified\n"; |
81
|
0
|
|
|
|
|
|
return; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} else { |
84
|
0
|
|
|
|
|
|
print $res->status_line,"\n"; |
85
|
0
|
|
|
|
|
|
exit 1; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub ACTION_buildagent { |
90
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
91
|
1
|
|
|
1
|
|
754
|
use FindBin; |
|
1
|
|
|
|
|
961
|
|
|
1
|
|
|
|
|
44
|
|
92
|
1
|
|
|
1
|
|
7
|
use File::Find; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
664
|
|
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my $pom = "$FindBin::Bin/agent/pom.xml"; |
95
|
0
|
|
|
|
|
|
my $version = &_extract_version(); |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
die "Cannot extract version from Perl Modul OSGi::Osgish" unless $version; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
find( sub { |
100
|
0
|
0
|
|
0
|
|
|
if ($_ eq "pom.xml") { |
101
|
|
|
|
|
|
|
&_replace_version($File::Find::name,$version, |
102
|
|
|
|
|
|
|
sub { |
103
|
0
|
|
|
|
|
|
my $v = shift; |
104
|
0
|
|
|
|
|
|
my $t = shift; |
105
|
0
|
|
|
|
|
|
$t =~ s|(\s+)\s*(.+)\s*()|$1$v$3|; |
106
|
0
|
|
|
|
|
|
$t =~ s|(osgish-core\s+)\s*(.+)\s*()|$1$v$3|; |
107
|
0
|
|
|
|
|
|
$t =~ s|(.*)\s*(.+)\s*(.*)|$1$v$3|s; |
108
|
0
|
|
|
|
|
|
return $t; |
109
|
0
|
|
|
|
|
|
}); |
110
|
|
|
|
|
|
|
} |
111
|
0
|
|
|
|
|
|
},"$FindBin::Bin/agent"); |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
|
|
|
|
print "Cannot re-create agent" |
114
|
|
|
|
|
|
|
unless $self->do_system(qw(mvn -f agent/pom.xml clean install)); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub _extract_version { |
118
|
0
|
|
|
0
|
|
|
my $version_perl = "$FindBin::Bin/lib/OSGi/Osgish.pm"; |
119
|
0
|
0
|
|
|
|
|
open(F,"$version_perl") || die "Cannot open $version_perl : $!"; |
120
|
0
|
|
|
|
|
|
my $v = join "",; |
121
|
0
|
|
|
|
|
|
close F; |
122
|
0
|
0
|
|
|
|
|
my $version = $1 if $v =~ /^\s+\$VERSION\s+=\s+"([^"]+)"/m; |
123
|
0
|
|
|
|
|
|
return $version; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub _replace_version { |
127
|
0
|
|
|
0
|
|
|
my $file = shift; |
128
|
0
|
|
|
|
|
|
my $version = shift; |
129
|
0
|
|
|
|
|
|
my $replace_sub = shift; |
130
|
|
|
|
|
|
|
|
131
|
0
|
0
|
|
|
|
|
my ($ma,$mi,$pa,$dev) = ($1,$2,$3,$4) if $version =~ /^(\d+)\.(\d+)(?:\.(\d+))?(?:_(\d+))?$/; |
132
|
0
|
0
|
|
|
|
|
$pa = "0" unless $pa; |
133
|
0
|
|
|
|
|
|
$version = "$ma.$mi.$pa"; |
134
|
0
|
0
|
|
|
|
|
if ($dev) { |
135
|
0
|
|
|
|
|
|
$version .= ".M" . $dev; |
136
|
|
|
|
|
|
|
} |
137
|
0
|
|
|
|
|
|
print "Setting version to $version in $file\n"; |
138
|
|
|
|
|
|
|
|
139
|
0
|
0
|
|
|
|
|
open(F,"$file") || die "Cannot open $file : $!"; |
140
|
0
|
|
|
|
|
|
my $c = join "",; |
141
|
0
|
|
|
|
|
|
close F; |
142
|
0
|
|
|
|
|
|
$c = &{$replace_sub}($version,$c); |
|
0
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
my $changed_perm = undef; |
144
|
0
|
0
|
|
|
|
|
if (! -w $file) { |
145
|
0
|
|
|
|
|
|
$changed_perm = 1; |
146
|
0
|
|
|
|
|
|
my $perm = (stat $file)[2] & 07777; |
147
|
0
|
0
|
|
|
|
|
chmod($perm | 0200,$file) || die "Cannot change write permission for $file : $!"; |
148
|
|
|
|
|
|
|
} |
149
|
0
|
0
|
|
|
|
|
open(F,">$file") || die "Cannot open $file for writing: $!"; |
150
|
0
|
|
|
|
|
|
print F $c; |
151
|
0
|
|
|
|
|
|
close F; |
152
|
0
|
0
|
|
|
|
|
if ($changed_perm) { |
153
|
0
|
|
|
|
|
|
my $perm = (stat $file)[2] & 0777; |
154
|
0
|
0
|
|
|
|
|
chmod($perm & 0577,$file) || die "Cannot remove write permission from $file : $!"; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
1; |