Search code examples
debian-packaging

How to source environmental variables of a postinst file of a debian package?


I have created a debian package for apache-maven, so that it can be installed via apt. The problem is while exporting few environmental variables like M2_HOME and PATH etc. I have created a postinst script file and pasted the export commands into it.

After building the .deb file and making it available to my sources.list via a repository url, I am successful able to install the maven via apt. But the environmental variables are not getting exported, and so I am unable to run the mvn command.

I have understood that only variables of a child process can be sourced by a parent process. How can I source the variables of the postinst file to the entire system in the same shell session?


Solution

  • You can drop files in /etc/profile.d which will be sourced when users start a new (Bourne-family) shell from that point on.