Ubuntu 16.04: Install and build Flatpak

Table of Contents

1 Install flatpak package

Install flatpak package from ppa repository according to flatpak.org.

$ sudo add-apt-repository -y ppa:alexlarsson/flatpak$ sudo apt update -y$ sudo apt install -y flatpak

This later is the same as the case of Fedora 24.

Following script will install org.gnome.gedit. Because org.gnome.Platform and org.gnome.Sdk have a problem, reinstall these for avoiding this problem.

#!/bin/shsudo add-apt-repository -y ppa:alexlarsson/flatpaksudo apt update -ysudo apt install -y flatpakwget –user remote-add –gpg-import=gnome-sdk.gpg gnome –user remote-add –gpg-import=gnome-sdk.gpg gnome-apps { flatpak –user list –runtime –app | grep ${2} > /dev/null && return 0 while : ; do flatpak –user install $@ & pid=$! sleep 300 ps -p ${pid} | awk ‘{ print $1 }’ | grep ${pid} > /dev/null || break sudo kill -KILL ${pid} done}flatpak –user install gnome-apps org.gnome.gedit stableflatpak_user_install gnome org.gnome.Platform 3.20flatpak_user_install gnome org.gnome.Sdk 3.20sudo reboot

2 Build application

This is the same as the case of Fedora 24. This article writes build script only.

2.1 Building application without flatpak build (Not recommended)

#!/bin/sh# Create directory for this package.mkdir shellmkdir shell/filesmkdir shell/files/binmkdir shell/export# Create the command in this package.cat <<EOF > shell/files/bin/shell.sh#!/bin/shif [ $# -eq 0 ]; then PS1=”shell> ” /bin/shelse echo “shell> $@” eval “$@”fiEOFchmod a+x shell/files/bin/shell.sh# Create the metadata in this package.cat <<EOF > shell/metadata[Application]name=com.example.shellruntime=org.gnome.Platform/x86_64/3.20command=shell.sh[Context]filesystems=host;EOF# Create repository.flatpak build-export repo shell# Install this package to user.flatpak –user remote-add –no-gpg-verify example-repo repoflatpak –user install example-repo com.example.shell

2.2 Building application with flatpak build (Recommended)

#!/bin/sh# Initialize flatpak buildflatpak build-init tetris com.hiroom2.tetris org.gnome.Sdk org.gnome.Platform 3.20# Download source codegit clone tetris-sdl-and-ncurses/# Build source code via flatpak buildflatpak build ../tetris make all install DESTDIR=/appcd ..# Finalize flatpak buildflatpak build-finish tetris –command=ncurses# Create repository.flatpak build-export repo tetris# Install this package to user.flatpak –user remote-add –no-gpg-verify tetris-repo repoflatpak –user install tetris-repo com.hiroom2.tetris

Android | Linux | SDL - Narrow Escape