- use DB_UNKNOWN to let berkeleydb autodetect the database type
authorMichael Schroeder <mls@suse.de>
Wed, 3 Jun 2009 17:20:13 +0000 (19:20 +0200)
committerMichael Schroeder <mls@suse.de>
Wed, 3 Jun 2009 17:20:13 +0000 (19:20 +0200)
- fix -r option if the root is not an abs path
- print rpm --rebuilddb hint

tools/repo_rpmdb.c

index e6d0055..657daa3 100644 (file)
@@ -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)