summaryrefslogtreecommitdiff
path: root/librazor
diff options
context:
space:
mode:
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 */