Openspades: Release game on Flatpak/Flathub

Created on 22 Nov 2018  Â·  15Comments  Â·  Source: yvt/openspades

On Linux the game is currently easily downloadable using Snap, but there are a couple of issues with that. The main issue is that Snap creates a loop device for every package you install with it, so imagine installing each package on it's own USB drive and then going to disk manager, it's a mess. Second is that Snap is centralized with no option for remote repositories, which a lot of people don't really like.

Flatpak does what Snap does and does it better. A lot of popular distros like Linux Mint and Manjaro (both more popular than Ubuntu under desktop users) come with Flatpak by default and not Snap. Please release this game as a Flatpak(on Flathub or a self-hosted repo), that would be really great.

distribution

Most helpful comment

I did some initial work on flatpak packaging. While compiling, it recognizes the dependencies but I have trouble getting it to actually compile. Would love to have help.

@yvt Would a pull request be welcome if we get this to work?

All 15 comments

I did some initial work on flatpak packaging. While compiling, it recognizes the dependencies but I have trouble getting it to actually compile. Would love to have help.

@yvt Would a pull request be welcome if we get this to work?

@kdeleteme Yes, much appreciated!

You mentioned you're having trouble getting it to compile. Maybe care to share the error messages that you get?

I also wrote an basic builder script a while ago: theunknownxy/openspades-flatpak. @kdeleteme feel free to use it as an source of inspiration.

EDIT: I updated the dependencies and it seems to still work. But some things need to be adapted to the flathub guidelines[1][2], if it should be published to flathub.

@theunknownxy Thanks! I checked it out found the script to be really helpful.

@yvt Here's the log during compilation (I'm using clang++):

-- The C compiler identification is Clang 6.0.1
-- The CXX compiler identification is Clang 6.0.1
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at CMakeLists.txt:16 (cmake_policy):
  The OLD behavior for policy CMP0054 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found SDL2: /usr/lib/x86_64-linux-gnu/libSDL2main.a;/usr/lib/x86_64-linux-gnu/libSDL2.so;-lpthread  
-- Found SDL2_image: /usr/lib/x86_64-linux-gnu/libSDL2_image.so  
CMake Warning (dev) at /usr/share/cmake-3.13/Modules/FindOpenGL.cmake:270 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  CMakeLists.txt:29 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.63.0") 
-- Found Freetype: /usr/lib/x86_64-linux-gnu/libfreetype.so (found version "2.9.1") 
-- Found OpusFile: /app/lib/libopusfile.so  
-- Looking for fcntl
-- Looking for fcntl - found
-- Looking for poll
-- Looking for poll - found
-- Looking for gethostbyname_r
-- Looking for gethostbyname_r - found
-- Looking for gethostbyaddr_r
-- Looking for gethostbyaddr_r - found
-- Looking for inet_pton
-- Looking for inet_pton - found
-- Looking for inet_ntop
-- Looking for inet_ntop - found
-- Performing Test HAS_MSGHDR_FLAGS
-- Performing Test HAS_MSGHDR_FLAGS - Success
-- Check size of socklen_t
-- Check size of socklen_t - done
-- Configuring done
-- Generating done
-- Build files have been written to: /run/build/openspades
Scanning dependencies of target OpenSpades_Resources_DevPaks
Scanning dependencies of target Angelscript_addons
Scanning dependencies of target OpenSpades_Resources
Scanning dependencies of target OpenSpades_Unix
[  1%] Packing assets
Generating FHS icons
/run/build/openspades/Resources/Icons/converticons.sh: line 14: convert: command not found
/run/build/openspades/Resources/Icons/converticons.sh: line 18: convert: command not found
[  2%] Building CXX object Sources/AngelScript/projects/cmake_addons/CMakeFiles/Angelscript_addons.dir/__/__/addons/scriptany.cpp.o
rm: cannot remove 'tmp/40x40.png': No such file or directory
/run/build/openspades/Resources /run/build/openspades/Resources
BASEURL ************ https://github.com/yvt/openspades-paks/releases/download/r33/OpenSpadesDevPackage-r33.zip
mv: cannot stat 'tmp/*.png': No such file or directory
Done generating FHS icons
[  2%] Built target OpenSpades_Unix
[  2%] Building CXX object Sources/AngelScript/projects/cmake_addons/CMakeFiles/Angelscript_addons.dir/__/__/addons/scriptarray.cpp.o
--2019-02-09 20:03:56--  https://github.com/yvt/openspades-paks/releases/download/r33/OpenSpadesDevPackage-r33.zip
Resolving github.com (github.com)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘github.com’
Archive:  OpenSpadesDevPackage-r33.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of OpenSpadesDevPackage-r33.zip or
        OpenSpadesDevPackage-r33.zip.zip, and cannot find OpenSpadesDevPackage-r33.zip.ZIP, period.
