diff options
author | Michael Schroeder <mls@suse.de> | 2014-04-15 18:01:31 +0200 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2014-04-15 18:01:31 +0200 |
commit | e831ddcee12a69a51b41eecb14faaa7328d9f86b (patch) | |
tree | c57ff71397ba6ce28b63a06570fbe82a28d28cef | |
parent | 6c492bc676d676ebc718a3ea4afeaad6ec93ae24 (diff) | |
download | libsolv-e831ddcee12a69a51b41eecb14faaa7328d9f86b.tar.gz libsolv-e831ddcee12a69a51b41eecb14faaa7328d9f86b.tar.bz2 libsolv-e831ddcee12a69a51b41eecb14faaa7328d9f86b.zip |
also check for read-only rpm db in /usr/share/rpm (ostree)
-rw-r--r-- | ext/repo_rpmdb.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/repo_rpmdb.c b/ext/repo_rpmdb.c index 9139fd1..c4ad78f 100644 --- a/ext/repo_rpmdb.c +++ b/ext/repo_rpmdb.c @@ -1045,6 +1045,7 @@ struct rpmdbstate { DB_ENV *dbenv; /* database environment */ DB *db; /* packages database */ int byteswapped; /* endianess of packages database */ + int is_ostree; /* read-only db that lives in /usr/share/rpm */ }; struct rpmdbentry { @@ -1135,6 +1136,10 @@ opendbenv(struct rpmdbstate *state) snprintf(dbpath, PATH_MAX, "%s/var/lib/rpm", rootdir ? rootdir : ""); if (access(dbpath, W_OK) == -1) { + snprintf(dbpath, PATH_MAX, "%s/usr/share/rpm/Packages", rootdir ? rootdir : ""); + if (access(dbpath, R_OK) == 0) + state->is_ostree = 1; + snprintf(dbpath, PATH_MAX, "%s%s", rootdir ? rootdir : "", state->is_ostree ? "/usr/share/rpm" : "/var/lib/rpm"); r = dbenv->open(dbenv, dbpath, DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL, 0); } else @@ -1448,7 +1453,7 @@ count_headers(struct rpmdbstate *state) DBT dbkey; DBT dbdata; - snprintf(dbpath, PATH_MAX, "%s/var/lib/rpm/Name", state->rootdir ? state->rootdir : ""); + snprintf(dbpath, PATH_MAX, "%s%s/Name", state->rootdir ? state->rootdir : "", state->is_ostree ? "/usr/share/rpm" : "/var/lib/rpm"); if (stat(dbpath, &statbuf)) return 0; memset(&dbkey, 0, sizeof(dbkey)); @@ -1766,7 +1771,7 @@ repo_add_rpmdb(Repo *repo, Repo *ref, int flags) } /* XXX: should get ro lock of Packages database! */ - snprintf(dbpath, PATH_MAX, "%s/var/lib/rpm/Packages", state.rootdir ? state.rootdir : ""); + snprintf(dbpath, PATH_MAX, "%s%s/Packages", state.rootdir ? state.rootdir : "", state.is_ostree ? "/usr/share/rpm" : "/var/lib/rpm"); if (stat(dbpath, &packagesstat)) { pool_error(pool, -1, "%s: %s", dbpath, strerror(errno)); |