Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support files for Flatpak builds #3723

Closed
wants to merge 10 commits into from
Closed

Support files for Flatpak builds #3723

wants to merge 10 commits into from

Conversation

aperezdc
Copy link

@aperezdc aperezdc commented Apr 24, 2017

⚠️ This is a working proof of concept, but I want to share it to request feedback ⚠️

In particular, I would like to iron out at least the following:

  • Application ID. For now it's im.riot.Riot, but maybe something else is more appropriate (comments welcome).
    • Changed to im.vector.Riot as per Matthew's comment.
  • Cleaning up files used for build which are unneeded at runtime. There are options which can be added to the JSON manifest for this, I just didn't have time to add them and test.
  • AppStream metadata is missing. This would be needed for the application to appear e.g. in GNOME Software.
    • It would be nice to have a screenshot of Riot available at some public URL to link it in the AppStream metadata.
  • Adding Flatpak builds to CI.
  • Figuring out with the Matrix developers in which way a Flatpak repository could be made available online for people to use. Probably needs some discussion first.

Install the dependency base Electron bundle with:

flatpak --user remote-add endless-electron-apps --from \
    https://s3-us-west-2.amazonaws.com/electron-flatpak.endlessm.com/endless-electron-apps.flatpakrepo
flatpak --user install endless-electron-apps io.atom.electron.BaseApp

then Riot can be built and saved to a Flatpak repository with (it takes a bit, it will build NodeJS inside the Flatpak sandbox):

flatpak-builder --repo=flatpak-repo flaptak-build \
    electron/build/im.riot.Riot.json

and installed locally for testing with:

flatpak --user remote-add --no-gpg-verify \
    riot-local file://`pwd`/flatpak-repo
flatpak --user install riot-local im.riot.Riot
flatpak run im.riot.Riot

@aperezdc
Copy link
Author

One thought about the application identifier: probably it should be org.matrix.Riot, or even maybe better im.vector.Riot given that the GitHub organization is vector-im. I guess we want @ara4n or someone else from the core team to vet one of those.

@aperezdc
Copy link
Author

I have added AppStream metadata:

  • The <description> is filled with a couple of paragraphs taken from riot.im — let me know if some other text is preferred.
  • Screenshots are missing. For adding this we would be nice to host the image somewhere, to be able to write the URL in the XML file. This should be in 16:9 ratio, with a minimum width of 620px (more info in the spec).

@ara4n
Copy link
Member

ara4n commented Apr 29, 2017

the application ID should definitely be im.vector.Riot - Riot's not made by Matrix.org but Vector. (Matrix.org is the non-profit; Vector is a separate startup building apps & services on top of Matrix).

This is looking really good. We can provide some 'official' screenshots and check the description field once you're ready for the PR to be reviewed and landed :)

@aperezdc
Copy link
Author

I have just added a few changes:

  • The application ID is not im.vector.Riot (thanks @ara4n for the clarification).
  • Allow using /tmp from the Flatpak sandbox, which is needed for Electron's unique instance checks.
  • Allow sending D-Bus messages to the notification daemon from gthe sandbox, which makes desktop notifications work.

@ara4n
Copy link
Member

ara4n commented May 15, 2017

@aperezdc is there anything to be done on this other than screenshots from us?

@aperezdc
Copy link
Author

@ara4n From my hitlist above, there are only two things missing: Making CI do Flatpak builds, and making a Flatpak repository available. Probably we can just merge this PR, and skip these two for now.


I think that figuring out how to provide a Flatpak repository for people to use can be done separately and shouldn't keep this from being merged. Probably it needs some discussion before and it may take a while to set up something.

