Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building and running applications with Flatpak

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Building and running applications with Flatpak

Abstract: Flatpak is the new way of packaging and running applications that is compatible across different Linux distributions. In this talk we will explore Flatpak’s internal sandboxing mechanisms and see how painless it is to install and run applications. Furthermore we will walk through all the components needed to package an application.

Presented at https://www.meetup.com/linux-technologies-berlin/events/239728061/

Avatar for Lili Cosic

Lili Cosic

May 17, 2017

More Decks by Lili Cosic

Other Decks in Programming

Transcript

  1. [email protected] Flatpak? • Desktop Applications in Containers • Targeted at

    Linux desktop applications • Old name xdg-app • github.com/flatpak/flatpak
  2. [email protected] Advantages of Flatpak • Easy distribution to multiple Linux

    distros • Secure sandboxed application • Dependency bundling • Install different versions of the same application
  3. [email protected] Installing from .flatpakref • Simple to install applications: $

    flatpak install --from https://s3.amazonaws.com/alexlarsson/spotify-repo/spotify.flatpakref $ flatpak run com.spotify.Client
  4. [email protected] Installing from remote repositories • Remote - repository which

    hosts applications $ flatpak remote-add --if-not-exists gnome https://sdk.gnome.org/gnome.flatpakrepo $ flatpak remote-add gnome-apps https://sdk.gnome.org/gnome-apps.flatpakrepo $ flatpak remote-ls gnome-apps $ flatpak install gnome-apps org.gnome.Totem
  5. [email protected] Flatpak Sandbox • Different to rkt, Docker, etc. •

    No need for root • bubblewrap • Unprivileged user namespaces* • portals
  6. [email protected] Building a simple application $ flatpak build-init dictionary org.gnome.Dictionary

    org.gnome.Sdk org.gnome.Platform 3.22 $ wget https://download.gnome.org/sources/gnome-dictionary/3.20/gnome-dictionary-3.20.0.tar.xz $ tar xvf gnome-dictionary-3.20.0.tar.xz $ cd gnome-dictionary-3.20.0/ $ flatpak build ../dictionary ./configure --prefix=/app $ flatpak build ../dictionary make $ flatpak build ../dictionary make install $ cd .. $ flatpak build-finish dictionary --socket=x11 --share=network --command=gnome-dictionary $ flatpak build-export repo dictionary $ flatpak --user remote-add --no-gpg-verify --if-not-exists tutorial-repo repo $ flatpak --user install tutorial-repo org.gnome.Dictionary $ flatpak run org.gnome.Dictionary
  7. [email protected] flatpak-builder • flatpak-builder - tool that automates multi-step build

    process • Simplifies building applications • Manifest files • Reproducible • Maintainable
  8. [email protected] Manifest file example { "app-id": "org.gnome.Dictionary", "runtime": "org.gnome.Platform", "runtime-version":

    "master", "sdk": "org.gnome.Sdk", "command": "gnome-dictionary", "finish-args": [ "--share=ipc", "--socket=wayland", "--share=network", "--filesystem=home" ], "cleanup": ["/include", "/lib/pkgconfig", "/share/pkgconfig", "/share/aclocal", "/man", "/share/man", "/share/gtk-doc", "*.la", "*.a", ], "modules": [ { "name": "gnome-dictionary", "sources": [ { "type": "git", "url": "git://git.gnome.org/gnome-dictionary" } ] } ] }
  9. [email protected] Manifest file example { "app-id": "org.gnome.Dictionary", "runtime": "org.gnome.Platform", "runtime-version":

    "master", "sdk": "org.gnome.Sdk", "command": "gnome-dictionary", "finish-args": [ "--share=ipc", "--socket=wayland", "--share=network", "--filesystem=home" ], "cleanup": ["/include", "/lib/pkgconfig", "/share/pkgconfig", "/share/aclocal", "/man", "/share/man", "/share/gtk-doc", "*.la", "*.a", ], "modules": [ { "name": "gnome-dictionary", "sources": [ { "type": "git", "url": "git://git.gnome.org/gnome-dictionary" } ] } ] }
  10. [email protected] Manifest file example { "app-id": "org.gnome.Dictionary", "runtime": "org.gnome.Platform", "runtime-version":

    "master", "sdk": "org.gnome.Sdk", "command": "gnome-dictionary", "finish-args": [ "--share=ipc", "--socket=wayland", "--share=network", "--filesystem=home" ], "cleanup": ["/include", "/lib/pkgconfig", "/share/pkgconfig", "/share/aclocal", "/man", "/share/man", "/share/gtk-doc", "*.la", "*.a", ], "modules": [ { "name": "gnome-dictionary", "sources": [ { "type": "git", "url": "git://git.gnome.org/gnome-dictionary" } ] } ] }
  11. [email protected] Runtimes • Runtimes - basic dependencies - libraries •

    Base of your application • Which runtime you want to use depends on each application and the dependencies it requires • Application runtime must be already installed on the host system
  12. [email protected] Manifest file example { "app-id": "org.gnome.Dictionary", "runtime": "org.gnome.Platform", "runtime-version":

    "master", "sdk": "org.gnome.Sdk", "command": "gnome-dictionary", "finish-args": [ "--share=ipc", "--socket=wayland", "--share=network", "--filesystem=home" ], "cleanup": ["/include", "/lib/pkgconfig", "/share/pkgconfig", "/share/aclocal", "/man", "/share/man", "/share/gtk-doc", "*.la", "*.a", ], "modules": [ { "name": "gnome-dictionary", "sources": [ { "type": "git", "url": "git://git.gnome.org/gnome-dictionary" } ] } ] }
  13. [email protected] Manifest file example { "app-id": "org.gnome.Dictionary", "runtime": "org.gnome.Platform", "runtime-version":

    "master", "sdk": "org.gnome.Sdk", "command": "gnome-dictionary", "finish-args": [ "--share=ipc", "--socket=wayland", "--share=network", "--filesystem=home" ], "cleanup": ["/include", "/lib/pkgconfig", "/share/pkgconfig", "/share/aclocal", "/man", "/share/man", "/share/gtk-doc", "*.la", "*.a", ], "modules": [ { "name": "gnome-dictionary", "sources": [ { "type": "git", "url": "git://git.gnome.org/gnome-dictionary" } ] } ] }
  14. [email protected] Manifest file example { "app-id": "org.gnome.Dictionary", "runtime": "org.gnome.Platform", "runtime-version":

    "master", "sdk": "org.gnome.Sdk", "command": "gnome-dictionary", "finish-args": [ "--share=ipc", "--socket=wayland", "--share=network", "--filesystem=home" ], "cleanup": ["/include", "/lib/pkgconfig", "/share/pkgconfig", "/share/aclocal", "/man", "/share/man", "/share/gtk-doc", "*.la", "*.a", ], "modules": [ { "name": "gnome-dictionary", "sources": [ { "type": "git", "url": "git://git.gnome.org/gnome-dictionary" } ] } ] }
  15. [email protected] Manifest file example { "app-id": "org.gnome.Dictionary", "runtime": "org.gnome.Platform", "runtime-version":

    "master", "sdk": "org.gnome.Sdk", "command": "gnome-dictionary", "finish-args": [ "--share=ipc", "--socket=wayland", "--share=network", "--filesystem=home" ], "cleanup": ["/include", "/lib/pkgconfig", "/share/pkgconfig", "/share/aclocal", "/man", "/share/man", "/share/gtk-doc", "*.la", "*.a", ], "modules": [ { "name": "gnome-dictionary", "sources": [ { "type": "git", "url": "git://git.gnome.org/gnome-dictionary" } ] } ] }
  16. [email protected] flatpak-builder $ flatpak-builder --repo=repo build org.gnome.Dictionary.json • Creates new

    directory called build • Builds and installs modules • Finishes the build using the finish arguments • Creates a directory called repo and exports to it
  17. [email protected] Flathub • Central place for building and hosting Flatpak

    builds • Flathub https://github.com/flatpak/flathub $ flatpak remote-add flathub http://flathub.org/repo/flathub.flatpakrepo $ flatpak --user install flathub org.gnome.Recipes
  18. [email protected] Flatpak Snap AppImage Distributions Linux desktop and embedded Linux

    desktop, server, embedded, mobile Linux Desktop Updates Yes Yes, automatic No Company RedHat Canonical Independent Advantage Flathub Auto-build and publish from github No dependency Sandbox Yes Yes No