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