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?

link|improve this question

67% accept rate
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
feedback

6 Answers

up vote 1 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.

link|improve this answer
4  
Which APT version do you have? Mine (0.8.10) doesn't have such an option. – Tshepang Mar 22 '11 at 12:25
2  
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
feedback

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

link|improve this answer
feedback

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.

link|improve this answer
feedback

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

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

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.

link|improve this answer
feedback

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!

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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