diff options
author | Patrick Vacek <patrickvacek@gmail.com> | 2017-10-06 15:39:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-06 15:39:40 +0200 |
commit | 36f1d8668a0ccdfe7f71f886a6829fb33be7cb48 (patch) | |
tree | 93e9b2d5eee766fab22dd1edca902ab5d7f15719 | |
parent | e789ff50f9d11f838a3e1cd985cb3ae34c1ca764 (diff) | |
parent | 2bce8708ca8be6931d9f524df735694d3c77a984 (diff) | |
download | meta-updater-36f1d8668a0ccdfe7f71f886a6829fb33be7cb48.tar.gz |
Merge pull request #143 from advancedtelematic/feat/PRO-3799/implicit-writer
Feat/pro 3799/implicit writer
-rw-r--r-- | classes/image_types_ostree.bbclass | 345 | ||||
-rw-r--r-- | classes/sota_bleeding.inc | 1 | ||||
-rw-r--r-- | recipes-sota/aktualizr/aktualizr-auto-prov.bb | 41 | ||||
-rw-r--r-- | recipes-sota/aktualizr/aktualizr-implicit-prov.bb | 34 | ||||
-rw-r--r-- | recipes-sota/aktualizr/aktualizr-native_git.bb | 16 | ||||
-rw-r--r-- | recipes-sota/aktualizr/aktualizr_common.inc | 19 | ||||
-rw-r--r-- | recipes-sota/aktualizr/aktualizr_git.bb | 29 | ||||
-rw-r--r-- | recipes-sota/aktualizr/files/sota_implicit_prov.toml | 11 |
8 files changed, 273 insertions, 223 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 97da1db..adcafe3 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
@@ -2,13 +2,11 @@ | |||
2 | 2 | ||
3 | inherit image | 3 | inherit image |
4 | 4 | ||
5 | IMAGE_DEPENDS_ostree = "ostree-native:do_populate_sysroot \ | 5 | IMAGE_DEPENDS_ostree = "ostree-native:do_populate_sysroot \ |
6 | openssl-native:do_populate_sysroot \ | 6 | openssl-native:do_populate_sysroot \ |
7 | zip-native:do_populate_sysroot \ | 7 | coreutils-native:do_populate_sysroot \ |
8 | coreutils-native:do_populate_sysroot \ | 8 | virtual/kernel:do_deploy \ |
9 | virtual/kernel:do_deploy \ | 9 | ${OSTREE_INITRAMFS_IMAGE}:do_image_complete" |
10 | ${OSTREE_INITRAMFS_IMAGE}:do_image_complete \ | ||
11 | unzip-native" | ||
12 | 10 | ||
13 | export OSTREE_REPO | 11 | export OSTREE_REPO |
14 | export OSTREE_BRANCHNAME | 12 | export OSTREE_BRANCHNAME |
@@ -21,202 +19,161 @@ OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" | |||
21 | export SYSTEMD_USED = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', '', d)}" | 19 | export SYSTEMD_USED = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', '', d)}" |
22 | 20 | ||
23 | IMAGE_CMD_ostree () { | 21 | IMAGE_CMD_ostree () { |
24 | if [ -z "$OSTREE_REPO" ]; then | 22 | if [ -z "$OSTREE_REPO" ]; then |
25 | bbfatal "OSTREE_REPO should be set in your local.conf" | 23 | bbfatal "OSTREE_REPO should be set in your local.conf" |
26 | fi | ||
27 | |||
28 | if [ -z "$OSTREE_BRANCHNAME" ]; then | ||
29 | bbfatal "OSTREE_BRANCHNAME should be set in your local.conf" | ||
30 | fi | ||
31 | |||
32 | OSTREE_ROOTFS=`mktemp -du ${WORKDIR}/ostree-root-XXXXX` | ||
33 | cp -a ${IMAGE_ROOTFS} ${OSTREE_ROOTFS} | ||
34 | chmod a+rx ${OSTREE_ROOTFS} | ||
35 | sync | ||
36 | |||
37 | cd ${OSTREE_ROOTFS} | ||
38 | |||
39 | # Create sysroot directory to which physical sysroot will be mounted | ||
40 | mkdir sysroot | ||
41 | ln -sf sysroot/ostree ostree | ||
42 | |||
43 | rm -rf tmp/* | ||
44 | ln -sf sysroot/tmp tmp | ||
45 | |||
46 | mkdir -p usr/rootdirs | ||
47 | |||
48 | mv etc usr/ | ||
49 | # Implement UsrMove | ||
50 | dirs="bin sbin lib" | ||
51 | |||
52 | for dir in ${dirs} ; do | ||
53 | if [ -d ${dir} ] && [ ! -L ${dir} ] ; then | ||
54 | mv ${dir} usr/rootdirs/ | ||
55 | rm -rf ${dir} | ||
56 | ln -sf usr/rootdirs/${dir} ${dir} | ||
57 | fi | ||
58 | done | ||
59 | |||
60 | if [ -n "$SYSTEMD_USED" ]; then | ||
61 | mkdir -p usr/etc/tmpfiles.d | ||
62 | tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf | ||
63 | echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf} | ||
64 | echo "L /var/rootdirs/home - - - - /sysroot/home" >>${tmpfiles_conf} | ||
65 | else | ||
66 | mkdir -p usr/etc/init.d | ||
67 | tmpfiles_conf=usr/etc/init.d/tmpfiles.sh | ||
68 | echo '#!/bin/sh' > ${tmpfiles_conf} | ||
69 | echo "mkdir -p /var/rootdirs; chmod 755 /var/rootdirs" >> ${tmpfiles_conf} | ||
70 | echo "ln -sf /sysroot/home /var/rootdirs/home" >> ${tmpfiles_conf} | ||
71 | |||
72 | ln -s ../init.d/tmpfiles.sh usr/etc/rcS.d/S20tmpfiles.sh | ||
73 | fi | ||
74 | |||
75 | # Preserve OSTREE_BRANCHNAME for future information | ||
76 | mkdir -p usr/share/sota/ | ||
77 | echo -n "${OSTREE_BRANCHNAME}" > usr/share/sota/branchname | ||
78 | |||
79 | # Preserve data in /home to be later copied to /sysroot/home by | ||
80 | # sysroot generating procedure | ||
81 | mkdir -p usr/homedirs | ||
82 | if [ -d "home" ] && [ ! -L "home" ]; then | ||
83 | mv home usr/homedirs/home | ||
84 | ln -sf var/rootdirs/home home | ||
85 | fi | ||
86 | |||
87 | # Move persistent directories to /var | ||
88 | dirs="opt mnt media srv" | ||
89 | |||
90 | for dir in ${dirs}; do | ||
91 | if [ -d ${dir} ] && [ ! -L ${dir} ]; then | ||
92 | if [ "$(ls -A $dir)" ]; then | ||
93 | bbwarn "Data in /$dir directory is not preserved by OSTree. Consider moving it under /usr" | ||
94 | fi | ||
95 | |||
96 | if [ -n "$SYSTEMD_USED" ]; then | ||
97 | echo "d /var/rootdirs/${dir} 0755 root root -" >>${tmpfiles_conf} | ||
98 | else | ||
99 | echo "mkdir -p /var/rootdirs/${dir}; chown 755 /var/rootdirs/${dir}" >>${tmpfiles_conf} | ||
100 | fi | ||
101 | rm -rf ${dir} | ||
102 | ln -sf var/rootdirs/${dir} ${dir} | ||
103 | fi | ||
104 | done | ||
105 | |||
106 | if [ -d root ] && [ ! -L root ]; then | ||
107 | if [ "$(ls -A root)" ]; then | ||
108 | bberror "Data in /root directory is not preserved by OSTree." | ||
109 | fi | ||
110 | |||
111 | if [ -n "$SYSTEMD_USED" ]; then | ||
112 | echo "d /var/roothome 0755 root root -" >>${tmpfiles_conf} | ||
113 | else | ||
114 | echo "mkdir -p /var/roothome; chown 755 /var/roothome" >>${tmpfiles_conf} | ||
115 | fi | ||
116 | |||
117 | rm -rf root | ||
118 | ln -sf var/roothome root | ||
119 | fi | ||
120 | |||
121 | mkdir -p var/sota | ||
122 | |||
123 | if [ -n "${SOTA_AUTOPROVISION_CREDENTIALS}" ]; then | ||
124 | bbwarn "SOTA_AUTOPROVISION_CREDENTIALS are ignored. Please use SOTA_PACKED_CREDENTIALS" | ||
125 | fi | 24 | fi |
126 | if [ -n "${SOTA_AUTOPROVISION_URL}" ]; then | 25 | |
127 | bbwarn "SOTA_AUTOPROVISION_URL is ignored. Please use SOTA_PACKED_CREDENTIALS" | 26 | if [ -z "$OSTREE_BRANCHNAME" ]; then |
27 | bbfatal "OSTREE_BRANCHNAME should be set in your local.conf" | ||
28 | fi | ||
29 | |||
30 | OSTREE_ROOTFS=`mktemp -du ${WORKDIR}/ostree-root-XXXXX` | ||
31 | cp -a ${IMAGE_ROOTFS} ${OSTREE_ROOTFS} | ||
32 | chmod a+rx ${OSTREE_ROOTFS} | ||
33 | sync | ||
34 | |||
35 | cd ${OSTREE_ROOTFS} | ||
36 | |||
37 | # Create sysroot directory to which physical sysroot will be mounted | ||
38 | mkdir sysroot | ||
39 | ln -sf sysroot/ostree ostree | ||
40 | |||
41 | rm -rf tmp/* | ||
42 | ln -sf sysroot/tmp tmp | ||
43 | |||
44 | mkdir -p usr/rootdirs | ||
45 | |||
46 | mv etc usr/ | ||
47 | # Implement UsrMove | ||
48 | dirs="bin sbin lib" | ||
49 | |||
50 | for dir in ${dirs} ; do | ||
51 | if [ -d ${dir} ] && [ ! -L ${dir} ] ; then | ||
52 | mv ${dir} usr/rootdirs/ | ||
53 | rm -rf ${dir} | ||
54 | ln -sf usr/rootdirs/${dir} ${dir} | ||
55 | fi | ||
56 | done | ||
57 | |||
58 | if [ -n "$SYSTEMD_USED" ]; then | ||
59 | mkdir -p usr/etc/tmpfiles.d | ||
60 | tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf | ||
61 | echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf} | ||
62 | echo "L /var/rootdirs/home - - - - /sysroot/home" >>${tmpfiles_conf} | ||
63 | else | ||
64 | mkdir -p usr/etc/init.d | ||
65 | tmpfiles_conf=usr/etc/init.d/tmpfiles.sh | ||
66 | echo '#!/bin/sh' > ${tmpfiles_conf} | ||
67 | echo "mkdir -p /var/rootdirs; chmod 755 /var/rootdirs" >> ${tmpfiles_conf} | ||
68 | echo "ln -sf /sysroot/home /var/rootdirs/home" >> ${tmpfiles_conf} | ||
69 | |||
70 | ln -s ../init.d/tmpfiles.sh usr/etc/rcS.d/S20tmpfiles.sh | ||
71 | fi | ||
72 | |||
73 | # Preserve OSTREE_BRANCHNAME for future information | ||
74 | mkdir -p usr/share/sota/ | ||
75 | echo -n "${OSTREE_BRANCHNAME}" > usr/share/sota/branchname | ||
76 | |||
77 | # Preserve data in /home to be later copied to /sysroot/home by sysroot | ||
78 | # generating procedure | ||
79 | mkdir -p usr/homedirs | ||
80 | if [ -d "home" ] && [ ! -L "home" ]; then | ||
81 | mv home usr/homedirs/home | ||
82 | ln -sf var/rootdirs/home home | ||
128 | fi | 83 | fi |
129 | if [ -n "${SOTA_AUTOPROVISION_URL_FILE}" ]; then | 84 | |
130 | bbwarn "SOTA_AUTOPROVISION_URL_FILE is ignored. Please use SOTA_PACKED_CREDENTIALS" | 85 | # Move persistent directories to /var |
86 | dirs="opt mnt media srv" | ||
87 | |||
88 | for dir in ${dirs}; do | ||
89 | if [ -d ${dir} ] && [ ! -L ${dir} ]; then | ||
90 | if [ "$(ls -A $dir)" ]; then | ||
91 | bbwarn "Data in /$dir directory is not preserved by OSTree. Consider moving it under /usr" | ||
92 | fi | ||
93 | |||
94 | if [ -n "$SYSTEMD_USED" ]; then | ||
95 | echo "d /var/rootdirs/${dir} 0755 root root -" >>${tmpfiles_conf} | ||
96 | else | ||
97 | echo "mkdir -p /var/rootdirs/${dir}; chown 755 /var/rootdirs/${dir}" >>${tmpfiles_conf} | ||
98 | fi | ||
99 | rm -rf ${dir} | ||
100 | ln -sf var/rootdirs/${dir} ${dir} | ||
101 | fi | ||
102 | done | ||
103 | |||
104 | if [ -d root ] && [ ! -L root ]; then | ||
105 | if [ "$(ls -A root)" ]; then | ||
106 | bberror "Data in /root directory is not preserved by OSTree." | ||
107 | fi | ||
108 | |||
109 | if [ -n "$SYSTEMD_USED" ]; then | ||
110 | echo "d /var/roothome 0755 root root -" >>${tmpfiles_conf} | ||
111 | else | ||
112 | echo "mkdir -p /var/roothome; chown 755 /var/roothome" >>${tmpfiles_conf} | ||
113 | fi | ||
114 | |||
115 | rm -rf root | ||
116 | ln -sf var/roothome root | ||
131 | fi | 117 | fi |
132 | if [ -n "${OSTREE_PUSH_CREDENTIALS}" ]; then | 118 | |
133 | bbwarn "OSTREE_PUSH_CREDENTIALS is ignored. Please use SOTA_PACKED_CREDENTIALS" | 119 | if [ -n "${SOTA_SECONDARY_ECUS}" ]; then |
120 | cp ${SOTA_SECONDARY_ECUS} var/sota/ecus | ||
134 | fi | 121 | fi |
135 | 122 | ||
136 | # deploy SOTA credentials | 123 | # Creating boot directories is required for "ostree admin deploy" |
137 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then | 124 | |
138 | if [ -e ${SOTA_PACKED_CREDENTIALS} ]; then | 125 | mkdir -p boot/loader.0 |
139 | cp ${SOTA_PACKED_CREDENTIALS} var/sota/sota_provisioning_credentials.zip | 126 | mkdir -p boot/loader.1 |
140 | # Device should not be able to push data to treehub | 127 | ln -sf boot/loader.0 boot/loader |
141 | zip -d var/sota/sota_provisioning_credentials.zip treehub.json | 128 | |
142 | fi | 129 | checksum=`sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " "` |
143 | fi | 130 | |
144 | 131 | cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} boot/vmlinuz-${checksum} | |
145 | if [ -n "${SOTA_SECONDARY_ECUS}" ]; then | 132 | cp ${DEPLOY_DIR_IMAGE}/${OSTREE_INITRAMFS_IMAGE}-${MACHINE}${RAMDISK_EXT} boot/initramfs-${checksum} |
146 | cp ${SOTA_SECONDARY_ECUS} var/sota/ecus | 133 | |
147 | fi | 134 | # Copy image manifest |
148 | 135 | cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest | |
149 | # Deploy client certificate and key. | 136 | |
150 | if [ -n "${SOTA_CLIENT_CERTIFICATE}" ]; then | 137 | cd ${WORKDIR} |
151 | if [ -e ${SOTA_CLIENT_CERTIFICATE} ]; then | 138 | |
152 | mkdir -p var/sota/token | 139 | # Create a tarball that can be then commited to OSTree repo |
153 | cp ${SOTA_CLIENT_CERTIFICATE} var/sota/token/ | 140 | OSTREE_TAR=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ostree.tar.bz2 |
154 | fi | 141 | tar -C ${OSTREE_ROOTFS} --xattrs --xattrs-include='*' -cjf ${OSTREE_TAR} . |
155 | fi | 142 | sync |
156 | if [ -n "${SOTA_CLIENT_KEY}" ]; then | 143 | |
157 | if [ -e ${SOTA_CLIENT_KEY} ]; then | 144 | rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 |
158 | mkdir -p var/sota/token | 145 | ln -s ${IMAGE_NAME}.rootfs.ostree.tar.bz2 ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 |
159 | cp ${SOTA_CLIENT_KEY} var/sota/token/ | 146 | |
160 | fi | 147 | if [ ! -d ${OSTREE_REPO} ]; then |
161 | fi | 148 | ostree --repo=${OSTREE_REPO} init --mode=archive-z2 |
162 | if [ -n "${SOTA_ROOT_CA}" ]; then | 149 | fi |
163 | if [ -e ${SOTA_ROOT_CA} ]; then | 150 | |
164 | cp ${SOTA_ROOT_CA} var/sota/ | 151 | # Commit the result |
165 | fi | 152 | ostree --repo=${OSTREE_REPO} commit \ |
166 | fi | 153 | --tree=dir=${OSTREE_ROOTFS} \ |
167 | 154 | --skip-if-unchanged \ | |
168 | # Creating boot directories is required for "ostree admin deploy" | 155 | --branch=${OSTREE_BRANCHNAME} \ |
169 | 156 | --subject="Commit-id: ${IMAGE_NAME}" | |
170 | mkdir -p boot/loader.0 | 157 | |
171 | mkdir -p boot/loader.1 | 158 | rm -rf ${OSTREE_ROOTFS} |
172 | ln -sf boot/loader.0 boot/loader | ||
173 | |||
174 | checksum=`sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " "` | ||
175 | |||
176 | cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} boot/vmlinuz-${checksum} | ||
177 | cp ${DEPLOY_DIR_IMAGE}/${OSTREE_INITRAMFS_IMAGE}-${MACHINE}${RAMDISK_EXT} boot/initramfs-${checksum} | ||
178 | |||
179 | # Copy image manifest | ||
180 | cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest | ||
181 | |||
182 | cd ${WORKDIR} | ||
183 | |||
184 | # Create a tarball that can be then commited to OSTree repo | ||
185 | OSTREE_TAR=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ostree.tar.bz2 | ||
186 | tar -C ${OSTREE_ROOTFS} --xattrs --xattrs-include='*' -cjf ${OSTREE_TAR} . | ||
187 | sync | ||
188 | |||
189 | rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 | ||
190 | ln -s ${IMAGE_NAME}.rootfs.ostree.tar.bz2 ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 | ||
191 | |||
192 | if [ ! -d ${OSTREE_REPO} ]; then | ||
193 | ostree --repo=${OSTREE_REPO} init --mode=archive-z2 | ||
194 | fi | ||
195 | |||
196 | # Commit the result | ||
197 | ostree --repo=${OSTREE_REPO} commit \ | ||
198 | --tree=dir=${OSTREE_ROOTFS} \ | ||
199 | --skip-if-unchanged \ | ||
200 | --branch=${OSTREE_BRANCHNAME} \ | ||
201 | --subject="Commit-id: ${IMAGE_NAME}" | ||
202 | |||
203 | rm -rf ${OSTREE_ROOTFS} | ||
204 | } | 159 | } |
205 | 160 | ||
206 | IMAGE_TYPEDEP_ostreepush = "ostree" | 161 | IMAGE_TYPEDEP_ostreepush = "ostree" |
207 | IMAGE_DEPENDS_ostreepush = "sota-tools-native:do_populate_sysroot" | 162 | IMAGE_DEPENDS_ostreepush = "sota-tools-native:do_populate_sysroot" |
208 | IMAGE_CMD_ostreepush () { | 163 | IMAGE_CMD_ostreepush () { |
209 | # Print warnings if credetials are not set or if the file has not been found. | 164 | # Print warnings if credetials are not set or if the file has not been found. |
210 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then | 165 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
211 | if [ -e ${SOTA_PACKED_CREDENTIALS} ]; then | 166 | if [ -e ${SOTA_PACKED_CREDENTIALS} ]; then |
212 | garage-push --repo=${OSTREE_REPO} \ | 167 | garage-push --repo=${OSTREE_REPO} \ |
213 | --ref=${OSTREE_BRANCHNAME} \ | 168 | --ref=${OSTREE_BRANCHNAME} \ |
214 | --credentials=${SOTA_PACKED_CREDENTIALS} \ | 169 | --credentials=${SOTA_PACKED_CREDENTIALS} \ |
215 | --cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt | 170 | --cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt |
216 | else | ||
217 | bbwarn "SOTA_PACKED_CREDENTIALS file does not exist." | ||
218 | fi | ||
219 | else | 171 | else |
220 | bbwarn "SOTA_PACKED_CREDENTIALS not set. Please add SOTA_PACKED_CREDENTIALS." | 172 | bbwarn "SOTA_PACKED_CREDENTIALS file does not exist." |
221 | fi | 173 | fi |
174 | else | ||
175 | bbwarn "SOTA_PACKED_CREDENTIALS not set. Please add SOTA_PACKED_CREDENTIALS." | ||
176 | fi | ||
222 | } | 177 | } |
178 | |||
179 | # vim:set ts=4 sw=4 sts=4 expandtab: | ||
diff --git a/classes/sota_bleeding.inc b/classes/sota_bleeding.inc index fc5947d..77d004b 100644 --- a/classes/sota_bleeding.inc +++ b/classes/sota_bleeding.inc | |||
@@ -1 +1,2 @@ | |||
1 | SRCREV_pn-aktualizr ?= "${AUTOREV}" | 1 | SRCREV_pn-aktualizr ?= "${AUTOREV}" |
2 | SRCREV_pn-aktualizr-native ?= "${AUTOREV}" | ||
diff --git a/recipes-sota/aktualizr/aktualizr-auto-prov.bb b/recipes-sota/aktualizr/aktualizr-auto-prov.bb index 054b5cd..48777b2 100644 --- a/recipes-sota/aktualizr/aktualizr-auto-prov.bb +++ b/recipes-sota/aktualizr/aktualizr-auto-prov.bb | |||
@@ -1,10 +1,13 @@ | |||
1 | SUMMARY = "Aktualizr systemd service and configurations" | 1 | SUMMARY = "Aktualizr systemd service and configurations" |
2 | DESCRIPTION = "Systemd service and configurations for Aktualizr, the SOTA Client application written in C++" | 2 | DESCRIPTION = "Systemd service and configurations for autoprovisioning Aktualizr, the SOTA Client application written in C++" |
3 | HOMEPAGE = "https://github.com/advancedtelematic/aktualizr" | 3 | HOMEPAGE = "https://github.com/advancedtelematic/aktualizr" |
4 | SECTION = "base" | 4 | SECTION = "base" |
5 | LICENSE = "MPL-2.0" | 5 | LICENSE = "MPL-2.0" |
6 | LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=9741c346eef56131163e13b9db1241b3" | 6 | LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=9741c346eef56131163e13b9db1241b3" |
7 | DEPENDS = "zip-native" | ||
7 | RDEPENDS_${PN} = "aktualizr" | 8 | RDEPENDS_${PN} = "aktualizr" |
9 | PV = "1.0" | ||
10 | PR = "6" | ||
8 | 11 | ||
9 | SRC_URI = " \ | 12 | SRC_URI = " \ |
10 | file://LICENSE \ | 13 | file://LICENSE \ |
@@ -12,8 +15,6 @@ SRC_URI = " \ | |||
12 | file://aktualizr-autoprovision.service \ | 15 | file://aktualizr-autoprovision.service \ |
13 | file://sota_autoprov.toml \ | 16 | file://sota_autoprov.toml \ |
14 | " | 17 | " |
15 | PV = "1.0" | ||
16 | PR = "6" | ||
17 | 18 | ||
18 | SYSTEMD_SERVICE_${PN} = "aktualizr.service" | 19 | SYSTEMD_SERVICE_${PN} = "aktualizr.service" |
19 | 20 | ||
@@ -22,18 +23,40 @@ inherit systemd | |||
22 | export SOTA_PACKED_CREDENTIALS | 23 | export SOTA_PACKED_CREDENTIALS |
23 | 24 | ||
24 | do_install_append() { | 25 | do_install_append() { |
26 | if [ -n "${SOTA_AUTOPROVISION_CREDENTIALS}" ]; then | ||
27 | bbwarn "SOTA_AUTOPROVISION_CREDENTIALS are ignored. Please use SOTA_PACKED_CREDENTIALS" | ||
28 | fi | ||
29 | if [ -n "${SOTA_AUTOPROVISION_URL}" ]; then | ||
30 | bbwarn "SOTA_AUTOPROVISION_URL is ignored. Please use SOTA_PACKED_CREDENTIALS" | ||
31 | fi | ||
32 | if [ -n "${SOTA_AUTOPROVISION_URL_FILE}" ]; then | ||
33 | bbwarn "SOTA_AUTOPROVISION_URL_FILE is ignored. Please use SOTA_PACKED_CREDENTIALS" | ||
34 | fi | ||
35 | if [ -n "${OSTREE_PUSH_CREDENTIALS}" ]; then | ||
36 | bbwarn "OSTREE_PUSH_CREDENTIALS is ignored. Please use SOTA_PACKED_CREDENTIALS" | ||
37 | fi | ||
38 | |||
25 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then | 39 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
26 | install -d ${D}/${systemd_unitdir}/system | 40 | install -d ${D}/${systemd_unitdir}/system |
27 | install -m 0644 ${WORKDIR}/aktualizr-autoprovision.service ${D}/${systemd_unitdir}/system/aktualizr.service | 41 | install -m 0644 ${WORKDIR}/aktualizr-autoprovision.service ${D}/${systemd_unitdir}/system/aktualizr.service |
28 | install -d ${D}/usr/lib/sota | 42 | install -d ${D}/usr/lib/sota |
29 | install -m "0644" ${WORKDIR}/sota_autoprov.toml ${D}/usr/lib/sota/sota.toml | 43 | install -m "0644" ${WORKDIR}/sota_autoprov.toml ${D}/usr/lib/sota/sota.toml |
44 | |||
45 | # deploy SOTA credentials | ||
46 | if [ -e ${SOTA_PACKED_CREDENTIALS} ]; then | ||
47 | mkdir -p ${D}/var/sota | ||
48 | cp ${SOTA_PACKED_CREDENTIALS} ${D}/var/sota/sota_provisioning_credentials.zip | ||
49 | # Device should not be able to push data to treehub | ||
50 | zip -d ${D}/var/sota/sota_provisioning_credentials.zip treehub.json | ||
51 | fi | ||
30 | else | 52 | else |
31 | install -d ${D}/${systemd_unitdir}/system | 53 | install -d ${D}/${systemd_unitdir}/system |
32 | install -m 0644 ${WORKDIR}/aktualizr-manual-provision.service ${D}/${systemd_unitdir}/system/aktualizr.service | 54 | install -m 0644 ${WORKDIR}/aktualizr-manual-provision.service ${D}/${systemd_unitdir}/system/aktualizr.service |
33 | fi | 55 | fi |
34 | } | 56 | } |
35 | 57 | ||
36 | FILES_${PN} = " \ | 58 | FILES_${PN} = " \ |
37 | ${systemd_unitdir}/system/aktualizr.service \ | 59 | ${systemd_unitdir}/system/aktualizr.service \ |
38 | /usr/lib/sota/sota.toml \ | 60 | /usr/lib/sota/sota.toml \ |
61 | /var/sota/sota_provisioning_credentials.zip \ | ||
39 | " | 62 | " |
diff --git a/recipes-sota/aktualizr/aktualizr-implicit-prov.bb b/recipes-sota/aktualizr/aktualizr-implicit-prov.bb new file mode 100644 index 0000000..a01ef48 --- /dev/null +++ b/recipes-sota/aktualizr/aktualizr-implicit-prov.bb | |||
@@ -0,0 +1,34 @@ | |||
1 | SUMMARY = "Aktualizr systemd service and configurations" | ||
2 | DESCRIPTION = "Systemd service and configurations for implicitly provisioning Aktualizr, the SOTA Client application written in C++" | ||
3 | HOMEPAGE = "https://github.com/advancedtelematic/aktualizr" | ||
4 | SECTION = "base" | ||
5 | LICENSE = "MPL-2.0" | ||
6 | LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=9741c346eef56131163e13b9db1241b3" | ||
7 | DEPENDS = "aktualizr-native" | ||
8 | RDEPENDS_${PN} = "aktualizr" | ||
9 | PV = "1.0" | ||
10 | PR = "1" | ||
11 | |||
12 | SRC_URI = " \ | ||
13 | file://LICENSE \ | ||
14 | file://aktualizr-autoprovision.service \ | ||
15 | file://sota_implicit_prov.toml \ | ||
16 | " | ||
17 | |||
18 | SYSTEMD_SERVICE_${PN} = "aktualizr.service" | ||
19 | |||
20 | inherit systemd | ||
21 | |||
22 | do_install() { | ||
23 | install -d ${D}/${systemd_unitdir}/system | ||
24 | install -m 0644 ${WORKDIR}/aktualizr-autoprovision.service ${D}/${systemd_unitdir}/system/aktualizr.service | ||
25 | install -d ${D}/usr/lib/sota | ||
26 | aktualizr_implicit_writer -c ${SOTA_PACKED_CREDENTIALS} \ | ||
27 | -i ${WORKDIR}/sota_implicit_prov.toml -o ${D}/usr/lib/sota/sota.toml -p ${D} | ||
28 | } | ||
29 | |||
30 | FILES_${PN} = " \ | ||
31 | ${systemd_unitdir}/system/aktualizr.service \ | ||
32 | /usr/lib/sota/sota.toml \ | ||
33 | /usr/lib/sota/root.crt \ | ||
34 | " | ||
diff --git a/recipes-sota/aktualizr/aktualizr-native_git.bb b/recipes-sota/aktualizr/aktualizr-native_git.bb new file mode 100644 index 0000000..59479fd --- /dev/null +++ b/recipes-sota/aktualizr/aktualizr-native_git.bb | |||
@@ -0,0 +1,16 @@ | |||
1 | require aktualizr_common.inc | ||
2 | |||
3 | DEPENDS = "boost-native openssl-native libarchive-native libsodium-native" | ||
4 | |||
5 | inherit native | ||
6 | |||
7 | EXTRA_OECMAKE = "-DWARNING_AS_ERROR=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_OSTREE=OFF -DAKTUALIZR_VERSION=${PV}" | ||
8 | |||
9 | do_install_append () { | ||
10 | rm ${D}${bindir}/aktualizr | ||
11 | rm ${D}${bindir}/aktualizr_cert_provider | ||
12 | } | ||
13 | |||
14 | FILES_${PN} = " \ | ||
15 | ${bindir}/aktualizr_implicit_writer \ | ||
16 | " | ||
diff --git a/recipes-sota/aktualizr/aktualizr_common.inc b/recipes-sota/aktualizr/aktualizr_common.inc new file mode 100644 index 0000000..b3f99cc --- /dev/null +++ b/recipes-sota/aktualizr/aktualizr_common.inc | |||
@@ -0,0 +1,19 @@ | |||
1 | SUMMARY = "Aktualizr SOTA Client" | ||
2 | DESCRIPTION = "SOTA Client application written in C++" | ||
3 | HOMEPAGE = "https://github.com/advancedtelematic/aktualizr" | ||
4 | SECTION = "base" | ||
5 | LICENSE = "MPL-2.0" | ||
6 | LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=9741c346eef56131163e13b9db1241b3" | ||
7 | |||
8 | PV = "1.0+git${SRCPV}" | ||
9 | PR = "7" | ||
10 | |||
11 | SRC_URI = " \ | ||
12 | git://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \ | ||
13 | " | ||
14 | SRCREV = "ed2c9684d3b7e605b41a3e7dda0afded1d4a084c" | ||
15 | BRANCH ?= "master" | ||
16 | |||
17 | S = "${WORKDIR}/git" | ||
18 | |||
19 | inherit cmake | ||
diff --git a/recipes-sota/aktualizr/aktualizr_git.bb b/recipes-sota/aktualizr/aktualizr_git.bb index 2d0dadc..4f6a175 100644 --- a/recipes-sota/aktualizr/aktualizr_git.bb +++ b/recipes-sota/aktualizr/aktualizr_git.bb | |||
@@ -1,32 +1,21 @@ | |||
1 | SUMMARY = "Aktualizr SOTA Client" | 1 | require aktualizr_common.inc |
2 | DESCRIPTION = "SOTA Client application written in C++" | 2 | |
3 | HOMEPAGE = "https://github.com/advancedtelematic/aktualizr" | 3 | DEPENDS = "boost curl jansson openssl libarchive libsodium ostree" |
4 | SECTION = "base" | ||
5 | LICENSE = "MPL-2.0" | ||
6 | LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=9741c346eef56131163e13b9db1241b3" | ||
7 | DEPENDS = "boost curl openssl jansson libsodium ostree" | ||
8 | RDEPENDS_${PN} = "lshw" | 4 | RDEPENDS_${PN} = "lshw" |
9 | 5 | ||
10 | DEPENDS_append = "${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'hsm', ' libp11', '', d)}" | 6 | DEPENDS_append = "${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'hsm', ' libp11', '', d)}" |
11 | |||
12 | RDEPENDS_${PN}_append = "${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'hsm', ' engine-pkcs11', '', d)}" | 7 | RDEPENDS_${PN}_append = "${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'hsm', ' engine-pkcs11', '', d)}" |
13 | RDEPENDS_${PN}_append = "${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'hsm-test', ' softhsm softhsm-testtoken', '', d)}" | 8 | RDEPENDS_${PN}_append = "${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'hsm-test', ' softhsm softhsm-testtoken', '', d)}" |
14 | 9 | ||
15 | SRC_URI = " \ | 10 | inherit systemd |
16 | git://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \ | ||
17 | " | ||
18 | SRCREV = "1004efa3f86cef90c012b34620992b5762b741e3" | ||
19 | BRANCH ?= "master" | ||
20 | |||
21 | PV = "1.0+git${SRCPV}" | ||
22 | PR = "7" | ||
23 | |||
24 | S = "${WORKDIR}/git" | ||
25 | |||
26 | inherit cmake systemd | ||
27 | 11 | ||
28 | EXTRA_OECMAKE = "-DWARNING_AS_ERROR=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_OSTREE=ON -DAKTUALIZR_VERSION=${PV}" | 12 | EXTRA_OECMAKE = "-DWARNING_AS_ERROR=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_OSTREE=ON -DAKTUALIZR_VERSION=${PV}" |
29 | 13 | ||
14 | do_install_append () { | ||
15 | rm ${D}${bindir}/aktualizr_cert_provider | ||
16 | rm ${D}${bindir}/aktualizr_implicit_writer | ||
17 | } | ||
18 | |||
30 | FILES_${PN} = " \ | 19 | FILES_${PN} = " \ |
31 | ${bindir}/aktualizr \ | 20 | ${bindir}/aktualizr \ |
32 | " | 21 | " |
diff --git a/recipes-sota/aktualizr/files/sota_implicit_prov.toml b/recipes-sota/aktualizr/files/sota_implicit_prov.toml new file mode 100644 index 0000000..756c868 --- /dev/null +++ b/recipes-sota/aktualizr/files/sota_implicit_prov.toml | |||
@@ -0,0 +1,11 @@ | |||
1 | [tls] | ||
2 | certificates_directory = "/var/sota/" | ||
3 | ca_file = "/usr/lib/sota/root.crt" | ||
4 | client_certificate = "client.pem" | ||
5 | pkey_file = "pkey.pem" | ||
6 | |||
7 | [uptane] | ||
8 | metadata_path = "/var/sota/metadata" | ||
9 | private_key_path = "ecukey.der" | ||
10 | public_key_path = "ecukey.pub" | ||
11 | |||