Use strings to identify section types in the on-disk repo format.
Previously, a given razor file type had a fixed number of sections in a
fixed order, identified by an integer type. Now, sections are identified
by a named string (stored in a string pool after the section lists).
This will allow for razor files to contain arbitrary sections.
For bonus points, also drop the 4k section alignment and change the
magic byte string to "RZDB".
committer: Kristian H?gsberg <krh@redhat.com>
2 * Copyright (C) 2008 Kristian Høgsberg <krh@redhat.com>
3 * Copyright (C) 2008 Red Hat, Inc
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 enum razor_repo_file_type {
27 RAZOR_REPO_FILE_DETAILS,
31 enum razor_detail_type {
32 RAZOR_DETAIL_LAST = 0, /* the sentinel */
37 RAZOR_DETAIL_DESCRIPTION,
42 enum razor_property_flags {
43 RAZOR_PROPERTY_LESS = 1 << 0,
44 RAZOR_PROPERTY_GREATER = 1 << 1,
45 RAZOR_PROPERTY_EQUAL = 1 << 2,
46 RAZOR_PROPERTY_RELATION_MASK =
48 RAZOR_PROPERTY_GREATER |
51 RAZOR_PROPERTY_REQUIRES = 0 << 3,
52 RAZOR_PROPERTY_PROVIDES = 1 << 3,
53 RAZOR_PROPERTY_CONFLICTS = 2 << 3,
54 RAZOR_PROPERTY_OBSOLETES = 3 << 3,
55 RAZOR_PROPERTY_TYPE_MASK = 3 << 3,
57 RAZOR_PROPERTY_PRE = 1 << 5,
58 RAZOR_PROPERTY_POST = 1 << 6,
59 RAZOR_PROPERTY_PREUN = 1 << 7,
60 RAZOR_PROPERTY_POSTUN = 1 << 8
66 * @short_description: Represents a set of packages and their metadata.
68 * This object represents a set of packages, their dependency
69 * information, the file lists and a number of other details.
74 struct razor_property;
79 * Create a new #razor_set object.
81 * Returns: the new #razor_set object.
83 struct razor_set *razor_set_create(void);
84 struct razor_set *razor_set_open(const char *filename);
85 void razor_set_destroy(struct razor_set *set);
86 int razor_set_write_to_fd(struct razor_set *set, int fd,
87 enum razor_repo_file_type type);
88 int razor_set_write(struct razor_set *set, const char *filename,
89 enum razor_repo_file_type type);
91 int razor_set_open_details(struct razor_set *set, const char *filename);
92 int razor_set_open_files(struct razor_set *set, const char *filename);
94 struct razor_package *
95 razor_set_get_package(struct razor_set *set, const char *package);
98 razor_package_get_details(struct razor_set *set,
99 struct razor_package *package, ...);
105 * @short_description: Objects for traversing packages or properties.
107 * The razor iterator objects provides a way to iterate through a set
108 * of packages or properties.
111 struct razor_package_iterator;
114 * razor_package_iterator_create:
116 * Create a new #razor_package_iterator object.
118 * Returns: the new #razor_package_iterator object.
121 struct razor_package_iterator *
122 razor_package_iterator_create(struct razor_set *set);
125 * razor_package_iterator_create_for_property:
127 * Create a new #razor_package_iterator object for the packages that
128 * own the given property.
130 * Returns: the new #razor_package_iterator object.
132 struct razor_package_iterator *
133 razor_package_iterator_create_for_property(struct razor_set *set,
134 struct razor_property *property);
137 * razor_package_iterator_create_for_file:
139 * Create a new #razor_package_iterator object for the packages that
140 * contain the given file name.
142 * Returns: the new #razor_package_iterator object.
144 struct razor_package_iterator *
145 razor_package_iterator_create_for_file(struct razor_set *set,
146 const char *filename);
148 int razor_package_iterator_next(struct razor_package_iterator *pi,
149 struct razor_package **package, ...);
150 void razor_package_iterator_destroy(struct razor_package_iterator *pi);
152 struct razor_package_query *
153 razor_package_query_create(struct razor_set *set);
155 razor_package_query_add_package(struct razor_package_query *pq,
156 struct razor_package *p);
158 razor_package_query_add_iterator(struct razor_package_query *pq,
159 struct razor_package_iterator *pi);
160 struct razor_package_iterator *
161 razor_package_query_finish(struct razor_package_query *pq);
163 struct razor_property_iterator;
164 struct razor_property_iterator *
165 razor_property_iterator_create(struct razor_set *set,
166 struct razor_package *package);
167 int razor_property_iterator_next(struct razor_property_iterator *pi,
168 struct razor_property **property,
171 const char **version);
173 razor_property_iterator_destroy(struct razor_property_iterator *pi);
175 void razor_set_list_files(struct razor_set *set, const char *prefix);
176 void razor_set_list_package_files(struct razor_set *set,
177 struct razor_package *package);
179 enum razor_diff_action {
180 RAZOR_DIFF_ACTION_ADD,
181 RAZOR_DIFF_ACTION_REMOVE,
184 typedef void (*razor_diff_callback_t)(enum razor_diff_action action,
185 struct razor_package *package,
192 razor_set_diff(struct razor_set *set, struct razor_set *upstream,
193 razor_diff_callback_t callback, void *data);
195 struct razor_install_iterator;
197 enum razor_install_action {
198 RAZOR_INSTALL_ACTION_ADD,
199 RAZOR_INSTALL_ACTION_REMOVE
202 struct razor_install_iterator *
203 razor_set_create_install_iterator(struct razor_set *set,
204 struct razor_set *next);
206 int razor_install_iterator_next(struct razor_install_iterator *ii,
207 struct razor_set **set,
208 struct razor_package **package,
209 enum razor_install_action *action,
212 void razor_install_iterator_destroy(struct razor_install_iterator *ii);
215 * SECTION:transaction
216 * @title: Transaction
217 * @short_description: Create a new package set by merging two or more sets.
219 * The razor transaction object provides a way to create a new package set
220 * from packages from one or more other package sets.
223 struct razor_transaction *
224 razor_transaction_create(struct razor_set *system, struct razor_set *upstream);
225 void razor_transaction_install_package(struct razor_transaction *transaction,
226 struct razor_package *package);
227 void razor_transaction_remove_package(struct razor_transaction *transaction,
228 struct razor_package *package);
229 void razor_transaction_update_package(struct razor_transaction *trans,
230 struct razor_package *package);
231 void razor_transaction_update_all(struct razor_transaction *transaction);
232 int razor_transaction_resolve(struct razor_transaction *trans);
233 int razor_transaction_describe(struct razor_transaction *trans);
234 struct razor_set *razor_transaction_finish(struct razor_transaction *trans);
235 void razor_transaction_destroy(struct razor_transaction *trans);
237 /* Temporary helper for test suite. */
238 int razor_transaction_unsatisfied_property(struct razor_transaction *trans,
241 const char *version);
246 * @short_description: Operating on RPM files.
248 * Functions for open RPM files and extracting information and
249 * installing or removing RPM files.
254 struct razor_rpm *razor_rpm_open(const char *filename);
255 int razor_rpm_install(struct razor_rpm *rpm, const char *root);
256 int razor_rpm_close(struct razor_rpm *rpm);
261 * @short_description: A mechanism for building #razor_set objects
263 * The %razor_importer is a helper object for building a razor set
264 * from external sources, like yum metadata, the RPM database or RPM
267 * The importer is a stateful object; it has the notion of a current
268 * package, and the caller can provide meta data such as properties,
269 * files and similiar for the package as it becomes available. Once a
270 * package is fully described, the next pacakge can begin. When all
271 * packages have been described to the importer, the importer will
272 * create a new %razor_set with the specified packages.
275 * of the importer will follow this template:
277 * importer = razor_importer_create();
279 * while ( /<!-- -->* more packages to import *<!-- -->/; ) {
280 * /<!-- -->* get name, version and arch of next package *<!-- -->/
281 * razor_importer_begin_package(importer, name, version, arch);
282 * razor_importer_add_details(importer, summary, description, url, license);
284 * while ( /<!-- -->* more properties to add *<!-- -->/ )
285 * razor_importer_add_property(importer, name, flags, version);
287 * while ( /<!-- -->* [more files to add *<!-- -->/ )
288 * razor_importer_add_file(importer, name);
290 * razor_importer_finish_package(importer);
293 * return razor_importer_finish(importer);
296 struct razor_importer;
298 struct razor_importer *razor_importer_create(void);
299 void razor_importer_destroy(struct razor_importer *importer);
300 void razor_importer_begin_package(struct razor_importer *importer,
304 void razor_importer_add_details(struct razor_importer *importer,
306 const char *description,
308 const char *license);
309 void razor_importer_add_property(struct razor_importer *importer,
312 const char *version);
313 void razor_importer_add_file(struct razor_importer *importer,
315 void razor_importer_finish_package(struct razor_importer *importer);
317 int razor_importer_add_rpm(struct razor_importer *importer,
318 struct razor_rpm *rpm);
320 struct razor_set *razor_importer_finish(struct razor_importer *importer);
322 struct razor_set *razor_set_create_from_yum(void);
323 struct razor_set *razor_set_create_from_rpmdb(void);
328 * @short_description: Functions for accessing an install root.
330 * The #razor_root object encapsulate access to and locking of a razor
335 int razor_root_create(const char *root);
336 struct razor_root *razor_root_open(const char *root);
337 struct razor_set *razor_root_open_read_only(const char *root);
338 struct razor_set *razor_root_get_system_set(struct razor_root *root);
339 int razor_root_close(struct razor_root *root);
340 void razor_root_update(struct razor_root *root, struct razor_set *next);
341 int razor_root_commit(struct razor_root *root);
346 * @title: Miscellaneous Functions
347 * @short_description: Various helper functions
349 * Functions that doesn't fit anywhere else.
353 razor_property_relation_to_string(struct razor_property *p);
355 razor_property_type_to_string(struct razor_property *p);
357 void razor_build_evr(char *evr_buf, int size, const char *epoch,
358 const char *version, const char *release);
359 int razor_versioncmp(const char *s1, const char *s2);
362 #endif /* _RAZOR_H_ */