pakfire_repo_unref(repo);
}
+ const char* packages[] = {
+ path, NULL
+ };
+
+ // Install the package into the build environment
+ r = pakfire_install(pakfire, packages, 0);
+ if (r) {
+ ERROR(pakfire, "Could not install %s\n", path);
+ goto ERROR;
+ }
+
const char* root = pakfire_get_path(pakfire);
// Create BUILDROOT
pakfire_make_path(pakfire, buildroot, "/tmp/.buildroot.XXXXXX");
if (!pakfire_mkdtemp(buildroot))
- return 1;
+ goto ERROR;
// Make relative BUILDROOT path
const char* buildroot_rel = pakfire_path_relpath(root, buildroot);
if (!buildroot_rel)
- return 1;
+ goto ERROR;
// Read makefile
r = pakfire_read_makefile(&makefile, pakfire, path, &error);
int pakfire_read_makefile(PakfireParser* parser, Pakfire pakfire, const char* path,
struct pakfire_parser_error** error);
+// Install/Erase/Update
+
+int pakfire_install(Pakfire pakfire, const char** packages, int flags);
+int pakfire_erase(Pakfire pakfire, const char** packages, int flags);
+int pakfire_update(Pakfire pakfire, const char** packages, int flags);
+
#ifdef PAKFIRE_PRIVATE
#include <solv/pool.h>
#include <pakfire/private.h>
#include <pakfire/pwd.h>
#include <pakfire/repo.h>
+#include <pakfire/request.h>
+#include <pakfire/transaction.h>
#include <pakfire/types.h>
#include <pakfire/util.h>
return archive;
}
+
+// Convenience functions to install/erase/update packages
+
+static int pakfire_perform_transaction(Pakfire pakfire,
+ int (*action)(struct pakfire_request* request, const char* what, int flags),
+ const char** packages, int flags) {
+ struct pakfire_request* request = NULL;
+ struct pakfire_transaction* transaction = NULL;
+ int r = 1;
+
+ // Packages cannot be NULL
+ if (!packages) {
+ errno = EINVAL;
+ return 1;
+ }
+
+ // Create a new request
+ r = pakfire_request_create(&request, pakfire, 0);
+ if (r)
+ goto ERROR;
+
+ // Perform action on all packages
+ for (const char** package = packages; *package; package++) {
+ r = action(request, *package, flags);
+ if (r) {
+ ERROR(pakfire, "Could not find '%s': %m\n", *package);
+ goto ERROR;
+ }
+ }
+
+ // Solve the request
+ r = pakfire_request_solve(request, 0);
+ if (r)
+ goto ERROR;
+
+ // Fetch the transaction
+ transaction = pakfire_request_get_transaction(request);
+ if (!transaction)
+ goto ERROR;
+
+ // Run the transaction
+ r = pakfire_transaction_run(transaction);
+ if (r)
+ goto ERROR;
+
+ // Success
+ r = 0;
+
+ERROR:
+ if (transaction)
+ pakfire_transaction_unref(transaction);
+ if (request)
+ pakfire_request_unref(request);
+
+ return r;
+}
+
+PAKFIRE_EXPORT int pakfire_install(Pakfire pakfire, const char** packages, int flags) {
+ return pakfire_perform_transaction(pakfire, pakfire_request_install, packages, flags);
+}
+
+PAKFIRE_EXPORT int pakfire_erase(Pakfire pakfire, const char** packages, int flags) {
+ return pakfire_perform_transaction(pakfire, pakfire_request_erase, packages, flags);
+}
+
+PAKFIRE_EXPORT int pakfire_update(Pakfire pakfire, const char** packages, int flags) {
+ return pakfire_perform_transaction(pakfire, pakfire_request_upgrade, packages, flags);
+}