Ubuntu – Prevent dependency from being installed with APT

aptjavatomcatUbuntu

I have this script line to install all packages for a new server.

apt-get install mysql-server openjdk-7-jre-headless tomcat7 tomcat7-admin jsvc apache2 ntp subversion

As you can see it installs Java 7, but Java 6 is also installed because tomcat7 (indirectly) depends on it. I'm pretty sure I can run Tomcat 7 with Java 7, so I don't want to install two JREs. How can I prevent Java 6 from being installed?

Update: Closer inspection shows that

  • tomcat7, via tomcat-common, depends on
    default-jre-headless | java6-runtime-headless | java6-runtime | java-6-runtime (assuming the pipes mean "one of").
  • openjdk-7-jre-headless provides java6-runtime-headless, so that dependency should be met.
  • Instead, default-jre-headless is installed, which installs Java 6.

Why does that happen? Is it because I install them all at once. Should I split it up into 2 calls?

(Ubuntu 12.04 server, 64-bit)

Best Answer

Use --nodeps option with apt-get to ignore dependencies being installed.

There is another way is that you download a package and install it with dpkg with --ignore-depends=package,...

A GUI package manager such as Synaptic, will make you able to select-deselect the dependencies before installation of selected packages.

Related Topic