struct pakfire_packager* packager = NULL;
struct pakfire_package* pkg = NULL;
- struct pakfire_repo* repo = NULL;
// Load makefile
int r = pakfire_read_makefile(&makefile, pakfire, path, &error);
if (r)
goto ERROR;
- repo = pakfire_get_repo(pakfire, PAKFIRE_REPO_DUMMY);
- if (!repo)
- goto ERROR;
-
// Get the package object
- r = pakfire_parser_create_package(makefile, &pkg, repo, NULL, "src");
+ r = pakfire_parser_create_package(makefile, &pkg, NULL, NULL, "src");
if (r)
goto ERROR;
pakfire_packager_unref(packager);
if (pkg)
pakfire_package_unref(pkg);
- if (repo)
- pakfire_repo_unref(repo);
pakfire_parser_unref(makefile);
return r;
return pkg;
}
-PAKFIRE_EXPORT struct pakfire_package* pakfire_package_create(struct pakfire* pakfire, struct pakfire_repo* repo, const char* name, const char* evr, const char* arch) {
+PAKFIRE_EXPORT struct pakfire_package* pakfire_package_create(
+ struct pakfire* pakfire, struct pakfire_repo* repo,
+ const char* name, const char* evr, const char* arch) {
+ struct pakfire_package* pkg = NULL;
+ struct pakfire_repo* dummy = NULL;
+
+ // Default to dummy repository
+ if (!repo) {
+ dummy = pakfire_get_repo(pakfire, PAKFIRE_REPO_DUMMY);
+ if (!dummy) {
+ errno = ENOENT;
+ return NULL;
+ }
+
+ repo = dummy;
+ }
+
+ // Allocate a new solvable
Id id = pakfire_repo_add_solvable(repo);
if (!id)
- return NULL;
+ goto ERROR;
- struct pakfire_package* pkg = pakfire_package_create_from_solvable(pakfire, id);
+ // Create a new package object
+ pkg = pakfire_package_create_from_solvable(pakfire, id);
if (!pkg)
- return NULL;
+ goto ERROR;
pkg->repo = pakfire_repo_ref(repo);
// Add self-provides
pakfire_package_add_self_provides(pakfire, pkg, name, evr);
+ERROR:
+ if (dummy)
+ pakfire_repo_unref(dummy);
+
return pkg;
}