[pacman-dev] [PATCH] alpm_checkdeps clean-up

Xavier shiningxc at gmail.com
Fri Nov 30 16:45:06 EST 2007

On Fri, Nov 30, 2007 at 08:37:13AM -0600, Dan McGee wrote:
> I'll be looking at it this weekend for sure. The "check localdb by
> hand" comment scares me a bit, but I haven't dove into the code yet.

Maybe some pseudo-code could help, but not sure if it's a good idea.

compute_requiredby(pkg) :
for p in localdb
  for dep in p.deps
    if pkg satisfies dep
      add p to the return list

checkdeps :
for p in {upgrade U remove}
  for q in compute_requiredby(p)
    for dep in q.deps
      if p satisfies dep
        /* check if dep is still satisfied by another pkg */

The minor problems with the above :
1) the localdb is scanned n times, with n = length of upgrade + remove lists.
2) the dependency that is the cause of q being required by p is lost
(the "for dep in q.deps; if p satisfies dep ..." is done twice : first in
compute_requiredby , then again in checkdeps)

Instead of that, the localdb just needs to be scanned once. And for each
package, we check if it depends on a package going to be upgraded or removed.

More information about the pacman-dev mailing list