3

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.

3

I believe both Ubuntu and RHEL use an /etc/profile.d/ structure, and I would recommend that you package a file in that directory, perhaps named for your application; e.g. /etc/profile.d/legacyapp.sh (and /etc/profile.d/legacyapp.csh if you need to support the CSH family).

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.