I am not a huge gamer, and in fact, besides playing old 16 bits game of my childhood, I do not play video games that often. But I was convinced to give a try to modern games a few months ago, and I settled on gog.com for buying them.
In June, I got Uplink for 1€. It was kinda a impulsive acquisition as I wasn’t planning to use it right away, but it was a good test for a flatpak package, and this post is the story of my Sunday evening dedicated to make this run on Silverblue 28. For people who want directly the happy end, as of 1h on Monday Paris time, it work. I started a few hours ago, around 21h.
What motivated me was a exchange with @sanja about http://www.nottonightgame.com/ then http://needtoknowgame.com/ , and then she pointed me to Orwell. Then I told that we can actually convert the game to flatpaks using either https://github.com/kujeger/flatpak-gog/ or https://github.com/hadess/flatpak-games . But truth is that I didn’t tried any of them, so I decided to just do that.
First step is downloading. This one requires a specific client on Linux, and the code is on https://github.com/Sude-/lgogdownloader . I wrote a quick and dirty Dockerfile to compile the version from git and run it. I was happily surprised to see that neither buildah nor podman requires root now and this was a really good news.
In retrospect, running the downloader from podman wasn’t a smart idea. The software first ask for my password, and then store a cookie in /root/.config. But I didn’t bind-mount a directory here, so it was asking my password each time. Then I got blacklisted after 5 times (using a captcha that the client didn’t understood). Switching to another connection, it triggered the 2 FA auth, who requires me to wait for a email to get the 2nd token (and greylisting delay mail sometime, making it a bit challenging). And then, because I was running podman without --rm, it did fill my home directory quite fast, because the container was using 820 M at each run, even when I was kicked out and nothing changed.
Anyway, I did manage with the right command:
podman run --rm -v $PWD/config:/root/.config -v $PWD/games:/tmp/games -ti localhost/gog_downloader /srv/lgogdownloader/lgogdownloader --directory /tmp/games --download --platform lin
and the right container:
FROM fedora:28 MAINTAINER misc RUN dnf install -y git cmake make gcc libcurl-devel gcc-c++ boost-devel openssl-devel liboauth-devel jsoncpp-devel tinyxml2-devel htmlcxx-devel rhash-devel ; dnf clean all RUN cd /srv/ && git clone https://github.com/Sude-/lgogdownloader.git && cd /srv/lgogdownloader && cmake . && make CMD /srv/lgogdownloader/lgogdownloader
Downloading was uneventful from then, and so the 2nd part begun.
I know how to make my own flatpak, but I was trying to use tools for that. Cause packages are like food, I tend to prefer when it is done by someone else.
Between the 2 tools I found, I decided to use flatpak-gog because it is in python. While I guess flatpak-games would also work, it requires a heavily patched version of a lua library, and I have no clue how to integrate that. It was too late to ask to the developer who is a friend of mine, and I wouldn’t be able to fix anything without learning lua if any bugs would arise (spoiler, it did happen)
I first tried to do that in a container, but I went to the git clone and local execution road first, because all the bind mounting is annoying. I did locally patch to have it run from anywhere, and generated a gen_com.gog.UplinkHackerElite.json file without any issue.
And then came the 3rd part. The final boss. Using flatpak-builder.
I know that flatpak-builder can now be run as a flatpak, but I was under the impression that using it with podman would have been simpler. I was kinda wrong.
I started with a simple container with a dnf install flatpak-builder. Then I tried to run it like lgogdownloader in podman, and found that it was more complicated. So I just went in the container with bash, and started to work inside:
podman run --rm -v $PWD:/srv -ti localhost/flatpak-builder bash
So first problem, I needed to install flathub, the SDK, the platform. I cut and paste commands and I ran flatpak-builder. It failed, asking for com.gog.Base, that I would need to build from flatpak-gog.
I pass the first hurdle and message about fuse not loading with --disable-rofiles-fuse but even after adding all missing files, the gog base image refuse to build (I do not remember why). Taking a look at the build, I see nothing special, and so I decide to bypass it as a test.
Then I face a issue with flatpak-builder saying “I can’t create a namespace for bwrap”, or something like this. I exit the container, figure that I need to run with --privileged and so restart. Bad luck, I have to readd flathub, install SDK, etc, because this time, I used --rm.
Then it start the build. And it fail with a error from the installer on desktop file installation. Trying outside of the flatpak builder process, it ran fine. It took me a while to figure what was wrong, partially because the installer is a shell script that uncompress a bundled gzip that do run a C software (mojosetup) that is mostly a lua interpreter along a glue for portability. Of course, using my legendary subtility, I start to take apart the binary before searching for the source code that could be found on github ( https://github.com/darealshinji/MojoSetup ). From here, I decided to use strace (again, rather than learning lua ), who did dropped me 122 log files to look at with the promise of a clue somewhere. The said clue was hidden being a truncated message (so restarted strace with a option to increase the limit), and the truncated message lead me to add 1 path on the generated json file, and finally generate the flatpak for Uplink.
Then the rest was almost too simple, cause the last issue I had was with gpg. If you add a remote without a GPG signature, it will show a error message asking to add:
But even with that config, the real way to do it is to use --no-gpg-verify. I wonder if the best solution would be to ignore gpg error for local filesystem, or make flatpak-builder generate a gpg key automatically and sign packages this way.
But now, I can see Uplink in Gnome shell, and a quick test show that the game start and play music.
Not wanting to jinx it, I didn’t played the game yet. I hope the game do save data in ~/.config, but we will see.
podman will fill your /home. There is likely no good solution, but a pattern we adopt must take that somehow in account this problem. I had plenty of space on /home (like 20G), but there is no good UX to clean all the crap I created by error (besides some scripting).
automated tool to generate flatpak are working, but not mature yet. Flatpak-gog didn’t work with the game I had and was a bit annoying, flatpak-games seems hard to install. Ideally, I would love either having flatpaks from gog.com, or have gnome-game (or gnome-software) integrate some download/conversion feature. I will submit a patch to flatpak-gog and try again with another game another day.
building things still requires strace and/or debugging tools. Bypassing the sandbox is still a required skill for a system integrator.