Question

Given some unix program which I've compiled, what might I need to do to relocate it to a different directory and have it continue running correctly.

I'm thinking of Perl, but would be interested in other systems like Apache which also seem to fail when this is done. To motivate the question, being able to perform this sort of relocation would be very useful when bundling other systems as part of a product install.

For what it's worth, ActivePerl's install process seems to contain some magic which performs the relocation during the install..

Installing ActivePerl...
Copying files to /opt/ActivePerl-5.8...done
Relocating...done (164 files relocated)
Generating HTML documentation...done
Syncing perl PPM database with .packlists...done 

ActivePerl has been successfully installed at /opt/ActivePerl-5.8.

Can anyone enlighten me as to what's happening behind that 'Relocating...' line?

Was it helpful?

Solution

When you compile perl, it expects certain files at certain locations. You can see some of those paths with perl -V. For ActivePerl, when you want to move the entire installation, you have to update where perl expects to find things and where its various helper programs expect to find perl. See the documentation for ActiveState's reloc_perl, and maybe look at the source if you have it.

What ActivePerl does has no general bearing on what you would do with other programs. It depends on what they each do and expect.

OTHER TIPS

A lot of it depends on the program. Some programs are fairly self-contained and thus handle moves more gracefully than other programs which have directory paths in externally-located configuration files or other less-forgiving elements.

Active Perl doesn't compile perl on your system, it just unpacks and copies it to the right location.

The problem is that a Perl install has many files that need to have installation specific information, such as where to find libraries, where the install is located, and so on. These files are modified to have the correct information during the relocation phase.

It depends of what do you mean under "relocate". You can run the binary and then move it to another directory, it should work under Linux.

So, you can write a program which will move all your binaries and configuration files into another directory and then just change current working directory.

Using UltraEdit to search and replace all files under the Perl installation: for example, when move from C:\Perl64 to G:\Perl64, replace all files that contain "C:\Perl64" to "G:\Perl64". In the process, we need to uncheck several config files and exe file's read-only property and redo the replace.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top