The main problem I had with this part is the problems it caused during pacman 2 -> pacman 3 upgrade (where pacman got new dependencies, libarchive and libdownload). Apparently, pacman2 first got a list of upgrade and resolved the dependencies, then checked if it was in the target list, and if it was, removed every package but itself from the target list (including its own new dependencies). And then it didn't resolve deps again either. On the other hand, pacman3 first adds the list of upgrade to the targets by calling alpm_trans_sysupgrade, then it checks if pacman is one of them. In this case, it cancels the old transaction and creates a new one with only pacman as target. And only then, it calls alpm_trans_prepare, which will resolve the dependencies. Attaching a pactest which should emulate pacman 2 -> pacman 3 upgrade, but it's now handled fine by pacman3 (not sure this test is very interesting). I let you decide if this behavior of automatically upgrading itself first is needed (apparently, it was in the past). And if it's needed, but you find the code ugly, maybe there are other ways of doing it better ? I personally don't have problems with this part, as it apparently now does its job correctly, but it doesn't mean it's good :)