line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PAR::Repository::Client::Util; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
21216
|
use 5.006; |
|
9
|
|
|
|
|
36
|
|
|
9
|
|
|
|
|
500
|
|
4
|
9
|
|
|
9
|
|
49
|
use strict; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
293
|
|
5
|
9
|
|
|
9
|
|
71
|
use warnings; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
430
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
8
|
|
|
|
|
|
|
|
9
|
9
|
|
|
9
|
|
46
|
use Carp qw/croak/; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
5628
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
PAR::Repository::Client::Util - Small helper methods common to all implementations |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use PAR::Repository::Client; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This module implements small helper methods which are common to all |
22
|
|
|
|
|
|
|
L implementations. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 PRIVATE METHODS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
These private methods should not be relied upon from the outside of |
27
|
|
|
|
|
|
|
the module. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 _unzip_file |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This is a private method. Callable as class or instance method. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Unzips the file given as first argument to the file |
34
|
|
|
|
|
|
|
given as second argument. |
35
|
|
|
|
|
|
|
If a third argument is used, the zip member of that name |
36
|
|
|
|
|
|
|
is extracted. If the zip member name is omitted, it is |
37
|
|
|
|
|
|
|
set to the target file name. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Returns the name of the unzipped file. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _unzip_file { |
44
|
13
|
|
|
13
|
|
33
|
my $class = shift; |
45
|
13
|
|
|
|
|
29
|
my $file = shift; |
46
|
13
|
|
|
|
|
49
|
my $target = shift; |
47
|
13
|
|
|
|
|
30
|
my $member = shift; |
48
|
13
|
50
|
|
|
|
104
|
$member = $target if not defined $member; |
49
|
13
|
50
|
|
|
|
302
|
return unless -f $file; |
50
|
|
|
|
|
|
|
|
51
|
13
|
|
|
|
|
162
|
my $zip = Archive::Zip->new; |
52
|
13
|
|
|
|
|
588
|
local %SIG; |
53
|
13
|
0
|
|
0
|
|
131
|
$SIG{__WARN__} = sub { print STDERR $_[0] unless $_[0] =~ /\bstat\b/ }; |
|
0
|
|
|
|
|
0
|
|
54
|
|
|
|
|
|
|
|
55
|
13
|
50
|
33
|
|
|
82
|
return unless $zip->read($file) == Archive::Zip::AZ_OK() |
56
|
|
|
|
|
|
|
and $zip->extractMember($member, $target) == Archive::Zip::AZ_OK(); |
57
|
|
|
|
|
|
|
|
58
|
13
|
|
|
|
|
40553
|
return $target; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# given a distribution name, recursively determines all distributions |
63
|
|
|
|
|
|
|
# it depends on |
64
|
|
|
|
|
|
|
sub _resolve_static_dependencies { |
65
|
2
|
|
|
2
|
|
14
|
my $self = shift; |
66
|
2
|
|
|
|
|
4
|
my $distribution = shift; |
67
|
|
|
|
|
|
|
|
68
|
2
|
|
|
|
|
19
|
my ($deph) = $self->dependencies_dbm(); |
69
|
2
|
50
|
|
|
|
16
|
return([]) if not exists $deph->{$distribution}; |
70
|
|
|
|
|
|
|
|
71
|
2
|
|
|
|
|
1583
|
my ($modh) = $self->modules_dbm(); |
72
|
|
|
|
|
|
|
|
73
|
2
|
|
|
|
|
4
|
my @module_queue = (keys %{$deph->{$distribution}}); |
|
2
|
|
|
|
|
16
|
|
74
|
2
|
|
|
|
|
12344
|
my @dep_dists; |
75
|
|
|
|
|
|
|
my %module_seen; |
76
|
0
|
|
|
|
|
0
|
my %dist_seen; |
77
|
|
|
|
|
|
|
|
78
|
2
|
|
|
|
|
128
|
while (@module_queue) { |
79
|
|
|
|
|
|
|
#use Data::Dumper; warn Dumper \@module_queue; |
80
|
18
|
|
|
|
|
26161
|
my $module = shift @module_queue; |
81
|
18
|
50
|
|
|
|
83
|
next if $module_seen{$module}++; |
82
|
18
|
100
|
|
|
|
253
|
next if not exists $modh->{$module}; # FIXME should this be somehow reported? |
83
|
4
|
|
|
|
|
3041
|
my $dist = $self->prefered_distribution($module, $modh->{$module}); |
84
|
4
|
50
|
|
|
|
23
|
next if not defined $dist; |
85
|
4
|
50
|
|
|
|
188
|
next if $dist_seen{$dist}++; |
86
|
4
|
|
|
|
|
7
|
push @dep_dists, $dist; |
87
|
4
|
50
|
|
|
|
27
|
push @module_queue, keys %{$deph->{$dist}} if exists $deph->{$dist}; |
|
4
|
|
|
|
|
3111
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
2
|
|
|
|
|
4197
|
return \@dep_dists; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub generate_private_cache_dir { |
94
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
95
|
0
|
|
|
|
|
|
my $uri = $self->{uri}; |
96
|
0
|
|
|
|
|
|
my $digester = PAR::SetupTemp::_get_digester(); # requires PAR 0.987! |
97
|
0
|
|
|
|
|
|
$digester->add($uri); |
98
|
0
|
|
|
|
|
|
my $digest = $digester->b64digest(); |
99
|
0
|
|
|
|
|
|
$digest =~ s/\W/_/g; |
100
|
0
|
|
|
|
|
|
my $user_temp_dir = PAR::SetupTemp::_get_par_user_tempdir(); |
101
|
0
|
|
|
|
|
|
my $priv_cache_dir = File::Spec->catdir($user_temp_dir, "par-repo-$digest"); |
102
|
0
|
|
|
|
|
|
return $priv_cache_dir; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
__END__ |