// Template when running Pakfire in a temporary environment
char tmppath[PATH_MAX] = PAKFIRE_TMP_DIR "/pakfire-root-XXXXXX";
+ // Don't do any of this when in stub mode
+ if (pakfire_has_flag(self, PAKFIRE_FLAGS_STUB))
+ return 0;
+
// If we don't have a path, create something temporary...
if (!path) {
// Create a new temporary directory
// Check path
if (path) {
+ // Check that we don't have a path in stub mode
+ if (flags & PAKFIRE_FLAGS_STUB) {
+ ERROR(ctx, "Cannot use path in stub mode\n");
+ r = -EINVAL;
+ goto ERROR;
+ }
+
// Check that we don't have path set when using snapshots
if (flags & PAKFIRE_USE_SNAPSHOT) {
ERROR(ctx, "Cannot use path with snapshots\n");
if (r < 0)
goto ERROR;
- // Setup the local repository
- if (p->flags & (PAKFIRE_FLAGS_BUILD|PAKFIRE_FLAGS_BUILD_LOCAL)) {
- r = pakfire_setup_local_repo(p);
- if (r < 0)
- goto ERROR;
- }
+ // Skip a couple of steps when in stub mode
+ if (!pakfire_has_flag(p, PAKFIRE_FLAGS_STUB)) {
+ // Setup the local repository
+ if (p->flags & (PAKFIRE_FLAGS_BUILD|PAKFIRE_FLAGS_BUILD_LOCAL)) {
+ r = pakfire_setup_local_repo(p);
+ if (r < 0)
+ goto ERROR;
+ }
- // Read repository configuration
- if (p->internal_flags & PAKFIRE_HAS_PATH) {
- r = pakfire_read_repo_config(p);
- if (r < 0)
- goto ERROR;
+ // Read repository configuration
+ if (p->internal_flags & PAKFIRE_HAS_PATH) {
+ r = pakfire_read_repo_config(p);
+ if (r < 0)
+ goto ERROR;
+ }
}
// Load installed packages
#include <pakfire/transaction.h>
enum pakfire_flags {
- PAKFIRE_FLAGS_BUILD = (1 << 0),
- PAKFIRE_FLAGS_BUILD_LOCAL = (1 << 1),
- PAKFIRE_USE_SNAPSHOT = (1 << 2),
+ PAKFIRE_FLAGS_STUB = (1 << 0),
+ PAKFIRE_FLAGS_BUILD = (1 << 1),
+ PAKFIRE_FLAGS_BUILD_LOCAL = (1 << 2),
+ PAKFIRE_USE_SNAPSHOT = (1 << 3),
};
// Callbacks
return EXIT_FAILURE;
}
+static int test_stub(const struct test* t) {
+ struct pakfire* pakfire = NULL;
+ int r = EXIT_FAILURE;
+
+ // Have some illegal calls
+ ASSERT_ERROR(pakfire_create(&pakfire, t->ctx, t->config, "PATH", NULL, PAKFIRE_FLAGS_STUB), EINVAL);
+
+ // Have a success call
+ ASSERT_SUCCESS(pakfire_create(&pakfire, t->ctx, t->config, NULL, NULL, PAKFIRE_FLAGS_STUB));
+
+ r = EXIT_SUCCESS;
+
+FAIL:
+ if (pakfire)
+ pakfire_unref(pakfire);
+
+ return r;
+}
+
static int test_fail(const struct test* t) {
struct pakfire_config* config = NULL;
struct pakfire* pakfire = NULL;
int main(int argc, const char* argv[]) {
testsuite_add_test(test_init, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_stub, 0);
testsuite_add_test(test_fail, 0);
return testsuite_run(argc, argv);