summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Vacek <patrickvacek@gmail.com>2017-10-06 15:39:40 +0200
committerGitHub <noreply@github.com>2017-10-06 15:39:40 +0200
commit36f1d8668a0ccdfe7f71f886a6829fb33be7cb48 (patch)
tree93e9b2d5eee766fab22dd1edca902ab5d7f15719
parente789ff50f9d11f838a3e1cd985cb3ae34c1ca764 (diff)
parent2bce8708ca8be6931d9f524df735694d3c77a984 (diff)
downloadmeta-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.bbclass345
-rw-r--r--classes/sota_bleeding.inc1
-rw-r--r--recipes-sota/aktualizr/aktualizr-auto-prov.bb41
-rw-r--r--recipes-sota/aktualizr/aktualizr-implicit-prov.bb34
-rw-r--r--recipes-sota/aktualizr/aktualizr-native_git.bb16
-rw-r--r--recipes-sota/aktualizr/aktualizr_common.inc19
-rw-r--r--recipes-sota/aktualizr/aktualizr_git.bb29
-rw-r--r--recipes-sota/aktualizr/files/sota_implicit_prov.toml11
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
3inherit image 3inherit image
4 4
5IMAGE_DEPENDS_ostree = "ostree-native:do_populate_sysroot \ 5IMAGE_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
13export OSTREE_REPO 11export OSTREE_REPO
14export OSTREE_BRANCHNAME 12export OSTREE_BRANCHNAME
@@ -21,202 +19,161 @@ OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}"
21export SYSTEMD_USED = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', '', d)}" 19export SYSTEMD_USED = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', '', d)}"
22 20
23IMAGE_CMD_ostree () { 21IMAGE_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
206IMAGE_TYPEDEP_ostreepush = "ostree" 161IMAGE_TYPEDEP_ostreepush = "ostree"
207IMAGE_DEPENDS_ostreepush = "sota-tools-native:do_populate_sysroot" 162IMAGE_DEPENDS_ostreepush = "sota-tools-native:do_populate_sysroot"
208IMAGE_CMD_ostreepush () { 163IMAGE_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 @@
1SRCREV_pn-aktualizr ?= "${AUTOREV}" 1SRCREV_pn-aktualizr ?= "${AUTOREV}"
2SRCREV_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 @@
1SUMMARY = "Aktualizr systemd service and configurations" 1SUMMARY = "Aktualizr systemd service and configurations"
2DESCRIPTION = "Systemd service and configurations for Aktualizr, the SOTA Client application written in C++" 2DESCRIPTION = "Systemd service and configurations for autoprovisioning Aktualizr, the SOTA Client application written in C++"
3HOMEPAGE = "https://github.com/advancedtelematic/aktualizr" 3HOMEPAGE = "https://github.com/advancedtelematic/aktualizr"
4SECTION = "base" 4SECTION = "base"
5LICENSE = "MPL-2.0" 5LICENSE = "MPL-2.0"
6LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=9741c346eef56131163e13b9db1241b3" 6LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=9741c346eef56131163e13b9db1241b3"
7DEPENDS = "zip-native"
7RDEPENDS_${PN} = "aktualizr" 8RDEPENDS_${PN} = "aktualizr"
9PV = "1.0"
10PR = "6"
8 11
9SRC_URI = " \ 12SRC_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 "
15PV = "1.0"
16PR = "6"
17 18
18SYSTEMD_SERVICE_${PN} = "aktualizr.service" 19SYSTEMD_SERVICE_${PN} = "aktualizr.service"
19 20
@@ -22,18 +23,40 @@ inherit systemd
22export SOTA_PACKED_CREDENTIALS 23export SOTA_PACKED_CREDENTIALS
23 24
24do_install_append() { 25do_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
36FILES_${PN} = " \ 58FILES_${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 @@
1SUMMARY = "Aktualizr systemd service and configurations"
2DESCRIPTION = "Systemd service and configurations for implicitly provisioning Aktualizr, the SOTA Client application written in C++"
3HOMEPAGE = "https://github.com/advancedtelematic/aktualizr"
4SECTION = "base"
5LICENSE = "MPL-2.0"
6LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=9741c346eef56131163e13b9db1241b3"
7DEPENDS = "aktualizr-native"
8RDEPENDS_${PN} = "aktualizr"
9PV = "1.0"
10PR = "1"
11
12SRC_URI = " \
13 file://LICENSE \
14 file://aktualizr-autoprovision.service \
15 file://sota_implicit_prov.toml \
16 "
17
18SYSTEMD_SERVICE_${PN} = "aktualizr.service"
19
20inherit systemd
21
22do_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
30FILES_${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 @@
1require aktualizr_common.inc
2
3DEPENDS = "boost-native openssl-native libarchive-native libsodium-native"
4
5inherit native
6
7EXTRA_OECMAKE = "-DWARNING_AS_ERROR=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_OSTREE=OFF -DAKTUALIZR_VERSION=${PV}"
8
9do_install_append () {
10 rm ${D}${bindir}/aktualizr
11 rm ${D}${bindir}/aktualizr_cert_provider
12}
13
14FILES_${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 @@
1SUMMARY = "Aktualizr SOTA Client"
2DESCRIPTION = "SOTA Client application written in C++"
3HOMEPAGE = "https://github.com/advancedtelematic/aktualizr"
4SECTION = "base"
5LICENSE = "MPL-2.0"
6LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=9741c346eef56131163e13b9db1241b3"
7
8PV = "1.0+git${SRCPV}"
9PR = "7"
10
11SRC_URI = " \
12 git://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \
13 "
14SRCREV = "ed2c9684d3b7e605b41a3e7dda0afded1d4a084c"
15BRANCH ?= "master"
16
17S = "${WORKDIR}/git"
18
19inherit 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 @@
1SUMMARY = "Aktualizr SOTA Client" 1require aktualizr_common.inc
2DESCRIPTION = "SOTA Client application written in C++" 2
3HOMEPAGE = "https://github.com/advancedtelematic/aktualizr" 3DEPENDS = "boost curl jansson openssl libarchive libsodium ostree"
4SECTION = "base"
5LICENSE = "MPL-2.0"
6LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=9741c346eef56131163e13b9db1241b3"
7DEPENDS = "boost curl openssl jansson libsodium ostree"
8RDEPENDS_${PN} = "lshw" 4RDEPENDS_${PN} = "lshw"
9 5
10DEPENDS_append = "${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'hsm', ' libp11', '', d)}" 6DEPENDS_append = "${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'hsm', ' libp11', '', d)}"
11
12RDEPENDS_${PN}_append = "${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'hsm', ' engine-pkcs11', '', d)}" 7RDEPENDS_${PN}_append = "${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'hsm', ' engine-pkcs11', '', d)}"
13RDEPENDS_${PN}_append = "${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'hsm-test', ' softhsm softhsm-testtoken', '', d)}" 8RDEPENDS_${PN}_append = "${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'hsm-test', ' softhsm softhsm-testtoken', '', d)}"
14 9
15SRC_URI = " \ 10inherit systemd
16 git://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \
17 "
18SRCREV = "1004efa3f86cef90c012b34620992b5762b741e3"
19BRANCH ?= "master"
20
21PV = "1.0+git${SRCPV}"
22PR = "7"
23
24S = "${WORKDIR}/git"
25
26inherit cmake systemd
27 11
28EXTRA_OECMAKE = "-DWARNING_AS_ERROR=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_OSTREE=ON -DAKTUALIZR_VERSION=${PV}" 12EXTRA_OECMAKE = "-DWARNING_AS_ERROR=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_OSTREE=ON -DAKTUALIZR_VERSION=${PV}"
29 13
14do_install_append () {
15 rm ${D}${bindir}/aktualizr_cert_provider
16 rm ${D}${bindir}/aktualizr_implicit_writer
17}
18
30FILES_${PN} = " \ 19FILES_${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]
2certificates_directory = "/var/sota/"
3ca_file = "/usr/lib/sota/root.crt"
4client_certificate = "client.pem"
5pkey_file = "pkey.pem"
6
7[uptane]
8metadata_path = "/var/sota/metadata"
9private_key_path = "ecukey.der"
10public_key_path = "ecukey.pub"
11