From: Michael Schroeder Date: Wed, 18 Nov 2020 12:09:36 +0000 (+0100) Subject: Make use of the %_dbpath macro if it is set X-Git-Tag: 0.7.17~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04d4d036b275693a23eef75fba634e7cea2f1a6d;p=thirdparty%2Flibsolv.git Make use of the %_dbpath macro if it is set --- diff --git a/ext/repo_rpmdb.c b/ext/repo_rpmdb.c index 67ce81da..d78893ee 100644 --- a/ext/repo_rpmdb.c +++ b/ext/repo_rpmdb.c @@ -1349,6 +1349,8 @@ freestate(struct rpmdbstate *state) #ifdef ENABLE_RPMDB if (state->dbenvopened) closedbenv(state); + if (state->dbpath_allocated) + solv_free((char *)state->dbpath); #endif if (state->rootdir) solv_free(state->rootdir); diff --git a/ext/repo_rpmdb_bdb.h b/ext/repo_rpmdb_bdb.h index 1c833171..4043ef1b 100644 --- a/ext/repo_rpmdb_bdb.h +++ b/ext/repo_rpmdb_bdb.h @@ -48,6 +48,7 @@ struct rpmdbstate { int dbenvopened; /* database environment opened */ int pkgdbopened; /* package database openend */ const char *dbpath; /* path to the database */ + int dbpath_allocated; /* do we need to free the path? */ DB_ENV *dbenv; /* database environment */ DB *db; /* packages database */ diff --git a/ext/repo_rpmdb_librpm.h b/ext/repo_rpmdb_librpm.h index 35a46fac..e326e8d7 100644 --- a/ext/repo_rpmdb_librpm.h +++ b/ext/repo_rpmdb_librpm.h @@ -24,6 +24,7 @@ struct rpmdbstate { int dbenvopened; /* database environment opened */ const char *dbpath; /* path to the database */ + int dbpath_allocated; /* do we need to free the path? */ rpmts ts; rpmdbMatchIterator mi; /* iterator over packages database */ @@ -45,6 +46,13 @@ access_rootdir(struct rpmdbstate *state, const char *dir, int mode) static void detect_dbpath(struct rpmdbstate *state) { + state->dbpath = rpmExpand("%{?_dbpath}", NULL); + if (state->dbpath && *state->dbpath) + { + state->dbpath_allocated = 1; + return; + } + solv_free((char *)state->dbpath); state->dbpath = access_rootdir(state, "/var/lib/rpm", W_OK) == -1 && (access_rootdir(state, "/usr/share/rpm/Packages", R_OK) == 0 || access_rootdir(state, "/usr/share/rpm/rpmdb.sqlite", R_OK) == 0) ? "/usr/share/rpm" : "/var/lib/rpm";