Building and running flatpak from command line

G’day again!

Builder generates a pretty decent project layout for me. Building and running the app is straightforward. I’d like to go back to working in PyCharm, so it would be convenient to build and run from the terminal. I can actually build with this command, copied:

jr@JR-Desktop:~/Code/learn_flatpack$ flatpak build --env=LANG=en_AU.UTF-8 --env=USER=jr --env=HOME=/home/jr --env=PATH=/usr/bin:/bin --env=TERM=xterm-256color --env=V=0 --env=CCACHE_DIR=/home/jr/.cache/gnome-builder/flatpak-builder/ccache --env=FLATPAK_CONFIG_DIR=/home/jr/.local/share/gnome-builder/flatpak/etc --env=PATH=/app/bin:/usr/bin --env=G_MESSAGES_DEBUG= --env=XDG_RUNTIME_DIR=/run/user/1000 --build-dir=/home/jr/.cache/gnome-builder/projects/learn_flatpack/builds/org.bswa.jhanarato.LearnFlatpack.json-flatpak-org.gnome.Platform-46-x86_64-master --share=network --nofilesystem=host --filesystem=/home/jr/.cache/gnome-builder --filesystem=/home/jr/Code/learn_flatpack --filesystem=/home/jr/.cache/gnome-builder/projects/learn_flatpack/builds/org.bswa.jhanarato.LearnFlatpack.json-flatpak-org.gnome.Platform-46-x86_64-master --env=NOCONFIGURE=1 /home/jr/.cache/gnome-builder/projects/learn_flatpack/flatpak/staging/x86_64-master ninja
[1/1] Generating src/learn_flatpack_gresource with a custom command

That’s kinda long! Can I do this with a shorter command?

Also, I’m not sure how to use flatpak to run the application.

Thanks again,

J.R.

1 Like

Aha! This does the build:

$ meson _build
$ cd _build
$ ninja

However, I’m not sure how to run it.

EDIT: I see the above commands just build the project and meson install will make the application available. Not really what I wanted.

Just to be clear: say I created a new GTK Python application via the builder template. Let’s call it HelloWorldGtk.

Ctrl-F5 builds a Flatpak, Ctrl-F7 runs the Flatpak

Given this template, how would I do this via the command line, after having created the project?

Oooohkay!

Working through the excellent flathub documentation, I have the magic incantations.

Note that I’ve changed the runtime from “master” to “46”.

$ flatpak install flathub org.gnome.Sdk/x86_64/46
$ flatpak-builder --force-clean --user --install builddir org.bswa.jhanarato.Helloworldgtk.json
$ flatpak run org.bswa.jhanarato.Helloworldgtk

I’m sure there are a million options I’ve missed above, but I get the Hello World window displayed.

Happy days!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.