[pacman-dev] [PATCH 1/2] Add test to check for indirect optdepend removal
If package brown-sugar provides package sugar and package coffee optionally depends on sugar, pacman should print a warning when brown-sugar is removed. Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> --- test/pacman/tests/TESTS | 1 + test/pacman/tests/remove072.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 test/pacman/tests/remove072.py diff --git a/test/pacman/tests/TESTS b/test/pacman/tests/TESTS index fc6a7e8..6c56268 100644 --- a/test/pacman/tests/TESTS +++ b/test/pacman/tests/TESTS @@ -112,6 +112,7 @@ TESTS += test/pacman/tests/remove052.py TESTS += test/pacman/tests/remove060.py TESTS += test/pacman/tests/remove070.py TESTS += test/pacman/tests/remove071.py +TESTS += test/pacman/tests/remove072.py TESTS += test/pacman/tests/replace100.py TESTS += test/pacman/tests/replace101.py TESTS += test/pacman/tests/replace102.py diff --git a/test/pacman/tests/remove072.py b/test/pacman/tests/remove072.py new file mode 100644 index 0000000..0a29b39 --- /dev/null +++ b/test/pacman/tests/remove072.py @@ -0,0 +1,14 @@ +self.description = "Remove a package that provides an optdepend" + +p1 = pmpkg("brown-sugar") +p1.provides = ["sugar"] +self.addpkg2db("local", p1) + +p2 = pmpkg("coffee") +p2.optdepends = ["sugar"] +self.addpkg2db("local", p2) + +self.args = "-R %s" % p1.name + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PACMAN_OUTPUT=coffee optionally requires sugar") -- 1.8.5.1
Print a warning when a package that satisfies an optional dependency for another package through its provides array is removed. Fixes FS#37669 Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> --- This is the simplest solution, although the downside is that the warning prints the name of the optdepend rather than the name of the package being removed. An alternative solution would be to modify the signature of the event so that the second parameter is an alpm_pkg_t rather than an alpm_depend_t. The best solution would be one where the warning prints the optdepend as well as the package that satisfies it. Something like: :: coffee optionally requires sugar (provided by brown-sugar-1.0-1) but I don't see a good way of doing this without adding a third parameter to all events... lib/libalpm/remove.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 9417a61..b3d1f1d 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -178,7 +178,7 @@ static void remove_notify_needed_optdepends(alpm_handle_t *handle, alpm_list_t * alpm_list_t *j; for(j = optdeps; j; j = alpm_list_next(j)) { alpm_depend_t *optdep = j->data; - if(alpm_pkg_find(lp, optdep->name)) { + if(alpm_find_satisfier(lp, optdep->name)) { EVENT(handle, ALPM_EVENT_OPTDEP_REQUIRED, pkg, optdep); } } -- 1.8.5.1
On 21/12/13 05:10, Chirantan Ekbote wrote:
Print a warning when a package that satisfies an optional dependency for another package through its provides array is removed.
Fixes FS#37669
Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> --- This is the simplest solution, although the downside is that the warning prints the name of the optdepend rather than the name of the package being removed.
An alternative solution would be to modify the signature of the event so that the second parameter is an alpm_pkg_t rather than an alpm_depend_t.
The best solution would be one where the warning prints the optdepend as well as the package that satisfies it. Something like:
:: coffee optionally requires sugar (provided by brown-sugar-1.0-1)
but I don't see a good way of doing this without adding a third parameter to all events...
We will save this for after the events rewrite gets in. That way we can pass whatever we want to the event. Allan
lib/libalpm/remove.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 9417a61..b3d1f1d 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -178,7 +178,7 @@ static void remove_notify_needed_optdepends(alpm_handle_t *handle, alpm_list_t * alpm_list_t *j; for(j = optdeps; j; j = alpm_list_next(j)) { alpm_depend_t *optdep = j->data; - if(alpm_pkg_find(lp, optdep->name)) { + if(alpm_find_satisfier(lp, optdep->name)) { EVENT(handle, ALPM_EVENT_OPTDEP_REQUIRED, pkg, optdep); } }
On 21/12/13 05:10, Chirantan Ekbote wrote:
If package brown-sugar provides package sugar and package coffee optionally depends on sugar, pacman should print a warning when brown-sugar is removed.
That is fine. I will pull this when we get the event sorted. For future reference, the test if added in a patch before the fix needs to have: self.expectfailure = True at the bottom. This line is removed when the fix gets added.
Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> --- test/pacman/tests/TESTS | 1 + test/pacman/tests/remove072.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 test/pacman/tests/remove072.py
diff --git a/test/pacman/tests/TESTS b/test/pacman/tests/TESTS index fc6a7e8..6c56268 100644 --- a/test/pacman/tests/TESTS +++ b/test/pacman/tests/TESTS @@ -112,6 +112,7 @@ TESTS += test/pacman/tests/remove052.py TESTS += test/pacman/tests/remove060.py TESTS += test/pacman/tests/remove070.py TESTS += test/pacman/tests/remove071.py +TESTS += test/pacman/tests/remove072.py TESTS += test/pacman/tests/replace100.py TESTS += test/pacman/tests/replace101.py TESTS += test/pacman/tests/replace102.py diff --git a/test/pacman/tests/remove072.py b/test/pacman/tests/remove072.py new file mode 100644 index 0000000..0a29b39 --- /dev/null +++ b/test/pacman/tests/remove072.py @@ -0,0 +1,14 @@ +self.description = "Remove a package that provides an optdepend" + +p1 = pmpkg("brown-sugar") +p1.provides = ["sugar"] +self.addpkg2db("local", p1) + +p2 = pmpkg("coffee") +p2.optdepends = ["sugar"] +self.addpkg2db("local", p2) + +self.args = "-R %s" % p1.name + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PACMAN_OUTPUT=coffee optionally requires sugar")
participants (2)
-
Allan McRae
-
Chirantan Ekbote