|
rhughes@241
|
1 |
/*
|
|
rhughes@241
|
2 |
* Copyright (C) 2008 Kristian Høgsberg <krh@redhat.com>
|
|
rhughes@241
|
3 |
* Copyright (C) 2008 Red Hat, Inc
|
|
rhughes@241
|
4 |
*
|
|
rhughes@241
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
rhughes@241
|
6 |
* it under the terms of the GNU General Public License as published by
|
|
rhughes@241
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
rhughes@241
|
8 |
* (at your option) any later version.
|
|
rhughes@241
|
9 |
*
|
|
rhughes@241
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
rhughes@241
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
rhughes@241
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
rhughes@241
|
13 |
* GNU General Public License for more details.
|
|
rhughes@241
|
14 |
*
|
|
rhughes@241
|
15 |
* You should have received a copy of the GNU General Public License along
|
|
rhughes@241
|
16 |
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
rhughes@241
|
17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
rhughes@241
|
18 |
*/
|
|
rhughes@241
|
19 |
|
|
rhughes@241
|
20 |
#ifndef _RAZOR_H_
|
|
rhughes@241
|
21 |
#define _RAZOR_H_
|
|
rhughes@241
|
22 |
|
|
rhughes@241
|
23 |
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
|
rhughes@241
|
24 |
|
|
rhughes@241
|
25 |
struct razor_set;
|
|
rhughes@241
|
26 |
struct razor_package;
|
|
rhughes@241
|
27 |
struct razor_property;
|
|
rhughes@241
|
28 |
|
|
jbowes@258
|
29 |
enum razor_repo_file_type {
|
|
jbowes@258
|
30 |
RAZOR_REPO_FILE_MAIN,
|
|
jbowes@258
|
31 |
RAZOR_REPO_FILE_DETAILS,
|
|
jbowes@258
|
32 |
RAZOR_REPO_FILE_FILES
|
|
jbowes@258
|
33 |
};
|
|
jbowes@258
|
34 |
|
|
krh@247
|
35 |
enum razor_property_flags {
|
|
krh@247
|
36 |
RAZOR_PROPERTY_LESS = 1 << 0,
|
|
krh@247
|
37 |
RAZOR_PROPERTY_GREATER = 1 << 1,
|
|
krh@247
|
38 |
RAZOR_PROPERTY_EQUAL = 1 << 2,
|
|
krh@247
|
39 |
RAZOR_PROPERTY_RELATION_MASK =
|
|
krh@247
|
40 |
RAZOR_PROPERTY_LESS |
|
|
krh@247
|
41 |
RAZOR_PROPERTY_GREATER |
|
|
krh@247
|
42 |
RAZOR_PROPERTY_EQUAL,
|
|
krh@247
|
43 |
|
|
krh@247
|
44 |
RAZOR_PROPERTY_REQUIRES = 0 << 3,
|
|
krh@247
|
45 |
RAZOR_PROPERTY_PROVIDES = 1 << 3,
|
|
krh@247
|
46 |
RAZOR_PROPERTY_CONFLICTS = 2 << 3,
|
|
krh@247
|
47 |
RAZOR_PROPERTY_OBSOLETES = 3 << 3,
|
|
krh@247
|
48 |
RAZOR_PROPERTY_TYPE_MASK = 3 << 3,
|
|
krh@247
|
49 |
|
|
krh@247
|
50 |
RAZOR_PROPERTY_PRE = 1 << 5,
|
|
krh@247
|
51 |
RAZOR_PROPERTY_POST = 1 << 6,
|
|
krh@247
|
52 |
RAZOR_PROPERTY_PREUN = 1 << 7,
|
|
krh@247
|
53 |
RAZOR_PROPERTY_POSTUN = 1 << 8
|
|
rhughes@241
|
54 |
};
|
|
rhughes@241
|
55 |
|
|
krh@247
|
56 |
const char *
|
|
krh@247
|
57 |
razor_property_relation_to_string(struct razor_property *p);
|
|
krh@247
|
58 |
const char *
|
|
krh@247
|
59 |
razor_property_type_to_string(struct razor_property *p);
|
|
rhughes@241
|
60 |
|
|
rhughes@241
|
61 |
struct razor_set *razor_set_create(void);
|
|
rhughes@241
|
62 |
struct razor_set *razor_set_open(const char *filename);
|
|
rhughes@241
|
63 |
void razor_set_destroy(struct razor_set *set);
|
|
jbowes@258
|
64 |
int razor_set_write_to_fd(struct razor_set *set, int fd,
|
|
jbowes@258
|
65 |
enum razor_repo_file_type type);
|
|
jbowes@258
|
66 |
int razor_set_write(struct razor_set *set, const char *filename,
|
|
jbowes@258
|
67 |
enum razor_repo_file_type type);
|
|
jbowes@258
|
68 |
|
|
jbowes@258
|
69 |
void razor_set_open_details(struct razor_set *set, const char *filename);
|
|
jbowes@258
|
70 |
void razor_set_open_files(struct razor_set *set, const char *filename);
|
|
rhughes@241
|
71 |
|
|
rhughes@241
|
72 |
struct razor_package *
|
|
rhughes@241
|
73 |
razor_set_get_package(struct razor_set *set, const char *package);
|
|
rhughes@241
|
74 |
|
|
jbowes@258
|
75 |
void
|
|
jbowes@258
|
76 |
razor_package_get_details(struct razor_set *set, struct razor_package *package,
|
|
jbowes@258
|
77 |
const char **summary, const char **description,
|
|
jbowes@258
|
78 |
const char **url, const char **license);
|
|
jbowes@258
|
79 |
|
|
rhughes@241
|
80 |
struct razor_package_iterator;
|
|
rhughes@241
|
81 |
struct razor_package_iterator *
|
|
rhughes@241
|
82 |
razor_package_iterator_create(struct razor_set *set);
|
|
rhughes@241
|
83 |
struct razor_package_iterator *
|
|
rhughes@241
|
84 |
razor_package_iterator_create_for_property(struct razor_set *set,
|
|
rhughes@241
|
85 |
struct razor_property *property);
|
|
rhughes@241
|
86 |
struct razor_package_iterator *
|
|
rhughes@241
|
87 |
razor_package_iterator_create_for_file(struct razor_set *set,
|
|
rhughes@241
|
88 |
const char *filename);
|
|
rhughes@241
|
89 |
|
|
rhughes@241
|
90 |
int razor_package_iterator_next(struct razor_package_iterator *pi,
|
|
rhughes@241
|
91 |
struct razor_package **package,
|
|
rhughes@241
|
92 |
const char **name,
|
|
rhughes@241
|
93 |
const char **version,
|
|
rhughes@241
|
94 |
const char **arch);
|
|
rhughes@241
|
95 |
void razor_package_iterator_destroy(struct razor_package_iterator *pi);
|
|
rhughes@241
|
96 |
|
|
rhughes@241
|
97 |
struct razor_package_query *
|
|
rhughes@241
|
98 |
razor_package_query_create(struct razor_set *set);
|
|
rhughes@241
|
99 |
void
|
|
rhughes@241
|
100 |
razor_package_query_add_package(struct razor_package_query *pq,
|
|
rhughes@241
|
101 |
struct razor_package *p);
|
|
rhughes@241
|
102 |
void
|
|
rhughes@241
|
103 |
razor_package_query_add_iterator(struct razor_package_query *pq,
|
|
rhughes@241
|
104 |
struct razor_package_iterator *pi);
|
|
rhughes@241
|
105 |
struct razor_package_iterator *
|
|
rhughes@241
|
106 |
razor_package_query_finish(struct razor_package_query *pq);
|
|
rhughes@241
|
107 |
|
|
rhughes@241
|
108 |
struct razor_property_iterator;
|
|
rhughes@241
|
109 |
struct razor_property_iterator *
|
|
rhughes@241
|
110 |
razor_property_iterator_create(struct razor_set *set,
|
|
rhughes@241
|
111 |
struct razor_package *package);
|
|
rhughes@241
|
112 |
int razor_property_iterator_next(struct razor_property_iterator *pi,
|
|
rhughes@241
|
113 |
struct razor_property **property,
|
|
rhughes@241
|
114 |
const char **name,
|
|
krh@247
|
115 |
uint32_t *flags,
|
|
krh@247
|
116 |
const char **version);
|
|
rhughes@241
|
117 |
void
|
|
rhughes@241
|
118 |
razor_property_iterator_destroy(struct razor_property_iterator *pi);
|
|
rhughes@241
|
119 |
|
|
rhughes@241
|
120 |
void razor_set_list_files(struct razor_set *set, const char *prefix);
|
|
rhughes@241
|
121 |
void razor_set_list_package_files(struct razor_set *set, const char *name);
|
|
rhughes@241
|
122 |
|
|
rhughes@241
|
123 |
void razor_set_list_unsatisfied(struct razor_set *set);
|
|
rhughes@241
|
124 |
|
|
krh@253
|
125 |
enum razor_diff_action {
|
|
krh@253
|
126 |
RAZOR_DIFF_ACTION_ADD,
|
|
krh@253
|
127 |
RAZOR_DIFF_ACTION_REMOVE,
|
|
krh@253
|
128 |
};
|
|
krh@253
|
129 |
|
|
krh@253
|
130 |
typedef void (*razor_diff_callback_t)(enum razor_diff_action action,
|
|
krh@253
|
131 |
struct razor_package *package,
|
|
krh@253
|
132 |
const char *name,
|
|
krh@253
|
133 |
const char *version,
|
|
krh@253
|
134 |
const char *arch,
|
|
krh@253
|
135 |
void *data);
|
|
krh@253
|
136 |
|
|
rhughes@241
|
137 |
void
|
|
rhughes@241
|
138 |
razor_set_diff(struct razor_set *set, struct razor_set *upstream,
|
|
krh@253
|
139 |
razor_diff_callback_t callback, void *data);
|
|
krh@254
|
140 |
struct razor_package_iterator *
|
|
krh@254
|
141 |
razor_set_create_remove_iterator(struct razor_set *set,
|
|
krh@254
|
142 |
struct razor_set *next);
|
|
krh@254
|
143 |
struct razor_package_iterator *
|
|
krh@254
|
144 |
razor_set_create_install_iterator(struct razor_set *set,
|
|
krh@254
|
145 |
struct razor_set *next);
|
|
rhughes@241
|
146 |
|
|
rhughes@241
|
147 |
/* Package transactions */
|
|
rhughes@241
|
148 |
|
|
rhughes@241
|
149 |
struct razor_transaction *
|
|
rhughes@241
|
150 |
razor_transaction_create(struct razor_set *system, struct razor_set *upstream);
|
|
rhughes@241
|
151 |
void razor_transaction_install_package(struct razor_transaction *transaction,
|
|
rhughes@241
|
152 |
struct razor_package *package);
|
|
rhughes@241
|
153 |
void razor_transaction_remove_package(struct razor_transaction *transaction,
|
|
rhughes@241
|
154 |
struct razor_package *package);
|
|
rhughes@241
|
155 |
void razor_transaction_update_package(struct razor_transaction *trans,
|
|
rhughes@241
|
156 |
struct razor_package *package);
|
|
rhughes@241
|
157 |
void razor_transaction_update_all(struct razor_transaction *transaction);
|
|
rhughes@241
|
158 |
int razor_transaction_resolve(struct razor_transaction *trans);
|
|
rhughes@241
|
159 |
int razor_transaction_describe(struct razor_transaction *trans);
|
|
rhughes@241
|
160 |
struct razor_set *razor_transaction_finish(struct razor_transaction *trans);
|
|
rhughes@241
|
161 |
void razor_transaction_destroy(struct razor_transaction *trans);
|
|
rhughes@241
|
162 |
|
|
rhughes@241
|
163 |
/* Temporary helper for test suite. */
|
|
rhughes@241
|
164 |
int razor_transaction_unsatisfied_property(struct razor_transaction *trans,
|
|
rhughes@241
|
165 |
const char *name,
|
|
krh@247
|
166 |
uint32_t flags,
|
|
krh@247
|
167 |
const char *version);
|
|
rhughes@241
|
168 |
|
|
rhughes@241
|
169 |
/* Importer interface; for building a razor set from external sources,
|
|
rhughes@241
|
170 |
* like yum, rpmdb or razor package files. */
|
|
rhughes@241
|
171 |
|
|
rhughes@241
|
172 |
struct razor_importer;
|
|
rhughes@241
|
173 |
struct razor_rpm;
|
|
rhughes@241
|
174 |
|
|
krh@249
|
175 |
struct razor_importer *razor_importer_create(void);
|
|
rhughes@241
|
176 |
void razor_importer_destroy(struct razor_importer *importer);
|
|
rhughes@241
|
177 |
void razor_importer_begin_package(struct razor_importer *importer,
|
|
rhughes@241
|
178 |
const char *name,
|
|
rhughes@241
|
179 |
const char *version,
|
|
rhughes@241
|
180 |
const char *arch);
|
|
jbowes@258
|
181 |
void razor_importer_add_details(struct razor_importer *importer,
|
|
jbowes@258
|
182 |
const char *summary,
|
|
jbowes@258
|
183 |
const char *description,
|
|
jbowes@258
|
184 |
const char *url,
|
|
jbowes@258
|
185 |
const char *license);
|
|
rhughes@241
|
186 |
void razor_importer_add_property(struct razor_importer *importer,
|
|
rhughes@241
|
187 |
const char *name,
|
|
krh@247
|
188 |
uint32_t flags,
|
|
krh@247
|
189 |
const char *version);
|
|
rhughes@241
|
190 |
void razor_importer_add_file(struct razor_importer *importer,
|
|
rhughes@241
|
191 |
const char *name);
|
|
rhughes@241
|
192 |
void razor_importer_finish_package(struct razor_importer *importer);
|
|
rhughes@241
|
193 |
|
|
rhughes@241
|
194 |
int razor_importer_add_rpm(struct razor_importer *importer,
|
|
rhughes@241
|
195 |
struct razor_rpm *rpm);
|
|
rhughes@241
|
196 |
|
|
rhughes@241
|
197 |
struct razor_set *razor_importer_finish(struct razor_importer *importer);
|
|
rhughes@241
|
198 |
|
|
rhughes@241
|
199 |
void razor_build_evr(char *evr_buf, int size, const char *epoch,
|
|
rhughes@241
|
200 |
const char *version, const char *release);
|
|
krh@248
|
201 |
int razor_versioncmp(const char *s1, const char *s2);
|
|
rhughes@241
|
202 |
|
|
rhughes@241
|
203 |
struct razor_set *razor_set_create_from_yum(void);
|
|
rhughes@241
|
204 |
struct razor_set *razor_set_create_from_rpmdb(void);
|
|
rhughes@241
|
205 |
|
|
rhughes@241
|
206 |
/* RPM functions */
|
|
rhughes@241
|
207 |
|
|
rhughes@241
|
208 |
struct razor_rpm *razor_rpm_open(const char *filename);
|
|
rhughes@241
|
209 |
int razor_rpm_install(struct razor_rpm *rpm, const char *root);
|
|
rhughes@241
|
210 |
int razor_rpm_close(struct razor_rpm *rpm);
|
|
rhughes@241
|
211 |
|
|
rhughes@241
|
212 |
|
|
krh@250
|
213 |
/* Razor root functions. The root data structure encapsulates
|
|
krh@250
|
214 |
* filesystem conventions and the locking protocol. */
|
|
rhughes@241
|
215 |
|
|
rhughes@241
|
216 |
struct razor_root;
|
|
rhughes@241
|
217 |
|
|
rhughes@241
|
218 |
int razor_root_create(const char *root);
|
|
krh@250
|
219 |
struct razor_root *razor_root_open(const char *root);
|
|
rhughes@241
|
220 |
struct razor_set *razor_root_open_read_only(const char *root);
|
|
krh@250
|
221 |
struct razor_set *razor_root_get_system_set(struct razor_root *root);
|
|
krh@250
|
222 |
int razor_root_close(struct razor_root *root);
|
|
krh@250
|
223 |
void razor_root_update(struct razor_root *root, struct razor_set *next);
|
|
krh@250
|
224 |
int razor_root_commit(struct razor_root *root);
|
|
rhughes@241
|
225 |
|
|
rhughes@241
|
226 |
#endif /* _RAZOR_H_ */
|