diff options
Diffstat (limited to 'classes')
| -rw-r--r-- | classes/image_repo_manifest.bbclass | 4 | ||||
| -rw-r--r-- | classes/image_types_ostree.bbclass | 99 | ||||
| -rw-r--r-- | classes/image_types_ota.bbclass | 84 | ||||
| -rw-r--r-- | classes/sota.bbclass | 25 | ||||
| -rw-r--r-- | classes/sota_sanity.bbclass | 54 |
5 files changed, 118 insertions, 148 deletions
diff --git a/classes/image_repo_manifest.bbclass b/classes/image_repo_manifest.bbclass index 467fd9a..c2e7056 100644 --- a/classes/image_repo_manifest.bbclass +++ b/classes/image_repo_manifest.bbclass | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | HOSTTOOLS_NONFATAL += " repo " | 12 | HOSTTOOLS_NONFATAL += " repo " |
| 13 | 13 | ||
| 14 | # Write build information to target filesystem | 14 | # Write build information to target filesystem |
| 15 | buildinfo () { | 15 | buildinfo_manifest () { |
| 16 | if [ $(which repo) ]; then | 16 | if [ $(which repo) ]; then |
| 17 | repo manifest --revision-as-HEAD -o ${IMAGE_ROOTFS}${sysconfdir}/manifest.xml || bbwarn "Android repo tool failed to run; manifest not copied" | 17 | repo manifest --revision-as-HEAD -o ${IMAGE_ROOTFS}${sysconfdir}/manifest.xml || bbwarn "Android repo tool failed to run; manifest not copied" |
| 18 | else | 18 | else |
| @@ -20,4 +20,4 @@ buildinfo () { | |||
| 20 | fi | 20 | fi |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | IMAGE_PREPROCESS_COMMAND += "buildinfo;" | 23 | IMAGE_PREPROCESS_COMMAND += "buildinfo_manifest;" |
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 0db8e50..4095de0 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
| @@ -1,42 +1,30 @@ | |||
| 1 | # OSTree deployment | 1 | # OSTree deployment |
| 2 | 2 | inherit distro_features_check | |
| 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 | 3 | ||
| 16 | OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" | 4 | OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" |
| 17 | 5 | OSTREE_ROOTFS ??= "${WORKDIR}/ostree-rootfs" | |
| 18 | OSTREE_COMMIT_SUBJECT ??= "Commit-id: ${IMAGE_NAME}" | 6 | OSTREE_COMMIT_SUBJECT ??= "Commit-id: ${IMAGE_NAME}" |
| 19 | OSTREE_COMMIT_BODY ??= "" | 7 | OSTREE_COMMIT_BODY ??= "" |
| 20 | OSTREE_UPDATE_SUMMARY ??= "0" | 8 | OSTREE_UPDATE_SUMMARY ??= "0" |
| 21 | 9 | ||
| 22 | export SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 'systemd', 'true', '')}" | 10 | BUILD_OSTREE_TARBALL ??= "1" |
| 23 | 11 | ||
| 24 | IMAGE_CMD_ostree () { | 12 | 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 | 13 | ||
| 29 | if [ -z "$OSTREE_BRANCHNAME" ]; then | 14 | IMAGE_CMD_TAR = "tar --xattrs --xattrs-include=*" |
| 30 | bbfatal "OSTREE_BRANCHNAME should be set in your local.conf" | 15 | 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 | 16 | CONVERSIONTYPES_append = " tar" |
| 32 | 17 | ||
| 33 | OSTREE_ROOTFS=`mktemp -du ${WORKDIR}/ostree-root-XXXXX` | 18 | REQUIRED_DISTRO_FEATURES = "usrmerge" |
| 34 | cp -a ${IMAGE_ROOTFS} ${OSTREE_ROOTFS} | 19 | OTA_IMAGE_ROOTFS_task-image-ostree = "${OSTREE_ROOTFS}" |
| 20 | do_image_ostree[dirs] = "${OSTREE_ROOTFS}" | ||
| 21 | do_image_ostree[cleandirs] = "${OSTREE_ROOTFS}" | ||
| 22 | do_image_ostree[depends] = "coreutils-native:do_populate_sysroot virtual/kernel:do_deploy ${INITRAMFS_IMAGE}:do_image_complete" | ||
| 23 | IMAGE_CMD_ostree () { | ||
| 24 | cp -a ${IMAGE_ROOTFS}/* ${OSTREE_ROOTFS} | ||
| 35 | chmod a+rx ${OSTREE_ROOTFS} | 25 | chmod a+rx ${OSTREE_ROOTFS} |
| 36 | sync | 26 | sync |
| 37 | 27 | ||
| 38 | cd ${OSTREE_ROOTFS} | ||
| 39 | |||
| 40 | for d in var/*; do | 28 | for d in var/*; do |
| 41 | if [ "${d}" != "var/local" ]; then | 29 | if [ "${d}" != "var/local" ]; then |
| 42 | rm -rf ${d} | 30 | rm -rf ${d} |
| @@ -53,18 +41,8 @@ IMAGE_CMD_ostree () { | |||
| 53 | mkdir -p usr/rootdirs | 41 | mkdir -p usr/rootdirs |
| 54 | 42 | ||
| 55 | mv etc usr/ | 43 | mv etc usr/ |
| 56 | # Implement UsrMove | ||
| 57 | dirs="bin sbin lib" | ||
| 58 | |||
| 59 | for dir in ${dirs} ; do | ||
| 60 | if [ -d ${dir} ] && [ ! -L ${dir} ] ; then | ||
| 61 | mv ${dir} usr/rootdirs/ | ||
| 62 | rm -rf ${dir} | ||
| 63 | ln -sf usr/rootdirs/${dir} ${dir} | ||
| 64 | fi | ||
| 65 | done | ||
| 66 | 44 | ||
| 67 | if [ -n "$SYSTEMD_USED" ]; then | 45 | if [ -n "${SYSTEMD_USED}" ]; then |
| 68 | mkdir -p usr/etc/tmpfiles.d | 46 | mkdir -p usr/etc/tmpfiles.d |
| 69 | tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf | 47 | tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf |
| 70 | echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf} | 48 | echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf} |
| @@ -100,7 +78,7 @@ IMAGE_CMD_ostree () { | |||
| 100 | bbwarn "Data in /$dir directory is not preserved by OSTree. Consider moving it under /usr" | 78 | bbwarn "Data in /$dir directory is not preserved by OSTree. Consider moving it under /usr" |
| 101 | fi | 79 | fi |
| 102 | 80 | ||
| 103 | if [ -n "$SYSTEMD_USED" ]; then | 81 | if [ -n "${SYSTEMD_USED}" ]; then |
| 104 | echo "d /var/rootdirs/${dir} 0755 root root -" >>${tmpfiles_conf} | 82 | echo "d /var/rootdirs/${dir} 0755 root root -" >>${tmpfiles_conf} |
| 105 | else | 83 | else |
| 106 | echo "mkdir -p /var/rootdirs/${dir}; chown 755 /var/rootdirs/${dir}" >>${tmpfiles_conf} | 84 | echo "mkdir -p /var/rootdirs/${dir}; chown 755 /var/rootdirs/${dir}" >>${tmpfiles_conf} |
| @@ -112,11 +90,10 @@ IMAGE_CMD_ostree () { | |||
| 112 | 90 | ||
| 113 | if [ -d root ] && [ ! -L root ]; then | 91 | if [ -d root ] && [ ! -L root ]; then |
| 114 | if [ "$(ls -A root)" ]; then | 92 | if [ "$(ls -A root)" ]; then |
| 115 | bberror "Data in /root directory is not preserved by OSTree." | 93 | bbfatal "Data in /root directory is not preserved by OSTree." |
| 116 | exit 1 | ||
| 117 | fi | 94 | fi |
| 118 | 95 | ||
| 119 | if [ -n "$SYSTEMD_USED" ]; then | 96 | if [ -n "${SYSTEMD_USED}" ]; then |
| 120 | echo "d /var/roothome 0755 root root -" >>${tmpfiles_conf} | 97 | echo "d /var/roothome 0755 root root -" >>${tmpfiles_conf} |
| 121 | else | 98 | else |
| 122 | echo "mkdir -p /var/roothome; chown 755 /var/roothome" >>${tmpfiles_conf} | 99 | echo "mkdir -p /var/roothome; chown 755 /var/roothome" >>${tmpfiles_conf} |
| @@ -126,11 +103,6 @@ IMAGE_CMD_ostree () { | |||
| 126 | ln -sf var/roothome root | 103 | ln -sf var/roothome root |
| 127 | fi | 104 | fi |
| 128 | 105 | ||
| 129 | if [ -n "${SOTA_SECONDARY_ECUS}" ]; then | ||
| 130 | mkdir -p var/sota/ecus | ||
| 131 | cp ${SOTA_SECONDARY_ECUS} var/sota/ecus | ||
| 132 | fi | ||
| 133 | |||
| 134 | checksum=`sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " "` | 106 | checksum=`sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " "` |
| 135 | 107 | ||
| 136 | cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} boot/vmlinuz-${checksum} | 108 | cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} boot/vmlinuz-${checksum} |
| @@ -145,17 +117,12 @@ IMAGE_CMD_ostree () { | |||
| 145 | 117 | ||
| 146 | # Copy image manifest | 118 | # Copy image manifest |
| 147 | cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest | 119 | cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest |
| 120 | } | ||
| 148 | 121 | ||
| 149 | cd ${WORKDIR} | 122 | IMAGE_TYPEDEP_ostreecommit = "ostree" |
| 150 | 123 | do_image_ostreecommit[depends] += "ostree-native:do_populate_sysroot" | |
| 151 | # Create a tarball that can be then commited to OSTree repo | 124 | do_image_ostreecommit[lockfiles] += "${OSTREE_REPO}/ostree.lock" |
| 152 | OSTREE_TAR=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ostree.tar.bz2 | 125 | IMAGE_CMD_ostreecommit () { |
| 153 | tar -C ${OSTREE_ROOTFS} --xattrs --xattrs-include='*' -cjf ${OSTREE_TAR} . | ||
| 154 | sync | ||
| 155 | |||
| 156 | rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 | ||
| 157 | ln -s ${IMAGE_NAME}.rootfs.ostree.tar.bz2 ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 | ||
| 158 | |||
| 159 | if ! ostree --repo=${OSTREE_REPO} refs 2>&1 > /dev/null; then | 126 | if ! ostree --repo=${OSTREE_REPO} refs 2>&1 > /dev/null; then |
| 160 | ostree --repo=${OSTREE_REPO} init --mode=archive-z2 | 127 | ostree --repo=${OSTREE_REPO} init --mode=archive-z2 |
| 161 | fi | 128 | fi |
| @@ -171,11 +138,9 @@ IMAGE_CMD_ostree () { | |||
| 171 | if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then | 138 | if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then |
| 172 | ostree --repo=${OSTREE_REPO} summary -u | 139 | ostree --repo=${OSTREE_REPO} summary -u |
| 173 | fi | 140 | fi |
| 174 | |||
| 175 | rm -rf ${OSTREE_ROOTFS} | ||
| 176 | } | 141 | } |
| 177 | 142 | ||
| 178 | IMAGE_TYPEDEP_ostreepush = "ostree" | 143 | IMAGE_TYPEDEP_ostreepush = "ostreecommit" |
| 179 | do_image_ostreepush[depends] += "aktualizr-native:do_populate_sysroot ca-certificates-native:do_populate_sysroot" | 144 | do_image_ostreepush[depends] += "aktualizr-native:do_populate_sysroot ca-certificates-native:do_populate_sysroot" |
| 180 | IMAGE_CMD_ostreepush () { | 145 | IMAGE_CMD_ostreepush () { |
| 181 | # Print warnings if credetials are not set or if the file has not been found. | 146 | # Print warnings if credetials are not set or if the file has not been found. |
| @@ -194,7 +159,7 @@ IMAGE_CMD_ostreepush () { | |||
| 194 | } | 159 | } |
| 195 | 160 | ||
| 196 | IMAGE_TYPEDEP_garagesign = "ostreepush" | 161 | IMAGE_TYPEDEP_garagesign = "ostreepush" |
| 197 | do_image_garagesign[depends] += "aktualizr-native:do_populate_sysroot" | 162 | do_image_garagesign[depends] += "unzip-native:do_populate_sysroot" |
| 198 | IMAGE_CMD_garagesign () { | 163 | IMAGE_CMD_garagesign () { |
| 199 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then | 164 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
| 200 | # if credentials are issued by a server that doesn't support offline signing, exit silently | 165 | # if credentials are issued by a server that doesn't support offline signing, exit silently |
| @@ -202,11 +167,9 @@ IMAGE_CMD_garagesign () { | |||
| 202 | 167 | ||
| 203 | java_version=$( java -version 2>&1 | awk -F '"' '/version/ {print $2}' ) | 168 | java_version=$( java -version 2>&1 | awk -F '"' '/version/ {print $2}' ) |
| 204 | if [ "${java_version}" = "" ]; then | 169 | if [ "${java_version}" = "" ]; then |
| 205 | bberror "Java is required for synchronization with update backend, but is not installed on the host machine" | 170 | bbfatal "Java is required for synchronization with update backend, but is not installed on the host machine" |
| 206 | exit 1 | ||
| 207 | elif [ "${java_version}" \< "1.8" ]; then | 171 | elif [ "${java_version}" \< "1.8" ]; then |
| 208 | bberror "Java version >= 8 is required for synchronization with update backend" | 172 | bbfatal "Java version >= 8 is required for synchronization with update backend" |
| 209 | exit 1 | ||
| 210 | fi | 173 | fi |
| 211 | 174 | ||
| 212 | rm -rf ${GARAGE_SIGN_REPO} | 175 | rm -rf ${GARAGE_SIGN_REPO} |
| @@ -240,7 +203,7 @@ IMAGE_CMD_garagesign () { | |||
| 240 | --length 0 \ | 203 | --length 0 \ |
| 241 | --url "${GARAGE_TARGET_URL}" \ | 204 | --url "${GARAGE_TARGET_URL}" \ |
| 242 | --sha256 ${ostree_target_hash} \ | 205 | --sha256 ${ostree_target_hash} \ |
| 243 | --hardwareids ${MACHINE} | 206 | --hardwareids ${SOTA_HARDWARE_ID} |
| 244 | garage-sign targets sign --repo tufrepo \ | 207 | garage-sign targets sign --repo tufrepo \ |
| 245 | --home-dir ${GARAGE_SIGN_REPO} \ | 208 | --home-dir ${GARAGE_SIGN_REPO} \ |
| 246 | --key-name=targets | 209 | --key-name=targets |
| @@ -257,14 +220,12 @@ IMAGE_CMD_garagesign () { | |||
| 257 | rm -rf ${GARAGE_SIGN_REPO} | 220 | rm -rf ${GARAGE_SIGN_REPO} |
| 258 | 221 | ||
| 259 | if [ "$push_success" -ne "1" ]; then | 222 | if [ "$push_success" -ne "1" ]; then |
| 260 | bberror "Couldn't push to garage repository" | 223 | bbfatal "Couldn't push to garage repository" |
| 261 | exit 1 | ||
| 262 | fi | 224 | fi |
| 263 | fi | 225 | fi |
| 264 | } | 226 | } |
| 265 | 227 | ||
| 266 | IMAGE_TYPEDEP_garagecheck = "ostreepush garagesign" | 228 | IMAGE_TYPEDEP_garagecheck = "garagesign" |
| 267 | do_image_garagecheck[depends] += "aktualizr-native:do_populate_sysroot" | ||
| 268 | IMAGE_CMD_garagecheck () { | 229 | IMAGE_CMD_garagecheck () { |
| 269 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then | 230 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
| 270 | # if credentials are issued by a server that doesn't support offline signing, exit silently | 231 | # 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..9883a68 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,38 +88,26 @@ 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}") |
| 130 | 98 | ||
| 131 | if [ $OTA_ROOTFS_SIZE -lt 0 ]; then | 99 | if [ ${OTA_ROOTFS_SIZE} -lt 0 ]; then |
| 132 | bbfatal "create_ota failed to calculate OTA rootfs size!" | 100 | bbfatal "create_ota failed to calculate OTA rootfs size!" |
| 133 | fi | 101 | fi |
| 134 | 102 | ||
| 135 | eval local COUNT=\"0\" | 103 | eval local COUNT=\"0\" |
| 136 | eval local MIN_COUNT=\"60\" | 104 | eval local MIN_COUNT=\"60\" |
| 137 | if [ $OTA_ROOTFS_SIZE -lt $MIN_COUNT ]; then | 105 | if [ ${OTA_ROOTFS_SIZE} -lt ${MIN_COUNT} ]; then |
| 138 | eval COUNT=\"$MIN_COUNT\" | 106 | eval COUNT=\"${MIN_COUNT}\" |
| 139 | fi | 107 | fi |
| 140 | 108 | ||
| 141 | dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ota-ext4 seek=${OTA_ROOTFS_SIZE} count=$COUNT bs=1024 | 109 | dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ota-ext4 seek=${OTA_ROOTFS_SIZE} count=${COUNT} bs=1024 |
| 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 98cc3de..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" |
| @@ -11,12 +5,14 @@ HOSTTOOLS_NONFATAL += "java" | |||
| 11 | SOTA_CLIENT ??= "aktualizr" | 5 | SOTA_CLIENT ??= "aktualizr" |
| 12 | SOTA_CLIENT_PROV ??= "aktualizr-auto-prov" | 6 | SOTA_CLIENT_PROV ??= "aktualizr-auto-prov" |
| 13 | SOTA_DEPLOY_CREDENTIALS ?= "1" | 7 | SOTA_DEPLOY_CREDENTIALS ?= "1" |
| 8 | SOTA_HARDWARE_ID ??= "${MACHINE}" | ||
| 14 | 9 | ||
| 15 | IMAGE_INSTALL_append_sota = " ostree os-release ${SOTA_CLIENT} ${SOTA_CLIENT_PROV}" | 10 | IMAGE_INSTALL_append_sota = " ostree os-release ${SOTA_CLIENT} ${SOTA_CLIENT_PROV}" |
| 16 | IMAGE_CLASSES += " image_types_ostree image_types_ota" | 11 | IMAGE_CLASSES += " image_types_ostree image_types_ota" |
| 17 | 12 | ||
| 18 | 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)}" |
| 19 | 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)}" | ||
| 20 | 16 | ||
| 21 | PACKAGECONFIG_append_pn-curl = " ssl" | 17 | PACKAGECONFIG_append_pn-curl = " ssl" |
| 22 | PACKAGECONFIG_remove_pn-curl = "gnutls" | 18 | PACKAGECONFIG_remove_pn-curl = "gnutls" |
| @@ -28,11 +24,13 @@ EXTRA_IMAGEDEPENDS_append_sota = " parted-native mtools-native dosfstools-native | |||
| 28 | 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')}" |
| 29 | 25 | ||
| 30 | # 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 |
| 31 | OSTREE_REPO ?= "${DEPLOY_DIR_IMAGE}/ostree_repo" | 27 | export OSTREE_REPO ?= "${DEPLOY_DIR_IMAGE}/ostree_repo" |
| 32 | OSTREE_BRANCHNAME ?= "${MACHINE}" | 28 | export OSTREE_BRANCHNAME ?= "${SOTA_HARDWARE_ID}" |
| 33 | OSTREE_OSNAME ?= "poky" | 29 | export OSTREE_OSNAME ?= "poky" |
| 30 | export OSTREE_BOOTLOADER ??= 'u-boot' | ||
| 31 | export OSTREE_BOOT_PARTITION ??= "/boot" | ||
| 32 | |||
| 34 | INITRAMFS_IMAGE ?= "initramfs-ostree-image" | 33 | INITRAMFS_IMAGE ?= "initramfs-ostree-image" |
| 35 | OSTREE_BOOTLOADER ??= 'u-boot' | ||
| 36 | 34 | ||
| 37 | GARAGE_SIGN_REPO ?= "${DEPLOY_DIR_IMAGE}/garage_sign_repo" | 35 | GARAGE_SIGN_REPO ?= "${DEPLOY_DIR_IMAGE}/garage_sign_repo" |
| 38 | GARAGE_SIGN_KEYNAME ?= "garage-key" | 36 | GARAGE_SIGN_KEYNAME ?= "garage-key" |
| @@ -48,6 +46,7 @@ SOTA_MACHINE_intel-corei7-64 ?= "minnowboard" | |||
| 48 | SOTA_MACHINE_qemux86-64 ?= "qemux86-64" | 46 | SOTA_MACHINE_qemux86-64 ?= "qemux86-64" |
| 49 | SOTA_MACHINE_am335x-evm ?= "am335x-evm-wifi" | 47 | SOTA_MACHINE_am335x-evm ?= "am335x-evm-wifi" |
| 50 | 48 | ||
| 51 | 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" | ||
| 52 | 51 | ||
| 53 | 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 | } | ||
