My adventure of doing a flatpak package of Uplink


#1

Hi,

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:

gpg-verify-summary=false

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.

Conclusion:

  • 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.


OKD on silverblue by default?
#2

Bug report for my issue with the missing directory: https://github.com/kujeger/flatpak-gog/issues/1 with a PR attached.


#3

Good news, the game work (but flicker a bit). Bad news, it is supposed to be run full screen, but the windows bar and the gnome shell bar do push the windows too low, and I wasn’t able to finish the tutorial as part of the UX is hidden off screen.

And if I move the windows up, then the gnome shell bar do hide the rest of the UX on top.

I didn’t found (yet) a way to run a software fullscreen with flatpak, but that seems like a huge issue if we want to use it for games. Searching showed me this is likely related to XWayland, and t seems to be tracked on this bug: https://bugzilla.redhat.com/show_bug.cgi?id=1289714

The problem is also more than the interface, that’s the fact that the interface is too small. One can take a look at the official screenshot to see the problem, such as the one on official website

(from https://www.introversion.co.uk/uplink/screenshots.html )


#4

Thanks for this wealth of information, I’ll try it out myself soon to get those games going. Gonna write here if I encounter anything in addition. :raised_hands:


#5

Until the issue with Uplink is fixed upstream, I can’t play it on Silverblue. So I had to make a choice. Either I skip the game part and hack satellites in real life with my hoodie and sun glasses for fun and profit (https://www.youtube.com/watch?v=ZTwCtQIEswM). Or I get another hacking game, such as the wonderful Hacknet. Luckily for the Internet, I went the 2nd road.

Now I know the process, it went fast except that I stumbled on a bug in flatpak-gog related to the DLC (Labyrinth, who is even more wonderful than the base game) with a easy workaround whose details are left as a exercise to the reader. And yet, when I tried to run it from gnome-shell, it failed. It failed without a error message, so I did had to run it from the terminal to be greeted with:

$ flatpak run com.gog.Hacknet 
Running Hacknet
./Hacknet.bin.x86_64: error while loading shared libraries: libgconf-2.so.4: cannot open shared object file: No such file or directory

No luck for me, that library is deprecated, and as such is not in the base layer. I guess that’s the price to pay for proprietary applications, we can’t rebuild them. And I guess the issue is just going to get more and more complex in the future to solve.

Slightly demoralized by that unexpected hurdle, I decided that maybe, my destiny is not to hack the world, but do something closer to the simplicity of the nature, and so decided to become a farmer. But since I have to go back to work tomorrow, I just downloaded Stardew Valley rather that actually investing into buying a property.

Stardew Valley is a farming simulation published in 2016, and while it may sound doing work (unlike me doing computer things), it is quite relaxing and fun. From what I gathered, the game is written in C# (like Hacknet) and the latest release is from 2 months ago, adding several requested features such as a sombrero for the horse, or multiplayer game. Unlike Hacknet, it did work out of the box on the 3.24 SDK I used as a base.

I didn’t see any sound issue, no graphical issue, the game is running fullscreen right away, I did used the 1.3.28 build. Now I just need to get my farm from my other computer to that one.

So in short:

  • older games may face issues with XWayland.
  • less older games may have issue with libraries requiring more libraries in a base image.
  • modern games are supported fine

I guess that the Hacknet issue would be easy to solve with a Centos base image or a Ubuntu one. Ubuntu, because that’s the one tested, and Centos, because Hacknet work on my RHEL 7 laptop. But AFAIK, Ubuntu push for snap, and I didn’t heard of any plan for a Centos based SDK.

As I am out of games for now to try to test, I would welcome suggestions provided it run on Linux, is cheap ( so less than 10€ ) and on GOG. So far, I selected 3 games, and in a effort to build some community here, I will make a poll.

So should I get:

  • Spacechem, because that’s a 32 bits game, and it will be fun to deal with that
  • TIS-100, because that’s the kind of game @misc like, and he deserve some fun after writing so much
  • Phantasmagoria 2, because what not to like with a horror game on Windows XP and who need to sleep anyway ?

0 voters


#6

+1 for using all the Discourse features I didn’t even know existed. :exploding_head:

All the Fedora karma points which aren’t even implemented yet here for these posts, thanks!


#7

Kinda related to this, I explored symlinking the container storage in your home directory to another location on the filesystem and found the following issue:

Thankfully, Giuseppe already has a PR to fix it. :slight_smile:


#8

Until the poll has a clear winner, I have been trying to make flatpak for others games (itch.io ones, based on renpy (https://www.renpy.org/). So I wrote a python script that do download zip file from itch.io, look if that’s a renpy games, download it, select the right zip, create a flatpak manifest, and build it. And since I do that on Silverblue and I try to not use rpm-ostree install, I decided to podman (again).

And it seems to be complicated as I do hit as usual the various security systems. There is a few pointers here and then (like https://github.com/projectatomic/bubblewrap/issues/269) but no matter how hard I tried (running as root, disabling seccomp, using a different policy), the only solution I found is using --privileged .

Which may be bad for untrusted code, but since that’s my code, I consider there is easier way for me to steal my own data. So yeah, my 3rd point is still valid.

I will also upload my code once I am satisfied with it (aka no more TODO, some tests and doc), and tested with a wider range of games that the one I selected.


#9
  • I’ve only ever had bad experiences via both the flatpak-builder Flatpak and running it inside a container. TBH you’re probably better off just layering it.
  • IIRC someone on IRC said that running podman as root supposedly does something to make things take less space? Not sure how true it is, but my own personal experiences seem to kind of corroborate this.
  • You can install gconf into the Flatpak. Endless OS’s Chrome launcher thingy does that.

#10

That’s part of the experience, trying to not layer it. And it runs with the right option, so maybe a improvement would be to detect that fuse is not present and set the option automatically. Or again, I can try to see how it can be run in a flatpak or from the Builder flatpak.

It doesn’t take less space, it just take it elsewhere than on /home. There is also duplication of the space if you have things in your home and on the system.

Yup, with enough make/make install, but that’s one more dep to manage, and I have no idea how big is the rabbit hole (what if it requires another packages, etc). And I did already finished Hacknet 2 times in 3 months, so I kinda need some time to forget it in order to replay.


#11

So, after getting 6 answers, I decided to buy a new game, and… took Infinifactory (which was not a choice in the poll), a 2015 game from the same team as TIS-100 and Spacechem if I am not wrong as you can see on https://www.gog.com/game/infinifactory.

I jumped on it mostly because it was on sale at 75% and in my list :stuck_out_tongue:
So stay tuned for my adventure trying to make a flatpak of it later this month, this time using flatpak-games.