diff options
-rw-r--r-- | classes/image_types_ostree.bbclass | 48 | ||||
-rw-r--r-- | classes/image_types_ota.bbclass | 4 | ||||
-rw-r--r-- | classes/sota_raspberrypi.bbclass | 5 | ||||
-rw-r--r-- | recipes-sota/aktualizr/aktualizr_git.bb | 32 | ||||
-rw-r--r-- | recipes-sota/aktualizr/files/aktualizr-manual-provision.service | 13 | ||||
-rw-r--r-- | recipes-sota/rvi-sota-client/rvi-sota-client_git.bb | 16 |
6 files changed, 91 insertions, 27 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 59d4510..2a74e51 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
@@ -3,6 +3,7 @@ | |||
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 | virtual/kernel:do_deploy \ | 7 | virtual/kernel:do_deploy \ |
7 | ${OSTREE_INITRAMFS_IMAGE}:do_image_complete" | 8 | ${OSTREE_INITRAMFS_IMAGE}:do_image_complete" |
8 | 9 | ||
@@ -16,6 +17,36 @@ OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" | |||
16 | 17 | ||
17 | export SYSTEMD_USED = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', '', d)}" | 18 | export SYSTEMD_USED = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', '', d)}" |
18 | 19 | ||
20 | python () { | ||
21 | if d.getVar("SOTA_PACKED_CREDENTIALS", True): | ||
22 | if d.getVar("SOTA_AUTOPROVISION_CREDENTIALS", True): | ||
23 | bb.warn("SOTA_AUTOPROVISION_CREDENTIALS are overriden by those in SOTA_PACKED_CREDENTIALS") | ||
24 | if d.getVar("SOTA_AUTOPROVISION_URL", True): | ||
25 | bb.warn("SOTA_AUTOPROVISION_URL is overriden by the one in SOTA_PACKED_CREDENTIALS") | ||
26 | |||
27 | if d.getVar("SOTA_AUTOPROVISION_URL_FILE", True): | ||
28 | bb.warn("SOTA_AUTOPROVISION_URL_FILE is overriden by the one in SOTA_PACKED_CREDENTIALS") | ||
29 | |||
30 | if d.getVar("OSTREE_PUSH_CREDENTIALS", True): | ||
31 | bb.warn("OSTREE_PUSH_CREDENTIALS are overriden by those in SOTA_PACKED_CREDENTIALS") | ||
32 | |||
33 | d.setVar("SOTA_AUTOPROVISION_CREDENTIALS", "%s/sota_credentials/autoprov_credentials.p12" % d.getVar("DEPLOY_DIR_IMAGE", True)) | ||
34 | d.setVar("SOTA_AUTOPROVISION_URL_FILE", "%s/sota_credentials/autoprov.url" % d.getVar("DEPLOY_DIR_IMAGE", True)) | ||
35 | d.setVar("OSTREE_PUSH_CREDENTIALS", "%s/sota_credentials/treehub.json" % d.getVar("DEPLOY_DIR_IMAGE", True)) | ||
36 | } | ||
37 | |||
38 | IMAGE_DEPENDS_ostreecredunpack = "unzip-native:do_populate_sysroot" | ||
39 | |||
40 | IMAGE_CMD_ostreecredunpack () { | ||
41 | if [ ${SOTA_PACKED_CREDENTIALS} ]; then | ||
42 | rm -rf ${DEPLOY_DIR_IMAGE}/sota_credentials | ||
43 | |||
44 | unzip ${SOTA_PACKED_CREDENTIALS} -d ${DEPLOY_DIR_IMAGE}/sota_credentials | ||
45 | fi | ||
46 | } | ||
47 | |||
48 | IMAGE_TYPEDEP_ostree = "ostreecredunpack" | ||
49 | |||
19 | IMAGE_CMD_ostree () { | 50 | IMAGE_CMD_ostree () { |
20 | if [ -z "$OSTREE_REPO" ]; then | 51 | if [ -z "$OSTREE_REPO" ]; then |
21 | bbfatal "OSTREE_REPO should be set in your local.conf" | 52 | bbfatal "OSTREE_REPO should be set in your local.conf" |
@@ -114,6 +145,23 @@ IMAGE_CMD_ostree () { | |||
114 | ln -sf var/roothome root | 145 | ln -sf var/roothome root |
115 | fi | 146 | fi |
116 | 147 | ||
148 | # deploy SOTA credentials | ||
149 | if [ -n "${SOTA_AUTOPROVISION_CREDENTIALS}" ]; then | ||
150 | EXPDATE=`openssl pkcs12 -in ${SOTA_AUTOPROVISION_CREDENTIALS} -password "pass:" -nodes 2>/dev/null | openssl x509 -noout -enddate | cut -f2 -d "="` | ||
151 | |||
152 | if [ `date +%s` -ge `date -d "${EXPDATE}" +%s` ]; then | ||
153 | bberror "Certificate ${SOTA_AUTOPROVISION_CREDENTIALS} has expired on ${EXPDATE}" | ||
154 | fi | ||
155 | |||
156 | mkdir -p var/sota | ||
157 | cp ${SOTA_AUTOPROVISION_CREDENTIALS} var/sota/sota_provisioning_credentials.p12 | ||
158 | if [ -n "${SOTA_AUTOPROVISION_URL_FILE}" ]; then | ||
159 | export SOTA_AUTOPROVISION_URL=`cat ${SOTA_AUTOPROVISION_URL_FILE}` | ||
160 | fi | ||
161 | echo "SOTA_GATEWAY_URI=${SOTA_AUTOPROVISION_URL}" > var/sota/sota_provisioning_url.env | ||
162 | fi | ||
163 | |||
164 | |||
117 | # Creating boot directories is required for "ostree admin deploy" | 165 | # Creating boot directories is required for "ostree admin deploy" |
118 | 166 | ||
119 | mkdir -p boot/loader.0 | 167 | mkdir -p boot/loader.0 |
diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index cb71899..8108d51 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass | |||
@@ -98,7 +98,11 @@ IMAGE_CMD_otaimg () { | |||
98 | HOME_TMP=`mktemp -d ${WORKDIR}/home-tmp-XXXXX` | 98 | HOME_TMP=`mktemp -d ${WORKDIR}/home-tmp-XXXXX` |
99 | tar --xattrs --xattrs-include='*' -C ${HOME_TMP} -xf ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 ./usr/homedirs ./var/sota || true | 99 | tar --xattrs --xattrs-include='*' -C ${HOME_TMP} -xf ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 ./usr/homedirs ./var/sota || true |
100 | mv ${HOME_TMP}/var/sota ${PHYS_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true | 100 | mv ${HOME_TMP}/var/sota ${PHYS_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true |
101 | # Create /var/sota if it doesn't exist yet | ||
102 | mkdir -p ${PHYS_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota || true | ||
101 | mv ${HOME_TMP}/usr/homedirs/home ${PHYS_SYSROOT}/ || true | 103 | mv ${HOME_TMP}/usr/homedirs/home ${PHYS_SYSROOT}/ || true |
104 | # Ensure that /var/local exists (AGL symlinks /usr/local to /var/local) | ||
105 | install -d ${PHYS_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/local | ||
102 | rm -rf ${HOME_TMP} | 106 | rm -rf ${HOME_TMP} |
103 | 107 | ||
104 | # Calculate image type | 108 | # Calculate image type |
diff --git a/classes/sota_raspberrypi.bbclass b/classes/sota_raspberrypi.bbclass index 7b67c0f..b6cf639 100644 --- a/classes/sota_raspberrypi.bbclass +++ b/classes/sota_raspberrypi.bbclass | |||
@@ -1,10 +1,7 @@ | |||
1 | IMAGE_CLASSES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'image_types_uboot sdcard_image-rpi-ota', '', d)}" | 1 | IMAGE_CLASSES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'image_types_uboot sdcard_image-rpi-ota', '', d)}" |
2 | IMAGE_FSTYPES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'rpi-sdimg-ota', 'rpi-sdimg', d)}" | 2 | IMAGE_FSTYPES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'rpi-sdimg-ota', 'rpi-sdimg', d)}" |
3 | 3 | ||
4 | ### both rpi-sdimg and rpi-sdimg-ota broken | 4 | IMAGE_FSTYPES_remove = "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'wic rpi-sdimg', '', d)}" |
5 | IMAGE_FSTYPES += "ext4.xz ext4.bmap tar.xz" | ||
6 | |||
7 | IMAGE_FSTYPES_remove = "wic" | ||
8 | 5 | ||
9 | KERNEL_IMAGETYPE_sota = "uImage" | 6 | KERNEL_IMAGETYPE_sota = "uImage" |
10 | PREFERRED_PROVIDER_virtual/bootloader_sota ?= "u-boot" | 7 | PREFERRED_PROVIDER_virtual/bootloader_sota ?= "u-boot" |
diff --git a/recipes-sota/aktualizr/aktualizr_git.bb b/recipes-sota/aktualizr/aktualizr_git.bb index e8a1a5e..fa71af8 100644 --- a/recipes-sota/aktualizr/aktualizr_git.bb +++ b/recipes-sota/aktualizr/aktualizr_git.bb | |||
@@ -2,24 +2,38 @@ SUMMARY = "Aktualizr SOTA Client" | |||
2 | DESCRIPTION = "SOTA Client application written in C++" | 2 | DESCRIPTION = "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 | |||
6 | LICENSE = "MPL-2.0" | 5 | LICENSE = "MPL-2.0" |
7 | LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=9741c346eef56131163e13b9db1241b3" | 6 | LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=9741c346eef56131163e13b9db1241b3" |
7 | DEPENDS = "boost curl openssl jansson libsodium ostree" | ||
8 | SRCREV = "4e9344ae375a444f02b964dca52fe808010d17df" | ||
9 | PV = "1.0+git${SRCPV}" | ||
8 | 10 | ||
9 | inherit cmake systemd | 11 | SRC_URI = " \ |
12 | git://github.com/advancedtelematic/aktualizr \ | ||
13 | file://aktualizr-manual-provision.service \ | ||
14 | " | ||
10 | 15 | ||
11 | S = "${WORKDIR}/git" | 16 | S = "${WORKDIR}/git" |
12 | PV = "1.0+git${SRCPV}" | 17 | SYSTEMD_SERVICE_${PN} = "aktualizr.service" |
13 | 18 | ||
14 | SRCREV = "4e9344ae375a444f02b964dca52fe808010d17df" | 19 | inherit cmake systemd |
15 | 20 | ||
16 | SRC_URI = "git://github.com/advancedtelematic/aktualizr" | 21 | EXTRA_OECMAKE = "-DWARNING_AS_ERROR=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_OSTREE=ON" |
17 | 22 | ||
18 | DEPENDS = "boost curl openssl jansson libsodium ostree" | 23 | export SOTA_AUTOPROVISION_CREDENTIALS |
19 | RDEPENDS = "" | ||
20 | 24 | ||
21 | EXTRA_OECMAKE = "-DWARNING_AS_ERROR=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_OSTREE=ON" | 25 | do_install_append() { |
26 | if [ -n "$SOTA_AUTOPROVISION_CREDENTIALS" ]; then | ||
27 | bbwarn "Aktualizr recipe currently lacks support for SOTA_AUTOPROVISION_CREDENTIALS. No systemd service will be created" | ||
28 | else | ||
29 | install -d ${D}/${systemd_unitdir}/system | ||
30 | install -m 0644 ${WORKDIR}/aktualizr-manual-provision.service ${D}/${systemd_unitdir}/system/aktualizr.service | ||
31 | fi | ||
32 | } | ||
33 | |||
34 | RDEPENDS = "" | ||
22 | 35 | ||
23 | FILES_${PN} = " \ | 36 | FILES_${PN} = " \ |
24 | ${bindir}/aktualizr \ | 37 | ${bindir}/aktualizr \ |
25 | " | 38 | ${systemd_unitdir}/system/aktualizr.service \ |
39 | " | ||
diff --git a/recipes-sota/aktualizr/files/aktualizr-manual-provision.service b/recipes-sota/aktualizr/files/aktualizr-manual-provision.service new file mode 100644 index 0000000..a70f2f9 --- /dev/null +++ b/recipes-sota/aktualizr/files/aktualizr-manual-provision.service | |||
@@ -0,0 +1,13 @@ | |||
1 | [Unit] | ||
2 | Description=Aktualizr SOTA Client | ||
3 | Wants=network-online.target | ||
4 | After=network.target network-online.target | ||
5 | Requires=network-online.target | ||
6 | |||
7 | [Service] | ||
8 | RestartSec=10 | ||
9 | Restart=always | ||
10 | ExecStart=/usr/bin/aktualizr --config /sysroot/boot/sota.toml --loglevel 2 | ||
11 | |||
12 | [Install] | ||
13 | WantedBy=multi-user.target | ||
diff --git a/recipes-sota/rvi-sota-client/rvi-sota-client_git.bb b/recipes-sota/rvi-sota-client/rvi-sota-client_git.bb index 9a3dbf9..9ba11ea 100644 --- a/recipes-sota/rvi-sota-client/rvi-sota-client_git.bb +++ b/recipes-sota/rvi-sota-client/rvi-sota-client_git.bb | |||
@@ -153,6 +153,7 @@ RDEPENDS_${PN} = " libcrypto \ | |||
153 | python-json \ | 153 | python-json \ |
154 | " | 154 | " |
155 | 155 | ||
156 | export SOTA_PACKED_CREDENTIALS | ||
156 | export SOTA_AUTOPROVISION_CREDENTIALS | 157 | export SOTA_AUTOPROVISION_CREDENTIALS |
157 | export SOTA_AUTOPROVISION_URL | 158 | export SOTA_AUTOPROVISION_URL |
158 | 159 | ||
@@ -171,7 +172,7 @@ do_install() { | |||
171 | 172 | ||
172 | if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then | 173 | if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then |
173 | install -d ${D}/${systemd_unitdir}/system | 174 | install -d ${D}/${systemd_unitdir}/system |
174 | if [ -n "$SOTA_AUTOPROVISION_CREDENTIALS" ]; then | 175 | if [ -n "$SOTA_AUTOPROVISION_CREDENTIALS" -o -n "$SOTA_PACKED_CREDENTIALS" ]; then |
175 | install -c ${S}/run/sota_client_uptane_auto.service ${D}${systemd_unitdir}/system/sota_client.service | 176 | install -c ${S}/run/sota_client_uptane_auto.service ${D}${systemd_unitdir}/system/sota_client.service |
176 | else | 177 | else |
177 | install -c ${S}/run/sota_client_ostree.service ${D}${systemd_unitdir}/system/sota_client.service | 178 | install -c ${S}/run/sota_client_ostree.service ${D}${systemd_unitdir}/system/sota_client.service |
@@ -184,17 +185,4 @@ do_install() { | |||
184 | install -c ${S}/run/sota_certificates ${D}${sysconfdir} | 185 | install -c ${S}/run/sota_certificates ${D}${sysconfdir} |
185 | ln -fs /lib ${D}/lib64 | 186 | ln -fs /lib ${D}/lib64 |
186 | 187 | ||
187 | if [ -n "$SOTA_AUTOPROVISION_CREDENTIALS" ]; then | ||
188 | EXPDATE=`openssl pkcs12 -in $SOTA_AUTOPROVISION_CREDENTIALS -password "pass:" -nodes 2>/dev/null | openssl x509 -noout -enddate | cut -f2 -d "="` | ||
189 | |||
190 | if [ `date +%s` -ge `date -d "${EXPDATE}" +%s` ]; then | ||
191 | bberror "Certificate ${SOTA_AUTOPROVISION_CREDENTIALS} has expired on ${EXPDATE}" | ||
192 | fi | ||
193 | |||
194 | install -d ${D}/var | ||
195 | install -d ${D}/var/sota | ||
196 | install -m 0655 $SOTA_AUTOPROVISION_CREDENTIALS ${D}/var/sota/sota_provisioning_credentials.p12 | ||
197 | echo "SOTA_GATEWAY_URI=$SOTA_AUTOPROVISION_URL" > ${D}/var/sota/sota_provisioning_url.env | ||
198 | fi | ||
199 | |||
200 | } | 188 | } |