1Dpkg::Index(3perl) libdpkg-perl Dpkg::Index(3perl)
2
3
4
6 Dpkg::Index - generic index of control information
7
9 This class represent a set of Dpkg::Control objects.
10
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 either the Tests or Test-Command fields;
42
43 • for CTRL_FILE_CHANGES it is the Source, Version and
44 Architecture fields (concatenated with "_");
45
46 • for CTRL_FILE_VENDOR it is the Vendor field;
47
48 • for CTRL_FILE_STATUS it is the Package and Architecture fields
49 (concatenated with "_");
50
51 • otherwise it is the Package field by default.
52
53 $index->get_type()
54 Returns the type of control information stored. See the type
55 parameter set during new().
56
57 $index->add($item, [$key])
58 Add a new item in the index. If the $key parameter is omitted, the
59 key will be generated with the get_key_func function (see
60 set_options() for details).
61
62 $index->parse($fh, $desc)
63 Reads the filehandle and creates all items parsed. When called
64 multiple times, the parsed stanzas are accumulated.
65
66 Returns the number of items parsed.
67
68 $index->load($file)
69 Reads the file and creates all items parsed. Returns the number of
70 items parsed. Handles compressed files transparently based on their
71 extensions.
72
73 $item = $index->new_item()
74 Creates a new item. Mainly useful for derived objects that would
75 want to override this method to return something else than a
76 Dpkg::Control object.
77
78 $item = $index->get_by_key($key)
79 Returns the item identified by $key or undef.
80
81 @keys = $index->get_keys(%criteria)
82 Returns the keys of items that matches all the criteria. The key of
83 the %criteria hash is a field name and the value is either a regex
84 that needs to match the field value, or a reference to a function
85 that must return true and that receives the field value as single
86 parameter, or a scalar that must be equal to the field value.
87
88 @items = $index->get(%criteria)
89 Returns all the items that matches all the criteria.
90
91 $index->remove_by_key($key)
92 Remove the item identified by the given key.
93
94 @items = $index->remove(%criteria)
95 Returns and removes all the items that matches all the criteria.
96
97 $index->merge($other_index, %opts)
98 Merge the entries of the other index. While merging, the keys of
99 the merged index are used, they are not re-computed (unless you
100 have set the options "keep_keys" to "0"). It's your responsibility
101 to ensure that they have been computed with the same function.
102
103 $index->sort(\&sortfunc)
104 Sort the index with the given sort function. If no function is
105 given, an alphabetic sort is done based on the keys. The sort
106 function receives the items themselves as parameters and not the
107 keys.
108
109 $str = $index->output([$fh])
110 "$index"
111 Get a string representation of the index. The Dpkg::Control objects
112 are output in the order which they have been read or added except
113 if the order have been changed with sort().
114
115 Print the string representation of the index to a filehandle if $fh
116 has been passed.
117
118 $index->save($file)
119 Writes the content of the index in a file. Auto-compresses files
120 based on their extensions.
121
123 Version 2.01 (dpkg 1.20.6)
124 New option: Add new "item_opts" option.
125
126 Version 2.00 (dpkg 1.20.0)
127 Change behavior: The "unique_tuple_key" option now defaults to true.
128
129 Version 1.01 (dpkg 1.19.0)
130 New option: Add new "unique_tuple_key" option to $index->set_options()
131 to set better default "get_key_func" options, which will become the
132 default behavior in 1.20.x.
133
134 Version 1.00 (dpkg 1.15.6)
135 Mark the module as public.
136
137
138
1391.20.9 2021-07-21 Dpkg::Index(3perl)