Fix importing flags from RPM file.
4 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
10 enum razor_property_type {
11 RAZOR_PROPERTY_REQUIRES,
12 RAZOR_PROPERTY_PROVIDES,
13 RAZOR_PROPERTY_CONFLICTS,
14 RAZOR_PROPERTY_OBSOLETES
17 enum razor_version_relation {
19 RAZOR_VERSION_LESS_OR_EQUAL,
21 RAZOR_VERSION_GREATER_OR_EQUAL,
24 extern const char * const razor_version_relations[];
26 struct razor_set *razor_set_create(void);
27 struct razor_set *razor_set_open(const char *filename);
28 void razor_set_destroy(struct razor_set *set);
29 int razor_set_write(struct razor_set *set, const char *filename);
31 struct razor_package *
32 razor_set_get_package(struct razor_set *set, const char *package);
34 struct razor_package_iterator;
35 struct razor_package_iterator *
36 razor_package_iterator_create(struct razor_set *set);
37 struct razor_package_iterator *
38 razor_package_iterator_create_for_property(struct razor_set *set,
39 struct razor_property *property);
40 struct razor_package_iterator *
41 razor_package_iterator_create_for_file(struct razor_set *set,
42 const char *filename);
44 int razor_package_iterator_next(struct razor_package_iterator *pi,
45 struct razor_package **package,
46 const char **name, const char **version);
47 void razor_package_iterator_destroy(struct razor_package_iterator *pi);
49 struct razor_property_iterator;
50 struct razor_property_iterator *
51 razor_property_iterator_create(struct razor_set *set,
52 struct razor_package *package);
53 int razor_property_iterator_next(struct razor_property_iterator *pi,
54 struct razor_property **property,
56 enum razor_version_relation *relation,
58 enum razor_property_type *type);
60 razor_property_iterator_destroy(struct razor_property_iterator *pi);
62 void razor_set_list_files(struct razor_set *set, const char *prefix);
63 void razor_set_list_package_files(struct razor_set *set, const char *name);
65 void razor_set_list_unsatisfied(struct razor_set *set);
67 typedef void (*razor_package_callback_t)(const char *name,
68 const char *old_version,
69 const char *new_version,
72 razor_set_diff(struct razor_set *set, struct razor_set *upstream,
73 razor_package_callback_t callback, void *data);
75 /* Package transactions */
77 enum razor_transaction_package_state {
79 RAZOR_PACKAGE_INSTALL,
80 RAZOR_PACKAGE_FORCED_UPDATE,
82 RAZOR_PACKAGE_OBSOLETED,
86 RAZOR_PACKAGE_FIRST_ERROR_STATE = 0x4,
87 RAZOR_PACKAGE_UNAVAILABLE_FLAG = 0x4,
89 /* Package requested for install does not exist */
90 RAZOR_PACKAGE_INSTALL_UNAVAILABLE = RAZOR_PACKAGE_INSTALL | RAZOR_PACKAGE_UNAVAILABLE_FLAG,
91 /* Package requiring update does not have any update */
92 RAZOR_PACKAGE_UPDATE_UNAVAILABLE = RAZOR_PACKAGE_FORCED_UPDATE | RAZOR_PACKAGE_UNAVAILABLE_FLAG,
93 /* Package requested for removal does not exist */
94 RAZOR_PACKAGE_REMOVE_NOT_INSTALLED = RAZOR_PACKAGE_REMOVE | RAZOR_PACKAGE_UNAVAILABLE_FLAG,
96 RAZOR_PACKAGE_OBSOLETE_UNAVAILABLE = RAZOR_PACKAGE_OBSOLETED | RAZOR_PACKAGE_UNAVAILABLE_FLAG,
98 /* No newer version of package is available */
99 RAZOR_PACKAGE_UP_TO_DATE,
100 /* Package marked for both install and remove */
101 RAZOR_PACKAGE_CONTRADICTION,
102 /* Package would add a conflict with an already-installed package */
103 RAZOR_PACKAGE_NEW_CONFLICT,
104 /* Already-installed package has a conflict against this package */
105 RAZOR_PACKAGE_OLD_CONFLICT,
106 /* Requirement of to-be-installed package can't be satisfied */
107 RAZOR_PACKAGE_UNSATISFIABLE,
110 struct razor_transaction_package {
111 const char *name, *old_version, *new_version;
112 struct razor_package *old_package, *new_package;
113 enum razor_transaction_package_state state;
115 /* dep_package is the name of the package that resulted in
116 * this entry being created (or NULL if the user requested the
117 * install/remove), with the other dep_ fields providing
118 * additional information.
120 * For INSTALL, if dep_type is REQUIRES, then dep_package
121 * required something that this package provides. If dep_type
122 * is CONFLICTS, then dep_package is a package that conflicted
123 * with an older version of this package, forcing an upgrade.
125 * For REMOVE, if dep_type is REQUIRES, then dep_package is a
126 * package that is being removed. If dep_type is OBSOLETES,
127 * then dep_package is a package that obsoletes this one.
129 * For OLD_CONFLICT or NEW_CONFLICT, dep_package is an
130 * existing package that conflicts with this one. The
131 * conflicting property comes from the already-installed
132 * package for OLD_CONFLICT, or the to-be-installed package
135 * For UNSATISFIABLE, the dep_ fields are as for an INSTALL,
136 * but the name field will be NULL.
138 const char *dep_package;
139 enum razor_property_type dep_type;
140 const char *dep_property;
141 enum razor_version_relation dep_relation;
142 const char *dep_version;
145 struct razor_transaction {
146 int package_count, errors;
147 struct razor_transaction_package *packages;
149 struct razor_set *system, *upstream;
152 struct razor_transaction *
153 razor_transaction_create(struct razor_set *system, struct razor_set *upstream,
154 int update_count, const char **update_packages,
155 int remove_count, const char **remove_packages);
156 void razor_transaction_describe(struct razor_transaction *trans);
157 struct razor_set *razor_transaction_run(struct razor_transaction *trans);
158 void razor_transaction_destroy(struct razor_transaction *trans);
160 /* Importer interface; for building a razor set from external sources,
161 * like yum, rpmdb or razor package files. */
163 struct razor_importer;
166 struct razor_importer *razor_importer_new(void);
167 void razor_importer_destroy(struct razor_importer *importer);
168 void razor_importer_begin_package(struct razor_importer *importer,
169 const char *name, const char *version);
170 void razor_importer_add_property(struct razor_importer *importer,
172 enum razor_version_relation relation,
174 enum razor_property_type type);
175 void razor_importer_add_file(struct razor_importer *importer,
177 void razor_importer_finish_package(struct razor_importer *importer);
179 int razor_importer_add_rpm(struct razor_importer *importer,
180 struct razor_rpm *rpm);
182 struct razor_set *razor_importer_finish(struct razor_importer *importer);
184 void razor_build_evr(char *evr_buf, int size, const char *epoch,
185 const char *version, const char *release);
187 struct razor_set *razor_set_create_from_yum(void);
188 struct razor_set *razor_set_create_from_rpmdb(void);
192 struct razor_rpm *razor_rpm_open(const char *filename);
193 int razor_rpm_install(struct razor_rpm *rpm, const char *root);
194 int razor_rpm_close(struct razor_rpm *rpm);
196 #endif /* _RAZOR_H_ */