2

I want to create postinst script for my application debian package and I need to modify /etc/environment file (add some path to it) to make my application bin directory content accessible globally in system.

With my current knowledge all I can do now is:

Is there easier way to add some path to environment variables permanently and globally?

Background:

I'm working on few packages to automate installation/deployment process, I have few things like Java, bash scripts, drivers and some c/c++ tool applications to deploy on many devices.

4

The path isn’t necessarily defined in /etc/environment, and even if it is, there is no guarantee that path will end up being the path that’s used by end users.

In a Debian package, to make commands available generally, you should install them to a directory which is expected to be on the path, typically /usr/bin. If you can’t move your binaries there, it’s fine to add wrapper scripts in /usr/bin which know where to find the “real” commands.

For Java, you shouldn’t try to re-package things yourself; use java-package to package Oracle JDKs and JREs, or the OpenJDK packages already available in Debian. See Installing JDK in a FHS-compliant way and Ways to configure alternative installations of Oracle JDK on Ubuntu? for details.

  • Thanks. That explains a lot. But what if I want to also add something like java bin directory to the path? Will it work normally? I'm worried that some executable may use some relative path to some file in application directory. – Kamil Aug 30 '18 at 21:36
  • See my update re Java. If you use wrapper scripts, the final execution path will be correct so binaries which use relative paths to find other files should work fine. – Stephen Kitt Aug 31 '18 at 9:07

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.