Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do I make apt-get ignore some dependencies? For example, I wanted to install mailx so I can use it to send email from cron scripts/report-generating tools. However, installing mailx also installs exim4 and a whole bunch of dependencies (I already have Postfix installed) I don't really need and which I guess mailx can also live without.

How do I ignore some dependencies but still use apt-get since it's a nice tool?

share|improve this question
    
how is postfix installed? via the debian package? or did you install postfix from source? –  stew Mar 23 '11 at 20:13
    
Yes, Postfix was installed from source –  FrancisV Mar 23 '11 at 22:26
1  
Debian's mailx package only 'recommends' exim4, doesn't require it. If you don't want to install recommended packages, just add APT::Install-Recommends "false"; to your apt.conf. –  ruief Jan 23 at 0:30

9 Answers 9

up vote 4 down vote accepted

You can try the --nodeps flag with apt-get.
Or download the package and install it using dpkg with the option --ignore-depends.

share|improve this answer
19  
Which APT version do you have? Mine (0.8.10) doesn't have such an option. –  Tshepang Mar 22 '11 at 12:25
3  
telling dpkg to ignore depndencies isn't an option for him. It only tells dpkg to ignore the dependencies for THIS transaction, it will try to then satisfy the dependencies or remove the pacakge the next time you do anything. –  stew Mar 23 '11 at 20:13
    
Yes, @stew is right. I just want to disable dependencies for this package only. –  FrancisV Mar 23 '11 at 22:23
1  
Still no luck with APT 0.8.16 BTW. Too bad since there don't seem to be reasonable alternatives. Which version did you use back in 2011 to get this to work? –  Christian Jul 12 '13 at 4:10

You can change the dependencies of a deb package like this:

  1. Unpack deb: ar x golden-linux.deb (will create i.e. three files: debian-binary control.tar.gz data.tar.gz)
  2. Unpack control archive: tar xzf control.tar.gz (will create: postinst postrm preinst prerm md5sums control)
  3. Fix dependencies in control (use a text editor)
  4. Repack control.tar.gz: tar c {post,pre}{inst,rm} md5sums control | gzip -c > control.tar.gz
  5. Repack deb: ar rcs newpackage.deb debian-binary control.tar.gz data.tar.gz (order important! See [Note] )

[Note]: dpkg wouldn't be able to read the metadata of a package quickly if it had to search for where the data section ended!

share|improve this answer
    
Nice,it solves to me a special case of dependencies for "raring8" to "raring6" but the same version =(, very thanks –  Felipe Alcacibar Jul 18 '13 at 16:36

Since you installed postfix from source, you need to install a "dummy" package which will satisfy the mail-transport-agent dependency of mailx (or bsd-mailx). The "equivs" package in debian exists to create such a dummy package which you can install to tell dpkg "this dependency is satisfied"

The reason that telling dpkg to simply ignore dependencies is not a good solution, is that you are only telling dpkg/apt to ignore it for a single transaction, you can't tell it to ignore dependencies forever. Everytime you use apt it checks the dependencies on all packages

share|improve this answer
    
See also this answer that links to a tutorial (although it is overly complex) superuser.com/a/416560/128960. Short version is: run equivs-control <name>, edit the file produced to provide the right dependency and have a nice name, then run equivs-build <name> and finally dpkg -i the resulting .deb file. –  Christian Jul 12 '13 at 7:36

After you install the package with the --ignore-depends option, go and edit the /var/lib/dpkg/status file, and remove whatever dependency you think is not needed. Just be very careful. In order a dep. to be required, it is more than likely to BE required

share|improve this answer
    
Thanks, that worked perfectly for me! –  AndreasT Aug 2 '13 at 23:29

I've been looking for this option on a Ubuntu 12.04 Server running Xen. In my domains I use the -virtual kernel, and apt persistently tried to install grub with every kernel package upgrade. Grub however is not needed inside the domU when using p[yv]grub.

I've been looking for the -nodeps option to apt-get as well, but it didn't work, so ended up uninstalling/purging grub* after each kernel upgrade.

After all, really reading a man page helps sometimes - it turns out a similar apt-get option on 12.04 seems to be --no-install-recommends, which actually works in this case, since grub is listed as 'recommended' in the package information (I guess so it is not a "real" dependency?).

I'm adding this here because in my case it solved a similar issue, and the hint for '--no-install-recommends' was not mentioned yet.

share|improve this answer

For the purposes of this, you could just install nail which I don't think has these dependencies?

apt-get install nail
share|improve this answer
    
Thanks for this alternative! –  FrancisV Mar 23 '11 at 22:21

On my debian system, bsd-mailx actually depends on default-mta | mail-transport-agent (you can check what a package depends on with apt-cache show <pkg> for anything in the archive or dpkg -s <pkg> for installed packages.

It may be that your postfix package doesn't have Provides: mail-transport-agent so apt doesn't realize you have an MTA installed. It would be worth filing a bug for that if it's an official package.

share|improve this answer

The dependencies required when you install a package through apt are listed by the package builder. So whoever built the mailx package decided that exim4 was a requirement (maybe mailx uses one of exim4's libraries?)

An alternative is to build mailx from source, and download the necessary libraries to do this. This will avoid involving the package manager.

share|improve this answer

Well - don't.

Using other people's work is very important on the road to any success. When you build some software from source (tarball), you miss the opportunity to use the distro's package manager's work.

You won't get "free" updates. Most of the time none ever updates the packages they installed from source. Because they need to track the software for new versions, rebuild it and all the dependent programs (try to remember them).

You will have problems with other packages from your distribution's repos. This is exactly the case stated in the question: ubuntu has a great package manager and some very nice people maintaining the packages. And they have decided, that for the mailx program to work you need an MTA. So if you installed postfix from sources ubuntu wouldn't ask you to install exim.

If for some reason the maintenance of the server passes to some other person (e.g. your project becomes very successful and you decide to hire another guy to manager the servers while you are busy with other stuff) he will naturally expect to run dpkg --get-selections to get all the installed packages.

Try to use the distro's package management software as much as possible. Learn to build your own packages if you can't find one prebuilt and you'll become a better professional.

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.