0

In short, is it possible to define Debian package dependencies directly from the backports repository?

I am trying to craft a custom Debian package which builds itself when installing the package. Building said package however requires the latest linux-headers package which is only available from the backports repository (along with the linux-compiler). This is because the kernel is also installed from backports.

I tried including a custom APT preferences file in the package, but that did not help. Which kind of makes sense in that apt will not re-read config files in the middle of an on-going install. Contents of the preferences file is as follows, and does provide the correct versions when installed manually.

Package: linux-headers-amd64 linux-compiler-gcc-6-x86
Pin: release n=stretch-backports
Pin-Priority: 1000

So is there any way I could make this whole thing work simply by saying apt install my-custom-package?

  • Yes to the first question, the user just has to enable them. But I guess the question you're probably intending to ask is "can I depend on versions in backports without having it enabled beforehand" – muru Jun 24 at 14:08
  • How is the kernel installed? You’re going to run into the general issue in Debian that kernel dependencies (including headers) are hard to define because Debian supports kernels which aren’t packaged. – Stephen Kitt Jun 24 at 14:08
2

You can’t specify repositories from which packages are to be installed, as package dependencies in a package itself. The only thing you can do is specify a minimal version:

Depends: linux-headers-amd64 (>= 4.19)

You can ship an apt configuration file in your package, but as you say it won’t be taken into account during the installation. A package installation also can’t request that other packages be installed, except using dependencies, so you can’t set a new repository up then run apt-get install from your postinst.

Perhaps your best approach could be to provide a package which configures the backports repository (if necessary, and without adding pin priorities — pinning in the way you’ve done in your question will end up breaking users’ setups), and tell users to install that then install your real package (they will have to specify -t stretch-backports anyway). Or you could use dkms.

As a side-note, you shouldn’t depend on the kernel compiler packages; specific header packages have the appropriate dependency, so if necessary the compiler package will be pulled in transitively.

  • This is pretty much what I expected. Fortunately I need not worry about breaking users' setups as this is an internal-only repository for custom packages to be installed on targets we manage ourselves. The kernel is installed in a preseed late_command from backports. I did not add the compiler as a dependency, but without pinning it would not install the correct version. – Teemu Karimerto Jun 24 at 14:28
  • So you never run apt-get upgrade? – Stephen Kitt Jun 24 at 14:29
  • Seems the best way to go about this installation is to just add a couple more steps in the install instructions and be done with it. Oh, and no, upgrade for generic software is not done, only our custom software is upgraded if necessary. – Teemu Karimerto Jun 24 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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