Sunday, December 2, 2018

Using the installers for Linux, on NetBSD prefers that you use their GOG Galaxy desktop app to download, install and manage all of your GOG games. But customers always have the option to install the game on their own terms, with a platform-specific installer.

GOG offers these installers for Mac, Windows and/or Linux, depending on which platforms the game is available for. The installers truly are platform-specific:

  • macOS games are distributed in a standard .pkg
  • Windows games are distributed in a setup wizard .exe
  • Linux games are distributed in a goofy shell archive

Of course, none of those are NetBSD. So, if I wanted to even attempt to play a game distributed by on NetBSD, which one should I pick? The obvious choice is the Linux installer, since Linux is the most similar to NetBSD, right? Au contraire! In practice, I found that it is easier to download the Windows installer.

Here’s what I mean. For example, I ported the open source version of Aquaria to pkgsrc, but that package is only the game’s engine, not the multimedia data. The multimedia data is still copyrighted. Therefore, you need to get it from somewhere else. GOG is usually a good choice, because they distribute their games without DRM. And as mentioned earlier, picking the Linux installer seemed like a natural choice.

But I quickly discovered that the Linux installer, that goofy shell archive, is not portable.

charlotte@sakuracity:~/games$ sh ./
Verifying archive integrity... All good.
Uncompressing Pyre (     0% gzip: unknown compression format
Extraction failed.
 100%  Signal caught, cleaning up

Ah, maybe you just need a different shell…

charlotte@sakuracity:~/games$ bash ./ 
Verifying archive integrity... All good.
Uncompressing Pyre (     0% gzip: unknown compression format
Extraction failed.
 100%  Signal caught, cleaning up

Lol no? OK fine whatever.

That’s when I discovered that GOG’s Windows installers are actually easier to deal with on NetBSD, with the help of the archivers/innoextract package. It really does Just Work. So, I’ve been using innoextract on GOG’s .exe files almost exclusively in order to obtain multimedia data for all sorts of games that have open source reimplementations of their game engines: Jazz Jackrabbit, Jade Empire, Grim Fandango, and more.

That was my only way forward, until I remembered that NetBSD has a Linux compatibility layer!

You just have to install one of the Linux compat packages. I’m on a 64-bit machine and I want the newest stuff, so I installed the emulators/suse_base package from pkgsrc.

When that package is done installing, it writes you a big fat note:

$NetBSD: MESSAGE.NetBSD,v 1.1 2013/12/05 11:42:14 obache Exp $

Do not forget to include COMPAT_LINUX in your kernel configuration file.
Linux binaries require this option in order to work.

Most Linux binaries also require procfs to be mounted with -o linux.
This can be automated by adding the following to your /etc/fstab:

procfs /emul/linux/proc procfs ro,linux

Some Linux binaries also require tmpfs to be mounted on /dev/shm.
This can be automated by adding the following to your /etc/fstab:

tmpfs /emul/linux/dev/shm tmpfs rw,-m1777


I’m not positive if those extra entries in fstab(5) are 100% necessary for the task at hand (run’s game installers for Linux), but it certainly doesn’t hurt. I have them enabled.

Alright, it’s go time!

charlotte@sakuracity:~/games$ bash 
Verifying archive integrity... All good.
Uncompressing Pyre (     0% gzip: unknown compression format
Extraction failed.
 100%  Signal caught, cleaning up

Oh, right, derp, I should put the Linux binaries in the front of my PATH.

charlotte@sakuracity:~/games$ LINUX=/usr/pkg/emul/linux

charlotte@sakuracity:~/games$ PATH=${LINUX}/bin:${LINUX}/sbin:${LINUX}/usr/bin:${LINUX}/usr/sbin:${PATH}
bash ./ 
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Verifying archive integrity... All good.
Uncompressing Pyre (  100%  
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Collecting info for this system...
Operating system: linux
CPU Arch: x86_64
trying mojosetup in bin/linux/x86_64
Error opening terminal: screen.
Error: Couldn't run mojosetup

It can’t run “mojosetup” (whatever that is) because it doesn’t like my $TERM? Also, what’s that deal about the locale, doesn’t know what en_US.UTF-8 is?

At this point I decided to use the simplest setup I could envision, and it worked! That means a locale of “C” and a TERM of “vt100”.

charlotte@sakuracity:~/games$ \
  PATH=${LINUX}/bin:${LINUX}/sbin:${LINUX}/usr/bin:${LINUX}/usr/sbin:${PATH} \
  TERM=vt100 \
  LC_ALL=C \
  bash ./ 

It’s this insane little setup wizard which has interesting curses support (??!!)

┌───────────────────────────────── Pyre ─────────────────────────────────┐
│                                                                        │
│ Pyre                                                                   │
│ Welcome to installer!                                          │
│                                                                        │
│ For technical support for this game, please visit our Support page at: │
│                                        │
│                          < Cancel > < Next >                           │

You use the arrow keys to highlight the option you want and hit SPACE and/or ENTER to select it.

┌──────────────────────────────────────────────────────────────── EULA ────────────────────────────────────────────────────────────────┐
│                                                                                                                                      │
│ End-User License Agreement                                                                                                   │
│ ========================================                                                                                             │
│                                                                                                                                      │
│ Your use of this product/service is subject to the GOG User Agreement. Copy and paste this link to your browser to check it out:     │
│                                                                               │
│                                                                                                                                      │
│                                                                                                                                      │
│ MojoSetup License Terms                                                                                                              │
│ ========================================                                                                                             │
│                                                                                                                                      │
│ Copyright (c) 2006-2010 Ryan C. Gordon and others.                                                                                   │
│                                                                                                                                      │
│ This software is provided 'as-is', without any express or implied warranty.                                                          │
│ In no event will the authors be held liable for any damages arising from                                                             │
│ the use of this software.                                                                                                            │
│                                                                                                                                      │
│ Permission is granted to anyone to use this software for any purpose,                                                                │
│ including commercial applications, and to alter it and redistribute it                                                               │
│ freely, subject to the following restrictions:                                                                                       │
│                                                                                                                                      │
│ 1. The origin of this software must not be misrepresented; you must not                                                              │
│ claim that you wrote the original software. If you use this software in a                                                            │
│ product, an acknowledgment in the product documentation would be                                                                     │
│ appreciated but is not required.                                                                                                     │
│                                                                                                                                      │
│ 2. Altered source versions must be plainly marked as such, and must not be                                                           │
│ misrepresented as being the original software.                                                                                       │
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────(  3%)──│
│                                                     < Cancel > < Back > < Next >                                                     │

Wow, incredible. I didn’t know you could do this in a shell archive?

The installer asks you if you’d like to install the game data to somewhere other than the default ~/GOG Games. I just left it at the default.

At a certain point, you’re invited to create a desktop shortcut and a “menu item” (most be some Ubuntu thing) and, well, I don’t know what happens with those options enabled on NetBSD, but I turned them off for safety.

┌──────────────── Options ─────────────────┐
│ [ ] Create a desktop shortcut            │
│ [ ] Create a menu item                   │
│ < Cancel > < Toggle > < Back > < Next >  │

And then the fun part, when the game is actually installed!

┌ Installing ─┐
│ Pyre        │
│     12%     │
│  Music...   │
│             │
│ < Cancel >  │

And sure enough, the game is installed in the place it said it would!

charlotte@sakuracity:~/GOG Games/Pyre$ ls -F
docs/                   gameinfo                support/
game/         *     *

I suspect that the uninstall script there would require Linux compatibility, too.

Now, actually PLAYING the games on NetBSD is a separate matter entirely. The game I’ve got here, though, my current obsession Pyre, is built with MonoGame and therefore could theoretically work on NetBSD, too, with the help of a library called FNA and a script for OpenBSD called fnaify. I do hope to create a pkgsrc package for FNA and port the fnaify script to NetBSD at some point.


So, lol, haha, it turns out that if you install the meta-pkgs/suse131 package, then we get a hold of the Linux version of glib2, which enables the GOG installer to spit out a GRAPHICAL SETUP WIZARD ON NETBSD


  1. Very interesting... But you can just get all the files from the Linux shell archive with 'unzip pyre_*.sh'.

    Be prepared that Pyre uses FMOD IIRC. Maybe you can run Linux FMOD libs with the compat layer, but there's currently no way to run FMOD games on OpenBSD.

    1. Ha you really can just unzip them? That is brilliantly counterintuitive. I'll give it a shot when I'm back at my NetBSD box.

      Yes, Pyre uses FMOD. I'm hopeful it'll Just Work™ with the compat layer.

    2. FYI we discuss more hackporting on FreeNode #openbsd-gaming...

  2. More mostly (OpenBSD-) tested games, including FNA here:

  3. I luuuuuuuuuuuuv innoextract! That is a wonderful tool to keep in your WinNT forensics toolkit! :D

    You can also unpack macOS .pkg archives with xar ( Okay, so I think things might be a bit outdated ( for xar on netbsd, but it probably builds fine, haha. Just another suggestion to accomplish the same thing, lol!!

    Can I just say that I love that you are taking the time to apply some forensics and really pick apart software construction? People do not appreciate enough how much work we put into investigating and porting the things we love! Thank you so much for sharing what you've discovered!

    (I don't know how to embed links on blogger)

  4. lots of good tips there, love it.