Secretchronicles / TSC

An open source two-dimensional platform game.
https://secretchronicles.org/
GNU General Public License v3.0
205 stars 49 forks source link

Add Flatpak support #639

Closed refi64 closed 6 years ago

refi64 commented 6 years ago

What exactly is this?

This PR adds a support for building a TSC Flatpak. This has a bunch of different benefits, from distribution to contributing.

Distribution

Flatpak is basically yet another distribution platform for Linux that has been brought up here before. There are a couple of highlights here:

Building

TSC has some hard-to-build dependencies (actually, mostly just CEGUI) that can make contributing difficult. Flatpak-builder largely solves this by having builds in an isolated environment, too.

IDE support

One other nicety (which is actually what inspired me to do this) is that you get great IDE support. I can open up the CMakeLists.txt in GNOME Builder and immediately have a full development environment with all the dependencies set up. Same apparently goes for KDevelop (FWIW KDE now primarily uses Flatpak for nighties).

TL;DR

It makes everything easier!

Quintus commented 6 years ago

Overall, looks fine to me. I only had a few minor points, see the respective review comments.

Quintus commented 6 years ago

One other nicety (which is actually what inspired me to do this) is that you get great IDE support. I can open up the CMakeLists.txt in GNOME Builder and immediately have a full development environment with all the dependencies set up. Same apparently goes for KDevelop (FWIW KDE now primarily uses Flatpak for nighties).

Emacs user here :-P

refi64 commented 6 years ago

Emacs user here :-P

rip

FWIW this was inspired by both me moving to Fedora Silverblue (where global packages are discouraged vs containers/Flatpak) and Sydney's troubles in building TSC.

Quintus commented 6 years ago

FWIW this was inspired by both me moving to Fedora Silverblue (where global packages are discouraged vs containers/Flatpak) and Sydney's troubles in building TSC.

I was not meaning to criticise you. I was just joking a little. I appreciate all your efforts into this, definitely!

xet7 commented 6 years ago

@kirbyfan64

What commands you used to install flatpak and build package? I could not get it working by following flatpak website docs.

refi64 commented 6 years ago

@xet7 You're on Debian, right? What exactly wasn't working?

xet7 commented 6 years ago

@kirbyfan64

I have wrong syntax. I don't know how to build package.

$ flatpak build-init tsc-build org.secretchronicles.TSC 18.08 org.freedesktop.Platform
error: '18.08' is not a valid sdk name: Name can't start with 1
refi64 commented 6 years ago

@xet7 I think you're mixing up some different stuff... In order to build this, you'd just do:

flatpak-builder --force-clean --install MY_BUILD_DIRECTORY-I-usually-use-"build" org.secretchronicles.TSC.json

(Note that it won't actually work yet since the CMake support commits haven't been merged, but it will after this PR.) --install will install TSC after building.

If you're looking to use it for development, you'll probably want something like GNOME Builder which supports building Flatpaks out-of-the-box. Just open CMakeLists.txt in Builder and watch the magic.

xet7 commented 6 years ago

@kirbyfan64

Magic did not work. I installed gnome-builder, but I don't know with what button to open CMakeLists.txt button and what to click next it.

$ dpkg -l | grep gnome-builder
ii  gnome-builder                           3.22.4-1+b1                              amd64        IDE for GNOME

$ dpkg -l | grep flatpak-builder
ii  flatpak-builder                         0.8.9-0+deb9u1                           amd64        Flatpak application building helper

$ flatpak-builder --force-clean --install build org.secretchronicles.TSC.json
Option parsing failed: Unknown option --install

$ flatpak-builder --force-clean --build-only build org.secretchronicles.TSC.json
(flatpak-builder:17548): flatpak-ERROR **: Failed to load included manifest (flatpak/shared-modules/glew/glew.json): Failed to open file 'flatpak/shared-modules/glew/glew.json': No such file or directory
refi64 commented 6 years ago

@xet7

refi64 commented 6 years ago

