PKG_CHECK_MODULES([ARCHIVE], [libarchive >= 3.3.3])
PKG_CHECK_MODULES([PYTHON_DEVEL], [python-${PYTHON_VERSION}])
-PKG_CHECK_MODULES([LMDB], [lmdb])
PKG_CHECK_MODULES([LZMA], [liblzma])
AM_PATH_LIBGCRYPT([1.8.0], [], [AC_MSG_ERROR([*** libgcrypt not found])])
#include <errno.h>
#include <stdlib.h>
-#include <lmdb.h>
-
#include <pakfire/db.h>
#include <pakfire/pakfire.h>
#include <pakfire/logging.h>
int nrefs;
};
-/*
- This function initialises the database environment, but stores it in the main pakfire
- object so that we do not have to create a circle-reference between pakfire and the
- database object.
-*/
-int pakfire_db_env_init(Pakfire pakfire, MDB_env** env) {
- DEBUG(pakfire, "Initialising database environment\n");
-
- // Allocate database environment
- int r = mdb_env_create(env);
- if (r) {
- ERROR(pakfire, "Could not allocate database environment\n");
- return r;
- }
-
- // The database path
- char* path = pakfire_make_path(pakfire, DATABASE_PATH);
-
- // Open the database environment
- r = mdb_env_open(*env, path, MDB_NOSUBDIR, 0660);
- if (r) {
- switch (r) {
- case MDB_VERSION_MISMATCH:
- ERROR(pakfire, "The database is of an incompatible version\n");
- errno = EINVAL;
- break;
-
- case MDB_INVALID:
- errno = EINVAL;
- break;
-
- default:
- ERROR(pakfire, "Could not open database %s: %s\n", path, strerror(errno));
- errno = r;
- }
-
- // Reset r to non-zero
- r = 1;
- goto ERROR;
- }
-
-ERROR:
- free(path);
-
- return r;
-}
-
-void pakfire_db_env_free(Pakfire pakfire, MDB_env* env) {
- DEBUG(pakfire, "Freeing database environment\n");
-
- if (env)
- mdb_env_close(env);
-}
-
int pakfire_db_open(struct pakfire_db** db, Pakfire pakfire) {
struct pakfire_db* o = pakfire_calloc(1, sizeof(*o));
if (!o)
#ifdef PAKFIRE_PRIVATE
-#include <lmdb.h>
-
#include <pakfire/types.h>
struct pakfire_db;
-int pakfire_db_env_init(Pakfire pakfire, MDB_env** env);
-void pakfire_db_env_free(Pakfire pakfire, MDB_env* env);
-
int pakfire_db_open(struct pakfire_db** db, Pakfire pakfire);
struct pakfire_db* pakfire_db_ref(struct pakfire_db* db);
#include <syslog.h>
#include <unistd.h>
-#include <lmdb.h>
-
#include <solv/evr.h>
#include <solv/pool.h>
#include <solv/poolarch.h>
char* cache_path;
char* arch;
- // Database Environment
- MDB_env* mdb_env;
-
// Pool stuff
Pool* pool;
int pool_ready;
pakfire_repo_free_all(pakfire);
- if (pakfire->mdb_env)
- pakfire_db_env_free(pakfire, pakfire->mdb_env);
-
if (pakfire->pool)
pool_free(pakfire->pool);
return r;
}
- // Initialise the database environment
- r = pakfire_db_env_init(p, &p->mdb_env);
- if (r) {
- _pakfire_free(p);
-
- return r;
- }
-
// Initialize the pool
p->pool = pool_create();
pool_setdisttype(p->pool, DISTTYPE_RPM);