When reading answers to this post, I wonder if we can make the programs we often used on our computers portable (in the Windows sense), so that we can make a copy of them on our flash drive, so that we don't have to worry if we don't have access to the programs we like on other computers?
Is it possible to make such portable installations?
Best Answer
Yes, you can do that. It's more work than relying on a package manager — the main attraction of “portable” installations under Windows is not to have to fight the lack of a decent package manager.
You'll need to arrange for the programs to find their dependencies: data files, libraries, etc. Many programs support environment variables for that. Some check the directory where the binary is located, or relative directories like
../lib
, for companion filesInstall the software under some root directory. Create the usual category directories under that root:
bin
,lib
,man
, etc. To manage all the software, install each one independently and then use a program like Stow create a forest of symbolic links to link them to the category directories. See Keeping track of programs for an introduction to Stow. You'll thus have symbolic links likeYou'll want a script to set up environment variables. Put it at the root of your installation and use
$0
to locate the script. Since a script can't influence its parent, the usual approach is to make the script produce output that can be evaluated by the calling shell. Let's call this scriptsetup.sh
.(Warning: untested code)
To use the portable installation from a shell, run
eval "`/path/to/setup.sh`"
.