mv: cannot stat './Nonfree/pak000-Nonfree.pak': No such file or directory
mv: cannot stat './OfficialMods/font-unifont.pak': No such file or directory
mv: cannot stat './Nonfree/LICENSE.md': No such file or directory
mv: cannot stat './OfficialMods/LICENSE': No such file or directory
make[2]: *** [Resources/CMakeFiles/OpenSpades_Resources_DevPaks.dir/build.make:57: OpenSpades_Resources_DevPaks] Error 1
make[1]: *** [CMakeFiles/Makefile2:169: Resources/CMakeFiles/OpenSpades_Resources_DevPaks.dir/all] Error 2

The above part I feel I can fix/workaround because it seems like it's more of a problem with my flatpak build script.

The real problem is in the following:

make[1]: *** Waiting for unfinished jobs....
[  3%] Building CXX object Sources/AngelScript/projects/cmake_addons/CMakeFiles/Angelscript_addons.dir/__/__/addons/scriptbuilder.cpp.o
/run/build/openspades/Resources
[  3%] Built target OpenSpades_Resources
[  3%] Building CXX object Sources/AngelScript/projects/cmake_addons/CMakeFiles/Angelscript_addons.dir/__/__/addons/scriptdictionary.cpp.o
[  3%] Building CXX object Sources/AngelScript/projects/cmake_addons/CMakeFiles/Angelscript_addons.dir/__/__/addons/scripthandle.cpp.o
[  4%] Building CXX object Sources/AngelScript/projects/cmake_addons/CMakeFiles/Angelscript_addons.dir/__/__/addons/scripthelper.cpp.o
[  4%] Building CXX object Sources/AngelScript/projects/cmake_addons/CMakeFiles/Angelscript_addons.dir/__/__/addons/scriptmath.cpp.o
[  4%] Building CXX object Sources/AngelScript/projects/cmake_addons/CMakeFiles/Angelscript_addons.dir/__/__/addons/scriptmathcomplex.cpp.o
[  5%] Building CXX object Sources/AngelScript/projects/cmake_addons/CMakeFiles/Angelscript_addons.dir/__/__/addons/scriptstdstring.cpp.o
[  5%] Building CXX object Sources/AngelScript/projects/cmake_addons/CMakeFiles/Angelscript_addons.dir/__/__/addons/scriptstdstring_utils.cpp.o
[  6%] Building CXX object Sources/AngelScript/projects/cmake_addons/CMakeFiles/Angelscript_addons.dir/__/__/addons/weakref.cpp.o
[  6%] Linking CXX static library ../../../../lib/libAngelscript_addons.a
[  6%] Built target Angelscript_addons
make: *** [Makefile:152: all] Error 2
Error: module openspades: Child process exited with code 2

@kdeleteme make usually continues for a while when an error happened and multiple cores are used for the build (flatpak-builder automatically takes care that make uses all available cores).

Resolving github.com (github.com)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘github.com’

