4

My server runs a Java application that requires I replace a few java library files with ones I downloaded on my own. This has to do with JCE security extensions and isn't really relevant to my question.

I've found that these library files tend to get overwritten by apt when it later updates my java package.

Is there an apt-friendly way of masking these specific files so apt won't touch them?

Potential Solutions

  1. I'm considering just removing the write flag from the files, though I'm expecting this will cause apt to spew its guts everywhere when it later tries to overwrite them?

  2. Perhaps there's a java custom library directory I don't know of, where I can park my files and they'll be loaded instead of the package's defaults?

  3. The last-resort option I'm considering is writing a cron job to periodically replace the files with my versions. I hate this option.

muru
  • 197,895
  • 55
  • 485
  • 740
  • 1
    While merely a little bit better than a cron job, a dpkg trigger could help you. The trigger can check the files and replace them according to your needs. Or preferably you could look into supplying your own java package where the files are replaced already. – TeTeT Aug 23 '14 at 12:42
  • Thanks Tetet, I'm currently exploring the viability of calling java with a flag to append a custom path to the Java library path. – James T Snell Aug 25 '14 at 22:25

2 Answers2

4

There is an elegant way, with dpkg-divert command (Override a package's version of a file, see this answer).

dpkg-divert --divert /full_path/file_to_preserve.packaged --rename /full_path/file_to_preserve

Please consider that putting together different versions of files of a given package it might be risky...

Pablo Bianchi
  • 15,657
0

Thanks to Pablo Bianchi, I solved my problem with overwriting the ath10k QCA6174 firmware by the linux-firmware package (new firmware does not support hibernation). However the suggested command did not work cause sudo apt upgrade throws an error: dpkg-divert: error: rename involves overwriting '...' with different file '...', not allowed and exits. But after I modified this command everything works fine:

dpkg-divert --no-rename --add /lib/firmware/ath10k/QCA6174/hw2.1/board.bin
dpkg-divert --no-rename --add /lib/firmware/ath10k/QCA6174/hw2.1/firmware-5.bin

Now linux-firmware is updated normally, and new firmware files are written to the same directory but with a .distrib suffix, e.g. firmware-5.bin.distrib.

almaceleste
  • 398
  • 4
  • 13