*
*/
+#include <rpm/rpmlib.h>
#include <rpm/rpmts.h>
#include <rpm/rpmmacro.h>
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 */
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";
return 0;
}
+/* rpm-4.16.0 cannot read the database if _db_backend is not set */
+#ifndef HAVE_RPMDBNEXTITERATORHEADERBLOB
+static void
+set_db_backend()
+{
+ static int db_backend_set;
+ char *db_backend;
+
+ if (db_backend_set)
+ return;
+ db_backend_set = 1;
+ db_backend = rpmExpand("%{?_db_backend}", NULL);
+ if (!db_backend || !*db_backend)
+ rpmReadConfigFiles(NULL, NULL);
+ solv_free(db_backend);
+}
+#endif
+
static int
opendbenv(struct rpmdbstate *state)
{
delMacro(NULL, "_dbpath");
return 0;
}
+#ifndef HAVE_RPMDBNEXTITERATORHEADERBLOB
+ if (!strcmp(RPMVERSION, "4.16.0"))
+ set_db_backend();
+#endif
if (rpmtsOpenDB(ts, O_RDONLY))
{
pool_error(state->pool, 0, "rpmtsOpenDB failed: %s", strerror(errno));