diff options
author | Anton Gerasimov <anton@advancedtelematic.com> | 2016-11-08 11:23:19 +0100 |
---|---|---|
committer | Anton Gerasimov <anton@advancedtelematic.com> | 2016-11-08 18:43:07 +0100 |
commit | 937f38696039d236f813340115efac14e189672f (patch) | |
tree | 43443ed9517a35151b9794fe8101a506d780b44a | |
parent | 34dc600256134efd8013e614105b0f4ca74c8e37 (diff) | |
download | meta-updater-937f38696039d236f813340115efac14e189672f.tar.gz |
A tool for uploading OSTree objects to a server together with
integration code
Bug-AGL: SPEC-194
Change-Id: I650e190bbda67ad48233bc5aedc0c10ff14aa58f
Signed-off-by: Anton Gerasimov <anton@advancedtelematic.com>
-rw-r--r-- | README.md | 107 | ||||
-rw-r--r-- | classes/image_types_ostree.bbclass | 19 | ||||
-rw-r--r-- | recipes-sota/sota-tools/sota-tools_git.bb | 24 |
3 files changed, 150 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..0e47cf6 --- /dev/null +++ b/README.md | |||
@@ -0,0 +1,107 @@ | |||
1 | meta-sota | ||
2 | ========= | ||
3 | |||
4 | This layer enables over-the-air updates with OSTree and RVI SOTA client. | ||
5 | |||
6 | [OSTree](https://github.com/ostreedev/ostree) is a tool for atomic full file | ||
7 | system upgrades with rollback capability. Main advantage of OSTree compared | ||
8 | to traditional dual partition model is that OSTree minimizes network bandwidth | ||
9 | and data storage footprint by sharing files with the same contents across file | ||
10 | system deployments. | ||
11 | |||
12 | [RVI SOTA client](https://github.com/advancedtelematic/rvi_sota_client) adds | ||
13 | authentication and provisioning capabilities to OTA and is integrated with | ||
14 | OSTree. | ||
15 | |||
16 | Build | ||
17 | ----- | ||
18 | |||
19 | With AGL you can just add agl-sota feature while configuring your build | ||
20 | environment as in | ||
21 | |||
22 | source meta-agl/scripts/aglsetup.sh -m porter agl-demo agl-appfw-smack agl-devel agl-sota | ||
23 | |||
24 | you can then just run | ||
25 | |||
26 | bitbake agl-demo-platform | ||
27 | |||
28 | and get as a result "ostree_repo" folder in your images directory | ||
29 | (tmp/deploy/images/${MACHINE}/ostree_repo) containing your OSTree repository | ||
30 | with rootfs committed as an OSTree deployment, 'otaimg' bootstrap image which | ||
31 | is an OSTree physical sysroot as a burnable filesystem image and optionally | ||
32 | some machine-dependent live images (e.g. '*.rpi-sdimg-ota' for Raspberry Pi or | ||
33 | '*.porter-sdimg-ota' Renesas Porter board). | ||
34 | |||
35 | Although aglsetup.sh hooks provide reasonable defaults for SOTA-related | ||
36 | variables you may want to tune some of them. | ||
37 | |||
38 | SOTA-related variables in local.conf | ||
39 | ------------------------------------ | ||
40 | |||
41 | * OSTREE_REPO - path to your OSTree repository. | ||
42 | Defaults to "${DEPLOY_DIR_IMAGE}/ostree_repo" | ||
43 | * OSTREE_BRANCHNAME - the branch your rootfs will be committed to. | ||
44 | Defaults to "agl-ota" | ||
45 | * OSTREE_OSNAME - OS deployment name on your target device. For more | ||
46 | information about deployments and osnames see | ||
47 | [OSTree documentation](https://ostree.readthedocs.io/en/latest/manual/deployment/) | ||
48 | Defaults to "agl". | ||
49 | * OSTREE_INITRAMFS_IMAGE - initramfs/initrd image that is used as a proxy while | ||
50 | booting into OSTree deployment. Do not change this setting unless you are | ||
51 | sure that your initramfs can serve as such proxy. | ||
52 | * OSTREE_REMOTE_URL - when set adds pushing your ostree commit to a remote | ||
53 | repo. Defaults to an empty string. | ||
54 | * OSTREE_REMOTE_USER and OSTREE_REMOTE_PASSWORD - should be set if | ||
55 | OSTREE_REMOTE_URL is set. Used to authenticate to the server set in | ||
56 | OSTREE_REMOTE_URL. Both default to an empty string. | ||
57 | |||
58 | Usage | ||
59 | ----- | ||
60 | |||
61 | ### OSTree ### | ||
62 | OSTree includes its own simple http server. It just exposes the whole OSTree | ||
63 | repository to the network so that any remote device can pull data from it to | ||
64 | device's local repository. To use OSTree http server you need OSTree installed | ||
65 | on your build machine. Alternatively, you could run version built inside Yocto | ||
66 | using bitbake's [devshell](http://www.openembedded.org/wiki/Devshell). | ||
67 | |||
68 | To expose your repo run ostree trivial-httpd using any free port. | ||
69 | |||
70 | ostree trivial-httpd tmp/deploy/images/qemux86-64/ostree_repo -P 57556 | ||
71 | |||
72 | You can then run from inside your device or QEMU emulation, provided your | ||
73 | network is set up correctly. | ||
74 | |||
75 | # agl-remote identifies the remote server in your local repo | ||
76 | ostree remote add --no-gpg-verify agl-remote http://192.168.7.1:57556 agl-ota | ||
77 | |||
78 | # agl-ota is a branch name in the remote repo, set in OSTREE_BRANCHNAME | ||
79 | ostree pull agl-remote agl-ota | ||
80 | |||
81 | # agl is OS name as set in OSTREE_OSNAME | ||
82 | ostree admin deploy --os=agl agl-remote:agl-ota | ||
83 | |||
84 | After restart you should boot into the newly deployed OS image. | ||
85 | |||
86 | E.g. for the raspberrypi3 you can try this sequence: | ||
87 | |||
88 | # add remote | ||
89 | ostree remote add --no-gpg-verify agl-snapshot https://download.automotivelinux.org/AGL/snapshots/master/latest/raspberrypi3/deploy/images/raspberrypi3/ostree_repo/ agl-ota | ||
90 | |||
91 | # pull | ||
92 | ostree pull agl-snapshot agl-ota | ||
93 | |||
94 | # deploy | ||
95 | ostree admin deploy --os=agl agl-snapshot:agl-ota | ||
96 | |||
97 | ### SOTA tools ### | ||
98 | SOTA tools now contains only one tool, garage-push that lets you push the | ||
99 | changes in OSTree repository generated by bitbake process. It communicates with | ||
100 | an http server capable of querying files with HEAD requests and uploading them | ||
101 | with POST requests. garage-push is used as following: | ||
102 | |||
103 | garage-push --repo=/path/to/ostree-repo --ref=mybranch --url=https://my.ostree.server/ --user=username --password=password | ||
104 | |||
105 | You can set OSTREE_REMOTE_URL, OSTREE_REMOTE_USER and OSTREE_REMOTE_PASSWORD in | ||
106 | your local.conf to make your build results be automatically synchronized with a | ||
107 | remote server. | ||
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index fcba6d9..453692e 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
@@ -124,3 +124,22 @@ IMAGE_CMD_ostree () { | |||
124 | rm -rf ${OSTREE_ROOTFS} | 124 | rm -rf ${OSTREE_ROOTFS} |
125 | } | 125 | } |
126 | 126 | ||
127 | IMAGE_TYPEDEP_ostreepush = "ostree" | ||
128 | IMAGE_DEPENDS_ostreepush = "sota-tools-native:do_populate_sysroot" | ||
129 | IMAGE_CMD_ostreepush () { | ||
130 | if [ ${OSTREE_REMOTE_URL} ]; then | ||
131 | if [ -z ${OSTREE_REMOTE_USER} ]; then | ||
132 | bberror "OSTREE_REMOTE_PASSWORD isn't set" | ||
133 | fi | ||
134 | |||
135 | if [ -z ${OSTREE_REMOTE_PASSWORD} ]; then | ||
136 | bberror "OSTREE_REMOTE_PASSWORD isn't set" | ||
137 | fi | ||
138 | |||
139 | garage-push --repo=${OSTREE_REPO} \ | ||
140 | --ref=${OSTREE_BRANCHNAME} \ | ||
141 | --url=${OSTREE_REMOTE_URL} \ | ||
142 | --user=${OSTREE_REMOTE_USER} \ | ||
143 | --password=${OSTREE_REMOTE_PASSWORD} | ||
144 | fi | ||
145 | } | ||
diff --git a/recipes-sota/sota-tools/sota-tools_git.bb b/recipes-sota/sota-tools/sota-tools_git.bb new file mode 100644 index 0000000..acd8e4a --- /dev/null +++ b/recipes-sota/sota-tools/sota-tools_git.bb | |||
@@ -0,0 +1,24 @@ | |||
1 | DESCRIPTION = "Utility to push data to a server" | ||
2 | LICENSE = "MPL-2.0" | ||
3 | |||
4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=65d26fcc2f35ea6a181ac777e42db1ea" | ||
5 | |||
6 | S = "${WORKDIR}/git" | ||
7 | |||
8 | SRC_URI = "gitsm://github.com/advancedtelematic/sota-tools.git;branch=master" | ||
9 | SRCREV = "7ff1d92c161ba4fb047a1e1e4cba5424b4adca00" | ||
10 | |||
11 | inherit cmake | ||
12 | |||
13 | DEPENDS = "boost" | ||
14 | |||
15 | BBCLASSEXTEND = "native" | ||
16 | |||
17 | FILES_${PN} = "${bindir}/garage-push" | ||
18 | |||
19 | EXTRA_OECMAKE = "-DWARNING_AS_ERROR=OFF" | ||
20 | |||
21 | do_install() { | ||
22 | install -d ${D}/${bindir} | ||
23 | install -m 755 garage-push ${D}/${bindir} | ||
24 | } | ||