Saturday, March 05, 2016

Lying to Get the Job Done: Adventures in setarch and export

It says something about the power and flexibility Linux when you are provided a means to lie in order to get an application to execute. And by this, I mean using the setarch command and a few other tricks to fool an application created for an older system so it will run on more modern system architectures.

I'm occupying myself trying to install some old games and so far, it has been challenging. In the heady turn-of-the-Millineum days, Linux installers were all the rage, promoted by Loki, a company the developed the installers and produced Linux versions of then-popular games, but wound up in Chapter 7 bankruptcy. Even in the throes of  their demise they didn't forget the Linux gaming community and made their installers and the GPL source code available for the world to use. That would be great had not fewer and fewer servers carried the actual (now-old) files -- most of the links are dead -- and had not the development of Linux progressed so much. Many of their *.run installation scripts can be downloaded from the author, Icculus.

For example, Unreal Tournament 2003 was shipped with a Linux installer on disc 3, but it won't execute on a modern Linux. The installer itself is created with makeself which is still available, but
"Archives created with Makeself prior to v2.1.2 were using an old syntax for the head and tail Unix commands that is being progressively obsoleted in their GNU forms. Therefore you may have problems uncompressing some of these archives. A workaround for this is to set the environment variable $_POSIX2_VERSION to enable the old syntax, i.e. : export _POSIX2_VERSION=199209 ."
 It is possible to launch the *.run file with useful arguments.
--help  displays the full list of arguments

--list lists the contents of the archive
--target extracts the contents of the                 archive to but does not install             anything
It's also possible to extract the archive, add files to it like special config files, updated binaries, add-ons and game data files, and recreate the *.run archive for your personal use.
So using that trick works and I can now list the contents of the .run file without a checksum error, but it won't install anything because of a glibc mismatch. 

That, however, can be fixed by invoking:

 $ export SETUP_LIBC=glibc-2.1

We're still not out of the woods because the installer checks the environment and, of course, balks at our powerful, modern 64-bit, kernel 4.x, multi-gigabyte RAM, multi-processor miracles of the modern age.

The fix for that is the setarch application. It deceives the application by feeding it bogus uname information. Not that it does not provide an actual environment, it just feeds information you can choose to the application so that it believes it is running in the appropriate environment.

If the application needs specific version of older libraries, you are still required to actually supply those. 

setarch deceives  about linux32, linux64, i386, i486, i586, i686, athlon and x86_64 , can tell the app that we're running kernel 2.6, can deceive about the amount of available RAM available and other devious things.

Finally, I was able to use the old, creaky installer on the CD by invoking

$ export _POSIX2_VERSION=199209 && export SETUP_LIBC=glibc-2.1. && linux32 ./

I expect to have use more deception to get the binaries to run. For example. to run Quake with sound, I had to create a wrapper script and execute SDL_AUDIODRIVER=dsp prior to executing the game binary.

If you run into these kinds of problems, now you can lie as well. It's all lies from now on.


DRM-free games. Most run using WINE

Old games packaged for win32, but extractable for the data files; most run using WINE

No comments: