[pacman-dev] [PATCH] Pactest for removing multiple items in a dependency chain
From 6981d942fdd38710895df8741f490201712b79eb Mon Sep 17 00:00:00 2001 From: Allan McRae <mcrae_allan@hotmail.com> Date: Thu, 3 Apr 2008 16:35:14 +1000 Subject: [PATCH] Pactest for removing multiple items in a dependency chain This adds a test for when removing multilpe packages recursively from a chain of dependent packages. This situation can occur when removing installed dependencies with makepkg if a "makedepend" recursively depends on a "depend" or if redundant dependancies are included. Signed-off-by: Allan McRae <mcrae_allan@hotmail.com> --- pactest/tests/remove052.py | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) create mode 100644 pactest/tests/remove052.py diff --git a/pactest/tests/remove052.py b/pactest/tests/remove052.py new file mode 100644 index 0000000..53f516e --- /dev/null +++ b/pactest/tests/remove052.py @@ -0,0 +1,22 @@ +self.description = "-Rs test (dependency chain)" + +lp1 = pmpkg("pkg1") +lp1.reason = 1 +self.addpkg2db("local", lp1) + +lp2 = pmpkg("pkg2") +lp2.depends = ["pkg1"] +lp2.reason = 1 +self.addpkg2db("local", lp2) + +lp3 = pmpkg("pkg3") +lp3.depends = ["pkg2"] +lp3.reason = 1 +self.addpkg2db("local", lp3) + +self.args = "-Rs %s" % " ".join([p.name for p in lp1, lp3]) + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=pkg1") +self.addrule("!PKG_EXIST=pkg2") +self.addrule("!PKG_EXIST=pkg3") -- 1.5.4.5
From 6981d942fdd38710895df8741f490201712b79eb Mon Sep 17 00:00:00 2001 From: Allan McRae <mcrae_allan@hotmail.com> Date: Thu, 3 Apr 2008 16:35:14 +1000 Subject: [PATCH] Pactest for removing multiple items in a dependency chain
This adds a test for when removing multilpe packages recursively from a chain of dependent packages. This situation can occur when removing installed dependencies with makepkg if a "makedepend" recursively depends on a "depend" or if redundant dependancies are included.
Signed-off-by: Allan McRae <mcrae_allan@hotmail.com> --- pactest/tests/remove052.py | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) create mode 100644 pactest/tests/remove052.py
diff --git a/pactest/tests/remove052.py b/pactest/tests/remove052.py new file mode 100644 index 0000000..53f516e --- /dev/null +++ b/pactest/tests/remove052.py @@ -0,0 +1,22 @@ +self.description = "-Rs test (dependency chain)" + +lp1 = pmpkg("pkg1") +lp1.reason = 1 +self.addpkg2db("local", lp1) + +lp2 = pmpkg("pkg2") +lp2.depends = ["pkg1"] +lp2.reason = 1 +self.addpkg2db("local", lp2) + +lp3 = pmpkg("pkg3") +lp3.depends = ["pkg2"] +lp3.reason = 1 +self.addpkg2db("local", lp3) + +self.args = "-Rs %s" % " ".join([p.name for p in lp1, lp3]) + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=pkg1") +self.addrule("!PKG_EXIST=pkg2") +self.addrule("!PKG_EXIST=pkg3") --
Hm. Maybe we should move recursedeps before checkdeps in alpm/remove.c Bye ---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
From 606d2a931da6f2d942cfc15ddc9400ecc4596a7b Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Sat, 19 Apr 2008 22:31:22 +0200 Subject: [PATCH] Fix for remove052.py by moving recursedeps before checkdeps Now -Rs is processed in the plausible way: first pull the dependencies then call checkdeps. Note: -Rs is a little bit slower now, because we shouldn't check the pulled deps In case of -Rcs we keep the old behavior because the bug cannot happen there and we must pull the pulled targets' deps too. Ref.: http://www.archlinux.org/pipermail/pacman-dev/2008-April/011569.html Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> --- lib/libalpm/remove.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index dfdcabe..556d175 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -96,6 +96,11 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) return(0); } + if((trans->flags & PM_TRANS_FLAG_RECURSE) && !(trans->flags & PM_TRANS_FLAG_CASCADE)) { + _alpm_log(PM_LOG_DEBUG, "finding removable dependencies\n"); + _alpm_recursedeps(db, trans->packages, trans->flags & PM_TRANS_FLAG_RECURSEALL); + } + if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) { EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL); @@ -163,7 +168,8 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) alpm_list_free(trans->packages); trans->packages = lp; - if(trans->flags & PM_TRANS_FLAG_RECURSE) { + /* -Rcs == -Rc then -Rs */ + if((trans->flags & PM_TRANS_FLAG_CASCADE) && (trans->flags & PM_TRANS_FLAG_RECURSE)) { _alpm_log(PM_LOG_DEBUG, "finding removable dependencies\n"); _alpm_recursedeps(db, trans->packages, trans->flags & PM_TRANS_FLAG_RECURSEALL); } -- 1.5.3.8
From 606d2a931da6f2d942cfc15ddc9400ecc4596a7b Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Sat, 19 Apr 2008 22:31:22 +0200 Subject: [PATCH] Fix for remove052.py by moving recursedeps before checkdeps
Now -Rs is processed in the plausible way: first pull the dependencies then call checkdeps. Note: -Rs is a little bit slower now, because we shouldn't check the pulled deps
In case of -Rcs we keep the old behavior because the bug cannot happen there and we must pull the pulled targets' deps too.
Ref.: http://www.archlinux.org/pipermail/pacman-dev/2008-April/011569.html
I don't know whether we should fix the issue or not, but I've created a patch for that. But I must mention a little (theoretical) edge case with my patch: pacman -Rus now can work a bit funny: Pacman first pulls the 'dep' removable dependency of 'foo'. Then it detects that foo cannot be removed, this is resolved by removing foo from target list. You may think, that the next step of "unneeded check" will also remove 'dep'. But not necessarily! Multiple satisfiers can confuse things. So in this case -Rus does some unwanted orphan deletion. Bye
participants (2)
-
Allan McRae
-
Nagy Gabor