[pacman-dev] [PATCH] Alternative interpretation of multiple replaces

Nagy Gabor ngaba at bibl.u-szeged.hu
Mon Jan 14 10:47:15 EST 2008


From 3c3804926d84734c918d2626becb1c19eeebbd7e Mon Sep 17 00:00:00 2001
From: Nagy Gabor <ngaba at bibl.u-szeged.hu>
Date: Mon, 14 Jan 2008 16:44:22 +0100
Subject: [PATCH] Alternative interpretation of multiple replaces

Ref.: http://www.archlinux.org/pipermail/pacman-dev/2008-January/010819.html
sync134.py and sync135.py were modified accordingly.

Signed-off-by: Nagy Gabor <ngaba at bibl.u-szeged.hu>
---
 lib/libalpm/sync.c       |   15 ++++++++++++++-
 pactest/tests/sync134.py |    6 +++---
 pactest/tests/sync135.py |    6 +++---
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index ca50efe..e2aebe2 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -115,7 +115,20 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
 					_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (to be replaced by %s-%s)\n"),
 										alpm_pkg_get_name(lpkg), alpm_pkg_get_version(lpkg),
 										alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
-				} else {
+					continue;
+				} 
+				/* check if we already elected lpkg as to-be-replaced */
+				int replaced = 0;
+				alpm_list_t *l;
+				for(l = *syncpkgs; l && !replaced; l = l->next) {
+					pmsyncpkg_t *sync = l->data;
+					if(sync->type == PM_SYNC_TYPE_REPLACE) {
+						if(_alpm_pkg_find(alpm_pkg_get_name(lpkg), sync->data)) {
+							replaced = 1;
+						}
+					}
+				}
+				if(!replaced) {
 					/* get confirmation for the replacement */
 					if(trans) {
 						int doreplace = 0;
diff --git a/pactest/tests/sync134.py b/pactest/tests/sync134.py
index 572ab32..2bdaebf 100644
--- a/pactest/tests/sync134.py
+++ b/pactest/tests/sync134.py
@@ -1,4 +1,4 @@
-self.description = "Sysupgrade with a set of sync packages replacing a set local one"
+self.description = "Multiple replacers (1)"
 
 sp1 = pmpkg("pkg2")
 sp1.replaces = ["pkg1"]
@@ -17,5 +17,5 @@ self.args = "-Su"
 
 self.addrule("PACMAN_RETCODE=0")
 self.addrule("!PKG_EXIST=pkg1")
-for p in sp1, sp2:
-	self.addrule("PKG_EXIST=%s" % p.name)
+self.addrule("PKG_EXIST=pkg2")
+self.addrule("!PKG_EXIST=pkg3")
diff --git a/pactest/tests/sync135.py b/pactest/tests/sync135.py
index 18c412a..10bd3b0 100644
--- a/pactest/tests/sync135.py
+++ b/pactest/tests/sync135.py
@@ -1,4 +1,4 @@
-self.description = "Sysupgrade with a set of sync packages replacing a set of local ones"
+self.description = "Multiple replacers (2)"
 
 sp1 = pmpkg("pkg2")
 sp1.replaces = ["pkg1"]
@@ -25,7 +25,7 @@ for p in lp1, lp2:
 self.args = "-Su"
 
 self.addrule("PACMAN_RETCODE=0")
-for p in lp1, lp2:
+for p in lp1, lp2, sp2, sp4:
 	self.addrule("!PKG_EXIST=%s" % p.name)
-for p in sp1, sp2, sp3, sp4: 
+for p in sp1, sp3: 
 	self.addrule("PKG_EXIST=%s" % p.name)
-- 
1.5.3.7





More information about the pacman-dev mailing list