diff options
| -rw-r--r-- | classes/image_types_ostree.bbclass | 80 | ||||
| -rw-r--r-- | classes/image_types_ota.bbclass | 74 | ||||
| -rw-r--r-- | classes/sota.bbclass | 24 | ||||
| -rw-r--r-- | classes/sota_sanity.bbclass | 54 | ||||
| -rw-r--r-- | recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb | 2 |
5 files changed, 108 insertions, 126 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 05c73ff..41b8d0d 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
| @@ -1,42 +1,28 @@ | |||
| 1 | # OSTree deployment | 1 | # OSTree deployment |
| 2 | 2 | ||
| 3 | do_image_ostree[depends] += "ostree-native:do_populate_sysroot \ | ||
| 4 | openssl-native:do_populate_sysroot \ | ||
| 5 | coreutils-native:do_populate_sysroot \ | ||
| 6 | unzip-native:do_populate_sysroot \ | ||
| 7 | virtual/kernel:do_deploy \ | ||
| 8 | ${INITRAMFS_IMAGE}:do_image_complete \ | ||
| 9 | " | ||
| 10 | do_image_ostree[lockfiles] += "${OSTREE_REPO}/ostree.lock" | ||
| 11 | |||
| 12 | export OSTREE_REPO | ||
| 13 | export OSTREE_BRANCHNAME | ||
| 14 | export GARAGE_TARGET_NAME | ||
| 15 | |||
| 16 | OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" | 3 | OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" |
| 17 | 4 | OSTREE_ROOTFS ??= "${WORKDIR}/ostree-rootfs" | |
| 18 | OSTREE_COMMIT_SUBJECT ??= "Commit-id: ${IMAGE_NAME}" | 5 | OSTREE_COMMIT_SUBJECT ??= "Commit-id: ${IMAGE_NAME}" |
| 19 | OSTREE_COMMIT_BODY ??= "" | 6 | OSTREE_COMMIT_BODY ??= "" |
| 20 | OSTREE_UPDATE_SUMMARY ??= "0" | 7 | OSTREE_UPDATE_SUMMARY ??= "0" |
| 21 | 8 | ||
| 22 | export SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 'systemd', 'true', '')}" | 9 | BUILD_OSTREE_TARBALL ??= "1" |
| 23 | 10 | ||
| 24 | IMAGE_CMD_ostree () { | 11 | SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 'systemd', 'true', '')}" |
| 25 | if [ -z "$OSTREE_REPO" ]; then | ||
| 26 | bbfatal "OSTREE_REPO should be set in your local.conf" | ||
| 27 | fi | ||
| 28 | 12 | ||
| 29 | if [ -z "$OSTREE_BRANCHNAME" ]; then | 13 | IMAGE_CMD_TAR = "tar --xattrs --xattrs-include=*" |
| 30 | bbfatal "OSTREE_BRANCHNAME should be set in your local.conf" | 14 | CONVERSION_CMD_tar = "touch ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}; ${IMAGE_CMD_TAR} --numeric-owner -cf ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.tar -C ${OTA_IMAGE_ROOTFS} . || [ $? -eq 1 ]" |
| 31 | fi | 15 | CONVERSIONTYPES_append = " tar" |
| 32 | 16 | ||
| 33 | OSTREE_ROOTFS=`mktemp -du ${WORKDIR}/ostree-root-XXXXX` | 17 | OTA_IMAGE_ROOTFS_task-image-ostree = "${OSTREE_ROOTFS}" |
| 34 | cp -a ${IMAGE_ROOTFS} ${OSTREE_ROOTFS} | 18 | do_image_ostree[dirs] = "${OSTREE_ROOTFS}" |
| 19 | do_image_ostree[cleandirs] = "${OSTREE_ROOTFS}" | ||
| 20 | do_image_ostree[depends] = "coreutils-native:do_populate_sysroot virtual/kernel:do_deploy ${INITRAMFS_IMAGE}:do_image_complete" | ||
| 21 | IMAGE_CMD_ostree () { | ||
| 22 | cp -a ${IMAGE_ROOTFS}/* ${OSTREE_ROOTFS} | ||
| 35 | chmod a+rx ${OSTREE_ROOTFS} | 23 | chmod a+rx ${OSTREE_ROOTFS} |
| 36 | sync | 24 | sync |
| 37 | 25 | ||
| 38 | cd ${OSTREE_ROOTFS} | ||
| 39 | |||
| 40 | for d in var/*; do | 26 | for d in var/*; do |
| 41 | if [ "${d}" != "var/local" ]; then | 27 | if [ "${d}" != "var/local" ]; then |
| 42 | rm -rf ${d} | 28 | rm -rf ${d} |
| @@ -64,7 +50,7 @@ IMAGE_CMD_ostree () { | |||
| 64 | fi | 50 | fi |
| 65 | done | 51 | done |
| 66 | 52 | ||
| 67 | if [ -n "$SYSTEMD_USED" ]; then | 53 | if [ -n "${SYSTEMD_USED}" ]; then |
| 68 | mkdir -p usr/etc/tmpfiles.d | 54 | mkdir -p usr/etc/tmpfiles.d |
| 69 | tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf | 55 | tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf |
| 70 | echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf} | 56 | echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf} |
| @@ -100,7 +86,7 @@ IMAGE_CMD_ostree () { | |||
| 100 | bbwarn "Data in /$dir directory is not preserved by OSTree. Consider moving it under /usr" | 86 | bbwarn "Data in /$dir directory is not preserved by OSTree. Consider moving it under /usr" |
| 101 | fi | 87 | fi |
| 102 | 88 | ||
| 103 | if [ -n "$SYSTEMD_USED" ]; then | 89 | if [ -n "${SYSTEMD_USED}" ]; then |
| 104 | echo "d /var/rootdirs/${dir} 0755 root root -" >>${tmpfiles_conf} | 90 | echo "d /var/rootdirs/${dir} 0755 root root -" >>${tmpfiles_conf} |
| 105 | else | 91 | else |
| 106 | echo "mkdir -p /var/rootdirs/${dir}; chown 755 /var/rootdirs/${dir}" >>${tmpfiles_conf} | 92 | echo "mkdir -p /var/rootdirs/${dir}; chown 755 /var/rootdirs/${dir}" >>${tmpfiles_conf} |
| @@ -112,11 +98,10 @@ IMAGE_CMD_ostree () { | |||
| 112 | 98 | ||
| 113 | if [ -d root ] && [ ! -L root ]; then | 99 | if [ -d root ] && [ ! -L root ]; then |
| 114 | if [ "$(ls -A root)" ]; then | 100 | if [ "$(ls -A root)" ]; then |
| 115 | bberror "Data in /root directory is not preserved by OSTree." | 101 | bbfatal "Data in /root directory is not preserved by OSTree." |
| 116 | exit 1 | ||
| 117 | fi | 102 | fi |
| 118 | 103 | ||
| 119 | if [ -n "$SYSTEMD_USED" ]; then | 104 | if [ -n "${SYSTEMD_USED}" ]; then |
| 120 | echo "d /var/roothome 0755 root root -" >>${tmpfiles_conf} | 105 | echo "d /var/roothome 0755 root root -" >>${tmpfiles_conf} |
| 121 | else | 106 | else |
| 122 | echo "mkdir -p /var/roothome; chown 755 /var/roothome" >>${tmpfiles_conf} | 107 | echo "mkdir -p /var/roothome; chown 755 /var/roothome" >>${tmpfiles_conf} |
| @@ -140,17 +125,12 @@ IMAGE_CMD_ostree () { | |||
| 140 | 125 | ||
| 141 | # Copy image manifest | 126 | # Copy image manifest |
| 142 | cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest | 127 | cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest |
| 128 | } | ||
| 143 | 129 | ||
| 144 | cd ${WORKDIR} | 130 | IMAGE_TYPEDEP_ostreecommit = "ostree" |
| 145 | 131 | do_image_ostreecommit[depends] += "ostree-native:do_populate_sysroot" | |
| 146 | # Create a tarball that can be then commited to OSTree repo | 132 | do_image_ostreecommit[lockfiles] += "${WORKDIR}/${OSTREE_REPO}-commit.lock" |
| 147 | OSTREE_TAR=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ostree.tar.bz2 | 133 | IMAGE_CMD_ostreecommit () { |
| 148 | tar -C ${OSTREE_ROOTFS} --xattrs --xattrs-include='*' -cjf ${OSTREE_TAR} . | ||
| 149 | sync | ||
| 150 | |||
| 151 | rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 | ||
| 152 | ln -s ${IMAGE_NAME}.rootfs.ostree.tar.bz2 ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 | ||
| 153 | |||
| 154 | if ! ostree --repo=${OSTREE_REPO} refs 2>&1 > /dev/null; then | 134 | if ! ostree --repo=${OSTREE_REPO} refs 2>&1 > /dev/null; then |
| 155 | ostree --repo=${OSTREE_REPO} init --mode=archive-z2 | 135 | ostree --repo=${OSTREE_REPO} init --mode=archive-z2 |
| 156 | fi | 136 | fi |
| @@ -166,11 +146,9 @@ IMAGE_CMD_ostree () { | |||
| 166 | if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then | 146 | if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then |
| 167 | ostree --repo=${OSTREE_REPO} summary -u | 147 | ostree --repo=${OSTREE_REPO} summary -u |
| 168 | fi | 148 | fi |
| 169 | |||
| 170 | rm -rf ${OSTREE_ROOTFS} | ||
| 171 | } | 149 | } |
| 172 | 150 | ||
| 173 | IMAGE_TYPEDEP_ostreepush = "ostree" | 151 | IMAGE_TYPEDEP_ostreepush = "ostreecommit" |
| 174 | do_image_ostreepush[depends] += "aktualizr-native:do_populate_sysroot ca-certificates-native:do_populate_sysroot" | 152 | do_image_ostreepush[depends] += "aktualizr-native:do_populate_sysroot ca-certificates-native:do_populate_sysroot" |
| 175 | IMAGE_CMD_ostreepush () { | 153 | IMAGE_CMD_ostreepush () { |
| 176 | # Print warnings if credetials are not set or if the file has not been found. | 154 | # Print warnings if credetials are not set or if the file has not been found. |
| @@ -189,7 +167,7 @@ IMAGE_CMD_ostreepush () { | |||
| 189 | } | 167 | } |
| 190 | 168 | ||
| 191 | IMAGE_TYPEDEP_garagesign = "ostreepush" | 169 | IMAGE_TYPEDEP_garagesign = "ostreepush" |
| 192 | do_image_garagesign[depends] += "aktualizr-native:do_populate_sysroot" | 170 | do_image_garagesign[depends] += "unzip-native:do_populate_sysroot" |
| 193 | IMAGE_CMD_garagesign () { | 171 | IMAGE_CMD_garagesign () { |
| 194 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then | 172 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
| 195 | # if credentials are issued by a server that doesn't support offline signing, exit silently | 173 | # if credentials are issued by a server that doesn't support offline signing, exit silently |
| @@ -197,11 +175,9 @@ IMAGE_CMD_garagesign () { | |||
| 197 | 175 | ||
| 198 | java_version=$( java -version 2>&1 | awk -F '"' '/version/ {print $2}' ) | 176 | java_version=$( java -version 2>&1 | awk -F '"' '/version/ {print $2}' ) |
| 199 | if [ "${java_version}" = "" ]; then | 177 | if [ "${java_version}" = "" ]; then |
| 200 | bberror "Java is required for synchronization with update backend, but is not installed on the host machine" | 178 | bbfatal "Java is required for synchronization with update backend, but is not installed on the host machine" |
| 201 | exit 1 | ||
| 202 | elif [ "${java_version}" \< "1.8" ]; then | 179 | elif [ "${java_version}" \< "1.8" ]; then |
| 203 | bberror "Java version >= 8 is required for synchronization with update backend" | 180 | bbfatal "Java version >= 8 is required for synchronization with update backend" |
| 204 | exit 1 | ||
| 205 | fi | 181 | fi |
| 206 | 182 | ||
| 207 | rm -rf ${GARAGE_SIGN_REPO} | 183 | rm -rf ${GARAGE_SIGN_REPO} |
| @@ -252,14 +228,12 @@ IMAGE_CMD_garagesign () { | |||
| 252 | rm -rf ${GARAGE_SIGN_REPO} | 228 | rm -rf ${GARAGE_SIGN_REPO} |
| 253 | 229 | ||
| 254 | if [ "$push_success" -ne "1" ]; then | 230 | if [ "$push_success" -ne "1" ]; then |
| 255 | bberror "Couldn't push to garage repository" | 231 | bbfatal "Couldn't push to garage repository" |
| 256 | exit 1 | ||
| 257 | fi | 232 | fi |
| 258 | fi | 233 | fi |
| 259 | } | 234 | } |
| 260 | 235 | ||
| 261 | IMAGE_TYPEDEP_garagecheck = "ostreepush garagesign" | 236 | IMAGE_TYPEDEP_garagecheck = "garagesign" |
| 262 | do_image_garagecheck[depends] += "aktualizr-native:do_populate_sysroot" | ||
| 263 | IMAGE_CMD_garagecheck () { | 237 | IMAGE_CMD_garagecheck () { |
| 264 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then | 238 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
| 265 | # if credentials are issued by a server that doesn't support offline signing, exit silently | 239 | # if credentials are issued by a server that doesn't support offline signing, exit silently |
diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index 03fe8d8..c9d21d1 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass | |||
| @@ -1,15 +1,9 @@ | |||
| 1 | # Image to use with u-boot as BIOS and OSTree deployment system | 1 | # Image to use with u-boot as BIOS and OSTree deployment system |
| 2 | 2 | ||
| 3 | #inherit image_types | ||
| 4 | |||
| 5 | # Boot filesystem size in MiB | 3 | # Boot filesystem size in MiB |
| 6 | # OSTree updates may require some space on boot file system for | 4 | # OSTree updates may require some space on boot file system for |
| 7 | # boot scripts, kernel and initramfs images | 5 | # boot scripts, kernel and initramfs images |
| 8 | # | 6 | # |
| 9 | |||
| 10 | |||
| 11 | do_image_ota_ext4[depends] += "e2fsprogs-native:do_populate_sysroot" | ||
| 12 | |||
| 13 | calculate_size () { | 7 | calculate_size () { |
| 14 | BASE=$1 | 8 | BASE=$1 |
| 15 | SCALE=$2 | 9 | SCALE=$2 |
| @@ -43,34 +37,14 @@ calculate_size () { | |||
| 43 | echo "${SIZE}" | 37 | echo "${SIZE}" |
| 44 | } | 38 | } |
| 45 | 39 | ||
| 46 | export OSTREE_OSNAME | 40 | OTA_SYSROOT = "${WORKDIR}/ota-sysroot" |
| 47 | export OSTREE_BRANCHNAME | 41 | OTA_IMAGE_ROOTFS_task-image-ota = "${OTA_SYSROOT}" |
| 48 | export OSTREE_REPO | 42 | IMAGE_TYPEDEP_ota = "ostreecommit" |
| 49 | export OSTREE_BOOTLOADER | 43 | do_image_ota[dirs] = "${OTA_SYSROOT}" |
| 50 | 44 | do_image_ota[cleandirs] = "${OTA_SYSROOT}" | |
| 51 | export GARAGE_TARGET_NAME | 45 | do_image_ota[depends] = "${@'grub:do_populate_sysroot' if d.getVar('OSTREE_BOOTLOADER', True) == 'grub' else ''} \ |
| 52 | 46 | ${@'virtual/bootloader:do_deploy' if d.getVar('OSTREE_BOOTLOADER', True) == 'u-boot' else ''}" | |
| 53 | export OTA_SYSROOT="${WORKDIR}/ota-sysroot" | 47 | IMAGE_CMD_ota () { |
| 54 | |||
| 55 | ## Common OTA image setup | ||
| 56 | fakeroot do_otasetup () { | ||
| 57 | |||
| 58 | if [ -z "$OSTREE_REPO" ]; then | ||
| 59 | bbfatal "OSTREE_REPO should be set in your local.conf" | ||
| 60 | fi | ||
| 61 | |||
| 62 | if [ -z "$OSTREE_OSNAME" ]; then | ||
| 63 | bbfatal "OSTREE_OSNAME should be set in your local.conf" | ||
| 64 | fi | ||
| 65 | |||
| 66 | if [ -z "$OSTREE_BRANCHNAME" ]; then | ||
| 67 | bbfatal "OSTREE_BRANCHNAME should be set in your local.conf" | ||
| 68 | fi | ||
| 69 | |||
| 70 | # HaX! Since we are using a peristent directory, we need to be sure to clean it on run. | ||
| 71 | mkdir -p ${OTA_SYSROOT} | ||
| 72 | rm -rf ${OTA_SYSROOT}/* | ||
| 73 | |||
| 74 | ostree admin --sysroot=${OTA_SYSROOT} init-fs ${OTA_SYSROOT} | 48 | ostree admin --sysroot=${OTA_SYSROOT} init-fs ${OTA_SYSROOT} |
| 75 | ostree admin --sysroot=${OTA_SYSROOT} os-init ${OSTREE_OSNAME} | 49 | ostree admin --sysroot=${OTA_SYSROOT} os-init ${OSTREE_OSNAME} |
| 76 | mkdir -p ${OTA_SYSROOT}/boot/loader.0 | 50 | mkdir -p ${OTA_SYSROOT}/boot/loader.0 |
| @@ -82,13 +56,12 @@ fakeroot do_otasetup () { | |||
| 82 | elif [ "${OSTREE_BOOTLOADER}" = "u-boot" ]; then | 56 | elif [ "${OSTREE_BOOTLOADER}" = "u-boot" ]; then |
| 83 | touch ${OTA_SYSROOT}/boot/loader/uEnv.txt | 57 | touch ${OTA_SYSROOT}/boot/loader/uEnv.txt |
| 84 | else | 58 | else |
| 85 | bberror "Invalid bootloader: ${OSTREE_BOOTLOADER}" | 59 | bbfatal "Invalid bootloader: ${OSTREE_BOOTLOADER}" |
| 86 | fi; | 60 | fi |
| 87 | 61 | ||
| 88 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) | 62 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) |
| 89 | 63 | ||
| 90 | ostree --repo=${OTA_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${ostree_target_hash} | 64 | ostree --repo=${OTA_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${ostree_target_hash} |
| 91 | export OSTREE_BOOT_PARTITION="/boot" | ||
| 92 | kargs_list="" | 65 | kargs_list="" |
| 93 | for arg in ${OSTREE_KERNEL_ARGS}; do | 66 | for arg in ${OSTREE_KERNEL_ARGS}; do |
| 94 | kargs_list="${kargs_list} --karg-append=$arg" | 67 | kargs_list="${kargs_list} --karg-append=$arg" |
| @@ -96,19 +69,14 @@ fakeroot do_otasetup () { | |||
| 96 | 69 | ||
| 97 | ostree admin --sysroot=${OTA_SYSROOT} deploy ${kargs_list} --os=${OSTREE_OSNAME} ${ostree_target_hash} | 70 | ostree admin --sysroot=${OTA_SYSROOT} deploy ${kargs_list} --os=${OSTREE_OSNAME} ${ostree_target_hash} |
| 98 | 71 | ||
| 99 | # Copy deployment /home and /var/sota to sysroot | ||
| 100 | HOME_TMP=`mktemp -d ${WORKDIR}/home-tmp-XXXXX` | ||
| 101 | |||
| 102 | tar --xattrs --xattrs-include='*' -C ${HOME_TMP} -xf ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 ./usr/homedirs ./var/local || true | ||
| 103 | |||
| 104 | cp -a ${IMAGE_ROOTFS}/var/sota ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true | 72 | cp -a ${IMAGE_ROOTFS}/var/sota ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true |
| 105 | # Create /var/sota if it doesn't exist yet | 73 | # Create /var/sota if it doesn't exist yet |
| 106 | mkdir -p ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota | 74 | mkdir -p ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota |
| 107 | # Ensure the permissions are correctly set | 75 | # Ensure the permissions are correctly set |
| 108 | chmod 700 ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota | 76 | chmod 700 ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota |
| 109 | 77 | ||
| 110 | mv ${HOME_TMP}/var/local ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true | 78 | cp -a ${OSTREE_ROOTFS}/var/local ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true |
| 111 | mv ${HOME_TMP}/usr/homedirs/home ${OTA_SYSROOT}/ || true | 79 | cp -a ${OSTREE_ROOTFS}/usr/homedirs/home ${OTA_SYSROOT}/ || true |
| 112 | # Ensure that /var/local exists (AGL symlinks /usr/local to /var/local) | 80 | # Ensure that /var/local exists (AGL symlinks /usr/local to /var/local) |
| 113 | install -d ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/local | 81 | install -d ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/local |
| 114 | # Set package version for the first deployment | 82 | # Set package version for the first deployment |
| @@ -120,10 +88,10 @@ fakeroot do_otasetup () { | |||
| 120 | fi | 88 | fi |
| 121 | mkdir -p ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota/import | 89 | mkdir -p ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota/import |
| 122 | echo "{\"${ostree_target_hash}\":\"${GARAGE_TARGET_NAME}-${target_version}\"}" > ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota/import/installed_versions | 90 | echo "{\"${ostree_target_hash}\":\"${GARAGE_TARGET_NAME}-${target_version}\"}" > ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota/import/installed_versions |
| 123 | echo "All done. Cleaning up dir: ${HOME_TMP}" | ||
| 124 | rm -rf ${HOME_TMP} | ||
| 125 | } | 91 | } |
| 126 | 92 | ||
| 93 | IMAGE_TYPEDEP_ota-ext4 = "ota" | ||
| 94 | do_image_ota_ext4[depends] = "e2fsprogs-native:do_populate_sysroot" | ||
| 127 | IMAGE_CMD_ota-ext4 () { | 95 | IMAGE_CMD_ota-ext4 () { |
| 128 | # Calculate image type | 96 | # Calculate image type |
| 129 | OTA_ROOTFS_SIZE=$(calculate_size `du -ks $OTA_SYSROOT | cut -f 1` "${IMAGE_OVERHEAD_FACTOR}" "${IMAGE_ROOTFS_SIZE}" "${IMAGE_ROOTFS_MAXSIZE}" `expr ${IMAGE_ROOTFS_EXTRA_SPACE}` "${IMAGE_ROOTFS_ALIGNMENT}") | 97 | OTA_ROOTFS_SIZE=$(calculate_size `du -ks $OTA_SYSROOT | cut -f 1` "${IMAGE_OVERHEAD_FACTOR}" "${IMAGE_ROOTFS_SIZE}" "${IMAGE_ROOTFS_MAXSIZE}" `expr ${IMAGE_ROOTFS_EXTRA_SPACE}` "${IMAGE_ROOTFS_ALIGNMENT}") |
| @@ -142,16 +110,4 @@ IMAGE_CMD_ota-ext4 () { | |||
| 142 | mkfs.ext4 -O ^64bit ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ota-ext4 -L otaroot -d ${OTA_SYSROOT} | 110 | mkfs.ext4 -O ^64bit ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ota-ext4 -L otaroot -d ${OTA_SYSROOT} |
| 143 | } | 111 | } |
| 144 | 112 | ||
| 145 | IMAGE_CMD_ota-tar () { | 113 | do_image_wic[depends] += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', '%s:do_image_ota_ext4' % d.getVar('IMAGE_BASENAME', True), '', d)}" |
| 146 | tar -cf ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ota-tar -C ${OTA_SYSROOT} . | ||
| 147 | } | ||
| 148 | |||
| 149 | do_otasetup[doc] = "Sets up the base ota rootfs used for subsequent image generation" | ||
| 150 | do_otasetup[depends] += "virtual/fakeroot-native:do_populate_sysroot \ | ||
| 151 | ${@'grub:do_populate_sysroot' if d.getVar('OSTREE_BOOTLOADER', True) == 'grub' else ''} \ | ||
| 152 | ${@'virtual/bootloader:do_deploy' if d.getVar('OSTREE_BOOTLOADER', True) == 'u-boot' else ''}" | ||
| 153 | |||
| 154 | addtask do_otasetup after do_image_ostree before do_image_ota_ext4 do_image_ota_tar | ||
| 155 | |||
| 156 | IMAGE_TYPEDEP_ota-ext4 = "ostree" | ||
| 157 | IMAGE_TYPEDEP_ota-tar = "ostree" | ||
diff --git a/classes/sota.bbclass b/classes/sota.bbclass index 7fb54dc..93f59eb 100644 --- a/classes/sota.bbclass +++ b/classes/sota.bbclass | |||
| @@ -1,9 +1,3 @@ | |||
| 1 | export BUILD_OTA_TARBALL | ||
| 2 | python __anonymous() { | ||
| 3 | if bb.utils.contains('DISTRO_FEATURES', 'sota', True, False, d): | ||
| 4 | d.appendVarFlag("do_image_wic", "depends", " %s:do_image_ota_ext4" % d.getVar("IMAGE_BASENAME", True)) | ||
| 5 | } | ||
| 6 | |||
| 7 | OVERRIDES .= "${@bb.utils.contains('DISTRO_FEATURES', 'sota', ':sota', '', d)}" | 1 | OVERRIDES .= "${@bb.utils.contains('DISTRO_FEATURES', 'sota', ':sota', '', d)}" |
| 8 | 2 | ||
| 9 | HOSTTOOLS_NONFATAL += "java" | 3 | HOSTTOOLS_NONFATAL += "java" |
| @@ -17,7 +11,8 @@ IMAGE_INSTALL_append_sota = " ostree os-release ${SOTA_CLIENT} ${SOTA_CLIENT_PRO | |||
| 17 | IMAGE_CLASSES += " image_types_ostree image_types_ota" | 11 | IMAGE_CLASSES += " image_types_ostree image_types_ota" |
| 18 | 12 | ||
| 19 | IMAGE_FSTYPES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'ostreepush garagesign garagecheck ota-ext4 wic', ' ', d)}" | 13 | IMAGE_FSTYPES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'ostreepush garagesign garagecheck ota-ext4 wic', ' ', d)}" |
| 20 | IMAGE_FSTYPES += "${@bb.utils.contains('BUILD_OTA_TARBALL', '1', 'ota-tar ota-tar.xz', ' ', d)}" | 14 | IMAGE_FSTYPES += "${@bb.utils.contains('BUILD_OSTREE_TARBALL', '1', 'ostree.tar.bz2', ' ', d)}" |
| 15 | IMAGE_FSTYPES += "${@bb.utils.contains('BUILD_OTA_TARBALL', '1', 'ota.tar.xz', ' ', d)}" | ||
| 21 | 16 | ||
| 22 | PACKAGECONFIG_append_pn-curl = " ssl" | 17 | PACKAGECONFIG_append_pn-curl = " ssl" |
| 23 | PACKAGECONFIG_remove_pn-curl = "gnutls" | 18 | PACKAGECONFIG_remove_pn-curl = "gnutls" |
| @@ -29,11 +24,13 @@ EXTRA_IMAGEDEPENDS_append_sota = " parted-native mtools-native dosfstools-native | |||
| 29 | INITRAMFS_FSTYPES ??= "${@oe.utils.ifelse(d.getVar('OSTREE_BOOTLOADER', True) == 'u-boot', 'cpio.gz.u-boot', 'cpio.gz')}" | 24 | INITRAMFS_FSTYPES ??= "${@oe.utils.ifelse(d.getVar('OSTREE_BOOTLOADER', True) == 'u-boot', 'cpio.gz.u-boot', 'cpio.gz')}" |
| 30 | 25 | ||
| 31 | # Please redefine OSTREE_REPO in order to have a persistent OSTree repo | 26 | # Please redefine OSTREE_REPO in order to have a persistent OSTree repo |
| 32 | OSTREE_REPO ?= "${DEPLOY_DIR_IMAGE}/ostree_repo" | 27 | export OSTREE_REPO ?= "${DEPLOY_DIR_IMAGE}/ostree_repo" |
| 33 | OSTREE_BRANCHNAME ?= "${SOTA_HARDWARE_ID}" | 28 | export OSTREE_BRANCHNAME ?= "${SOTA_HARDWARE_ID}" |
| 34 | OSTREE_OSNAME ?= "poky" | 29 | export OSTREE_OSNAME ?= "poky" |
| 30 | export OSTREE_BOOTLOADER ??= 'u-boot' | ||
| 31 | export OSTREE_BOOT_PARTITION ??= "/boot" | ||
| 32 | |||
| 35 | INITRAMFS_IMAGE ?= "initramfs-ostree-image" | 33 | INITRAMFS_IMAGE ?= "initramfs-ostree-image" |
| 36 | OSTREE_BOOTLOADER ??= 'u-boot' | ||
| 37 | 34 | ||
| 38 | GARAGE_SIGN_REPO ?= "${DEPLOY_DIR_IMAGE}/garage_sign_repo" | 35 | GARAGE_SIGN_REPO ?= "${DEPLOY_DIR_IMAGE}/garage_sign_repo" |
| 39 | GARAGE_SIGN_KEYNAME ?= "garage-key" | 36 | GARAGE_SIGN_KEYNAME ?= "garage-key" |
| @@ -49,6 +46,7 @@ SOTA_MACHINE_intel-corei7-64 ?= "minnowboard" | |||
| 49 | SOTA_MACHINE_qemux86-64 ?= "qemux86-64" | 46 | SOTA_MACHINE_qemux86-64 ?= "qemux86-64" |
| 50 | SOTA_MACHINE_am335x-evm ?= "am335x-evm-wifi" | 47 | SOTA_MACHINE_am335x-evm ?= "am335x-evm-wifi" |
| 51 | 48 | ||
| 52 | inherit sota_${SOTA_MACHINE} | 49 | SOTA_OVERRIDES_BLACKLIST = "ostree ota" |
| 50 | SOTA_REQUIRED_VARIABLES = "OSTREE_REPO OSTREE_BRANCHNAME OSTREE_OSNAME OSTREE_BOOTLOADER OSTREE_BOOT_PARTITION GARAGE_SIGN_REPO GARAGE_TARGET_NAME" | ||
| 53 | 51 | ||
| 54 | inherit image_repo_manifest | 52 | inherit sota_sanity sota_${SOTA_MACHINE} image_repo_manifest |
diff --git a/classes/sota_sanity.bbclass b/classes/sota_sanity.bbclass new file mode 100644 index 0000000..e47de19 --- /dev/null +++ b/classes/sota_sanity.bbclass | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | # Sanity check the sota setup for common misconfigurations | ||
| 2 | |||
| 3 | def sota_check_overrides(status, d): | ||
| 4 | for var in (d.getVar('SOTA_OVERRIDES_BLACKLIST', True) or "").split(): | ||
| 5 | if var in d.getVar('OVERRIDES', True).split(':'): | ||
| 6 | status.addresult("%s should not be a overrides, because it is a image fstype in updater layer, please check your OVERRIDES setting.\n" % var) | ||
| 7 | |||
| 8 | def sota_check_required_variables(status, d): | ||
| 9 | for var in (d.getVar('SOTA_REQUIRED_VARIABLES', True) or "").split(): | ||
| 10 | if not d.getVar(var, True): | ||
| 11 | status.addresult("%s should be set in your local.conf.\n" % var) | ||
| 12 | |||
| 13 | def sota_raise_sanity_error(msg, d): | ||
| 14 | if d.getVar("SANITY_USE_EVENTS", True) == "1": | ||
| 15 | bb.event.fire(bb.event.SanityCheckFailed(msg), d) | ||
| 16 | return | ||
| 17 | |||
| 18 | bb.fatal("Sota's config sanity checker detected a potential misconfiguration.\n" | ||
| 19 | "Please fix the cause of this error then you can continue to build.\n" | ||
| 20 | "Following is the list of potential problems / advisories:\n" | ||
| 21 | "\n%s" % msg) | ||
| 22 | |||
| 23 | def sota_check_sanity(sanity_data): | ||
| 24 | class SanityStatus(object): | ||
| 25 | def __init__(self): | ||
| 26 | self.messages = "" | ||
| 27 | self.reparse = False | ||
| 28 | |||
| 29 | def addresult(self, message): | ||
| 30 | if message: | ||
| 31 | self.messages = self.messages + message | ||
| 32 | |||
| 33 | status = SanityStatus() | ||
| 34 | |||
| 35 | sota_check_overrides(status, sanity_data) | ||
| 36 | sota_check_required_variables(status, sanity_data) | ||
| 37 | |||
| 38 | if status.messages != "": | ||
| 39 | sota_raise_sanity_error(sanity_data.expand(status.messages), sanity_data) | ||
| 40 | |||
| 41 | addhandler sota_check_sanity_eventhandler | ||
| 42 | sota_check_sanity_eventhandler[eventmask] = "bb.event.SanityCheck" | ||
| 43 | |||
| 44 | python sota_check_sanity_eventhandler() { | ||
| 45 | if bb.event.getName(e) == "SanityCheck": | ||
| 46 | sanity_data = copy_data(e) | ||
| 47 | if e.generateevents: | ||
| 48 | sanity_data.setVar("SANITY_USE_EVENTS", "1") | ||
| 49 | reparse = sota_check_sanity(sanity_data) | ||
| 50 | e.data.setVar("BB_INVALIDCONF", reparse) | ||
| 51 | bb.event.fire(bb.event.SanityCheckPassed(), e.data) | ||
| 52 | |||
| 53 | return | ||
| 54 | } | ||
diff --git a/recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb b/recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb index 41af7c0..e2d52da 100644 --- a/recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb +++ b/recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb | |||
| @@ -33,7 +33,7 @@ do_install() { | |||
| 33 | fi | 33 | fi |
| 34 | 34 | ||
| 35 | if [ -z ${SOTA_CAKEY_PATH} ]; then | 35 | if [ -z ${SOTA_CAKEY_PATH} ]; then |
| 36 | bberror "SOTA_CAKEY_PATH should be set when using implicit provisioning" | 36 | bbfatal "SOTA_CAKEY_PATH should be set when using implicit provisioning" |
| 37 | fi | 37 | fi |
| 38 | 38 | ||
| 39 | install -m 0700 -d ${D}${localstatedir}/sota | 39 | install -m 0700 -d ${D}${localstatedir}/sota |
