Skip to content

Instantly share code, notes, and snippets.

@sgnn7
Last active August 10, 2017 16:29
Show Gist options
  • Select an option

  • Save sgnn7/fdcc082bda8ebb4b899882d9ce89ed38 to your computer and use it in GitHub Desktop.

Select an option

Save sgnn7/fdcc082bda8ebb4b899882d9ce89ed38 to your computer and use it in GitHub Desktop.
Build foreign arch target Flatpak in a Docker instance (Docker optional though)

Multiarch Flatpak in Docker

  • (Optional if on Docker) Run your docker instance
    • Ensure that you include --privileged flag
    • Ensure to have qemu-user-static package in your Dockerfile
  • Add --arch flag to flatpak's manifest or build-init, runtime --install, runtime --update, build-export, and build-bundle stages if doing it manually.
  • Add new binfmt for your target arch. This is because you won't have qemu within the Sdk probably and you can't bindmount /usr into the flatpak container
    • WARNING! This will change handling of those arch QEMU emulators on your host too!
    • Mount binfmt with mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
    • Remove old qemu mapping with echo -1 > /proc/sys/fs/binfmt_misc/qemu-<arch_name>
    • Add your new mapping with echo 'magic string' > /proc/sys/fs/binfmt_misc/register. You can use this as a template for them but make sure to append 'OC' as flags on them.
  • Add --bind-mount=/var/opt/qemu-<arch_name>-static=/usr/bin/qemu-<arch_name>-static to your flatpak build step

That's it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment