Some background information:

As you may know, in a Debian package, there may be alternative dependencies, written in the CONTROL file as Depends: apache2|something-else, for example. How does apt select which dependencies to choose, and how can I override this so I can minimize download size?

I'm on a slow connection on some locations and need it to use the smallest total download size. How can I force it to do so?

Edit: I'm not asking about skipping recommends.

Edit 2: I am not asking about skipping dependencies. I am trying to get all dependencies, just in the smallest total size, especially noting and deeply traversing package1|package2 choices.

Edit 3: A grep or otherwise shell script is acceptable.

Unfortunately, since the current answers do not really answer the question, they can't really get the bounty. It's still out there for someone willing to write a bash script!

Edit 4: Although the bounty has been awarded to a good answer which I encourage you to upvote, I am still seeking a more concrete answer. If it also elegantly handles virtual packages provided by one or more packages, then I'll possibly give another after-the-fact bounty to award that answer.


You could always have apt list all the dependencies then by hand you could install the packages that you would rather install but I've searched man pages and several forums but I could not answer your exact question other than rewriting the source to apt that's how opensource works anyways.

  • This may help but I'll need something more specific than that. Try fleshing out your post with more details, or a shell script while you are at it, and welcome to Ask Ubuntu!.
    – nanofarad
    Oct 22 '12 at 22:47
  • 1
    @ObsessiveSSOℲ Honestly I don't have the time, however if you wish to do it then this command: VAR=$(apt-cache show gedit | grep "Size" | grep -Ev 'I' | sed 's/Size: //g') will get you the package size which you could use to compare to values in an array populated using this command. Sorry I couldn't help more.
    – David
    Oct 22 '12 at 23:39
  • If nothing better comes by, you are truly the winner of this bounty.
    – nanofarad
    Oct 22 '12 at 23:52
  • @ObsessiveSSOℲ could you give an example of a package with alt dependancies
    – David
    Oct 23 '12 at 1:02
  • Something as simple as wordpress, which involves apache2|httpd. Also note that httpd is a virtual package. I'll also give you the bounty. I won't accept just yet, though.
    – nanofarad
    Oct 23 '12 at 10:34

As far as I know, there is no way to optimize that. Most things are already greatly compressed, so you don't download nearly the whole file size. (Next time you install a package, take a look at the difference between the amount of data to be downloaded and the total hard drive space to be consumed.)

If you know what you're doing, (e.g., you already installed foo, but it says that you need to reinstall it,) and want to leave all the dependencies off when you install a file, add the flag --no-install-recommends.
Some of the answers to this question explain how to install specific packages without the dependencies. They covered it quite a bit deeper than I did, so if you're still having trouble or my answer didn't solve your problem, I'd recommend taking a look at that thread.


I think you're confusing how dependencies work. If something is dependent- then by definition it is needed. I suppose what you could do is find out exactly which files from the dependency the app you want is using... and remove everything that it doesn't call.. but that seems like a lot of work for a few megabytes..

You seem to be asking for a car that will still drive missing a 4th wheel(let's say the 'back-left', for the sake of this metaphor),to save on weight. At some point you're going to need to turn Right. The car will still roll, but only with certain functionality... by not installing the 'Recommended' i think you are going as light as safely possible with out having to delve into development.

  • 6
    You really didn't understand the question. He knows the dependencies. But you should know that, there can be two packages satisfying same dependency. in that case, he wanted the less sized one
    – Anwar
    Oct 19 '12 at 18:49
  • IMO it's unfortunate that these answers have to suffer downvotes. They're good answers, and I hope nobody has been discouraged. Just make sure you answer the question.
    – nanofarad
    Oct 22 '12 at 21:28
  • @a.s. ty for clarifying and informing. :) (i don't mind the down votes.)
    – knope
    Oct 25 '12 at 17:05
  • I didn't downvote you first, just explained the matter. but Now, I've given, because the answer didn't address the issue @ObsessiveSSOℲ talked in his question
    – Anwar
    Oct 26 '12 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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