FWIW as there doesn't seem to really be opposition to this, I'm just going to merge it now a sec, that way the manifest will actually work standalone (yay!)...

Quintus commented 6 years ago

Mh, I had some comments left in the patch commit diff. It doesn't look as if you addressed them... I can see that GitHub makes it easy to overlook such comments, so you might still want to take look now?

xet7 commented 6 years ago

@kirbyfan64

Please, don't merge PR's yourself. And please do not consider these comments to PR's as "not any real opposition". These comments are not unreal. It's not opposition. I really need to get PR's working myself before merging.

I still get this error:

$ flatpak install flathub org.gnome.Builder
error: app/org.gnome.Builder/x86_64/stable needs a later flatpak version (0.10.0)

Please do not expect that when it works on your computer that it will work for me. I have spent many hours to get this working, and it still does not work.

refi64 commented 6 years ago

@xet7

Please, don't merge PR's yourself. And please do not consider these comments to PR's as "not any real opposition". These comments are not unreal. It's not opposition. I really need to get PR's working myself before merging.

Sorry, that's not what I meant...

AFAIK we don't really seem to have a PR merge policy, and last time someone asked if I was waiting for anything to merge. The Flatpak manifest uses the Git repo, meaning it wasn't going to work fully until it was merged (I actually should probably change it to a directory source instead).

I didn't mean to downplay your comments. I meant it as in, "the PR itself is fine".

What version of Debian are you on? For some reason, Jessie's backports only has Flatpak 0.8.9, which is a bugfix release of the previous Flatpak stable version that's now over a year-old. I'm asking around to see, but my best guess is that this is due to Debian packaging restrictions. I'll check and see if I can get in touch with them and see if a newer version can be pushed to the backports, since that's a little too old to be useful right now.

xet7 commented 6 years ago

I use Debian 9 mostly, but I can use any other distro that has working Flatpak version. Please provide steps to build package.

refi64 commented 6 years ago

Debian 9

Ohhhh...

Try installing the version in backports:

apt-get install -t stretch-backports flatpak flatpak-builder

Now should be able to run:

flatpak-builder --install --force-clean my-build-directory org.secretchronicles.TSC.json

and it'll all work.

xet7 commented 6 years ago

I still have errors. I added my current build scripts to repo.

$ ./build-flatpak.sh 
Downloading sources
Fetching git repo https://github.com/mattn/mruby-json, ref refs/heads/master
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
Fetching git repo https://github.com/mattn/mruby-md5, ref refs/heads/master
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
Fetching full git repo https://github.com/mattn/mruby-pcre-regexp
Fetching git repo https://github.com/matsumotory/mruby-sleep, ref refs/heads/master
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
Initialized empty Git repository in /home/user/repos/Secretchronicles/TSC/.flatpak-builder/git/_home_user_repos_Secretchronicles_TSC_https_github.com_Secretchronicles_TSC-51VUQZ/
fatal: '/home/user/repos/Secretchronicles/TSC/https:/github.com/Secretchronicles/TSC' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Failed to download sources: module tsc: Child process exited with code 128
refi64 commented 6 years ago

@xet7 Ahhhhh sorry that one was all me... I typo'd. :man_facepalming:

Potential solution: try changing these lines to:

{
    "type": "dir",
    "path": "."
}
xet7 commented 6 years ago

@kirbyfan64

Thanks! Now it installed flatpak and I see TSC on desktop game menu.

How do I make .flatpak package file and add it to be installed from Alexandria?

refi64 commented 6 years ago

@xet7 Run:

flatpak-builder --repo a-repo-directory my-build-directory org.secretchronicles.TSC.json
flatpak build-export a-repo-directory my-build-directory

That being said: the preferred way is to host a Flatpak repo. My ideal, eventual scenario (that I might start work on now) is that CI will automatically build a Flatpak bundle as a build artifact (to make it easy to test different builds). Then, every night, Alexandria will import the latest bundle from the master branch into a nightly repository, which can be easily used by users to install a nightly TSC (you basically have to make a simple text file that users will double-click to add the repo + install it).