From db58e575655be131df4a597d66bfdec2ca128474 Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Fri, 23 Dec 2016 12:34:33 +0100 Subject: Deploy credentials to physical sysroot's /boot --- classes/image_types_ota.bbclass | 17 ++++++++++++++ conf/distro/sota.conf.inc | 3 ++- .../rvi-sota-client/rvi-sota-client_git.bb | 6 ++++- recipes-sota/sota-credentials/sota-credentials.bb | 27 ---------------------- 4 files changed, 24 insertions(+), 29 deletions(-) delete mode 100644 recipes-sota/sota-credentials/sota-credentials.bb diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index d017904..bee1ea4 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass @@ -87,6 +87,22 @@ IMAGE_CMD_otaimg () { mv ${HOME_TMP}/usr/homedirs/home ${PHYS_SYSROOT}/ rm -rf ${HOME_TMP} + # Deploy device credentials + if [ -n "$SOTA_CREDENTIALS" ]; then + if [ -f "$SOTA_CREDENTIALS" ]; then + EXT=`basename $SOTA_CREDENTIALS | cut -d'.' -f2` + if [ "$EXT" != "toml" ]; then + bbwarn "File\'s extension is not \'toml\', make sure you have the correct file" + fi + + cat $SOTA_CREDENTIALS | sed 's/^package_manager = .*$/package_manager = "ostree"/' > ${PHYS_SYSROOT}/boot/sota.toml + chmod 644 ${PHYS_SYSROOT}/boot/sota.toml + else + bberror "File $SOTA_CREDENTIALS does not exist" + fi + fi + + # Calculate image type OTA_ROOTFS_SIZE=$(calculate_size `du -ks $PHYS_SYSROOT | cut -f 1` "${IMAGE_OVERHEAD_FACTOR}" "${IMAGE_ROOTFS_SIZE}" "${IMAGE_ROOTFS_MAXSIZE}" `expr ${IMAGE_ROOTFS_EXTRA_SPACE}` "${IMAGE_ROOTFS_ALIGNMENT}") if [ $OTA_ROOTFS_SIZE -lt 0 ]; then @@ -98,6 +114,7 @@ IMAGE_CMD_otaimg () { eval COUNT=\"$MIN_COUNT\" fi + # create image rm -rf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg sync dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg seek=$OTA_ROOTFS_SIZE count=$COUNT bs=1024 diff --git a/conf/distro/sota.conf.inc b/conf/distro/sota.conf.inc index 3136092..7602464 100644 --- a/conf/distro/sota.conf.inc +++ b/conf/distro/sota.conf.inc @@ -1,4 +1,4 @@ -IMAGE_INSTALL_append = " ostree rvi-sota-client sota-credentials" +IMAGE_INSTALL_append = " ostree rvi-sota-client" # live image for OSTree-enabled systems IMAGE_CLASSES_append = " image_types_ostree image_types_ota" @@ -28,3 +28,4 @@ PREFERRED_PROVIDER_virtual/bootloader_raspberrypi3 = "u-boot" DISTRO_TYPE ?= "${@bb.utils.contains("IMAGE_FEATURES", "debug-tweaks", "debug", "release",d)}" DISTROOVERRIDES_append = ":sota" +DISTRO_FEATURES_append = " sota" 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 0acc6c6..8ffe7ce 100644 --- a/recipes-sota/rvi-sota-client/rvi-sota-client_git.bb +++ b/recipes-sota/rvi-sota-client/rvi-sota-client_git.bb @@ -118,7 +118,11 @@ do_install() { if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then install -d ${D}${systemd_unitdir}/system - install -c ${S}/run/sota_client.service ${D}${systemd_unitdir}/system + if ${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'true', 'false', d)}; then + install -c ${S}/run/sota_client_ostree.service ${D}${systemd_unitdir}/system/sota_client.service + else + install -c ${S}/run/sota_client.service ${D}${systemd_unitdir}/system/sota_client.service + fi fi install -d ${D}${sysconfdir} diff --git a/recipes-sota/sota-credentials/sota-credentials.bb b/recipes-sota/sota-credentials/sota-credentials.bb deleted file mode 100644 index f523f21..0000000 --- a/recipes-sota/sota-credentials/sota-credentials.bb +++ /dev/null @@ -1,27 +0,0 @@ -SUMMARY = "Deploy SOTA credentials on the defice" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" - -FILES_${PN} += "${sysconfdir}/sota.toml" - -ALLOW_EMPTY_${PN} = "1" - -export SOTA_CREDENTIALS - -do_install() { - if [ -n "$SOTA_CREDENTIALS" ]; then - if [ -f "$SOTA_CREDENTIALS" ]; then - EXT=`basename $SOTA_CREDENTIALS | cut -d'.' -f2` - if [ "$EXT" != "toml" ]; then - bbwarn "File\'s extension is not \'toml\', make sure you have the correct file" - fi - - install -d ${D}${sysconfdir} - cat $SOTA_CREDENTIALS | sed 's/^package_manager = .*$/package_manager = "ostree"/' > ${D}${sysconfdir}/sota.toml - chmod 644 ${D}${sysconfdir}/sota.toml - else - bberror "File $SOTA_CREDENTIALS does not exist" - fi - fi -} - -- cgit v1.2.3-54-g00ecf