1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
/*
* Copyright (C) 2008 Kristian Høgsberg <krh@redhat.com>
* Copyright (C) 2008 Red Hat, Inc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _RAZOR_H_
#define _RAZOR_H_
#include <stdint.h>
enum razor_repo_file_type {
RAZOR_REPO_FILE_MAIN,
RAZOR_REPO_FILE_DETAILS,
RAZOR_REPO_FILE_FILES
};
enum razor_detail_type {
RAZOR_DETAIL_NAME = 1, /* 0 is the marker for the vararg */
RAZOR_DETAIL_VERSION,
RAZOR_DETAIL_ARCH,
RAZOR_DETAIL_SUMMARY,
RAZOR_DETAIL_DESCRIPTION,
RAZOR_DETAIL_URL,
RAZOR_DETAIL_LICENSE
};
enum razor_property_flags {
RAZOR_PROPERTY_LESS = 1 << 0,
RAZOR_PROPERTY_GREATER = 1 << 1,
RAZOR_PROPERTY_EQUAL = 1 << 2,
RAZOR_PROPERTY_RELATION_MASK =
RAZOR_PROPERTY_LESS |
RAZOR_PROPERTY_GREATER |
RAZOR_PROPERTY_EQUAL,
RAZOR_PROPERTY_REQUIRES = 0 << 3,
RAZOR_PROPERTY_PROVIDES = 1 << 3,
RAZOR_PROPERTY_CONFLICTS = 2 << 3,
RAZOR_PROPERTY_OBSOLETES = 3 << 3,
RAZOR_PROPERTY_TYPE_MASK = 3 << 3,
RAZOR_PROPERTY_PRE = 1 << 5,
RAZOR_PROPERTY_POST = 1 << 6,
RAZOR_PROPERTY_PREUN = 1 << 7,
RAZOR_PROPERTY_POSTUN = 1 << 8
};
/**
* SECTION:set
* @title: Package Set
* @short_description: Represents a set of packages and their metadata.
*
* This object represents a set of packages, their dependency
* information, the file lists and a number of other details.
**/
struct razor_set;
struct razor_package;
struct razor_property;
/**
* razor_set_create:
*
* Create a new #razor_set object.
*
* Returns: the new #razor_set object.
**/
struct razor_set *razor_set_create(void);
struct razor_set *razor_set_open(const char *filename);
void razor_set_destroy(struct razor_set *set);
int razor_set_write_to_fd(struct razor_set *set, int fd,
enum razor_repo_file_type type);
int razor_set_write(struct razor_set *set, const char *filename,
enum razor_repo_file_type type);
int razor_set_open_details(struct razor_set *set, const char *filename);
int razor_set_open_files(struct razor_set *set, const char *filename);
struct razor_package *
razor_set_get_package(struct razor_set *set, const char *package);
void
razor_package_get_details(struct razor_set *set, struct razor_package *package, ...);
/**
* SECTION:iterator
* @title: Iterators
* @short_description: Objects for traversing packages or properties.
*
* The razor iterator objects provides a way to iterate through a set
* of packages or properties.
**/
struct razor_package_iterator;
/**
* razor_package_iterator_create:
*
* Create a new #razor_package_iterator object.
*
* Returns: the new #razor_package_iterator object.
**/
struct razor_package_iterator *
razor_package_iterator_create(struct razor_set *set);
/**
* razor_package_iterator_create_for_property:
*
* Create a new #razor_package_iterator object for the packages that
* own the given property.
*
* Returns: the new #razor_package_iterator object.
**/
struct razor_package_iterator *
razor_package_iterator_create_for_property(struct razor_set *set,
struct razor_property *property);
/**
* razor_package_iterator_create_for_file:
*
* Create a new #razor_package_iterator object for the packages that
* contain the given file name.
*
* Returns: the new #razor_package_iterator object.
**/
struct razor_package_iterator *
razor_package_iterator_create_for_file(struct razor_set *set,
const char *filename);
int razor_package_iterator_next(struct razor_package_iterator *pi,
struct razor_package **package, ...);
void razor_package_iterator_destroy(struct razor_package_iterator *pi);
struct razor_package_query *
razor_package_query_create(struct razor_set *set);
void
razor_package_query_add_package(struct razor_package_query *pq,
struct razor_package *p);
void
razor_package_query_add_iterator(struct razor_package_query *pq,
struct razor_package_iterator *pi);
struct razor_package_iterator *
razor_package_query_finish(struct razor_package_query *pq);
struct razor_property_iterator;
struct razor_property_iterator *
razor_property_iterator_create(struct razor_set *set,
struct razor_package *package);
int razor_property_iterator_next(struct razor_property_iterator *pi,
struct razor_property **property,
const char **name,
uint32_t *flags,
const char **version);
void
razor_property_iterator_destroy(struct razor_property_iterator *pi);
void razor_set_list_files(struct razor_set *set, const char *prefix);
void razor_set_list_package_files(struct razor_set *set, const char *name);
enum razor_diff_action {
RAZOR_DIFF_ACTION_ADD,
RAZOR_DIFF_ACTION_REMOVE,
};
typedef void (*razor_diff_callback_t)(enum razor_diff_action action,
struct razor_package *package,
const char *name,
const char *version,
const char *arch,
void *data);
void
razor_set_diff(struct razor_set *set, struct razor_set *upstream,
razor_diff_callback_t callback, void *data);
struct razor_package_iterator *
razor_set_create_remove_iterator(struct razor_set *set,
struct razor_set *next);
struct razor_package_iterator *
razor_set_create_install_iterator(struct razor_set *set,
struct razor_set *next);
/**
* SECTION:transaction
* @title: Transaction
* @short_description: Create a new package set by merging two or more sets.
*
* The razor transaction object provides a way to create a new package set
* from packages from one or more other package sets.
**/
struct razor_transaction *
razor_transaction_create(struct razor_set *system, struct razor_set *upstream);
void razor_transaction_install_package(struct razor_transaction *transaction,
struct razor_package *package);
void razor_transaction_remove_package(struct razor_transaction *transaction,
struct razor_package *package);
void razor_transaction_update_package(struct razor_transaction *trans,
struct razor_package *package);
void razor_transaction_update_all(struct razor_transaction *transaction);
int razor_transaction_resolve(struct razor_transaction *trans);
int razor_transaction_describe(struct razor_transaction *trans);
struct razor_set *razor_transaction_finish(struct razor_transaction *trans);
void razor_transaction_destroy(struct razor_transaction *trans);
/* Temporary helper for test suite. */
int razor_transaction_unsatisfied_property(struct razor_transaction *trans,
const char *name,
uint32_t flags,
const char *version);
/**
* SECTION:rpm
* @title: Razor RPM
* @short_description: Operating on RPM files.
*
* Functions for open RPM files and extracting information and
* installing or removing RPM files.
**/
struct razor_rpm;
struct razor_rpm *razor_rpm_open(const char *filename);
int razor_rpm_install(struct razor_rpm *rpm, const char *root);
int razor_rpm_close(struct razor_rpm *rpm);
/**
* SECTION:importer
* @title: Importer
* @short_description: A mechanism for building #razor_set objects
*
* For building a razor set from external sources, like yum, rpmdb or
* RPM files.
**/
struct razor_importer;
struct razor_importer *razor_importer_create(void);
void razor_importer_destroy(struct razor_importer *importer);
void razor_importer_begin_package(struct razor_importer *importer,
const char *name,
const char *version,
const char *arch);
void razor_importer_add_details(struct razor_importer *importer,
const char *summary,
const char *description,
const char *url,
const char *license);
void razor_importer_add_property(struct razor_importer *importer,
const char *name,
uint32_t flags,
const char *version);
void razor_importer_add_file(struct razor_importer *importer,
const char *name);
void razor_importer_finish_package(struct razor_importer *importer);
int razor_importer_add_rpm(struct razor_importer *importer,
struct razor_rpm *rpm);
struct razor_set *razor_importer_finish(struct razor_importer *importer);
struct razor_set *razor_set_create_from_yum(void);
struct razor_set *razor_set_create_from_rpmdb(void);
/**
* SECTION:root
* @title: Root
* @short_description: Functions for accessing an install root.
*
* The #razor_root object encapsulate access to and locking of a razor
* install root.
**/
struct razor_root;
int razor_root_create(const char *root);
struct razor_root *razor_root_open(const char *root);
struct razor_set *razor_root_open_read_only(const char *root);
struct razor_set *razor_root_get_system_set(struct razor_root *root);
int razor_root_close(struct razor_root *root);
void razor_root_update(struct razor_root *root, struct razor_set *next);
int razor_root_commit(struct razor_root *root);
/**
* SECTION:misc
* @title: Miscellaneous Functions
* @short_description: Various helper functions
*
* Functions that doesn't fit anywhere else.
**/
const char *
razor_property_relation_to_string(struct razor_property *p);
const char *
razor_property_type_to_string(struct razor_property *p);
void razor_build_evr(char *evr_buf, int size, const char *epoch,
const char *version, const char *release);
int razor_versioncmp(const char *s1, const char *s2);
#endif /* _RAZOR_H_ */
|