1Dpkg::Index(3perl)               libdpkg-perl               Dpkg::Index(3perl)
2
3
4

NAME

6       Dpkg::Index - generic index of control information
7

DESCRIPTION

9       This class represent a set of Dpkg::Control objects.
10

METHODS

12       $index = Dpkg::Index->new(%opts)
13           Creates a new empty index. See set_options() for more details.
14
15       $index->set_options(%opts)
16           The "type" option is checked first to define default values for
17           other options. Here are the relevant options: "get_key_func" is a
18           function returning a key for the item passed in parameters,
19           "unique_tuple_key" is a boolean requesting whether the default key
20           should be the unique tuple (default to true), "item_opts" is a hash
21           reference that will be passed to the item constructor in the
22           new_item() method.  The index can only contain one item with a
23           given key.  The "get_key_func" function used depends on the type:
24
25           •   for CTRL_INFO_SRC, it is the Source field;
26
27           •   for CTRL_INDEX_SRC and CTRL_PKG_SRC it is the Package and
28               Version fields (concatenated with "_") when "unique_tuple_key"
29               is true (the default), or otherwise the Package field;
30
31           •   for CTRL_INFO_PKG it is simply the Package field;
32
33           •   for CTRL_INDEX_PKG and CTRL_PKG_DEB it is the Package, Version
34               and Architecture fields (concatenated with "_") when
35               "unique_tuple_key" is true (the default) or otherwise the
36               Package field;
37
38           •   for CTRL_CHANGELOG it is the Source and the Version fields
39               (concatenated with an intermediary "_");
40
41           •   for CTRL_TESTS is an integer index (0-based) corresponding to
42               the Tests or Test-Command field stanza;
43
44           •   for CTRL_FILE_CHANGES it is the Source, Version and
45               Architecture fields (concatenated with "_");
46
47           •   for CTRL_FILE_VENDOR it is the Vendor field;
48
49           •   for CTRL_FILE_STATUS it is the Package and Architecture fields
50               (concatenated with "_");
51
52           •   otherwise it is the Package field by default.
53
54       $index->get_type()
55           Returns the type of control information stored. See the type
56           parameter set during new().
57
58       $index->add($item, [$key])
59           Add a new item in the index. If the $key parameter is omitted, the
60           key will be generated with the get_key_func function (see
61           set_options() for details).
62
63       $index->parse($fh, $desc)
64           Reads the filehandle and creates all items parsed. When called
65           multiple times, the parsed stanzas are accumulated.
66
67           Returns the number of items parsed.
68
69       $index->load($file)
70           Reads the file and creates all items parsed. Returns the number of
71           items parsed. Handles compressed files transparently based on their
72           extensions.
73
74       $item = $index->new_item()
75           Creates a new item. Mainly useful for derived objects that would
76           want to override this method to return something else than a
77           Dpkg::Control object.
78
79       $item = $index->get_by_key($key)
80           Returns the item identified by $key or undef.
81
82       @keys = $index->get_keys(%criteria)
83           Returns the keys of items that matches all the criteria. The key of
84           the %criteria hash is a field name and the value is either a regex
85           that needs to match the field value, or a reference to a function
86           that must return true and that receives the field value as single
87           parameter, or a scalar that must be equal to the field value.
88
89       @items = $index->get(%criteria)
90           Returns all the items that matches all the criteria.
91
92       $index->remove_by_key($key)
93           Remove the item identified by the given key.
94
95       @items = $index->remove(%criteria)
96           Returns and removes all the items that matches all the criteria.
97
98       $index->merge($other_index, %opts)
99           Merge the entries of the other index. While merging, the keys of
100           the merged index are used, they are not re-computed (unless you
101           have set the options "keep_keys" to "0"). It's your responsibility
102           to ensure that they have been computed with the same function.
103
104       $index->sort(\&sortfunc)
105           Sort the index with the given sort function. If no function is
106           given, an alphabetic sort is done based on the keys. The sort
107           function receives the items themselves as parameters and not the
108           keys.
109
110       $str = $index->output([$fh])
111       "$index"
112           Get a string representation of the index. The Dpkg::Control objects
113           are output in the order which they have been read or added except
114           if the order have been changed with sort().
115
116           Print the string representation of the index to a filehandle if $fh
117           has been passed.
118
119       $index->save($file)
120           Writes the content of the index in a file. Auto-compresses files
121           based on their extensions.
122

CHANGES

124   Version 3.00 (dpkg 1.21.2)
125       Change behavior: The CTRL_TESTS key now defaults to a stanza index.
126
127   Version 2.01 (dpkg 1.20.6)
128       New option: Add new "item_opts" option.
129
130   Version 2.00 (dpkg 1.20.0)
131       Change behavior: The "unique_tuple_key" option now defaults to true.
132
133   Version 1.01 (dpkg 1.19.0)
134       New option: Add new "unique_tuple_key" option to $index->set_options()
135       to set better default "get_key_func" options, which will become the
136       default behavior in 1.20.x.
137
138   Version 1.00 (dpkg 1.15.6)
139       Mark the module as public.
140
141
142
1431.21.9                            2022-08-04                Dpkg::Index(3perl)
Impressum