[pacman-dev] [PATCH] New sync1007.py pactest
From 49a346d598433b46e19f841432938f84df480c28 Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Fri, 11 Jan 2008 21:02:50 +0100 Subject: [PATCH] New sync1007.py pactest This pactest checks what happens when more than one package can replace the same package. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> --- pactest/tests/sync1007.py | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) create mode 100644 pactest/tests/sync1007.py diff --git a/pactest/tests/sync1007.py b/pactest/tests/sync1007.py new file mode 100644 index 0000000..6f5d9f6 --- /dev/null +++ b/pactest/tests/sync1007.py @@ -0,0 +1,19 @@ +self.description = "Multiple packages replace the same package" + +sp1 = pmpkg("alternative1") +sp1.replaces = [ "pkg" ] +self.addpkg2db("sync", sp1) + +sp2 = pmpkg("alternative2") +sp2.replaces = [ "pkg" ] +self.addpkg2db("sync", sp2) + +lp = pmpkg("pkg", "1.0-1") +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=pkg1") +self.addrule("PKG_EXIST=alternative1") +self.addrule("!PKG_EXIST=alternative2") -- 1.5.3.7
From 49a346d598433b46e19f841432938f84df480c28 Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Fri, 11 Jan 2008 21:02:50 +0100 Subject: [PATCH] New sync1007.py pactest
This pactest checks what happens when more than one package can replace the same package.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> --- pactest/tests/sync1007.py | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) create mode 100644 pactest/tests/sync1007.py
diff --git a/pactest/tests/sync1007.py b/pactest/tests/sync1007.py new file mode 100644 index 0000000..6f5d9f6 --- /dev/null +++ b/pactest/tests/sync1007.py @@ -0,0 +1,19 @@ +self.description = "Multiple packages replace the same package" + +sp1 = pmpkg("alternative1") +sp1.replaces = [ "pkg" ] +self.addpkg2db("sync", sp1) + +sp2 = pmpkg("alternative2") +sp2.replaces = [ "pkg" ] +self.addpkg2db("sync", sp2) + +lp = pmpkg("pkg", "1.0-1") +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=pkg1") +self.addrule("PKG_EXIST=alternative1") +self.addrule("!PKG_EXIST=alternative2")
Wow, I made a patch for this, and during testing I realized that sync134.py and sync135.py expect the opposite behavior. So, what to do if more packages can replace one? 1. Assume that we have a SET of replacers (sync134.py) 2. Assume that we one replacer is enough (sync1007.py) Imho 2. is more intuitive, when package foo replaces bar, I think that foo is "enough" as a replacer. But 1. is also reasonable... Bye
2008/1/14, Nagy Gabor <ngaba@bibl.u-szeged.hu>:
From 49a346d598433b46e19f841432938f84df480c28 Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Fri, 11 Jan 2008 21:02:50 +0100 Subject: [PATCH] New sync1007.py pactest
This pactest checks what happens when more than one package can replace the same package.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> --- pactest/tests/sync1007.py | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) create mode 100644 pactest/tests/sync1007.py
diff --git a/pactest/tests/sync1007.py b/pactest/tests/sync1007.py new file mode 100644 index 0000000..6f5d9f6 --- /dev/null +++ b/pactest/tests/sync1007.py @@ -0,0 +1,19 @@ +self.description = "Multiple packages replace the same package" + +sp1 = pmpkg("alternative1") +sp1.replaces = [ "pkg" ] +self.addpkg2db("sync", sp1) + +sp2 = pmpkg("alternative2") +sp2.replaces = [ "pkg" ] +self.addpkg2db("sync", sp2) + +lp = pmpkg("pkg", "1.0-1") +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=pkg1") +self.addrule("PKG_EXIST=alternative1") +self.addrule("!PKG_EXIST=alternative2")
Wow, I made a patch for this, and during testing I realized that sync134.py and sync135.py expect the opposite behavior.
So, what to do if more packages can replace one? 1. Assume that we have a SET of replacers (sync134.py) 2. Assume that we one replacer is enough (sync1007.py)
Imho 2. is more intuitive, when package foo replaces bar, I think that foo is "enough" as a replacer. But 1. is also reasonable...
I don't think there should be situations when more than one packages with replaces=('foobar') Replaces are used when a package changed its name (fglrx->catalyst) or when developers decided to go with a better alternative (cdrtools->cdrkit). If there are more than one replacing package then its a packaging error, and pacman shouldn't handle this, so #2 is ok. -- Roman Kyrylych (Роман Кирилич)
I don't think there should be situations when more than one packages with replaces=('foobar') Replaces are used when a package changed its name (fglrx->catalyst) or when developers decided to go with a better alternative (cdrtools->cdrkit). If there are more than one replacing package then its a packaging error, and pacman shouldn't handle this, so #2 is ok.
And imho multiple repos (testing...) can also lead to problems with #1. Bye
From 3c3804926d84734c918d2626becb1c19eeebbd7e Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@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@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
participants (2)
-
Nagy Gabor
-
Roman Kyrylych