flatpak-builder with local sources and dependancies

1.8k Views Asked by At

How I can build local sources and dependancies with flatpak-builder?

I can build local sources

flatpak build ../dictionary ./configure --prefix=/app

I can extract and build application with dependancies with a .json

flatpak-builder --repo=repo dictionary2 org.gnome.Dictionary.json

But no way to build dependancies and local sources? I don't find sources type like dir or other, only archive, git (no hg?) ...

2

There are 2 best solutions below

2
On

There's a expermental cli tool if you want to use it https://gitlab.com/csoriano/flatpak-dev-cli

You can read the docs

In a nutshell this is what you need to use flatpak as develop workbench

https://github.com/albfan/gnome-builder/wiki/flatpak

1
On

flatpak-builder is meant to automate the whole build process, with a single entry-point: the JSON manifest.

Everything else it obtains from Git, Bazaar or tarballs. Note that for these the "url" property may be a local URL starting with file://.

(There is indeed no support for Hg. If that's important for you, feel free to request it.)

In addition to that, there are a few more source types (see the flatpak-manifest(5) manpage), which can be used to modify the extracted sources:

  • file which point to a local file to copy somewhere in the extracted sources;
  • patch which point to a local patch file to apply to the extracted sources;
  • script which creates a script in the extracted sources, from an array of commands;
  • shell which modifies the extracted sources by running an array of commands;

Adding a dir source type might be useful.

However (and I only flatpaked a few apps, and contributed 2 or 3 patches to the code, so I might be completely wrong) care must be taken as this would easily make builds completely unreproducible, which is one thing flatpak-builder tries very hard to enable.

For example, when using a local file source, flatpak-builder will base64-econde the content of that file and use it as a data:text/plain;charset=utf8;base64,<content> URL for the file which it stores in the manifest included inside the final build.

Something similar might be needed for a dir source (tar the folder then base64-encode the content of the tar?), otherwise it would be impossible to reproduce the build. I've just been told (after submitting this answer) that this changed in Git master, in favour of a new flatpak-builder --bundle-sources option. This would probably make it easier to support reproducible builds with a dir source type.

In any case, feel free to start the conversation around a new dir source type in the upstream bug tracker. :)