Yepoleb

How the GOG Linux Installers Work

GOG uses installers generated by mojosetup-package, which are popular for distributing DRM free proprietary games on Linux. They come as a shell script with a huge chunk of binary data appended. The basic structure is script, installer and game data at the end. These are the steps that happen before the setup window pops up:

  1. Shell runs the Makeself code at the start of the package
  2. Makeself sets $MAKESELF_SHAR to the package location.
  3. Makeself reads a hardcoded number of lines and counts the bytes to determine its own size and therefore the installer archive offset.
  4. Makeself unpacks the installer archive to a temporary location using dd, gzip and tar.
  5. Makeself runs the installer start script, which assigns $MAKESELF_SHAR to $MOJOSETUP_BASE and runs the MojoSetup binary.
  6. MojoSetup opens the package by searching for known magic numbers in the file. This is a different archive in zip format added after the one for the installer.
  7. MojoSetup does the installation by copying the files from /data and running the scripts in /scripts.

You can find a script to extract each part at https://github.com/Yepoleb/gogextract