As for the CI, would it make sense to make Travis-CI do also Flatpak builds? I suppose it's fine to skip this, but it would be nice to have. So far I haven't had some free time to sit down to figure out how to get flatpak-builder to work inside Travis (it could be as well that it doesn't work because of the union mounts and the setuid sandbox helper). I think it's fine to merge this PR and I can make a separate follow-up PR which modifies .travis.yml later on (if I ever get it to work).

@Croydon
Copy link

Croydon commented May 15, 2017

You might want to have a look at Flathub. However I'm not sure if this is already ready for real usage.

https://github.com/flathub/flathub/wiki
https://flathub.org/builds/

@TingPing
Copy link

You might want to have a look at Flathub. However I'm not sure if this is already ready for real usage.

Packager for Flathub here. So the main blocker at a glance is you currently pass --share=network as a build option and this is not acceptable on the Flathub build servers. I'm not super familiar with npm but I did find a project called npm-bundle that might be useful, if releases are made using this it might work without network access.

@TingPing
Copy link

TingPing commented May 15, 2017

As for Travis CI, that won't be easy because Travis is too old for Flatpak and running flatpak-builder inside a docker container or such is PITA.

Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

electron has been moved to electron_app
so these new files will need moving accordingly

Type=Application
Icon=im.vector.Riot
StartupWMClass="Riot"
Categories=Network;InstantMessaging;Chat;IRCClient
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match the cats being used in the Linux app, (though Chat should be in them and I missed it)
i.e remove IRCClient

@aperezdc
Copy link
Author

aperezdc commented Jun 7, 2017

I have added a couple of commits to move the files under electron_app/, fix the categories in the .desktop file, and update the used sources to Riot version 0.10.2

Could we merge this as it is now for a first pass, and then improve things in follow-up PRs if needed?

Install the dependency base Electron bundle with:

  flatpak --user remote-add endless-electron-apps --from \
    https://s3-us-west-2.amazonaws.com/electron-flatpak.endlessm.com/endless-electron-apps.flatpakrepo
  flatpak --user install endless-electron-apps io.atom.electron.BaseApp

then Riot can be built and saved to a Flatpak repository with:

  flatpak-builder --repo=flatpak-repo flaptak-build electron/build/im.riot.Riot.json

and installed locally for testing with:

  flatpak --user remote-add --no-gpg-verify riot-local file://`pwd`/flatpak-repo
  flatpak --user install riot-local im.riot.Riot
  flatpak run im.riot.Riot
NodeJS is built and installed only to be able to build Riot. The generated
Electron application does not need it to be installed at runtime, therefore we
can instruct flatpak-builder to zap all the files of the module.
This is needed for Flatpak packages to appear in software centers like GNOME
Software.
This is needed for Electron's unique instance checks. Without this,
re-launching the application brings up a new instance, instead of
the already running one.
Allow talking over to the notification daemon over D-Bus from inside the
sandbox makes desktop notifications work.
@aperezdc
Copy link
Author

Updated to build v0.12.2, and also fixed the paths (s/electron/electron_app/) to make builds work again.

@dbkr
Copy link
Member

dbkr commented Jan 5, 2018

This looks nice, although I'm struggling to find any kind of docs on what the various options in the manifest are and the --share options seems to make no appearance in the flatpak-builder man page (I'm assuming it allows network access for the build process so npm can download the rest of the deps?)

Main thing here is wondering if this would be better in its own repo? ie. the same layout as a build hosted on flathub (see https://github.com/flathub/org.blender.Blender or indeed https://github.com/flathub/im.riot.Riot)

If that sounds good, I can pull all this out into its own repo.

"finish-args": [
"--device=dri",
"--filesystem=home",
"--filesystem=/tmp",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should set $TMPDIR at runtime to $XDG_CACHE_HOME

@TingPing
Copy link

TingPing commented Jan 5, 2018

I'm struggling to find any kind of docs on what the various options in the manifest are and the --share options seems to make no appearance in the flatpak-builder man page

man flatpak-build-finish (or man flatpak-metadata for slightly more depth)

{
"type": "file",
"path": "flatpak-Makefile",
"dest-filename": "Makefile"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general these are avoided these days. You can do:

{
  "name": "riot-web",
  "buildsystem": "simple",
  "build-commands": [
    "install -Dm644 foo /app/share/foo",
    "etc"
  ]
}

@dbkr
Copy link
Member

dbkr commented Jan 8, 2018

@TingPing thanks! I had completely failed to realise flatpak-build-finish was separate from flatpak-builder.

@TingPing
Copy link

TingPing commented Jan 8, 2018

@dbkr flatpak-builder is a tool built on top of flatpak build* so there is some overlap in where docs discuss some things.

@jonathancross
Copy link

Is anyone still working on this PR?

@dbkr
Copy link
Member

dbkr commented Jan 11, 2022

I think this is superseded by element-hq/element-desktop#293

@dbkr dbkr closed this Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants