From c1960edee249cffcfd48a311c02ba99b2088adf4 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Wed, 3 Jun 2009 19:20:13 +0200 Subject: [PATCH] - use DB_UNKNOWN to let berkeleydb autodetect the database type - fix -r option if the root is not an abs path - print rpm --rebuilddb hint --- tools/repo_rpmdb.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/repo_rpmdb.c b/tools/repo_rpmdb.c index e6d0055..657daa3 100644 --- a/tools/repo_rpmdb.c +++ b/tools/repo_rpmdb.c @@ -1197,7 +1197,7 @@ count_headers(const char *rootdir, DB_ENV *dbenv) perror("db_create"); exit(1); } - if (db->open(db, 0, dbpath, 0, DB_HASH, DB_RDONLY, 0664)) + if (db->open(db, 0, "Name", 0, DB_UNKNOWN, DB_RDONLY, 0664)) { perror("db->open var/lib/rpm/Name"); exit(1); @@ -1309,7 +1309,7 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir, int flags) if ((flags & RPMDB_REPORT_PROGRESS) != 0) count = count_headers(rootdir, dbenv); - if (db->open(db, 0, dbpath, 0, DB_HASH, DB_RDONLY, 0664)) + if (db->open(db, 0, "Packages", 0, DB_UNKNOWN, DB_RDONLY, 0664)) { perror("db->open var/lib/rpm/Packages"); exit(1); @@ -1423,8 +1423,7 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir, int flags) Id dircache[512]; memset(dircache, 0, sizeof(dircache)); - snprintf(dbpath, PATH_MAX, "%s/var/lib/rpm/Name", rootdir); - if (db->open(db, 0, dbpath, 0, DB_HASH, DB_RDONLY, 0664)) + if (db->open(db, 0, "Name", 0, DB_UNKNOWN, DB_RDONLY, 0664)) { perror("db->open var/lib/rpm/Name"); exit(1); @@ -1549,8 +1548,7 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir, int flags) perror("db_create"); exit(1); } - snprintf(dbpath, PATH_MAX, "%s/var/lib/rpm/Packages", rootdir); - if (db->open(db, 0, dbpath, 0, DB_HASH, DB_RDONLY, 0664)) + if (db->open(db, 0, "Packages", 0, DB_UNKNOWN, DB_RDONLY, 0664)) { perror("db->open var/lib/rpm/Packages"); exit(1); @@ -1577,7 +1575,8 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir, int flags) if (db->get(db, NULL, &dbkey, &dbdata, 0)) { perror("db->get"); - fprintf(stderr, "corrupt rpm database\n"); + fprintf(stderr, "corrupt rpm database, key %d not found\n", dbid); + fprintf(stderr, "please run 'rpm --rebuilddb' to recreate the database index files\n"); exit(1); } if (dbdata.size < 8) -- 2.7.4