Is it possible to create a self-contained DOSBox installation in Linux? By self-contained I mean a directory where all DOSBox files are stored and can be moved to a different drive or stored in a flash drive and transferred to a different computer (with Linux installed) and still work. I know that I can do this in Windows, which makes it portable, but I haven't found a way to do it in Linux. The DOSBox configuration file along with other DOSBox related files and subdirectories are in the var directory of my home partition in Linux.
It's certainly possible. GOG.com does it for their Linux releases of DOS games. I'd suggest taking a look at their Linux release of
Jill of the Jungle: The Complete Trilogy (because it's a free offering).
You can unpack the installer without running it using
unzip
.
There are basically two halves to it:
First, you need to make the data paths relative to your DOSBox bundle and, second, you need to decide whether you're going to rely on an OS-provided DOSBox install and, if not, bundle the libraries for that.
If you want to make a portable build of DOSBox itself, rather than relying on having DOSBox already installed on the system, then you need to start on the oldest Linux you want to support (because of how glibc versioning works), then use
ldd
to identify which dynamic libraries DOSBox depends on, copy the ones you want to bundle (because some should match the host OS, not the application, for proper reliability), and then write a launcher shell script to set
LD_LIBRARY_PATH
to point to them.
The resulting launcher script will look something like this:
Bash:
#!/bin/sh
# Make relative paths relative to the launcher script
cd -- "$(dirname -- "$(readlink -f -- "$0")")"
export LD_LIBRARY_PATH="$PWD/libs"
./dosbox -conf $PWD/dosbox.conf -noautoexec -c "mount c $PWD/drive_c" -c "c:" go.bat -exit
foo
(The
-noautoexec
is to ensure we can run our
$PWD
-relative
mount
command before we do anything else.)