summaryrefslogtreecommitdiff
path: root/librazor
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-06-20 21:56:43 -0400
committerKristian Høgsberg <krh@redhat.com>2008-06-20 21:56:43 -0400
commit8a813368430e6773afbfd9c34a7da9454d4799ae (patch)
treeb833546f2217aa8640b560ca6d178826f834d966 /librazor
parent4d070f05b5e5616c238302e0e49877e7bff2c2fe (diff)
Introduce install/remove iterators.
These iterator constructors lets you pass in two sets and creates an iterator for the packages to remove or the packages to install. The iterators will step through the packages in a sequence that respects the pre, post, preun and postun modifiers. Right now, the install order isn't actually implemented, this patch just implements the API changes and updates the applications.
Diffstat (limited to 'librazor')
-rw-r--r--librazor/razor.c52
-rw-r--r--librazor/razor.h6
2 files changed, 58 insertions, 0 deletions
diff --git a/librazor/razor.c b/librazor/razor.c
index b27f49d..bb05700 100644
--- a/librazor/razor.c
+++ b/librazor/razor.c
@@ -463,3 +463,55 @@ razor_set_diff(struct razor_set *set, struct razor_set *upstream,
razor_package_iterator_destroy(pi1);
razor_package_iterator_destroy(pi2);
}
+
+static void
+add_new_package(enum razor_diff_action action,
+ struct razor_package *package,
+ const char *name,
+ const char *version,
+ const char *arch,
+ void *data)
+{
+ if (action == RAZOR_DIFF_ACTION_ADD)
+ razor_package_query_add_package(data, package);
+}
+
+struct razor_package_iterator *
+razor_set_create_remove_iterator(struct razor_set *set,
+ struct razor_set *next)
+{
+ struct razor_package_query *query;
+ struct razor_package_iterator *pi;
+
+ query = razor_package_query_create(set);
+ razor_set_diff(next, set, add_new_package, query);
+
+ pi = razor_package_query_finish(query);
+
+ /* FIXME: We need to figure out the right install order here,
+ * so the post and pre scripts can run. */
+
+ /* sort */
+
+ return pi;
+}
+
+struct razor_package_iterator *
+razor_set_create_install_iterator(struct razor_set *set,
+ struct razor_set *next)
+{
+ struct razor_package_query *query;
+ struct razor_package_iterator *pi;
+
+ query = razor_package_query_create(next);
+ razor_set_diff(set, next, add_new_package, query);
+
+ pi = razor_package_query_finish(query);
+
+ /* FIXME: We need to figure out the right install order here,
+ * so the post and pre scripts can run. */
+
+ /* sort */
+
+ return pi;
+}
diff --git a/librazor/razor.h b/librazor/razor.h
index dfe17d8..d8da00b 100644
--- a/librazor/razor.h
+++ b/librazor/razor.h
@@ -121,6 +121,12 @@ typedef void (*razor_diff_callback_t)(enum razor_diff_action action,
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);
/* Package transactions */