views:

34

answers:

2

Let's say I am writing installation script for the program which contains executable file and shared library. By default, this script places executable to /usr/local/bin, and shared library to /usr/local/lib. In this case my program may be executed by any user by typing its name in the command line.

Suppose that user selects custom installation directory, like ~/myprogram/. Is it user's responsibility to ensure that my program may be executed, or my installation script must do this?

+1  A: 

It is going to depend on whether your installer is run by root.

If the software is installed in /opt/myprogram, then everyone might use it and it would be semi-appropriate to fix /etc/ld.so.conf (or its equivalent) so anyone can use it.

Under an individual's home directory, or when the installer is not run by root, the best you can do is say "Add ~/myprogram/lib to LD_LIBRARY_PATH".

If there's an environment variable you can use to identify the install location, then you could install a script that ensures LD_LIBRARY_PATH is set in ~/myprogram/bin, which then runs the executable with the environment set. The might be in ~/myprogram/libexec, if I remember the FHS correctly1.


1 The libexec directory does not appear to be mentioned in the FHS. It is commonly used in the autoconf and related GNU installation systems.

Jonathan Leffler
Thank you. Actually, I want to know, whether my installation script should do this, or user. For now, I don't ask how can I ensure that the program can be executed from any directory.
Alex Farber
Your installer can note where it is asked to put the software. If you're using RPM, there are post-install scripts. If you use the script+libexec mechanism, then your install is the same regardless - you edit the script during the install with the actual install directory, set LD_LIBRARY_PATH, and go.
Jonathan Leffler
@Alex Farber: the direct answer to your question is "yes, if at all possible, the software installer should ensure that the software is usable when the install is complete". Think about other packages you install - what do you have to do to get it to work? You shouldn't have to do more with your software.
Jonathan Leffler
Maybe there is some problem with my English... Again, I don't ask HOW to do this. My question is: if user selects custom installation directory, is it MY responsibility to set running environment, or it is USER's responsibility. What are common guidelines for such situation?
Alex Farber
@Alex: sorry - I didn't see a problem with your English. The installer software should set the system up so the software is usable immediately if at all possible. If the installer software cannot do it for some reason, then it becomes the user's responsibility. But that is not desirable.
Jonathan Leffler
Thank you, it is clear now.
Alex Farber
+2  A: 

Normally the "make install" or installation script uses the install command to copy the file and set permissions (including the execute bits).

The install process should either append any new (i.e. if it doesn't already exist) directories to use for shared libraries, or tell the user what needs to be added. Such as the case if the program is install in a directory not already listed in /etc/ld.so.conf or in a conf file in directory /etc/ld.so.conf.d/.

For reference the two major packaging guidelines that you can refer to are the Linux Standard Base, and the Debian Policy Manual.

I hope that answers your question.

mctylr