Skip to content

Commit c78a330

Browse files
committed
Add _db_backend workaround for rpm-4.16.0
Rpm 4.16.0 cannot read the database if _db_config is not set.
1 parent f74c5b7 commit c78a330

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

ext/repo_rpmdb_librpm.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*
1313
*/
1414

15+
#include <rpm/rpmlib.h>
1516
#include <rpm/rpmts.h>
1617
#include <rpm/rpmmacro.h>
1718

@@ -98,6 +99,24 @@ stat_database(struct rpmdbstate *state, struct stat *statbuf)
9899
return 0;
99100
}
100101

102+
/* rpm-4.16.0 cannot read the database if _db_backend is not set */
103+
#ifndef HAVE_RPMDBNEXTITERATORHEADERBLOB
104+
static void
105+
set_db_backend()
106+
{
107+
static int db_backend_set;
108+
char *db_backend;
109+
110+
if (db_backend_set)
111+
return;
112+
db_backend_set = 1;
113+
db_backend = rpmExpand("%{?_db_backend}", NULL);
114+
if (!db_backend || !*db_backend)
115+
rpmReadConfigFiles(NULL, NULL);
116+
solv_free(db_backend);
117+
}
118+
#endif
119+
101120
static int
102121
opendbenv(struct rpmdbstate *state)
103122
{
@@ -116,6 +135,10 @@ opendbenv(struct rpmdbstate *state)
116135
delMacro(NULL, "_dbpath");
117136
return 0;
118137
}
138+
#ifndef HAVE_RPMDBNEXTITERATORHEADERBLOB
139+
if (!strcmp(RPMVERSION, "4.16.0"))
140+
set_db_backend();
141+
#endif
119142
if (rpmtsOpenDB(ts, O_RDONLY))
120143
{
121144
pool_error(state->pool, 0, "rpmtsOpenDB failed: %s", strerror(errno));

0 commit comments

Comments
 (0)