From 5a56b1cc2fe0993600e3f6072771b941a47b0677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Petu=C5=A1ka?= Date: Fri, 25 Mar 2022 00:58:27 +0000 Subject: [PATCH] install script json schema --- .editorconfig | 3 +- schema/installer.schema.json | 511 +++++++++++++++++++++++++++++++++++ schema/installer.schema.yml | 347 ++++++++++++++++++++++++ schema/sample.json | 42 +++ schema/sample.yml | 2 + schema/ymlToJson.sh | 8 + 6 files changed, 912 insertions(+), 1 deletion(-) create mode 100644 schema/installer.schema.json create mode 100644 schema/installer.schema.yml create mode 100644 schema/sample.json create mode 100644 schema/sample.yml create mode 100755 schema/ymlToJson.sh diff --git a/.editorconfig b/.editorconfig index 61657ca95..4120388a9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,8 +16,9 @@ max_line_length = 120 [*.rst] tab_width = 4 -[*.yml] +[*.{yaml,yml}] tab_width = 2 +indent_size = 2 [Makefile] indent_style = tab diff --git a/schema/installer.schema.json b/schema/installer.schema.json new file mode 100644 index 000000000..509a359eb --- /dev/null +++ b/schema/installer.schema.json @@ -0,0 +1,511 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "required": [ + "name", + "game_slug", + "version", + "slug", + "runner", + "script" + ], + "description": "Lutris install script", + "type": "object", + "properties": { + "name": { + "description": "Name of the game, should be surrounded in quotes if containing special characters.", + "type": "string" + }, + "game_slug": { + "description": "Game identifier on the Lutris website", + "type": "string" + }, + "version": { + "description": "Name of the installer", + "type": "string" + }, + "slug": { + "description": "Installer identifier", + "type": "string" + }, + "require-binaries": { + "description": "Additional binaries", + "type": "string" + }, + "requires": { + "description": "Mods and add-ons", + "type": "string" + }, + "extends": { + "description": "Extensions / patches", + "type": "string" + }, + "install_complete_text": { + "description": "Custom end of install text", + "type": "string" + }, + "runner": { + "description": "The runner to be used by this game", + "type": "string", + "enum": [ + "ags", + "atari800", + "browser", + "citra", + "desmume", + "dgen", + "dolphin", + "dosbox", + "frotz", + "fsuae", + "hatari", + "jzintv", + "libretro", + "linux", + "mame", + "mednafen", + "mupen64plus", + "o2em", + "openmsx", + "osmose", + "pcsx2", + "pcsxr", + "ppsspp", + "reicast", + "residualvm", + "rpcs3", + "scummvm", + "snes9x", + "steam", + "winesteam", + "stella", + "vice", + "virtualjaguar", + "web", + "wine", + "yuzu", + "zdoom" + ] + }, + "script": { + "description": "Main script", + "type": "object", + "additionalProperties": true, + "required": [ + "game", + "installer" + ], + "patternProperties": { + "": { + "type": "object" + } + }, + "properties": { + "game": { + "type": "object", + "description": "The game schema", + "required": [ + "exe", + "args", + "prefix" + ], + "properties": { + "exe": { + "type": "string", + "description": "The exe schema" + }, + "args": { + "type": "string", + "description": "The args schema" + }, + "prefix": { + "type": "string", + "description": "The prefix schema" + } + } + }, + "files": { + "type": "array", + "description": "Fetch required files", + "items": { + "anyOf": [ + { + "type": "string", + "description": "File URL" + }, + { + "type": "object", + "properties": { + "url": { + "type": "string", + "description": "File URL" + }, + "filename": { + "type": "string", + "description": "The name of the file's saved copy" + }, + "referer": { + "type": "string", + "description": "File referer domain" + } + } + } + ] + } + }, + "installer": { + "type": "array", + "description": "Installation script", + "additionalItems": false, + "items": { + "additionalProperties": false, + "type": "object", + "properties": { + "insert-disc": { + "type": "object", + "description": "'Insert disc' dialog", + "properties": { + "requires": { + "description": "Required disk", + "type": "string" + } + }, + "required": [ + "requires" + ] + }, + "move": { + "type": "object", + "description": "Move files and directories", + "properties": { + "src": { + "description": "Source file ID or path", + "type": "string" + }, + "dst": { + "description": "Destination path", + "type": "string" + } + }, + "required": [ + "src", + "dst" + ] + }, + "merge": { + "type": "object", + "description": "Copy and merge directories", + "properties": { + "src": { + "description": "Source file ID or path", + "type": "string" + }, + "dst": { + "description": "Destination path", + "type": "string" + } + }, + "required": [ + "src", + "dst" + ] + }, + "extract": { + "type": "object", + "description": "Copy and merge directories", + "properties": { + "file": { + "description": "Source file ID or path", + "type": "string" + }, + "dst": { + "description": "Destination path", + "type": "string" + }, + "format": { + "description": "Archive's type", + "type": "string", + "enum": [ + "tgz", + "tar", + "zip", + "7z", + "rar", + "txz", + "bz2", + "gzip", + "deb", + "exe", + "gog" + ] + } + }, + "required": [ + "file", + "dst" + ] + }, + "chmodx": { + "type": "string", + "description": "Path to a file to Make executable" + }, + "execute": { + "type": "object", + "description": "Executes a file", + "properties": { + "command": { + "description": "Full bash command to execute", + "type": "string" + }, + "file": { + "description": "File ID or a path to file", + "type": "string" + }, + "args": { + "description": "Executable arguments", + "type": "string" + }, + "terminal": { + "description": "Execute in a new terminal window", + "type": "boolean" + }, + "exclude_processes": { + "description": "Space-separated list of processes to exclude from being monitored when determining if the execute phase finished", + "type": "string" + }, + "include_processes": { + "description": "Space-separated list of processes to monitor when determining if the execute phase finished", + "type": "string" + }, + "disable_runtime": { + "description": "Run a process without Lutris runtime", + "type": "boolean" + }, + "env": { + "$ref": "#/definitions/env" + } + }, + "oneOf": [ + { + "required": [ + "file", + "args" + ] + }, + { + "required": [ + "command" + ] + } + ] + }, + "write_file": { + "type": "object", + "description": "Write text files", + "properties": { + "content": { + "description": "File content to write", + "type": "string" + }, + "file": { + "description": "Destination file pathpath", + "type": "string" + } + }, + "required": [ + "content", + "file" + ] + }, + "write_config": { + "type": "object", + "description": "Write into an INI type config file", + "properties": { + "merge": { + "description": "Truncate the file", + "type": "boolean" + }, + "file": { + "description": "Destination file pathpath", + "type": "string" + }, + "section": { + "description": "INI section to write", + "type": "string" + }, + "key": { + "description": "Property key", + "type": "string" + }, + "value": { + "description": "Property value", + "type": "string" + }, + "data": { + "description": "Free form data to write", + "type": "object" + } + }, + "oneOf": [ + { + "required": [ + "file", + "section", + "key", + "value" + ] + }, + { + "required": [ + "file", + "data" + ] + } + ] + }, + "write_json": { + "type": "object", + "description": "Write into an JSON type file", + "properties": { + "merge": { + "description": "Update the file", + "type": "boolean" + }, + "file": { + "description": "Destination file pathpath", + "type": "string" + }, + "data": { + "description": "Free form data to write", + "type": "object" + } + }, + "required": [ + "file", + "data" + ] + }, + "task": { + "type": "object", + "description": "Run a task provided by the runner" + }, + "input_menu": { + "type": "object", + "description": "Display a drop-down menu with options", + "properties": { + "description": { + "type": "string", + "description": "Dropdown label" + }, + "id": { + "type": "string", + "description": "$INPUT_ reference key" + }, + "options": { + "type": "array", + "description": "Indented list of `value: label` lines to show", + "items": { + "anyOf": [ + { + "type": "string" + } + ] + } + }, + "preselect": { + "type": "string", + "description": "Default selected value" + } + }, + "required": [ + "description", + "options" + ] + } + }, + "oneOf": [ + { + "required": [ + "insert-disk" + ] + }, + { + "required": [ + "move" + ] + }, + { + "required": [ + "merge" + ] + }, + { + "required": [ + "extract" + ] + }, + { + "required": [ + "chmodx" + ] + }, + { + "required": [ + "execute" + ] + }, + { + "required": [ + "write_file" + ] + }, + { + "required": [ + "write_config" + ] + }, + { + "required": [ + "write_json" + ] + }, + { + "required": [ + "write_task" + ] + }, + { + "required": [ + "input_menu" + ] + } + ] + } + }, + "system": { + "type": "object", + "description": "System configuration directives", + "properties": { + "env": { + "$ref": "#/definitions/env" + } + } + }, + "wine": { + "type": "object", + "description": "Wine runner configuration directives" + } + } + } + }, + "definitions": { + "env": { + "description": "Environment variables", + "type": "object", + "patternProperties": { + "": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/schema/installer.schema.yml b/schema/installer.schema.yml new file mode 100644 index 000000000..6c5c65022 --- /dev/null +++ b/schema/installer.schema.yml @@ -0,0 +1,347 @@ +$schema: "http://json-schema.org/draft-07/schema#" +required: + - name + - game_slug + - version + - slug + - runner + - script +description: Lutris install script +type: object +properties: + name: + description: Name of the game, should be surrounded in quotes if containing special characters. + type: string + game_slug: + description: Game identifier on the Lutris website + type: string + version: + description: Name of the installer + type: string + slug: + description: Installer identifier + type: string + require-binaries: + description: Additional binaries + type: string + requires: + description: Mods and add-ons + type: string + extends: + description: Extensions / patches + type: string + install_complete_text: + description: Custom end of install text + type: string + runner: + description: The runner to be used by this game + type: string + enum: + - ags + - atari800 + - browser + - citra + - desmume + - dgen + - dolphin + - dosbox + - frotz + - fsuae + - hatari + - jzintv + - libretro + - linux + - mame + - mednafen + - mupen64plus + - o2em + - openmsx + - osmose + - pcsx2 + - pcsxr + - ppsspp + - reicast + - residualvm + - rpcs3 + - scummvm + - snes9x + - steam + - winesteam + - stella + - vice + - virtualjaguar + - web + - wine + - yuzu + - zdoom + script: + description: Main script + type: object + additionalProperties: true + required: + - game + - installer + patternProperties: + "": + type: object + properties: + game: + # TODO https://github.com/lutris/lutris/blob/master/docs/installers.rst#game-configuration-directives + type: object + description: The game schema + required: + - exe + - args + - prefix + properties: + exe: + type: string + description: The exe schema + args: + type: string + description: The args schema + prefix: + type: string + description: The prefix schema + files: + type: array + description: Fetch required files + items: + anyOf: + - type: string + description: File URL + - type: object + properties: + url: + type: string + description: File URL + filename: + type: string + description: The name of the file's saved copy + referer: + type: string + description: File referer domain + installer: + type: array + description: Installation script + additionalItems: false + items: + additionalProperties: false + type: object + properties: + insert-disc: + type: object + description: "'Insert disc' dialog" + properties: + requires: + description: Required disk + type: string + required: + - requires + move: + type: object + description: Move files and directories + properties: + src: + description: Source file ID or path + type: string + dst: + description: Destination path + type: string + required: + - src + - dst + merge: + type: object + description: Copy and merge directories + properties: + src: + description: Source file ID or path + type: string + dst: + description: Destination path + type: string + required: + - src + - dst + extract: + type: object + description: Copy and merge directories + properties: + file: + description: Source file ID or path + type: string + dst: + description: Destination path + type: string + format: + description: Archive's type + type: string + enum: + - tgz + - tar + - zip + - 7z + - rar + - txz + - bz2 + - gzip + - deb + - exe + - gog + required: + - file + - dst + chmodx: + type: string + description: Path to a file to Make executable + execute: + type: object + description: Executes a file + properties: + command: + description: Full bash command to execute + type: string + file: + description: File ID or a path to file + type: string + args: + description: Executable arguments + type: string + terminal: + description: Execute in a new terminal window + type: boolean + exclude_processes: + description: Space-separated list of processes to exclude from being monitored when determining if the execute phase finished + type: string + include_processes: + description: Space-separated list of processes to monitor when determining if the execute phase finished + type: string + disable_runtime: + description: Run a process without Lutris runtime + type: boolean + env: + $ref: "#/definitions/env" + oneOf: + - required: + - file + - args + - required: + - command + write_file: + type: object + description: Write text files + properties: + content: + description: File content to write + type: string + file: + description: Destination file pathpath + type: string + required: + - content + - file + write_config: + type: object + description: Write into an INI type config file + properties: + merge: + description: Truncate the file + type: boolean + file: + description: Destination file pathpath + type: string + section: + description: INI section to write + type: string + key: + description: Property key + type: string + value: + description: Property value + type: string + data: + description: Free form data to write + type: object + oneOf: + - required: + - file + - section + - key + - value + - required: + - file + - data + write_json: + type: object + description: Write into an JSON type file + properties: + merge: + description: Update the file + type: boolean + file: + description: Destination file pathpath + type: string + data: + description: Free form data to write + type: object + required: + - file + - data + task: + type: object + description: Run a task provided by the runner + # TODO https://github.com/lutris/lutris/blob/master/docs/installers.rst#running-a-task-provided-by-a-runner + input_menu: + type: object + description: Display a drop-down menu with options + properties: + description: + type: string + description: Dropdown label + id: + type: string + description: $INPUT_ reference key + options: + type: array + description: "Indented list of `value: label` lines to show" + items: + anyOf: + - type: string + preselect: + type: string + description: Default selected value + required: + - description + - options + oneOf: + - required: [ insert-disk ] + - required: [ move ] + - required: [ merge ] + - required: [ extract ] + - required: [ chmodx ] + - required: [ execute ] + - required: [ write_file ] + - required: [ write_config ] + - required: [ write_json ] + - required: [ write_task ] + - required: [ input_menu ] + system: + type: object + description: System configuration directives + properties: + env: + $ref: "#/definitions/env" + #TODO https://github.com/lutris/lutris/blob/master/docs/installers.rst#system-configuration-directives + wine: + type: object + description: Wine runner configuration directives + # TODO https://github.com/lutris/lutris/blob/master/docs/installers.rst#wine + +definitions: + env: + description: Environment variables + type: object + patternProperties: + "": + type: string diff --git a/schema/sample.json b/schema/sample.json new file mode 100644 index 000000000..80e1d954d --- /dev/null +++ b/schema/sample.json @@ -0,0 +1,42 @@ +{ + "$schema": "./installer.schema.json", + "name": "", + "game_slug": "", + "version": "", + "slug": "", + "runner": "linux", + "script": { + "game": { + "exe": "", + "args": "", + "prefix": "" + }, + "system": { + "env": { + "a": "" + } + }, + "wine": { + + }, + "files": [ + + ], + "installer": [ + { + "execute": { + "command": "", + "env": { + "a": "" + } + } + }, + { + "move": { + "src": "", + "dst": "" + } + } + ] + } +} diff --git a/schema/sample.yml b/schema/sample.yml new file mode 100644 index 000000000..bba7ef254 --- /dev/null +++ b/schema/sample.yml @@ -0,0 +1,2 @@ +$schema: "./installer.schema.json" + diff --git a/schema/ymlToJson.sh b/schema/ymlToJson.sh new file mode 100755 index 000000000..53843f1ba --- /dev/null +++ b/schema/ymlToJson.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +SELF_DIR="$(dirname "$0")" + +curl -d "$(cat "$SELF_DIR/installer.schema.yml")" \ + -H "Content-Type: text/plain" \ + -H 'Accept: application/json' \ + -o "$SELF_DIR/installer.schema.json" \ + https://www.anyjson.in/api/v2/data/yamltojson