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?
Simple and easy solution: just specify the unwanted packages with an extra
-
after each of them.Example without the
-
switch:Example using the switch to avoid installing
exim4-base
. Notice the-
at the end:As you can see,
apt-get
does not try anymore to install theexim4-base
package, and it does not try to install its various dependencies (exim4-config
etc).And if you were wrong and needed that
exim4-base
dependency after all, you can justapt-get install
it later!You can change the dependencies of a deb package like this:
ar x golden-linux.deb
(will create i.e. three files: debian-binary control.tar.gz data.tar.gz)tar xzf control.tar.gz
(will create: postinst postrm preinst prerm md5sums control)control
(use a text editor)tar --ignore-failed-read -cvzf control.tar.gz {post,pre}{inst,rm} md5sums control
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!
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 requiredYou can try the
--nodeps
flag withapt-get
.Or download the package and install it using
dpkg
with the option--ignore-depends
.For example, if you want to install package
foo
without dependencybar
: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
An alternate way to manually tweak the dependencies is:
You can download the package with apt-get and then install it with dpkg, manually listing the dependancy you would like to be ignored.
For example if I want to download mypackage but it depends on libperl5.14 and I dont want to install libperl5.14 as I have a different version I can ignore this dependancy as follow:
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.
On my debian system, bsd-mailx actually depends on
default-mta | mail-transport-agent
(you can check what a package depends on withapt-cache show <pkg>
for anything in the archive ordpkg -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.For the purposes of this, you could just install nail which I don't think has these dependencies?