[pacman-dev] [PATCH] Print error on duplicated database entries

Nagy Gabor ngaba at bibl.u-szeged.hu
Fri Nov 13 10:58:59 EST 2009


Some users reported duplicated database entries in /var/lib/pacman/local/,
for example, both foo-1.0-1 and foo-2.0-1 subdirectories existed. (Bogus
3rd-party scripts, backup?) In this case pacman reported no error and its
behaviour was mysterious.

>From now on, pacman detects this situation and prints an error message.

Signed-off-by: Nagy Gabor <ngaba at bibl.u-szeged.hu>
---
 lib/libalpm/be_files.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index ffbaa8d..feb71f8 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -348,6 +348,13 @@ int _alpm_db_populate(pmdb_t *db)
 			continue;
 		}
 
+		/* duplicated database entries are not allowed */
+		if(_alpm_pkg_find(db->pkgcache, pkg->name)) {
+			_alpm_log(PM_LOG_ERROR, _("duplicated database entry '%s'\n"), pkg->name);
+			_alpm_pkg_free(pkg);
+			continue;
+		}
+
 		/* explicitly read with only 'BASE' data, accessors will handle the rest */
 		if(_alpm_db_read(db, pkg, INFRQ_BASE) == -1) {
 			_alpm_log(PM_LOG_ERROR, _("corrupted database entry '%s'\n"), name);
-- 
1.6.5.2



More information about the pacman-dev mailing list