On Thu, Jul 19, 2018 at 08:43:03PM +0200, Paul Gevers wrote:
> On 19-07-18 13:41, Niko Tyni wrote:

> > I think breaking out of the for loop after the first time
> > we call _synthesize_deps() would work?
> 
> From a quick look that sounds like it works in most cases, yes. However,
> you don't actually know what the apt run before actually installed, so
> if you want to do the right thing you need to check which one got installed.

Right, I was just thinking of fixing the worst bug where we currently
try to install both the alternatives rather than just one of them.

Tracking which alternative dependency got installed by the first apt pass
(or was already installed before that, as in Samuel's case) is somewhat
hard for the case of Provides. The best I can come up with is something
like (for an example of perl Providing libtest-simple-perl):

 dpkg-query -W -f'${Status} ${Provides}\n' \* | grep -q '^install ok 
.*libtest-simple-perl' && echo yes

which seems rather silly and not very well performing but probably works.

As for the rest of the implementation, we'd have to keep the list of
alternative dependencies around for longer, so that we still have the
information after running apt the first time. We can then run dpkg-query
and see if any one of the alternatives is installed as a real package.

If one is installed as a real package, there's no need for a separate apt
run for those packages. (Much of the same logic could probably also be
used to optimize away any unnecessary apt second pass runs that we're
currently doing.)

If none of the alternatives are installed as a real package, we'd have
to check which of them is provided by some other package, and only ask
for that in the second apt pass.

Does that make sense?
-- 
Niko

Reply via email to