Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm working on some machine setup instructions, and I was surprised to find out that apt-get install A B can behave differently than apt-get install A && apt-get install B.

My specific example is A == openjdk-7-jdk and B == ant.

So, openjdk-7-jdk depends on openjdk-7-jre-headless, which satisfies ant's dependency java6-runtime-headless. But if you install them as apt-get install openjdk-7-jdk ant, APT doesn't seem to figure this out and installs default-jre-headless. But if you install openjdk-7-jdk prior to installing ant, its dependency is satisfied and all is good.

APT is usually smart enough to figure this sort of thing out, so why can't it do so in this case? I'd like to have a better understanding as to why it works this way, so this sort of thing doesn't trip me up again in the future.

share|improve this question
    
Looking at my apt cache I see that openjdk-7-jdk 7~u3-2.1.1~pre1-1ubuntu2 depends upon openjdk-7-jre, which in turn depends upon openjdk-7-jre-headless, so this dependency is indirect. ant depends directly on default-jre-headless. I'm using Precise. I'm only guessing but apt-get could either arbitrarily start with ant, or start with level 1 dependencies and then go to level 2 dependencies. In any case, if you care about the final configuration of packages (want openjdk-7-jre-headless over default-..-..) specifying them specifically and individually is probably the best way to control that. –  John S Gruber May 19 '12 at 3:56
    
Are you still interested in that question? –  guntbert Feb 14 '13 at 19:39
    
@guntbert Sure, although I've resigned myself into believing that there is no reason; it's just the way it is. –  dave Feb 14 '13 at 23:25
5  
To see how the APT resolver works, look at apt-get install -o Debug::pkgProblemResolver=true package1 package2.... That might give you a hint why it's working that way. –  Lasall Feb 17 '13 at 15:56

2 Answers 2

Seems that there is some kind of "weight" system playing here:

$ aptitude why ant openjdk-7-jdk
p   ant                 Recommends ant-optional       
p   ant-optional        Suggests   libgnumail-java    
p   libgnumail-java     Suggests   libgnumail-java-doc
p   libgnumail-java-doc Recommends default-jdk-doc    
p   default-jdk-doc     Depends    openjdk-7-doc      
p   openjdk-7-doc       Suggests   openjdk-7-jdk

As you can see ant depends of openjdk-7-jdk due a complicated and intricated amounts of suggestions, recommendations and dependency, while when using openjdk-6-jdk the dependency is more direct:

$ aptitude why ant openjdk-6-jdk
p   ant           Suggests default-jdk | java-compiler | java-sdk
p   openjdk-6-jdk Provides java-sdk

Of course aptitude methods of dependency resolution, could be different of apt-get's. BTW, running a simulation of ant without openjdk-7-jdk installed don't pulled openjdk-6-jdk:

$ sudo apt-get install ant
[sudo] password for braiam: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  ant-optional
Suggested packages:
  default-jdk java-compiler java-sdk ant-gcj ant-doc liboro-java junit
  libregexp-java jython antlr libbcel-java libjdepend-java libgnumail-java
  libcommons-net-java libjsch-java javacc ant-optional-gcj
The following NEW packages will be installed:
  ant ant-optional
0 upgraded, 2 newly installed, 0 to remove and 9 not upgraded.
Need to get 2,234 kB of archives.
After this operation, 3,041 kB of additional disk space will be used.
Do you want to continue [Y/n]? 

Maybe if you use the same methods as I did, you could figure out more, since I'm using Debian testing right now and repositories could have changed in the meanwhile.

share|improve this answer

AFAIK, it has defaults for satisfying a dependency, so if that dependency has not been satisfied prior to installing a package, it installs the dependency and then installs the requested package.

This could also just be a large bug, though.

Either way, hope that helps.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.