line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Apt::SourceEntry; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
21757
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
173
|
|
4
|
6
|
|
|
6
|
|
33
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
276
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Config::Apt::SourceEntry - Manipulate apt source entries |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.10 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
17
|
6
|
|
|
6
|
|
31
|
use Carp; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
4257
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Config::Apt::SourceEntry; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $src = new Config::Apt::SourceEntry; |
24
|
|
|
|
|
|
|
$src->from_string("deb http://ftp.us.debian.org/debian/ unstable main"); |
25
|
|
|
|
|
|
|
... |
26
|
|
|
|
|
|
|
my $src = new Config::Apt::SourceEntry("deb http://ftp.us.debian.org/debian/ unstable main non-free"); |
27
|
|
|
|
|
|
|
$src->set_uri("http://apt-proxy:9999/"); |
28
|
|
|
|
|
|
|
print $src->to_string(); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 FUNCTIONS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 new |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The Config::Apt::SourceEntry constructor has one optional string argument. If |
35
|
|
|
|
|
|
|
the optional argument is given, it will be parsed as an apt source. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub new { |
40
|
28
|
|
|
28
|
1
|
412
|
my ($class_name) = @_; |
41
|
28
|
|
|
|
|
113
|
my ($self) = { 'type' => "", |
42
|
|
|
|
|
|
|
'uri' => "", |
43
|
|
|
|
|
|
|
'dist' => "", |
44
|
|
|
|
|
|
|
'components' => [ ], |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
28
|
|
|
|
|
69
|
bless($self, $class_name); |
48
|
28
|
100
|
|
|
|
73
|
if (@_ > 1) { |
49
|
27
|
100
|
|
|
|
63
|
if (!defined(from_string($self,$_[1]))) { $self = undef }; |
|
1
|
|
|
|
|
3
|
|
50
|
|
|
|
|
|
|
} |
51
|
28
|
|
|
|
|
151
|
return $self; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 to_string |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Returns the string representation of the apt source. Takes no arguments. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
print $src->to_string(); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub to_string { |
64
|
23
|
|
|
23
|
1
|
33
|
my $self = shift; |
65
|
23
|
|
|
|
|
35
|
local $"=' '; |
66
|
23
|
|
|
|
|
60
|
my $ret = $self->{'type'} . " " . $self->{'uri'} . " " . $self->{'dist'}; |
67
|
23
|
100
|
|
|
|
38
|
if (@{$self->{'components'}} > 0) { |
|
23
|
|
|
|
|
63
|
|
68
|
22
|
|
|
|
|
26
|
$ret .= " " . "@{ $self->{'components'} }"; |
|
22
|
|
|
|
|
67
|
|
69
|
|
|
|
|
|
|
} |
70
|
23
|
|
|
|
|
667
|
return $ret; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 from_string |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Parses the given string argument as an apt source. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$src->from_string("deb http://ftp.us.debian.org/debian/ unstable main"); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Returns undef on error, otherwise 1. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub from_string { |
84
|
28
|
|
|
28
|
1
|
49
|
my ($self,$str) = @_; |
85
|
|
|
|
|
|
|
# trim whitespace |
86
|
28
|
|
|
|
|
88
|
$str =~ s/^\s+//; |
87
|
28
|
|
|
|
|
83
|
$str =~ s/\s+$//; |
88
|
28
|
|
|
|
|
222
|
$str =~ s/\s+/ /g; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# trim comments |
91
|
28
|
|
|
|
|
68
|
$str =~ s/#.*$//g; |
92
|
|
|
|
|
|
|
|
93
|
28
|
|
|
|
|
100
|
my @source = split / /,$str; |
94
|
28
|
100
|
|
|
|
85
|
unless (@source >= 3) { |
95
|
1
|
|
|
|
|
529
|
carp "Invalid source"; |
96
|
1
|
|
|
|
|
806
|
return undef; |
97
|
|
|
|
|
|
|
} |
98
|
27
|
|
|
|
|
58
|
$self->{'type'} = shift @source; |
99
|
27
|
|
|
|
|
44
|
$self->{'uri'} = shift @source; |
100
|
27
|
|
|
|
|
36
|
$self->{'dist'} = shift @source; |
101
|
27
|
|
|
|
|
57
|
$self->{'components'} = [ @source ]; |
102
|
27
|
|
|
|
|
101
|
return 1; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 get_type, get_uri, get_dist, get_components |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Returns the type, uri, distribution (strings), or components (array of strings) |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
2
|
|
|
2
|
1
|
11
|
sub get_type { my $self=shift;return $self->{'type'}; } |
|
2
|
|
|
|
|
7
|
|
112
|
2
|
|
|
2
|
1
|
9
|
sub get_uri { my $self=shift;return $self->{'uri'}; } |
|
2
|
|
|
|
|
6
|
|
113
|
2
|
|
|
2
|
1
|
9
|
sub get_dist { my $self=shift;return $self->{'dist'}; } |
|
2
|
|
|
|
|
5
|
|
114
|
4
|
|
|
4
|
1
|
14
|
sub get_components { my $self=shift;return @{ $self->{'components'} };} |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
24
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 set_type, set_uri, set_dist, set_components |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Sets the type, uri, distribution (strings), or components (array of strings) |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
1
|
|
|
1
|
1
|
694
|
sub set_type { my $self=shift;$self->{'type'} = shift; } |
|
1
|
|
|
|
|
3
|
|
123
|
3
|
|
|
3
|
1
|
10
|
sub set_uri { my $self=shift;$self->{'uri'} = shift; } |
|
3
|
|
|
|
|
9
|
|
124
|
1
|
|
|
1
|
1
|
5
|
sub set_dist { my $self=shift;$self->{'dist'} = shift; } |
|
1
|
|
|
|
|
4
|
|
125
|
1
|
|
|
1
|
1
|
4
|
sub set_components { my $self=shift;$self->{'components'} = [ @_ ]; } |
|
1
|
|
|
|
|
4
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHOR |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Ian Kilgore, C<< >> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 BUGS |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
134
|
|
|
|
|
|
|
C, or through the web interface at |
135
|
|
|
|
|
|
|
L. |
136
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
137
|
|
|
|
|
|
|
your bug as I make changes. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SUPPORT |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
perldoc Config::Apt::Source |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
You can also look for information at: |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=over 4 |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * CPAN Ratings |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * Search CPAN |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=back |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Copyright 2007 Ian Kilgore, all rights reserved. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
172
|
|
|
|
|
|
|
under the same terms as Perl itself. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; # End of Config::Apt::Source |