line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Debian::Control - manage Debian source package control files |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 SYNOPSIS |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $c = Debian::Control->new(); # construct a new |
9
|
|
|
|
|
|
|
$c->read($file); # parse debian/control file |
10
|
|
|
|
|
|
|
$c->write($file); # write to file |
11
|
|
|
|
|
|
|
print $c->source->Source; |
12
|
|
|
|
|
|
|
print $c->source->Build_Depends; # Debian::Dependencies object |
13
|
|
|
|
|
|
|
$c->binary->{'libfoo-perl'}->Description( |
14
|
|
|
|
|
|
|
"Foo Perl module\n" . |
15
|
|
|
|
|
|
|
" Foo makes this and that" |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Debian::Control can be used for representation and manipulation of Debian |
21
|
|
|
|
|
|
|
source package control files in an object-oriented way. It provides easy |
22
|
|
|
|
|
|
|
reading and writing of the F file found in Debian source |
23
|
|
|
|
|
|
|
packages. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 FIELDS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=over |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=item source |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
An instance of L class. Contains the source |
32
|
|
|
|
|
|
|
stanza of the Debian source package control file. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item binary |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
A hash reference with keys being binary |
37
|
|
|
|
|
|
|
package names and values instances of L class. |
38
|
|
|
|
|
|
|
Contains the information of the binary package stanzas of Debian source package |
39
|
|
|
|
|
|
|
control file. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item binary_tie |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
A L object tied to the B hash. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=back |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
package Debian::Control; |
50
|
|
|
|
|
|
|
|
51
|
4
|
|
|
4
|
|
500661
|
use base 'Class::Accessor'; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
1517
|
|
52
|
4
|
|
|
4
|
|
6507
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
77
|
|
53
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
206
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
our $VERSION = '0.96'; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw( source binary binary_tie _parser )); |
58
|
|
|
|
|
|
|
|
59
|
4
|
|
|
4
|
|
1218
|
use Parse::DebControl; |
|
4
|
|
|
|
|
358687
|
|
|
4
|
|
|
|
|
94
|
|
60
|
4
|
|
|
4
|
|
2067
|
use Debian::Control::Stanza::Source; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
use Debian::Control::Stanza::Binary; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=over |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item new |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Constructs a new L instance. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The C |
72
|
|
|
|
|
|
|
L and C field is initialized with an |
73
|
|
|
|
|
|
|
empty instance of L. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub new { |
80
|
|
|
|
|
|
|
my $class = shift; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $self = $class->SUPER::new(); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$self->_parser( Parse::DebControl->new ); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my %b; |
87
|
|
|
|
|
|
|
$self->binary_tie( tie %b, 'Tie::IxHash' ); |
88
|
|
|
|
|
|
|
$self->binary( \%b ); |
89
|
|
|
|
|
|
|
$self->source( Debian::Control::Stanza::Source->new ); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
return $self; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 METHODS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=over |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item read I |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Parse L and populate C |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
I can be either a file name, an opened file handle or a string scalar |
103
|
|
|
|
|
|
|
reference. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub read { |
108
|
|
|
|
|
|
|
my ( $self, $file ) = @_; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my $parser_method = 'parse_file'; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
if ( ref($file) ) { |
113
|
|
|
|
|
|
|
$file = $$file; |
114
|
|
|
|
|
|
|
$parser_method = 'parse_mem'; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $stanzas = $self->_parser->$parser_method( $file, |
118
|
|
|
|
|
|
|
{ useTieIxHash => 1, verbMultiLine => 1, stripComments => 1 } ); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
for (@$stanzas) { |
121
|
|
|
|
|
|
|
if ( $_->{Source} ) { |
122
|
|
|
|
|
|
|
$self->source( Debian::Control::Stanza::Source->new($_) ); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
elsif ( $_->{Package} ) { |
125
|
|
|
|
|
|
|
$self->binary_tie->Push( |
126
|
|
|
|
|
|
|
$_->{Package} => Debian::Control::Stanza::Binary->new($_) ); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
else { |
129
|
|
|
|
|
|
|
die "Got control stanza with neither Source nor Package field\n"; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item write I |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Writes a debian/control-like file in I with the contents defined in the |
137
|
|
|
|
|
|
|
C |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
I can be either a file name, an opened file handle or a string scalar |
140
|
|
|
|
|
|
|
reference. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
All dependency lists are sorted before writing. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub write { |
147
|
|
|
|
|
|
|
my ( $self, $file ) = @_; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
for my $s ( $self->source, $self->binary_tie->Values ) { |
150
|
|
|
|
|
|
|
for ( $s->fields ) { |
151
|
|
|
|
|
|
|
$s->$_->sort if $s->is_dependency_list($_); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
if ( ref($file) and ref($file) eq 'SCALAR' ) { |
156
|
|
|
|
|
|
|
$$file = join( "\n", $self->source, $self->binary_tie->Values ); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
elsif ( ref($file) and ref($file) eq 'GLOB' ) { |
159
|
|
|
|
|
|
|
$file->print( join( "\n", $self->source, $self->binary_tie->Values ) ); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
else { |
162
|
|
|
|
|
|
|
my $fh; |
163
|
|
|
|
|
|
|
open $fh, '>', $file or die "Unable to open '$file' for writing: $!"; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
print $fh join( "\n", $self->source, $self->binary_tie->Values ); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item is_arch_dep |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Returns true if the package is architecture-dependent. This is determined by |
172
|
|
|
|
|
|
|
the C field of the first binary package. If it equals to C, |
173
|
|
|
|
|
|
|
then the package is architecture-independent; otherwise it is |
174
|
|
|
|
|
|
|
architecture-dependent. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Returns I if it is not possible to determine whether the package is |
177
|
|
|
|
|
|
|
architecture-dependent or not. This is the case when there are no binary |
178
|
|
|
|
|
|
|
package stanzas present or the first has no C field. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub is_arch_dep { |
183
|
|
|
|
|
|
|
my $self = shift; |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
my $bin = $self->binary_tie->Values(0); |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
return undef unless $bin; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
my $arch = $bin->Architecture; |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
return undef unless defined($arch); |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
return ( $arch ne 'all' ); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=back |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 SEE ALSO |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
L, L, |
201
|
|
|
|
|
|
|
L |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Copyright (C) 2009 Damyan Ivanov L |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
208
|
|
|
|
|
|
|
the terms of the GNU General Public License version 2 as published by the Free |
209
|
|
|
|
|
|
|
Software Foundation. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
212
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
213
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=cut |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
1; |