From 3a5a0d53bced32b42fd553952c2f74d52981d9ef Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 14 Dec 2018 21:44:24 +0100 Subject: Move skipping of duplicate sync/remove targets into libalpm sync: As pointed out by Andrew Gregory there could be an error when adding duplicates if they are two separate packages with the same name. Add a check in alpm_add_pkg() to test whether the duplicate is actually the same package, and if so, log a debug message and return success to skip the package. If the duplicate is a different package return ALPM_ERR_TRANS_DUP_TARGET and treat that error just like any other error in pacman. remove: Change alpm_remove_pkg() to just log a debug message and return success to skip duplicates. Remove the handling of ALPM_ERR_TRANS_DUP_TARGET in pacman. Also fixes FS#49377. Suggested-by: Andrew Gregory Signed-off-by: Michael Straube Signed-off-by: Allan McRae --- lib/libalpm/add.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/libalpm/add.c') diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index e415bb17..c39f9ecf 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -53,6 +53,7 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg) const char *pkgname, *pkgver; alpm_trans_t *trans; alpm_pkg_t *local; + alpm_pkg_t *dup; /* Sanity checks */ CHECK_HANDLE(handle, return -1); @@ -70,7 +71,12 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg) _alpm_log(handle, ALPM_LOG_DEBUG, "adding package '%s'\n", pkgname); - if(alpm_pkg_find(trans->add, pkgname)) { + if((dup = alpm_pkg_find(trans->add, pkgname))) { + if(dup == pkg) { + _alpm_log(handle, ALPM_LOG_DEBUG, "skipping duplicate target: %s\n", pkgname); + return 0; + } + /* error for separate packages with the same name */ RET_ERR(handle, ALPM_ERR_TRANS_DUP_TARGET, -1); } -- cgit v1.2.3-54-g00ecf