Merging two Flatpak (OSTree) repositories

Flatpak is mostly known for being a sandbox-like format that bundles all of it’s dependencies similar to how AppImage did. However, under the hood all of the repositories are also OStree repositories. To some extent you can think of that as something similar to a git repository.

When you run the flatpak build-export command it commits to the OStree repository and runs the ostree summary --update command. This means you can actually have two completely separate repositories:

(Note I’m ignoring the part where you would need to import GPG signatures and such here)

flatpak build-export repo_a/ app_build_dir_a/
flatpak build-export repo_b/ app_build_dir_b/

Now you can create a new OSTree repository that is a combination of both:

ostree init --repo repo_c/
ostree remote add --repo repo_c repo_a file:///repo_a
ostree remote add --repo repo_c repo_b file:///repo_b
ostree pull --repo repo_c --mirror repo_a
ostree pull --repo repo_c --mirror repo_b
flatpak build-update-repo repo_c
flatpak remote-ls file:///repo_c

Here you’ll see that flatpak remote-ls will list both the packages for app_a and app_b. This means you can have multiple systems generating Flatpak builds and a central repository that collects all the builds.