Hello everyone!
I'm hoping someone here can help me when it comes to understanding what shell files do, or rather, what they are capable of doing. I have some software I'd eventually like to get running on my computer, and I think shell files might just be the way to do it (at least in the time being - long term of course would be better with something more permanent).
For the example here, I will use Mount & Blade Warband from GOG.com...
Mount & Blade Warband (M&B for short) is an interesting package to download and install from GOG. Aside from the general troubleshooting one might do with ldd, it installs much in the same manner as any other GOG game - you download the installer (itself an .sh or shell file), type in sh, and basically drag the file into the terminal to copy and paste the file name along with its current path. Punch enter and the installation dialogue starts up, and you're ready to install the application into your user folder. You can choose an alternate directory, of course, though opting to do so may result in some complications. For instance, creating an opt directory and expecting to install there will generally only result in frustration. The default, in this case, is certainly the way to go...
Here is why M&B is interesting: not all the packages needed to run the application are present on the current Solus repository. However, if you begin the process of running the game through start.sh, it works just fine.
...I want to know why and how this works!
Let's start by looking at the application with ldd:
user@user ~/GOG Games/Mount Blade Warband/game $ ldd ./mb_warband_linux
./mb_warband_linux: /usr/lib/libcurl-gnutls.so.4: no version information available (required by ./mb_warband_linux)
linux-vdso.so.1 (0x00007ffe413fb000)
libGL.so.1 => /usr/lib/libGL.so.1 (0x00007f2a932c7000)
libGLEW.so.2.1 => /usr/lib/libGLEW.so.2.1 (0x00007f2a93228000)
libSDL2-2.0.so.0 => /usr/lib/libSDL2-2.0.so.0 (0x00007f2a9305a000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f2a93038000)
libcurl-gnutls.so.4 => /usr/lib/libcurl-gnutls.so.4 (0x00007f2a92fb5000)
libfmodex64.so => not found
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f2a92db1000)
libm.so.6 => /usr/lib/haswell/libm.so.6 (0x00007f2a92c6f000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f2a92c54000)
libc.so.6 => /usr/lib/haswell/libc.so.6 (0x00007f2a92a63000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f2a93365000)
libGLX.so.0 => /usr/lib/libGLX.so.0 (0x00007f2a92a2e000)
libGLdispatch.so.0 => /usr/lib/libGLdispatch.so.0 (0x00007f2a92972000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f2a9296b000)
libnettle.so.8 => /usr/lib/libnettle.so.8 (0x00007f2a92924000)
libgnutls.so.30 => /usr/lib/libgnutls.so.30 (0x00007f2a9272a000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007f2a92711000)
libX11.so.6 => /usr/lib/libX11.so.6 (0x00007f2a925b5000)
libp11-kit.so.0 => /usr/lib/libp11-kit.so.0 (0x00007f2a92481000)
libunistring.so.2 => /usr/lib/libunistring.so.2 (0x00007f2a922ff000)
libtasn1.so.6 => /usr/lib/libtasn1.so.6 (0x00007f2a922ea000)
libhogweed.so.6 => /usr/lib/libhogweed.so.6 (0x00007f2a922a2000)
libgmp.so.10 => /usr/lib/libgmp.so.10 (0x00007f2a92226000)
libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007f2a921f6000)
libffi.so.6 => /usr/lib/libffi.so.6 (0x00007f2a921eb000)
libXau.so.6 => /usr/lib/libXau.so.6 (0x00007f2a921e6000)
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007f2a921dd000)
First, the apparent error on the second line above does not seem to have a bearing on the program working. Something appears to not be quite ideal, but it's not a deal breaker, if you will.
...The elephant in the room is on a lower line: libfmodex64.so => not found. This package is of course FMOD, which is a package that is unlikely to make it into the repository. But, this library actually is contained in the M&B folder. It's located in the "game" folder within the principal M&B directory (it's the same path as shown for the terminal commands and output above). The game actually comes with a few other libraries as well. In total, these exist in the game folder:
libfmodex64.so
libGLEW.so.2.1
libSDL2-2.0.so.0
...The bottom two libraries are in the Solus repository. I'm not sure if having them in the game folder might be causing a conflict, and to be honest, I've not tried removing them to find out. But, what I do know is this:
Trying to launch the game directly through the application (mb_warband_linux) will result in an error and the game will not run. Launching the game through the shell file (start.sh in the main game directory) will get the program going, however.
So, here's the contents of the start.sh file:
#!/bin/bash
# GOG.com (www.gog.com)
# Mount And Blade - Warband
# Initialization
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "${CURRENT_DIR}"
source support/gog_com.shlib
# Game info
GAME_NAME="$(get_gameinfo 1)"
VERSION="$(get_gameinfo 2)"
VERSION_DEV="$(get_gameinfo 3)"
# Actions
run_game() {
echo "Running ${GAME_NAME}"
cd game
chmod +x mb_warband*
./"mb_warband.sh"
}
run_config() {
echo "Running ${GAME_NAME} config"
cd game
chmod +x mbw_config*
./"mbw_config.sh"
}
default() {
run_game
}
# Options
define_option "-s" "--start" "start ${GAME_NAME}" "run_game" "$@"
define_option "-g" "--config" "start ${GAME_NAME} config" "run_config" "$@"
# Defaults
standard_options "$@"
...This shell file then calls up two other shell files, which are mb_warband.sh and mbw_config.sh. Their contents are as follows:
First, mb_warband.sh:
#!/bin/sh
PROGRAM_DIRECTORY="`dirname "$0"`"
export LD_LIBRARY_PATH="$PROGRAM_DIRECTORY"
"$PROGRAM_DIRECTORY/mb_warband_linux" "$@"
Now, mbw_config.sh:
#!/bin/sh
PROGRAM_DIRECTORY="`dirname "$0"`"
export LD_LIBRARY_PATH="$PROGRAM_DIRECTORY"
"$PROGRAM_DIRECTORY/mbw_config_linux" "$@"
I kind of see what's going on here, but not quite. I'd really appreciate if someone could get me started on this, because if I can start to understand how this stuff works, I just might be able to finally get some of my old projects started back up. Ideally, everything needed to run the applications would be part of the Solus repository, but that just isn't the case for several retail packages, or otherwise obscure packages.
Looking forward to your insights, and many thanks!