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",
    "--socket=wayland",
    "--share=network",
    "--filesystem=xdg-pictures"
  ],
  "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
finish-args:
  - --share=ipc
  - --socket=x11
  - --socket=wayland
  - --share=network
  # Grant app access to ~/Pictures
  - --filesystem=xdg-pictures
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

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 【阅读原文】。感谢您的支持!

您可能感兴趣的

iOS用Socket自定义协议写一套聊天系统(C+S)... 前言 我非常佩服那些文章写的好的人,我想了很久这篇文章应该怎么去写,名字怎么起,内容怎么安排,甚至每个内容深入到什么程度。写出来的东西能不能让大家明白?本着我一贯的风格:不光要自己懂,写出来的文章也要让别人看懂;我也是这样来检测自己到底...
WCTF-party-Writeup 悄咪咪的参加了WCTF的线上赛,本弱鸡表示一脸懵逼,当时只看了party和Cyber_Mimic_Defense。反正是没做出来,赛后看了 WCTF-party 总结下party的解法。 顺便还是.net逆向初体验23...
DELPHI黑客编程(二):反弹后门原理实现... *本文原创作者:5ecurity,本文属FreeBuf原创奖励计划,未经许可禁止转载 PS:本文仅作为技术讨论分享,严禁用于任何非法用途。 上一节主要是通过DELPHI实现了一个正向连接的后门,本节将给大家带来反向...
V8 release v6.8 Every six weeks, we create a new branch of V8 as part of our release process . Each version is branched from V8’s Gi...
Issue upgrading node.js I tried updating node.js on both package manager : Setting up nodejs (0.6.14-1chl1~oneiric1) ... XXX@TPSL4...