From de3f36acc91bf13e694bb479e8dbe0502a4cc4e1 Mon Sep 17 00:00:00 2001
From: Michael Schroeder <mls@suse.de>
Date: Tue, 14 Apr 2020 11:09:29 +0200
Subject: [PATCH] Add an index sync call at the end of a database rebuild

This is normally unneeded because an index sync is already done
after each package is added to the database. But rebuilding an
empty database lead to no index sync being done and a mismatch
between the generation count. This in turn will trigger a
index regeneration.

Found by using ndb when running the test suite.

URL:https://github.com/rpm-software-management/rpm/commit/de3f36acc91bf13e694bb479e8dbe0502a4cc4e1
---
 lib/rpmdb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/rpmdb.c b/lib/rpmdb.c
index 57a3c3d..4c10156 100644
--- a/lib/rpmdb.c
+++ b/lib/rpmdb.c
@@ -2578,6 +2578,7 @@ int rpmdbRebuild(const char * prefix, rpmts ts,
     }
 
     rpmdbClose(olddb);
+    dbCtrl(newdb, DB_CTRL_INDEXSYNC);
     rpmdbClose(newdb);
 
     if (failed) {
-- 
1.8.3.1

