YAMLing the flathub

综合技术 2018-05-04 阅读原文

The most common way to build flatpak is using a tool called flatpak-builder. This is a tool that takes a higher level description of the sources that go into an application and generate the build commands to build it. This description is called a manifest
, and is traditionally a JSON file.

JSON is very common in the web world, and it is a well known format that have many implementations. However, it is not really great for humans to write.

For example, JSON has no support for comments, which you typically want in something as complicated as a build script. There are ways to work around this, but it is not pretty.

The syntax, while easy for a machine to parse, is very verbose and noisy to read and picky to write. For example, all lists have to be comma separated, but you can’t have a trailing comma, which you often run into when deleting or moving items around. Also, both keys and values always have to be quoted, which feels pretty unnecessary for the simple one-word keys and values that are common case in manifest files.

This is what a JSON manifest look like:

  "id": "org.gnome.frogr",
  "runtime": "org.gnome.Platform",
  "sdk": "org.gnome.Sdk",
  "runtime-version": "3.26",
  "command": "frogr",
  "finish-args": [
    "--share=ipc", "--socket=x11",
  "build-options" : {
    "cflags": "-O2 -g",
    "env": {
      "V": "1"
  "cleanup": [ "/share/man" ],
  "modules": [
      "name": "frogr",
      "buildsystem": "meson",
      "sources": [
          "type": "git",
          "url": "git://git.gnome.org/frogr",
          "branch": "RELEASE_1.4",
          "commit": "e2322c8f99f9d3a3cdc020b79c6c7224ad1988d0"

Starting in flatpak-builder 0.10.10 you can now also use YAML
for manifests. In term of the content model, YAML is a superset of JSON, but it is easier for humans to read and write. This makes it a good fit for flatpak-builder. In fact, the implementation internally just converts the YAML parser nodes to JSON parser nodes.

Yesterday I enabled support in flathub
, so you can now convert existing apps, or submit new apps using YAML.

Here is how the above manifest looks in YAML:

id: org.gnome.frogr
runtime: org.gnome.Platform
sdk: org.gnome.Sdk
runtime-version: 3.26
command: frogr
  - --share=ipc
  - --socket=x11
  - --socket=wayland
  - --share=network
  # Grant app access to ~/Pictures
  - --filesystem=xdg-pictures
  cflags: -O2 -g
  env: { V: '1' }
cleanup: [ /share/man ]
  - name: frogr
    buildsystem: meson
      - type: git
        url: git://git.gnome.org/frogr
        branch: RELEASE_1.4
        commit: e2322c8f99f9d3a3cdc020b79c6c7224ad1988d0

This is clearly the same content as above (except it has a comment), but shorter and more readable.

For a longer example, see this conversion of a flathub app.

Of course, YAML is not perfect. Its a pretty complex format, it relies on indentation, and the specification has historically been a bit vague with implementations sometimes differing in interpretation. Going forward both JSON and YAML will be supported (and can even be mixed when you use includes), allowing you to chose what works best for you.

责编内容by:Alexander Larsson 【阅读原文】。感谢您的支持!


6种常见的Git错误以及解决的办法 我们都会犯错误,尤其是在使用像Git这样复杂的东西时。如果你是Git的新手,可以学习 如何在命令行上开始使用Git 。下面介绍如何解决六个最常见的Git错误。...
文件事件 时间事件 redis是一个事件驱动程序 主要包含 文件事件和时间事件 文件事件:主要就是server和client进行操作产生的文件 时间事件:主要就是一些需要定...
ExpressJS – Socket.IO with Route Separation I'm trying to get my head around ExpressJS and Socket.IO. I've got my routes in ...
K线三方库__ZXKline Animation.gif 1.简介篇 蜡烛图和山形图绘制切换 5种指标绘制切换 长按蜡烛和指标线详情展示 触底...
Counting socket.io users across horizontal servers I have multiple socket.io servers scaled horizontally using a redisstore. ...