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