From a2a222a4c78caa18eb0e7d2ec147b5c9d623ca2b Mon Sep 17 00:00:00 2001 From: Trong Nghia Nguyen Date: Sat, 5 May 2018 19:29:19 +0200 Subject: [PATCH 1/4] Re-organize contracts directory structure --- contracts/arch.sw/armel/contract.json | 12 ++++++------ contracts/arch.sw/armhf/contract.json | 19 +++++-------------- contracts/arch.sw/armv7hf/contract.json | 12 ++++++------ contracts/arch.sw/rpi/contract.json | 12 ++++++------ .../vab820-quad/boot-external.tpl | 1 + .../vab820-quad/boot-internal.tpl | 1 + .../vab820-quad/prepare-network.tpl | 1 + 7 files changed, 26 insertions(+), 32 deletions(-) create mode 100644 contracts/hw.device-type/vab820-quad/boot-external.tpl create mode 100644 contracts/hw.device-type/vab820-quad/boot-internal.tpl create mode 100644 contracts/hw.device-type/vab820-quad/prepare-network.tpl diff --git a/contracts/arch.sw/armel/contract.json b/contracts/arch.sw/armel/contract.json index b5cc061c..08767067 100644 --- a/contracts/arch.sw/armel/contract.json +++ b/contracts/arch.sw/armel/contract.json @@ -3,13 +3,13 @@ "version": "1", "type": "arch.sw", "name": "ARM v5", - "data": { "arch": "armel" }, + "arch": "armel", "requires": [ { - "type": "hw.device-type", - "data": { - "arch": "armel" - } + "or": [ + { "type": "hw.device-type", "arch": "armel" } + ] } - ] + ], + "variants": "" } diff --git a/contracts/arch.sw/armhf/contract.json b/contracts/arch.sw/armhf/contract.json index 39a48fd2..3b1ec147 100644 --- a/contracts/arch.sw/armhf/contract.json +++ b/contracts/arch.sw/armhf/contract.json @@ -3,23 +3,14 @@ "version": "1", "type": "arch.sw", "name": "ARM Hard Float", - "data": { "arch": "armhf" }, + "arch": "armhf", "requires": [ { "or": [ - { - "type": "hw.device-type", - "data": { - "arch": "armv7hf" - } - }, - { - "type": "hw.device-type", - "data": { - "arch": "rpi" - } - } + { "type": "hw.device-type", "arch": "armv7hf" }, + { "type": "hw.device-type", "arch": "rpi" } ] } - ] + ], + "variants": "" } diff --git a/contracts/arch.sw/armv7hf/contract.json b/contracts/arch.sw/armv7hf/contract.json index 9f907917..416f20da 100644 --- a/contracts/arch.sw/armv7hf/contract.json +++ b/contracts/arch.sw/armv7hf/contract.json @@ -3,13 +3,13 @@ "version": "1", "type": "arch.sw", "name": "ARM v7", - "data": { "arch": "armv7hf" }, + "arch": "armv7hf", "requires": [ { - "type": "hw.device-type", - "data": { - "arch": "armv7hf" - } + "or": [ + { "type": "hw.device-type", "arch": "armv7hf" } + ] } - ] + ], + "variants": "" } diff --git a/contracts/arch.sw/rpi/contract.json b/contracts/arch.sw/rpi/contract.json index 023c5c1c..67695ef5 100644 --- a/contracts/arch.sw/rpi/contract.json +++ b/contracts/arch.sw/rpi/contract.json @@ -3,13 +3,13 @@ "version": "1", "type": "arch.sw", "name": "ARM v6", - "data": { "arch": "armv6hf" }, + "arch": "armv6hf", "requires": [ { - "type": "hw.device-type", - "data": { - "arch": "rpi" - } + "or": [ + { "type": "hw.device-type", "arch": "rpi" } + ] } - ] + ], + "variants": "" } diff --git a/contracts/hw.device-type/vab820-quad/boot-external.tpl b/contracts/hw.device-type/vab820-quad/boot-external.tpl new file mode 100644 index 00000000..10cbe6fc --- /dev/null +++ b/contracts/hw.device-type/vab820-quad/boot-external.tpl @@ -0,0 +1 @@ +Set boot selector to boot from {{hw.device-type.media.installation}}, this will depend on what base carrier board you are using. Now apply power to the board diff --git a/contracts/hw.device-type/vab820-quad/boot-internal.tpl b/contracts/hw.device-type/vab820-quad/boot-internal.tpl new file mode 100644 index 00000000..8f7965d3 --- /dev/null +++ b/contracts/hw.device-type/vab820-quad/boot-internal.tpl @@ -0,0 +1 @@ +Set the J11 jumper to position 1-2 and Replug the power cable for the {{hw.device-type.name}} to power it back up diff --git a/contracts/hw.device-type/vab820-quad/prepare-network.tpl b/contracts/hw.device-type/vab820-quad/prepare-network.tpl new file mode 100644 index 00000000..7ef8d976 --- /dev/null +++ b/contracts/hw.device-type/vab820-quad/prepare-network.tpl @@ -0,0 +1 @@ +Ensure the Wifi dongle is attached to your device, and that the ethernet cable is plugged into your device and leads to an internet-connected router From d89eaf80df2a26a8f51c7af6f83aee6e50ddbc77 Mon Sep 17 00:00:00 2001 From: Trong Nghia Nguyen Date: Wed, 9 May 2018 09:49:36 +0700 Subject: [PATCH 2/4] Update comments --- contracts/arch.sw/armel/contract.json | 12 ++++++------ contracts/arch.sw/armhf/contract.json | 19 ++++++++++++++----- contracts/arch.sw/armv7hf/contract.json | 12 ++++++------ contracts/arch.sw/rpi/contract.json | 12 ++++++------ .../vab820-quad/boot-external.tpl | 1 - .../vab820-quad/boot-internal.tpl | 1 - .../vab820-quad/prepare-network.tpl | 1 - 7 files changed, 32 insertions(+), 26 deletions(-) delete mode 100644 contracts/hw.device-type/vab820-quad/boot-external.tpl delete mode 100644 contracts/hw.device-type/vab820-quad/boot-internal.tpl delete mode 100644 contracts/hw.device-type/vab820-quad/prepare-network.tpl diff --git a/contracts/arch.sw/armel/contract.json b/contracts/arch.sw/armel/contract.json index 08767067..b5cc061c 100644 --- a/contracts/arch.sw/armel/contract.json +++ b/contracts/arch.sw/armel/contract.json @@ -3,13 +3,13 @@ "version": "1", "type": "arch.sw", "name": "ARM v5", - "arch": "armel", + "data": { "arch": "armel" }, "requires": [ { - "or": [ - { "type": "hw.device-type", "arch": "armel" } - ] + "type": "hw.device-type", + "data": { + "arch": "armel" + } } - ], - "variants": "" + ] } diff --git a/contracts/arch.sw/armhf/contract.json b/contracts/arch.sw/armhf/contract.json index 3b1ec147..39a48fd2 100644 --- a/contracts/arch.sw/armhf/contract.json +++ b/contracts/arch.sw/armhf/contract.json @@ -3,14 +3,23 @@ "version": "1", "type": "arch.sw", "name": "ARM Hard Float", - "arch": "armhf", + "data": { "arch": "armhf" }, "requires": [ { "or": [ - { "type": "hw.device-type", "arch": "armv7hf" }, - { "type": "hw.device-type", "arch": "rpi" } + { + "type": "hw.device-type", + "data": { + "arch": "armv7hf" + } + }, + { + "type": "hw.device-type", + "data": { + "arch": "rpi" + } + } ] } - ], - "variants": "" + ] } diff --git a/contracts/arch.sw/armv7hf/contract.json b/contracts/arch.sw/armv7hf/contract.json index 416f20da..9f907917 100644 --- a/contracts/arch.sw/armv7hf/contract.json +++ b/contracts/arch.sw/armv7hf/contract.json @@ -3,13 +3,13 @@ "version": "1", "type": "arch.sw", "name": "ARM v7", - "arch": "armv7hf", + "data": { "arch": "armv7hf" }, "requires": [ { - "or": [ - { "type": "hw.device-type", "arch": "armv7hf" } - ] + "type": "hw.device-type", + "data": { + "arch": "armv7hf" + } } - ], - "variants": "" + ] } diff --git a/contracts/arch.sw/rpi/contract.json b/contracts/arch.sw/rpi/contract.json index 67695ef5..023c5c1c 100644 --- a/contracts/arch.sw/rpi/contract.json +++ b/contracts/arch.sw/rpi/contract.json @@ -3,13 +3,13 @@ "version": "1", "type": "arch.sw", "name": "ARM v6", - "arch": "armv6hf", + "data": { "arch": "armv6hf" }, "requires": [ { - "or": [ - { "type": "hw.device-type", "arch": "rpi" } - ] + "type": "hw.device-type", + "data": { + "arch": "rpi" + } } - ], - "variants": "" + ] } diff --git a/contracts/hw.device-type/vab820-quad/boot-external.tpl b/contracts/hw.device-type/vab820-quad/boot-external.tpl deleted file mode 100644 index 10cbe6fc..00000000 --- a/contracts/hw.device-type/vab820-quad/boot-external.tpl +++ /dev/null @@ -1 +0,0 @@ -Set boot selector to boot from {{hw.device-type.media.installation}}, this will depend on what base carrier board you are using. Now apply power to the board diff --git a/contracts/hw.device-type/vab820-quad/boot-internal.tpl b/contracts/hw.device-type/vab820-quad/boot-internal.tpl deleted file mode 100644 index 8f7965d3..00000000 --- a/contracts/hw.device-type/vab820-quad/boot-internal.tpl +++ /dev/null @@ -1 +0,0 @@ -Set the J11 jumper to position 1-2 and Replug the power cable for the {{hw.device-type.name}} to power it back up diff --git a/contracts/hw.device-type/vab820-quad/prepare-network.tpl b/contracts/hw.device-type/vab820-quad/prepare-network.tpl deleted file mode 100644 index 7ef8d976..00000000 --- a/contracts/hw.device-type/vab820-quad/prepare-network.tpl +++ /dev/null @@ -1 +0,0 @@ -Ensure the Wifi dongle is attached to your device, and that the ethernet cable is plugged into your device and leads to an internet-connected router From b4f10f6886b8e266bf9fee5c66a102431e8a29e1 Mon Sep 17 00:00:00 2001 From: Giovanni Garufi Date: Mon, 21 May 2018 12:01:36 +0200 Subject: [PATCH 3/4] Added schema and contracts for blueprints. Change-type: minor --- .../device-instructions/contract.json | 28 +++++++++ .../docker-images-base/contract.json | 33 ++++++++++ .../docker-images-device-type/contract.json | 26 ++++++++ schema/sw.blueprint.json | 60 +++++++++++++++++++ 4 files changed, 147 insertions(+) create mode 100644 contracts/sw.blueprint/device-instructions/contract.json create mode 100644 contracts/sw.blueprint/docker-images-base/contract.json create mode 100644 contracts/sw.blueprint/docker-images-device-type/contract.json create mode 100644 schema/sw.blueprint.json diff --git a/contracts/sw.blueprint/device-instructions/contract.json b/contracts/sw.blueprint/device-instructions/contract.json new file mode 100644 index 00000000..27f3d0f9 --- /dev/null +++ b/contracts/sw.blueprint/device-instructions/contract.json @@ -0,0 +1,28 @@ +{ + "slug": "device-instructions", + "type": "sw.blueprint", + "version": "1", + "componentVersion": "1", + "aliases": [], + "tags": [], + + "data": { + "selector": { + "sw.os": "1", + "sw.image-writer": "1", + "hw.device-type": "1", + "sw.platform": "1" + }, + "output": { + "filename": "README.txt", + "type": "doc.instructions.device", + "slug": "{{children.sw.platform.slug}}-{{children.hw.device-type.slug}}:{{children.sw.os.slug}}-{{children.sw.os.version}}:{{children.sw.image-writer.slug}}", + "template": [ + { + "name": "instructions", + "data": "1. {{import partial=\"download\" combination=\"sw.os\"}} 2. {{import partial=\"download\" combination=\"sw.image-writer\"}}. {{import partial=\"flash\" combination=\"sw.image-writer+hw.device-type\"}}. 3. {{import partial=\"insert-install-media\" combination=\"hw.device-type\"}}. {{import partial=\"prepare-network\" combination=\"hw.device-type\"}}. {{import partial=\"boot-external\" combination=\"hw.device-type\"}} {{#hw.device-type.storage.internal}} 4. The device should appear on you dashboard in a configuring state. {{import partial=\"description-of-internal-process\" combination=\"sw.image-writer\"}}. {{import partial=\"visual-appearance-when-off\" combination=\"hw.device-type\"}} 5. {{import partial=\"remove-install-media\" combination=\"hw.device-type\"}}. {{import partial=\"boot-internal\" combination=\"hw.device-type\"}} {{/hw.device-type.storage.internal}} 6. Your device should appear here in the IDLE state in 30 seconds or so. Have fun! **Troubleshooting:** If, upon boot, the device LED is blinking in groups of four, it is an indication that the device cannot connect to the internet. Please ensure the network adapter is functional. {{#compare hw.device-type.media.installation \"!==\" \"dfu\"}} **Pro tip:** You can repeat the initialisation steps for any amount of {{hw.device-type.name}}'s you have available, using the same {{hw.device-type.media.installation}}. {{/compare}}" + } + ] + } + } +} diff --git a/contracts/sw.blueprint/docker-images-base/contract.json b/contracts/sw.blueprint/docker-images-base/contract.json new file mode 100644 index 00000000..5afa04d7 --- /dev/null +++ b/contracts/sw.blueprint/docker-images-base/contract.json @@ -0,0 +1,33 @@ +{ + "slug": "docker-images-base", + "type": "sw.blueprint", + "version": "1", + "componentVersion": "1", + "aliases": [], + "tags": [], + + "data": { + "selector": { + "sw.os": "1", + "sw.arch": "1", + "sw.blob": "1+" + }, + "output": { + "filename": "Dockerfile", + "type": "sw.docker-image.base", + "slug": "{{children.sw.arch.slug}}-{{children.sw.os.slug}}:{{children.sw.os.version}}", + "requires": [ + { + "type": "hw.device-type", + "arch": "{{children.sw.arch.slug}}" + } + ], + "template": [ + { + "name": "docker-images", + "data": "{{import partial=\"from\" combination=\"sw.os+sw.arch\"}}\nLABEL io.resin.architecture=\"{{sw.arch.slug}}\"\n{{import partial=\"os-config\" combination=\"sw.os+sw.arch\"}}\n{{#sw.blob.qemu}} {{import partial=\"qemu\" combination=\"sw.os+sw.arch\"}} {{/sw.blob.qemu}}\n{{import partial=\"base-dependencies\" combination=\"sw.os+sw.arch\"}}\nCOPY {{sw.blob.resin-xbuild.assets.bin.main}} /usr/bin/\nRUN ln -s {{sw.blob.resin-xbuild.assets.bin.main}} /usr/bin/cross-build-start \\\n && ln -s {{sw.blob.resin-xbuild.assets.bin.main}} /usr/bin/cross-build-end\n\nENV TINI_VERSION {{sw.blob.tini.version}}\nRUN chmod +x {{sw.blob.tini.assets.bin.main}} \\\n && mv {{sw.blob.tini.assets.bin.main}} /sbin/tini\n\n{{import partial=\"init-system\" combination=\"sw.os+sw.arch\"}}" + } + ] + } + } +} diff --git a/contracts/sw.blueprint/docker-images-device-type/contract.json b/contracts/sw.blueprint/docker-images-device-type/contract.json new file mode 100644 index 00000000..cafa452a --- /dev/null +++ b/contracts/sw.blueprint/docker-images-device-type/contract.json @@ -0,0 +1,26 @@ +{ + "slug": "docker-images-device-type", + "type": "sw.blueprint", + "version": "1", + "componentVersion": "1", + "aliases": [], + "tags": [], + + "data": { + "selector": { + "hw.device-type": "1", + "sw.docker-image.base": "1" + }, + "output": { + "filename": "Dockerfile", + "type": "sw.docker-image.device-type", + "slug": "{{children.hw.device-type.slug}}-{{children.sw.docker-image.base.children.sw.os.slug}}:{{children.hw.device-type.version}}-{{children.sw.docker-image.base.children.sw.os.version}}", + "template": [ + { + "name": "docker-images", + "data": "FROM resin/{{sw.docker-image.base.slug}}\nLABEL io.resin.device-type=\"{{hw.device-type.slug}}\"\n{{import partial=\"distro-config\" combination=\"sw.os+hw.device-type\"}}\n{{import partial=\"dependencies\" combination=\"sw.os+hw.device-type\"}}" + } + ] + } + } +} diff --git a/schema/sw.blueprint.json b/schema/sw.blueprint.json new file mode 100644 index 00000000..e8d4df93 --- /dev/null +++ b/schema/sw.blueprint.json @@ -0,0 +1,60 @@ +{ + "$id": "sw.blueprint.json", + "type": "object", + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "data": { + "type": "object", + "properties": { + "selector": { + "$id": "/properties/selector", + "type": "object", + "patternProperties": { + "^.*$": { + "type": "string", + } + } + }, + "output": { + "$id": "/properties/output", + "type": "object", + "additionalProperties": false, + "allOf": [ + { + "$ref": "contract.json#/definitions/partialContract" + }, + { + "properties": { + "filename": { + "$id": "/properties/output/properties/filename", + "type": "string" + }, + "template": { + "$id": "/properties/output/properties/template", + "type": "array", + "additionalItems": false, + "items": { + "$id": "/properties/output/properties/template/items", + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "$id": "/properties/output/properties/template/items/properties/name", + "type": "string" + }, + "data": { + "$id": "/properties/output/properties/template/items/properties/data", + "type": "string" + } + } + } + } + } + } + ] + } + } + } + } +} From 11cf69c31e6895b0c5bd88ece72ca1508183125b Mon Sep 17 00:00:00 2001 From: Giovanni Garufi Date: Tue, 22 May 2018 10:57:28 +0200 Subject: [PATCH 4/4] Updated according to review --- schema/sw.blueprint.json | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/schema/sw.blueprint.json b/schema/sw.blueprint.json index e8d4df93..31f78992 100644 --- a/schema/sw.blueprint.json +++ b/schema/sw.blueprint.json @@ -12,7 +12,18 @@ "type": "object", "patternProperties": { "^.*$": { - "type": "string", + "anyOf": [ + { + "type": "string", + }, + { + "type": "array", + "additionalItems": false, + "items": { + "type": "string" + } + } + ] } } }, @@ -28,7 +39,8 @@ "properties": { "filename": { "$id": "/properties/output/properties/filename", - "type": "string" + "type": "string", + "pattern": "^(\\.\\.\/|[a-zA-Z0-9_/\\\\-])*\\.[a-zA-Z0-9]+$" }, "template": { "$id": "/properties/output/properties/template", @@ -47,10 +59,12 @@ "$id": "/properties/output/properties/template/items/properties/data", "type": "string" } - } + }, + "required": [ "name", "data" ] } } - } + }, + "required": [ "properties", "template" ] } ] }