return 0;
}
-static int pakfire_populate_pool(struct pakfire* pakfire) {
- struct pakfire_db* db = NULL;
- struct pakfire_repo* commandline = NULL;
- struct pakfire_repo* dummy = NULL;
- struct pakfire_repo* system = NULL;
+static int pakfire_setup_pool(struct pakfire* pakfire) {
int r;
- const char* arch = pakfire_get_effective_arch(pakfire);
-
// Initialize the pool
Pool* pool = pakfire->pool = pool_create();
pool_setdisttype(pool, DISTTYPE_RPM);
#endif
// Set architecture of the pool
- pool_setarchpolicy(pool, arch);
+ pool_setarchpolicy(pool, pakfire_get_effective_arch(pakfire));
// Set path
pool_set_rootdir(pool, pakfire->path);
queue_push2(&pool->pooljobs, SOLVER_SOLVABLE_PROVIDES|SOLVER_MULTIVERSION, id);
}
- // Open database in read-only mode and try to load all installed packages
- r = pakfire_db_open(&db, pakfire, PAKFIRE_DB_READWRITE);
- if (r)
+ // Lock the running kernel
+ if (pakfire_on_root(pakfire)) {
+ r = pakfire_lock_running_kernel(pakfire);
+ if (r < 0)
+ return r;
+ }
+
+ return 0;
+}
+
+static int pakfire_load_installed_packages(struct pakfire* self) {
+ struct pakfire_repo* repo = NULL;
+ struct pakfire_db* db = NULL;
+ int r;
+
+ // Fetch the system repository
+ repo = pakfire_get_repo(self, PAKFIRE_REPO_SYSTEM);
+
+ // Open the database (or create a new one)
+ r = pakfire_db_open(&db, self, PAKFIRE_DB_READWRITE);
+ if (r < 0)
goto ERROR;
+ // Load database content
+ r = pakfire_db_load(db, repo);
+ if (r < 0)
+ goto ERROR;
+
+ERROR:
+ if (repo)
+ pakfire_repo_unref(repo);
+ if (db)
+ pakfire_db_unref(db);
+
+ return r;
+}
+
+static int pakfire_setup_default_repos(struct pakfire* self) {
+ struct pakfire_repo* commandline = NULL;
+ struct pakfire_repo* dummy = NULL;
+ struct pakfire_repo* system = NULL;
+ int r;
+
// Create a dummy repository
- r = pakfire_repo_create(&dummy, pakfire, PAKFIRE_REPO_DUMMY);
- if (r)
+ r = pakfire_repo_create(&dummy, self, PAKFIRE_REPO_DUMMY);
+ if (r < 0)
goto ERROR;
// Disable the repository
pakfire_repo_set_enabled(dummy, 0);
// Create the system repository
- r = pakfire_repo_create(&system, pakfire, PAKFIRE_REPO_SYSTEM);
- if (r)
+ r = pakfire_repo_create(&system, self, PAKFIRE_REPO_SYSTEM);
+ if (r < 0)
goto ERROR;
// Set this repository as the installed one
- pool_set_installed(pool, pakfire_repo_get_repo(system));
+ pool_set_installed(self->pool, pakfire_repo_get_repo(system));
// Create the command line repo
- r = pakfire_repo_create(&commandline, pakfire, PAKFIRE_REPO_COMMANDLINE);
- if (r)
- goto ERROR;
-
- // Load database content
- r = pakfire_db_load(db, system);
- if (r)
+ r = pakfire_repo_create(&commandline, self, PAKFIRE_REPO_COMMANDLINE);
+ if (r < 0)
goto ERROR;
- // Lock the running kernel
- if (pakfire_on_root(pakfire)) {
- r = pakfire_lock_running_kernel(pakfire);
- if (r)
- goto ERROR;
- }
-
ERROR:
- if (db)
- pakfire_db_unref(db);
if (commandline)
pakfire_repo_unref(commandline);
if (dummy)
goto ERROR;
}
- // Populate pool
- r = pakfire_populate_pool(p);
+ // Setup the pool
+ r = pakfire_setup_pool(p);
+ if (r < 0)
+ goto ERROR;
+
+ // Create the default repositories
+ r = pakfire_setup_default_repos(p);
if (r < 0)
goto ERROR;
goto ERROR;
}
+ // Load installed packages
+ if (!pakfire_has_flag(p, PAKFIRE_FLAGS_STUB)) {
+ r = pakfire_load_installed_packages(p);
+ if (r < 0)
+ goto ERROR;
+ }
+
// Refresh repositories
r = pakfire_repo_walk(p, pakfire_refresh_repo, NULL);
if (r < 0)