return cnt;
}
+static int pakfire_repo_to_packagelist(
+ struct pakfire_repo* self, struct pakfire_packagelist** list) {
+ struct pakfire_packagelist* l = NULL;
+ struct pakfire_package* pkg = NULL;
+ Solvable* s = NULL;
+ Id id;
+ int i;
+ int r;
+
+ // Create a new packagelist
+ r = pakfire_packagelist_create(&l, self->ctx);
+ if (r < 0)
+ goto ERROR;
+
+ FOR_REPO_SOLVABLES(self->repo, i, s) {
+ // Convert the solvable into an ID
+ id = pool_solvable2id(self->repo->pool, s);
+
+ // Create a new package
+ r = pakfire_package_create_from_solvable(&pkg, self->pakfire, id);
+ if (r < 0)
+ goto ERROR;
+
+ // Add the package to the list
+ r = pakfire_packagelist_add(l, pkg);
+ if (r < 0)
+ goto ERROR;
+
+ pakfire_package_unref(pkg);
+ pkg = NULL;
+ }
+
+ // Return the list
+ *list = pakfire_packagelist_ref(l);
+
+ERROR:
+ if (pkg)
+ pakfire_package_unref(pkg);
+ if (l)
+ pakfire_packagelist_unref(l);
+
+ return r;
+}
+
void pakfire_repo_has_changed(struct pakfire_repo* repo) {
repo->appdata->ready = 0;
return r;
}
-static int pakfire_repo_to_packagelist(struct pakfire_repo* repo,
- struct pakfire_packagelist* list) {
- struct pakfire_package* pkg = NULL;
- Solvable* s = NULL;
- Id id;
- int i;
- int r;
-
- FOR_REPO_SOLVABLES(repo->repo, i, s) {
- // Convert the solvable into an ID
- id = pool_solvable2id(repo->repo->pool, s);
-
- // Create a new package
- r = pakfire_package_create_from_solvable(&pkg, repo->pakfire, id);
- if (r < 0)
- return r;
-
- // Add the package to the list
- r = pakfire_packagelist_add(list, pkg);
- pakfire_package_unref(pkg);
- if (r < 0)
- return r;
- }
-
- return 0;
-}
-
int pakfire_repo_walk_packages(struct pakfire_repo* self,
int (*callback)(struct pakfire_ctx* ctx, struct pakfire_package* pkg, void* data), void* data, int flags) {
struct pakfire_packagelist* list = NULL;
int r;
- // Create a new packagelist
- r = pakfire_packagelist_create(&list, self->ctx);
- if (r < 0)
- goto ERROR;
-
// Import all packages
- r = pakfire_repo_to_packagelist(self, list);
+ r = pakfire_repo_to_packagelist(self, &list);
if (r < 0)
goto ERROR;
if (!pakfire_repo_is_local(self))
return -ENOTSUP;
- // Create a new packagelist
- r = pakfire_packagelist_create(&list, self->ctx);
- if (r < 0)
- goto ERROR;
-
// Import all packages
- r = pakfire_repo_to_packagelist(self, list);
+ r = pakfire_repo_to_packagelist(self, &list);
if (r < 0)
goto ERROR;