I am working on a legacy cross-platform project packaged to both DEB and RPM formats.
Once the Linux package is installed, an environment variable holding the path to the installation folder is required for scripts (e.g. CMake and Bash scripts) and programs execution. This variable has a known name and can point to Program Files\My Package
on Windows and to /opt/my_package
on Unix systems.
Currently, Linux users have to manually register the variable to use the software. A convenient solution would be to register the environment variable as part of the package installation.
I am aware one can set system-wide environment variables in configuration files such as /etc/profile
and /etc/bashrc
. I could modify such a file as part of the postinst
script.
Is it a good practice to create system-wide environment variables during package installation? If so, what is the preferred way to do it?
The Linux packages are distributed to users on Ubuntu 16.04 and RHEL 7.