line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Packager::Builder::Deb; |
2
|
2
|
|
|
2
|
|
1545
|
use Mouse; |
|
2
|
|
|
|
|
34874
|
|
|
2
|
|
|
|
|
19
|
|
3
|
2
|
|
|
2
|
|
1668
|
use Carp; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
202
|
|
4
|
2
|
|
|
2
|
|
682
|
use CPAN::Packager::FileUtil qw(file dir openw); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
153
|
|
5
|
2
|
|
|
2
|
|
563
|
use CPAN::Packager::ListUtil qw(any); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
119
|
|
6
|
2
|
|
|
2
|
|
556
|
use CPAN::Packager::Home; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
51
|
|
7
|
2
|
|
|
2
|
|
638
|
use CPAN::Packager::Util; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
94
|
|
8
|
|
|
|
|
|
|
with 'CPAN::Packager::Builder::Role'; |
9
|
2
|
|
|
2
|
|
23
|
use Log::Log4perl qw(:easy); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
18
|
|
10
|
2
|
|
|
2
|
|
8481
|
use Try::Tiny; |
|
2
|
|
|
|
|
10823
|
|
|
2
|
|
|
|
|
11299
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'package_output_dir' => ( |
13
|
|
|
|
|
|
|
+default => sub { |
14
|
|
|
|
|
|
|
my $self = shift; |
15
|
|
|
|
|
|
|
dir( CPAN::Packager::Home->detect, 'deb' ); |
16
|
|
|
|
|
|
|
}, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub BUILD { |
20
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
21
|
0
|
|
|
|
|
0
|
$self->check_executables_exist_in_path; |
22
|
0
|
|
|
|
|
0
|
File::Path::mkpath($self->package_output_dir); |
23
|
0
|
|
|
|
|
0
|
$self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub check_executables_exist_in_path { |
27
|
0
|
0
|
|
0
|
0
|
0
|
die "dh_make_perl doesn't exist in PATH" |
28
|
|
|
|
|
|
|
if CPAN::Packager::Util::run_command("which dh-make-perl"); |
29
|
0
|
0
|
|
|
|
0
|
die "dpkg doesn't exist in PATH" |
30
|
|
|
|
|
|
|
if CPAN::Packager::Util::run_command("which dpkg"); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub build { |
34
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $module ) = @_; |
35
|
0
|
0
|
|
|
|
0
|
$self->release( $module->{release} ) if $module->{release}; |
36
|
0
|
0
|
|
|
|
0
|
$self->pkg_name( $module->{pkg_name} ) if $module->{pkg_name}; |
37
|
0
|
|
|
|
|
0
|
my $package = $self->_build_package_with_dh_make_perl($module); |
38
|
0
|
|
|
|
|
0
|
$self->install($module); |
39
|
0
|
|
|
|
|
0
|
return $package; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _build_package_with_dh_make_perl { |
43
|
0
|
|
|
0
|
|
0
|
my ( $self, $module ) = @_; |
44
|
0
|
0
|
|
|
|
0
|
die "module param must have module name" unless $module->{module}; |
45
|
0
|
0
|
|
|
|
0
|
die "Can't find source for package" unless $module->{src}; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
my $package = $self->get_package_name($module); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
my $package_output_dir = $self->package_output_dir; |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
0
|
if ( !$module->{force_build} ) { |
52
|
0
|
0
|
|
|
|
0
|
if ( $self->is_installed($package) ) { |
53
|
0
|
|
|
|
|
0
|
return $package; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
my $verbose = $self->config( global => "verbose" ); |
58
|
|
|
|
|
|
|
try { |
59
|
0
|
|
|
0
|
|
0
|
CPAN::Packager::Util::run_command( "rm -rf $module->{src}/debian", |
60
|
|
|
|
|
|
|
$verbose ); |
61
|
0
|
|
|
|
|
0
|
my $dh_make_perl_cmd |
62
|
|
|
|
|
|
|
= $self->_build_dh_make_perl_command( $module, $package ); |
63
|
0
|
|
|
|
|
0
|
CPAN::Packager::Util::run_command( $dh_make_perl_cmd, $verbose ); |
64
|
0
|
|
|
|
|
0
|
CPAN::Packager::Util::run_command( |
65
|
|
|
|
|
|
|
"cp $module->{src}/../$package*.deb $package_output_dir", |
66
|
|
|
|
|
|
|
$verbose ); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} catch { |
69
|
0
|
|
|
0
|
|
0
|
INFO($_); |
70
|
0
|
|
|
|
|
0
|
die; |
71
|
0
|
|
|
|
|
0
|
}; |
72
|
0
|
|
|
|
|
0
|
$package; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub install { |
76
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $module ) = @_; |
77
|
0
|
|
|
|
|
0
|
my $package = $self->get_package_name($module); |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
0
|
CPAN::Packager::Util::run_command( |
80
|
0
|
|
|
|
|
0
|
"sudo dpkg -i $module->{src}/../${package}_@{[ $module->{version} ]}*.deb", |
81
|
|
|
|
|
|
|
$self->config( global => "verbose" ) |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _build_dh_make_perl_command { |
87
|
0
|
|
|
0
|
|
0
|
my ( $self, $module, $package ) = @_; |
88
|
0
|
|
|
|
|
0
|
my @depends = $self->depends($module); |
89
|
0
|
|
|
|
|
0
|
my $depends = join ',', @depends; |
90
|
0
|
|
|
|
|
0
|
DEBUG("depends: $depends"); |
91
|
0
|
|
|
|
|
0
|
my $dh_make_perl_cmd |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# = "dh-make-perl --build --depends '\${shlibs:Depends},$depends' $module->{src} --package $package "; # hmm. etch's dh-make-perl don't have --package option. |
94
|
|
|
|
|
|
|
= "dh-make-perl --build --depends '\${shlibs:Depends},$depends' $module->{src}"; |
95
|
0
|
0
|
|
|
|
0
|
if ( $module->{skip_test} ) { |
96
|
0
|
|
|
|
|
0
|
$dh_make_perl_cmd .= " --notest"; |
97
|
|
|
|
|
|
|
} |
98
|
0
|
0
|
|
|
|
0
|
if ( $module->{version} ) { |
99
|
0
|
|
|
|
|
0
|
my $version = $module->{version}; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# XXX: Debian package compare version. |
102
|
|
|
|
|
|
|
# So if module version is 1.2 and debian's module version is 1.1901, |
103
|
|
|
|
|
|
|
# atitude install 1.1901. |
104
|
|
|
|
|
|
|
# so convert vertion 1.2 to 1.2000. |
105
|
0
|
0
|
|
|
|
0
|
if ( $version =~ /^(\d+\.)(\d)+$/ ) { # major-minor pattern version. |
106
|
0
|
|
|
|
|
0
|
my $geta = length $1; |
107
|
0
|
|
|
|
|
0
|
while ( length($version) - $geta < 4 ) { |
108
|
0
|
|
|
|
|
0
|
$version .= "0"; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
0
|
if ( $self->release ) { |
113
|
0
|
|
|
|
|
0
|
$version .= "-" . $self->release; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
else { |
116
|
0
|
|
|
|
|
0
|
$version .= "-1"; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
0
|
$dh_make_perl_cmd .= " --version $version"; |
120
|
|
|
|
|
|
|
} |
121
|
0
|
0
|
|
|
|
0
|
if ( $self->pkg_name ) { |
122
|
0
|
|
|
|
|
0
|
$dh_make_perl_cmd .= " --packagename " . $self->pkg_name; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
0
|
$dh_make_perl_cmd; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub depends { |
129
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $module ) = @_; |
130
|
0
|
|
|
|
|
0
|
my @depends = (); |
131
|
|
|
|
|
|
|
|
132
|
0
|
0
|
|
|
|
0
|
push @depends, map { $self->package_name($_) } @{ $module->{depends} } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
133
|
|
|
|
|
|
|
if $module->{depends}; |
134
|
0
|
|
|
|
|
0
|
my $module_name = $module->{module}; |
135
|
0
|
0
|
0
|
|
|
0
|
if ( $self->config( modules => $module_name ) |
136
|
|
|
|
|
|
|
&& $self->config( modules => $module_name )->{no_depends} ) |
137
|
|
|
|
|
|
|
{ |
138
|
0
|
|
|
|
|
0
|
my @no_depends = (); |
139
|
0
|
|
|
|
|
0
|
push @no_depends, |
140
|
0
|
|
|
|
|
0
|
map { $self->package_name($_) } @{ $module->{no_depends} }; |
|
0
|
|
|
|
|
0
|
|
141
|
0
|
|
|
|
|
0
|
@depends = $self->_filter_requires( \@depends, \@no_depends ); |
142
|
|
|
|
|
|
|
} |
143
|
0
|
|
|
|
|
0
|
push @depends, 'perl'; |
144
|
0
|
0
|
|
|
|
0
|
wantarray ? @depends : \@depends; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub _filter_requires { |
148
|
0
|
|
|
0
|
|
0
|
my ( $self, $depends, $no_depends ) = @_; |
149
|
0
|
|
|
|
|
0
|
my @filtered = (); |
150
|
0
|
|
|
|
|
0
|
foreach my $depend ( @{$depends} ) { |
|
0
|
|
|
|
|
0
|
|
151
|
0
|
|
|
0
|
|
0
|
my $is_no_depend = any { $_ eq $depend } @{$no_depends}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
152
|
0
|
0
|
|
|
|
0
|
push @filtered, $depend unless $is_no_depend; |
153
|
|
|
|
|
|
|
} |
154
|
0
|
0
|
|
|
|
0
|
wantarray ? @filtered : \@filtered; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub package_name { |
159
|
2
|
|
|
2
|
0
|
6
|
my ( $self, $module_name ) = @_; |
160
|
2
|
50
|
|
|
|
6
|
die "module_name is required" unless $module_name; |
161
|
2
|
100
|
|
|
|
9
|
return 'libwww-perl' if $module_name eq 'libwww::perl'; |
162
|
1
|
|
|
|
|
1018
|
$module_name =~ s{::}{-}g; |
163
|
1
|
|
|
|
|
2
|
$module_name =~ s{_}{-}g; |
164
|
1
|
|
|
|
|
6
|
'lib' . lc($module_name) . '-perl'; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub is_installed { |
168
|
0
|
|
|
0
|
0
|
|
my ( $self, $package ) = @_; |
169
|
|
|
|
|
|
|
|
170
|
0
|
0
|
|
|
|
|
if ( $package !~ /^lib.+-perl/ ) { |
171
|
0
|
0
|
0
|
|
|
|
if ( $self->config( modules => $package ) |
172
|
|
|
|
|
|
|
&& $self->config( modules => $package )->{pkg_name} ) |
173
|
|
|
|
|
|
|
{ |
174
|
0
|
|
|
|
|
|
$package = $self->config( modules => $package )->{pkg_name}; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
else { |
177
|
0
|
|
|
|
|
|
$package = $self->package_name($package); |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
my $already_installed; |
182
|
0
|
|
|
|
|
|
eval { $already_installed = system("dpkg -L $package > /dev/null"); }; |
|
0
|
|
|
|
|
|
|
183
|
0
|
0
|
0
|
|
|
|
if ( defined $already_installed && $already_installed == 0 ) { |
184
|
0
|
|
|
|
|
|
INFO("$package already installed. skip building"); |
185
|
0
|
|
|
|
|
|
return 1; |
186
|
|
|
|
|
|
|
} |
187
|
0
|
0
|
|
|
|
|
if ($@) { |
188
|
0
|
|
|
|
|
|
$@ = undef; # ok. skiped. |
189
|
|
|
|
|
|
|
} |
190
|
0
|
|
|
|
|
|
return 0; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub installed_packages { |
194
|
0
|
|
|
0
|
0
|
|
my @installed_pkg; |
195
|
0
|
|
|
|
|
|
my $is_pkg = 0; |
196
|
0
|
|
|
|
|
|
for my $l ( split /[¥r¥n]+/, qx{LANG=C dpkg -l 'lib*-perl'} ) { |
197
|
0
|
0
|
0
|
|
|
|
if ( $l =~ /^[+]{3}/ ) { |
|
|
0
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
$is_pkg = 1; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
elsif ( $is_pkg && $l =~ /^ii/ ) { # if installed |
201
|
0
|
|
|
|
|
|
my ( $stat, $pkg, $ver, $desc ) = split ' ', $l; |
202
|
0
|
|
|
|
|
|
push @installed_pkg, $pkg; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
} |
205
|
0
|
|
|
|
|
|
@installed_pkg; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub print_installed_packages { |
209
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
210
|
0
|
|
|
|
|
|
my $installed_file = file( $self->package_output_dir, 'installed' ); |
211
|
0
|
|
|
|
|
|
my $fh = openw($installed_file); |
212
|
0
|
|
|
|
|
|
print $fh "aptitude -y install $_\n" for $self->installed_packages; |
213
|
0
|
|
|
|
|
|
close $fh; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
2
|
|
|
2
|
|
27
|
no Mouse; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
50
|
|
217
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
218
|
|
|
|
|
|
|
1; |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
__END__ |