line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Apt::Sources; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
130411
|
use warnings; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
160
|
|
4
|
5
|
|
|
5
|
|
27
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
186
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
28
|
use Carp; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
364
|
|
7
|
5
|
|
|
5
|
|
5766
|
use UNIVERSAL qw( isa ); |
|
5
|
|
|
|
|
71
|
|
|
5
|
|
|
|
|
26
|
|
8
|
5
|
|
|
5
|
|
5317
|
use Config::Apt::SourceEntry; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
63
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Config::Apt::Sources - Parse and manipulate apt sources |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.10 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Config::Apt::Sources; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $srcs = Config::Apt::Sources->new(); |
26
|
|
|
|
|
|
|
$srcs->parse_stream(do { local $/; <> }); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my @sources = $srcs->get_sources(); |
29
|
|
|
|
|
|
|
$sources[0]->set_uri("http://ftp.us.debian.org/debian/"); |
30
|
|
|
|
|
|
|
$srcs->set_sources(@sources); |
31
|
|
|
|
|
|
|
print $srcs->to_string(); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 FUNCTIONS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 new |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
The Config::Apt::Sources constructor takes no arguments. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new { |
42
|
4
|
|
|
4
|
1
|
754
|
my ($class_name) = @_; |
43
|
4
|
|
|
|
|
21
|
my ($self) = { 'sources' => [ ] }; |
44
|
|
|
|
|
|
|
|
45
|
4
|
|
|
|
|
14
|
bless($self, $class_name); |
46
|
4
|
|
|
|
|
15
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 parse_stream |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Parses the given string argument as the contents of an apt sources.list file. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$srcs->parse_stream(do { local $/; }); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub parse_stream { |
58
|
3
|
|
|
3
|
1
|
109
|
my $self = shift; |
59
|
3
|
|
|
|
|
22
|
my @lines = split("\n",shift); |
60
|
|
|
|
|
|
|
|
61
|
3
|
|
|
|
|
8
|
my @line; |
62
|
|
|
|
|
|
|
my @sources; |
63
|
3
|
|
|
|
|
8
|
for my $line (@lines) { |
64
|
11
|
100
|
|
|
|
111
|
next if $line =~ /(^\s*#|^$)/; # skip comments and blank lines |
65
|
7
|
|
|
|
|
32
|
chomp $line; |
66
|
7
|
|
|
|
|
38
|
push @sources,new Config::Apt::SourceEntry($line); |
67
|
|
|
|
|
|
|
} |
68
|
3
|
|
|
|
|
91
|
$self->{'sources'} = [ @sources ]; |
69
|
3
|
|
|
|
|
108
|
return 1; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 to_string |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Returns the sources.list as a string. Takes no arguments. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $newsrcs = $srcs->to_string; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub to_string { |
81
|
1
|
|
|
1
|
1
|
6
|
my $self = shift; |
82
|
1
|
|
|
|
|
3
|
my $ret = ""; |
83
|
1
|
|
|
|
|
2
|
for (@{ $self->{'sources'} }) { |
|
1
|
|
|
|
|
3
|
|
84
|
3
|
|
|
|
|
12
|
$ret .= $_->to_string() . "\n"; |
85
|
|
|
|
|
|
|
} |
86
|
1
|
|
|
|
|
9
|
return $ret; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 get_sources |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns an array of Config::Apt::SourceEntry objects. Takes no arguments. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my @sources = $srcs->get_sources(); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub get_sources { |
98
|
6
|
|
|
6
|
1
|
40
|
my $self = shift; |
99
|
6
|
|
|
|
|
9
|
return map { new Config::Apt::SourceEntry($_->to_string()) } @{$self->{'sources'}}; |
|
16
|
|
|
|
|
62
|
|
|
6
|
|
|
|
|
14
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 set_sources |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Reads an array of Config::Apt::SourceEntry objects. returns undef if |
105
|
|
|
|
|
|
|
any element is not a Config::Apt::SourceEntry object. Otherwise, |
106
|
|
|
|
|
|
|
returns 1. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$srcs->set_sources(@sources); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub set_sources { |
113
|
2
|
|
|
2
|
1
|
874
|
my $self = shift; |
114
|
2
|
|
|
|
|
4
|
my @sources; |
115
|
|
|
|
|
|
|
|
116
|
2
|
|
|
|
|
6
|
foreach (@_) { |
117
|
4
|
100
|
|
|
|
36
|
unless (isa($_, 'Config::Apt::SourceEntry')) { |
118
|
1
|
|
|
|
|
9
|
carp "arguments must be Config::Apt::SourceEntry objects"; |
119
|
1
|
|
|
|
|
614
|
return undef; |
120
|
|
|
|
|
|
|
} |
121
|
3
|
|
|
|
|
7
|
push @sources,$_; |
122
|
|
|
|
|
|
|
} |
123
|
1
|
|
|
|
|
3
|
$self->{'sources'} = [ @sources ]; |
124
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
5
|
return 1; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 AUTHOR |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Ian Kilgore, C<< >> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 BUGS |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
136
|
|
|
|
|
|
|
C, or through the web interface at |
137
|
|
|
|
|
|
|
L. |
138
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
139
|
|
|
|
|
|
|
your bug as I make changes. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SUPPORT |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
perldoc Config::Apt::Sources |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
You can also look for information at: |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=over 4 |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
L |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * CPAN Ratings |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
L |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
L |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item * Search CPAN |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=back |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Copyright 2007 Ian Kilgore, all rights reserved. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
174
|
|
|
|
|
|
|
under the same terms as Perl itself. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; # End of Config::Apt::Sources |