VA-11 HALL-A using NetBSD's Linux emulation

a while ago, I acquired a DRM-free copy of VA-11 HALL-A: Cyberpunk Bartender Action. to quote Wikipedia, VA-11 HALL-A is an indie bartender simulation video game with visual novel elements. it can also serve as a good example of how to use the Linux emulation on NetBSD :)

VA-11 HALL-A running seamlessly on NetBSD

as of NetBSD 9.0, the Linux emulation as provided with NetBSD's packaging system is based on openSUSE 13.1. there are various reasons for going with openSUSE (probably other than historical ones), it's RPM-based and has relatively long support cycles and has a wider selection of packages by default than something like CentOS.

however, you can "emulate" any distribution you prefer by placing libraries and binaries into /emul/linux or /emul/linux32. the NetBSD kernel currently claims to emulate Linux 3.11.6, so beware that newer distributions might have packages that use unsupported features.

getting dependencies

the executable shipping with the DRM-free version of the game is called runner. we can run some commands to get a little bit of information about what it expects from the system:

$ file ./runner
./runner: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=2be998c78cf1f2c65279abccb8e71ffd7a1c00a1, stripped
$ readelf -d ./runner

Dynamic section at offset 0x3a2e94 contains 40 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so.6]
 0x00000001 (NEEDED)                     Shared library: [libz.so.1]
 0x00000001 (NEEDED)                     Shared library: [libXxf86vm.so.1]
 0x00000001 (NEEDED)                     Shared library: [libGL.so.1]
 0x00000001 (NEEDED)                     Shared library: [libopenal.so.1]
 0x00000001 (NEEDED)                     Shared library: [libm.so.6]
 0x00000001 (NEEDED)                     Shared library: [librt.so.1]
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [libdl.so.2]
 0x00000001 (NEEDED)                     Shared library: [libcrypto.so.1.0.0]
 0x00000001 (NEEDED)                     Shared library: [libXext.so.6]
 0x00000001 (NEEDED)                     Shared library: [libX11.so.6]
 0x00000001 (NEEDED)                     Shared library: [libXrandr.so.2]
 0x00000001 (NEEDED)                     Shared library: [libGLU.so.1]
 0x00000001 (NEEDED)                     Shared library: [libssl.so.1.0.0]
 0x00000001 (NEEDED)                     Shared library: [libgcc_s.so.1]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]

we know it's a 32-bit executable (so we need the 32-bit SUSE packages)

we know what system libraries it requires.

now to install the right packages.

so now,

$ pkgin install suse32_base-13.1 suse32_glx-13.1 suse32_x11-13.1 suse32_openal-13.1 suse32_openssl-13.1

enabling and using Linux emulation

depending on the NetBSD kernel version, Linux emulation may not be enabled by default (for security reasons).

you can enable it as follows:

# modload compat_linux32
# sysctl -w emul.linux32.enabled=1

you can make this persist between reboots by adding compat_linux32 to /etc/modules.conf and emul.linux32.enabled=1 to /etc/sysctl.conf. if your system has kern.securelevel=1, kernel modules cannot be loaded after booting is complete, so you will need to do this anyway.

to actually run the program is pretty simple, since the kernel knows how to do the right thing:

$ ./runner

missing libraries?

if your binary requires some Linux libraries that aren't in pkgsrc yet, it's possible to add them by hand.

I had to do this for OpenAL before, but recently made a package for it.

$ ftp https://ftp5.gwdg.de/pub/opensuse/discontinued/distribution/13.1/repo/oss/suse/i586/libopenal1-1.15.1-2.1.2.i586.rpm
Trying [2001:638:60f:110::1:2]:443 ...
ftp: Can't connect to `2001:638:60f:110::1:2:443': No route to host
Trying 134.76.12.6:443 ...
Requesting https://ftp5.gwdg.de/pub/opensuse/discontinued/distribution/13.1/repo/oss/suse/i586/libopenal1-1.15.1-2.1.2.i586.rpm
100% |****************************************************************************|   159 KiB  588.43 KiB/s    00:00 ETA
162952 bytes retrieved in 00:00 (588.19 KiB/s)
$ tar xvf libopenal1-1.15.1-2.1.2.i586.rpm
x ./usr/lib/libopenal.so.1
x ./usr/lib/libopenal.so.1.15.1
$ cp ./usr/lib/libopenal.so.1* /emul/linux32/usr/lib/

unexpected problems

OpenGL wasn't loading properly. After some debugging it was clearly because suse32_expat-13.1 wasn't installed.

I added suse32_expat-13.1 as a dependency of suse32_glx-13.1.

can you do this in a sandbox?

most likely yes!