This error happens because flatpak-builder isolates the build (you can't do network requests inside the build). I worked around the problem by simply removing the nonfree Pak file from the build and using the extra data mechanism. The benefit of extra-data is also that the non-free part is only downloaded when the app is actually installed.

/run/build/openspades/Resources/Icons/converticons.sh: line 14: convert: command not found
/run/build/openspades/Resources/Icons/converticons.sh: line 18: convert: command not found

That's the reason why I built imagemagick in my script (and remove it in the final image with the clean directive).

Depending on where the package should hosted (self-hosted vs flathub), the location of the build script might matter. Flathub seems to require a separate repository in the flathub organization.

I got it to work but it has the same problem as the snap. Every time the game is run, the configuration gets reset. The flatpak script and appstream data needs some polishing though.

@theunknownxy Thanks for the heads up about the flathub distribution. What are your suggestions? I'm thinking of doing a pull request to this repo for now, so that people can build openspades with flatpak for themselves if they choose to.

Edit: #811

I guess publishing it on flathub would be much more convenient for users. It's basically an one click install if flatpak is set up correctly.

About the pull request in this repository: it makes it much easier to develop on OS ("flatpak-builder --ccache ..." + "flatpak-builder --run ..." is pretty nice), but most will probably just use it get an trunk build of OS. The only problem is that you need to keep two builder configs up to date, one in a separate repository for flathub and one in this repository.

Any update on publishing this game on to Flathub?

EDIT: I have gone ahead and created a PR https://github.com/flathub/flathub/pull/929
Unfortunately the build is failing. I have a question, does the repository have to have everything from the openspades/flatpak folder? I only pushed the .json and .xml files. Any help would be appreciated (this is my first time playing with flatpak).

I closed the PR. If anyone wants to take over and submit it to Flathub, you will need to update the manifest .json file with up-to-date and static link to ImageMagick with the correct SHA256. Also, be sure to add the modules to your repository otherwise it the bot can't compile it -> git submodule add https://github.com/flathub/shared-modules.git

@digiberk Why did you give up? Basically everything worked, except the build for ARM processors. But these currently aren't supported by OpenSpades and restricting the build to i386 + x86_64 would be enough to fix it.

And now something offtopic: Is there a particular reason why there isn't a "official" chat room (Discord, IRC, Gitter, ...) for OpenSpades? I think it would be really useful for issues like this one.

I already spent too much time on it and I didn't know what to do so I just closed it. Luckily, I can just reopen the PR and it should all be fine, I still have the files so all I would have to do is push them. I'll look into restricting the builds. I'll post an update here shortly on what the situation, maybe I shouldn't have given up.

One question, once the builds succeed and is put onto Flathub, do I need to do any maintenance?

@digiberk Oh sorry I forgot to insert the relevant link: https://github.com/flathub/flathub/wiki/App-Maintenance#limiting-the-set-of-architectures-to-build-on
And thank you for spending your time on the issue :+1:

EDIT: Okay the maintenance part is actually the interesting part... I didn't submit it myself, simply because I don't play the game anymore and thus can't ensure that it works after updates/rebuilds. That is I wouldn't notice when there is a problem ^^. Ideally someone who plays game and is willing to spend some time on the flatpak packaging can take care of it. But I don't think it's necessary to spend much time on it once everything works. Additionally I will happily help if there is any problem.

Yeah, I don't play it often either, I guess I want it to be easy for people who do. That was one reason why I deleted it in the first place. I got it working natively on my distro (Fedora) but I thought I'd help out and put the package up on Flathub. Looking at Flatpak packaging, it seems quite straightforward and once all is setup, there is little work to be done. I can always once in a while check that everything works. It is always good to contribute some back and in return, I'm sure this game will gain popularity because it's on Flathub.

Anyways, since I messed it up before, I created a new PR https://github.com/flathub/flathub/pull/930

It's my first time creating a PR and submitting a Flatpak package, fun stuff! :smile:

The app has been added. If upstream would like to take it over, just let us know at flathub. https://github.com/flathub/jp.yvt.OpenSpades

Closing this since the issue is resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

parkerlreed picture parkerlreed  Â·  4Comments

dwnpr picture dwnpr  Â·  4Comments

NotAFile picture NotAFile  Â·  5Comments

NotAFile picture NotAFile  Â·  4Comments

tomlister picture tomlister  Â·  3Comments