Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: third_party/dpkg-dev/scripts/Dpkg/Control.pm

Issue 2411423002: Linux build: Use sysroot when calculating dependencies (Closed)
Patch Set: Update expected_deps Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright © 2007-2009 Raphaël Hertzog <hertzog@debian.org>
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16 package Dpkg::Control;
17
18 use strict;
19 use warnings;
20
21 our $VERSION = '1.00';
22
23 use Dpkg::Gettext;
24 use Dpkg::ErrorHandling;
25 use Dpkg::Control::Types;
26 use Dpkg::Control::Hash;
27 use Dpkg::Control::Fields;
28
29 use Exporter qw(import);
30
31 use parent qw(Dpkg::Control::Hash);
32
33 our @EXPORT = qw(CTRL_UNKNOWN CTRL_INFO_SRC CTRL_INFO_PKG CTRL_INDEX_SRC
34 CTRL_INDEX_PKG CTRL_PKG_SRC CTRL_PKG_DEB CTRL_FILE_CHANGES
35 CTRL_FILE_VENDOR CTRL_FILE_STATUS CTRL_CHANGELOG);
36
37 =encoding utf8
38
39 =head1 NAME
40
41 Dpkg::Control - parse and manipulate official control-like information
42
43 =head1 DESCRIPTION
44
45 The Dpkg::Control object is a smart version of Dpkg::Control::Hash.
46 It associates a type to the control information. That type can be
47 used to know what fields are allowed and in what order they must be
48 output.
49
50 The types are constants that are exported by default. Here's the full
51 list:
52
53 =over 4
54
55 =item CTRL_UNKNOWN
56
57 This type is the default type, it indicates that the type of control
58 information is not yet known.
59
60 =item CTRL_INFO_SRC
61
62 Corresponds to the first block of information in a F<debian/control> file in
63 a Debian source package.
64
65 =item CTRL_INFO_PKG
66
67 Corresponds to subsequent blocks of information in a F<debian/control> file
68 in a Debian source package.
69
70 =item CTRL_INDEX_SRC
71
72 Corresponds to an entry in a F<Sources> file of a source package
73 repository.
74
75 =item CTRL_INDEX_PKG
76
77 Corresponds to an entry in a F<Packages> file of a binary package
78 repository.
79
80 =item CTRL_PKG_SRC
81
82 Corresponds to a .dsc file of a Debian source package.
83
84 =item CTRL_PKG_DEB
85
86 Corresponds to the F<control> file generated by dpkg-gencontrol
87 (F<DEBIAN/control>) and to the same file inside .deb packages.
88
89 =item CTRL_FILE_CHANGES
90
91 Corresponds to a .changes file.
92
93 =item CTRL_FILE_VENDOR
94
95 Corresponds to a vendor file in $Dpkg::CONFDIR/origins/.
96
97 =item CTRL_FILE_STATUS
98
99 Corresponds to an entry in dpkg's F<status> file ($Dpkg::ADMINDIR/status).
100
101 =item CTRL_CHANGELOG
102
103 Corresponds to the output of dpkg-parsechangelog.
104
105 =back
106
107 =head1 FUNCTIONS
108
109 All the methods of Dpkg::Control::Hash are available. Those listed below
110 are either new or overridden with a different behaviour.
111
112 =over 4
113
114 =item my $c = Dpkg::Control->new(%opts)
115
116 If the "type" option is given, it's used to setup default values
117 for other options. See set_options() for more details.
118
119 =cut
120
121 sub new {
122 my ($this, %opts) = @_;
123 my $class = ref($this) || $this;
124
125 my $self = Dpkg::Control::Hash->new();
126 bless $self, $class;
127 $self->set_options(%opts);
128
129 return $self;
130 }
131
132 =item $c->set_options(%opts)
133
134 Changes the value of one or more options. If the "type" option is changed,
135 it is used first to define default values for others options. The option
136 "allow_pgp" is set to 1 for CTRL_PKG_SRC and CTRL_FILE_CHANGES and to 0
137 otherwise. The option "drop_empty" is set to 0 for CTRL_INFO_PKG and
138 CTRL_INFO_SRC and to 1 otherwise. The option "name" is set to a textual
139 description of the type of control information.
140
141 The output order is also set to match the ordered list returned by
142 Dpkg::Control::Fields::field_ordered_list($type).
143
144 =cut
145
146 sub set_options {
147 my ($self, %opts) = @_;
148 if (exists $opts{type}) {
149 my $t = $opts{type};
150 $$self->{allow_pgp} = ($t & (CTRL_PKG_SRC | CTRL_FILE_CHANGES)) ? 1 : 0;
151 $$self->{drop_empty} = ($t & (CTRL_INFO_PKG | CTRL_INFO_SRC)) ? 0 : 1;
152 if ($t == CTRL_INFO_SRC) {
153 $$self->{name} = _g('general section of control info file');
154 } elsif ($t == CTRL_INFO_PKG) {
155 $$self->{name} = _g("package's section of control info file");
156 } elsif ($t == CTRL_CHANGELOG) {
157 $$self->{name} = _g('parsed version of changelog');
158 } elsif ($t == CTRL_INDEX_SRC) {
159 $$self->{name} = sprintf(_g("entry in repository's %s file"), 'Sourc es');
160 } elsif ($t == CTRL_INDEX_PKG) {
161 $$self->{name} = sprintf(_g("entry in repository's %s file"), 'Packa ges');
162 } elsif ($t == CTRL_PKG_SRC) {
163 $$self->{name} = sprintf(_g('%s file'), '.dsc');
164 } elsif ($t == CTRL_PKG_DEB) {
165 $$self->{name} = _g('control info of a .deb package');
166 } elsif ($t == CTRL_FILE_CHANGES) {
167 $$self->{name} = sprintf(_g('%s file'), '.changes');
168 } elsif ($t == CTRL_FILE_VENDOR) {
169 $$self->{name} = _g('vendor file');
170 } elsif ($t == CTRL_FILE_STATUS) {
171 $$self->{name} = _g("entry in dpkg's status file");
172 }
173 $self->set_output_order(field_ordered_list($opts{type}));
174 }
175
176 # Options set by the user override default values
177 $$self->{$_} = $opts{$_} foreach keys %opts;
178 }
179
180 =item $c->get_type()
181
182 Returns the type of control information stored. See the type parameter
183 set during new().
184
185 =cut
186
187 sub get_type {
188 my ($self) = @_;
189 return $$self->{type};
190 }
191
192 =back
193
194 =head1 AUTHOR
195
196 Raphaël Hertzog <hertzog@debian.org>.
197
198 =cut
199
200 1;
OLDNEW
« no previous file with comments | « third_party/dpkg-dev/scripts/Dpkg/Conf.pm ('k') | third_party/dpkg-dev/scripts/Dpkg/Control/Changelog.pm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698