Skip to content

Commit ea03772

Browse files
committed
Add workaround to stat_database() to find other database backends
This is pretty horrible. Rpm upstream wants to add a function that stats the database for us, so we may use that in some future version.
1 parent 94df5d6 commit ea03772

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

ext/repo_rpmdb_librpm.h

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,32 @@ struct rpmdbstate {
3333
static int
3434
stat_database(struct rpmdbstate *state, struct stat *statbuf)
3535
{
36-
char *dbpath;
37-
dbpath = solv_dupjoin(state->rootdir, state->is_ostree ? "/usr/share/rpm/" : "/var/lib/rpm/", "Packages");
38-
if (stat(dbpath, statbuf))
36+
static const char *dbname[] = {
37+
"Packages",
38+
"Packages.db",
39+
"rpmdb.sqlite",
40+
"data.mdb",
41+
"Packages", /* for error reporting */
42+
0,
43+
};
44+
int i;
45+
46+
for (i = 0; ; i++)
3947
{
40-
pool_error(state->pool, -1, "%s: %s", dbpath, strerror(errno));
41-
free(dbpath);
42-
return -1;
48+
char *dbpath = solv_dupjoin(state->rootdir, state->is_ostree ? "/usr/share/rpm/" : "/var/lib/rpm/", dbname[i]);
49+
if (!stat(dbpath, statbuf))
50+
{
51+
free(dbpath);
52+
return 0;
53+
}
54+
if (errno != ENOENT || !dbname[i + 1])
55+
{
56+
pool_error(state->pool, -1, "%s: %s", dbpath, strerror(errno));
57+
solv_free(dbpath);
58+
return -1;
59+
}
60+
solv_free(dbpath);
4361
}
44-
free(dbpath);
4562
return 0;
4663
}
4764

0 commit comments

Comments
 (0)