0

A package being installed with apt-get has a dependency on java that I want to ignore.

$ apt-cache depends some-package
some-package
  PreDepends: <java7-runtime-headless>
    default-jre-headless
    openjdk-7-jre-headless
  PreDepends: unzip
  ...

$ sudo apt-get install some-package -o Dpkg::Options::='--ignore-depends=default-jre-headless,openjdk-7-jre-headless,java7-runtime-headless'

The following extra packages will be installed:
ca-certificates-java fontconfig-config fonts-dejavu-core java-common
libasyncns0 libcups2 libflac8 libfontconfig1 libjpeg-turbo8 libjpeg8
liblcms2-2 libnspr4 libnss3 libnss3-nssdb libogg0 libpulse0 libsctp1
libsndfile1 libvorbis0a libvorbisenc2 lksctp-tools openjdk-7-jre-headless
tzdata-java

I went with a shotgun approach on the ignore-depends parameter to try cover various packages, but openjdk-7-jre-headless seems to always be pulled in. Have also tried adding in the PreDepends to exclude.

How can I prevent openjdk from being installed?

edit seems like the installation is being triggered by the predepends:

From What is the difference between dependencies and pre-depends?

Pre-Depends

This field is like Depends, except that it also forces dpkg to 
complete installation of the packages named before even starting the
installation of the package which declares the pre-dependency

https://serverfault.com/questions/250224/how-do-i-get-apt-get-to-ignore-some-dependencies discusses a way around this:

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

So I am assuming this is something I would need to do to get this to work...

6
  • Possible duplicate of How can I install a package without installing some dependencies?
    – Panther
    May 23, 2016 at 16:09
  • Hey bodhi, I looked at that and a few others. The biggest difference between mine and the others is that my dependency is being pulled in from a predepends - read up a bit on this, and found another solution somewhere that discussed fetching the dpkg, extracting it, rewritting one of the metadata files and repacking it before installing.
    – Brett
    May 23, 2016 at 16:15
  • Here's the post on the difference between different types: askubuntu.com/questions/83553/…
    – Brett
    May 23, 2016 at 16:15
  • I understand the difference, but, AFIK you need either to download the source, modify the dependencies, and rebuild the package (probably best) or use dpkg. Even better, just install the dependencies. If you want some sort of minimal install, use Gentoo or Arch ;)
    – Panther
    May 23, 2016 at 17:56
  • 2
    It's not possible to install a package without its pre-dependencies because they're required to install the package. In contrast, regular dependencies are required to use the package. May 24, 2016 at 10:58

1 Answer 1

0

The short answer, as per David-Foerster's comment - It's not possible to install a package without its pre-dependencies because they're required to install the package. In contrast, regular dependencies are required to use the package

More info:

From Binary Dependencies in Debian Packages

Pre-Depends

This field is like Depends, except that it also forces dpkg to 
complete installation of the packages named before even starting the
installation of the package which declares the pre-dependency

This workaround discusses 1 approach by modifying Pre-Depends of a deb package:

  1. Unpack deb: ar x some-package-ver.deb (will create files, e.g.: debian-binary control.tar.gz data.tar.gz). You can grab the archive with apt-get download some-package
  2. Unpack control archive: FILES=$(tar xzvf control.tar.gz | egrep -v '^./$) (will create: postinst postrm preinst prerm control etc, but exclude ./ that may be listed in some archives)
  3. Fix dependencies in control (e.g. delete Pre-Depends line - sed -r -i '/^Pre-Depends:.+/d control)
  4. Repack control.tar.gz: tar zcf control.tar.gz $FILES
  5. Repack deb: ar rcs newpackage.deb debian-binary control.tar.gz data.tar.gz
  6. Install without Pre-Depends: dpkg -i newpackage.deb.
  7. If there are regular dependencies that you want to resolve from the package, you can resolve and install these after this using apt-get: apt-get install -f if you provided options to skip these.

I found that moving the Java dependency from Pre-Depends to Depends allowed me to install the package with ignore-depends using dpkg, but if I ran an apt-get install after that, the dependencies would still be resolved and installed at a later stage.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .