diff options
Diffstat (limited to 'classes/image_types_ota.bbclass')
-rw-r--r-- | classes/image_types_ota.bbclass | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index 857161a..ad067da 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass | |||
@@ -45,13 +45,17 @@ do_image_ota[cleandirs] = "${OTA_SYSROOT}" | |||
45 | do_image_ota[depends] = "${@'grub:do_populate_sysroot' if d.getVar('OSTREE_BOOTLOADER') == 'grub' else ''} \ | 45 | do_image_ota[depends] = "${@'grub:do_populate_sysroot' if d.getVar('OSTREE_BOOTLOADER') == 'grub' else ''} \ |
46 | ${@'virtual/bootloader:do_deploy' if d.getVar('OSTREE_BOOTLOADER') == 'u-boot' else ''}" | 46 | ${@'virtual/bootloader:do_deploy' if d.getVar('OSTREE_BOOTLOADER') == 'u-boot' else ''}" |
47 | IMAGE_CMD_ota () { | 47 | IMAGE_CMD_ota () { |
48 | export OSTREE_BOOT_PARTITION=${OSTREE_BOOT_PARTITION} | ||
49 | ostree admin --sysroot=${OTA_SYSROOT} init-fs ${OTA_SYSROOT} | 48 | ostree admin --sysroot=${OTA_SYSROOT} init-fs ${OTA_SYSROOT} |
50 | ostree admin --sysroot=${OTA_SYSROOT} os-init ${OSTREE_OSNAME} | 49 | ostree admin --sysroot=${OTA_SYSROOT} os-init ${OSTREE_OSNAME} |
50 | |||
51 | # Preparation required to steer ostree bootloader detection | ||
51 | mkdir -p ${OTA_SYSROOT}/boot/loader.0 | 52 | mkdir -p ${OTA_SYSROOT}/boot/loader.0 |
52 | ln -s loader.0 ${OTA_SYSROOT}/boot/loader | 53 | ln -s loader.0 ${OTA_SYSROOT}/boot/loader |
53 | 54 | ||
54 | if [ "${OSTREE_BOOTLOADER}" = "grub" ]; then | 55 | if [ "${OSTREE_BOOTLOADER}" = "grub" ]; then |
56 | # Used by ostree-grub-generator called by the ostree binary | ||
57 | export OSTREE_BOOT_PARTITION=${OSTREE_BOOT_PARTITION} | ||
58 | |||
55 | mkdir -p ${OTA_SYSROOT}/boot/grub2 | 59 | mkdir -p ${OTA_SYSROOT}/boot/grub2 |
56 | ln -s ../loader/grub.cfg ${OTA_SYSROOT}/boot/grub2/grub.cfg | 60 | ln -s ../loader/grub.cfg ${OTA_SYSROOT}/boot/grub2/grub.cfg |
57 | elif [ "${OSTREE_BOOTLOADER}" = "u-boot" ]; then | 61 | elif [ "${OSTREE_BOOTLOADER}" = "u-boot" ]; then |
@@ -60,15 +64,25 @@ IMAGE_CMD_ota () { | |||
60 | bbfatal "Invalid bootloader: ${OSTREE_BOOTLOADER}" | 64 | bbfatal "Invalid bootloader: ${OSTREE_BOOTLOADER}" |
61 | fi | 65 | fi |
62 | 66 | ||
63 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) | 67 | ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest) |
64 | 68 | ||
69 | # Use OSTree hash to avoid any potential race conditions between | ||
70 | # multiple builds accessing the same ${OSTREE_REPO}. | ||
65 | ostree --repo=${OTA_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${ostree_target_hash} | 71 | ostree --repo=${OTA_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${ostree_target_hash} |
66 | kargs_list="" | 72 | kargs_list="" |
67 | for arg in ${OSTREE_KERNEL_ARGS}; do | 73 | for arg in ${OSTREE_KERNEL_ARGS}; do |
68 | kargs_list="${kargs_list} --karg-append=$arg" | 74 | kargs_list="${kargs_list} --karg-append=$arg" |
69 | done | 75 | done |
70 | 76 | ||
71 | ostree admin --sysroot=${OTA_SYSROOT} deploy ${kargs_list} --os=${OSTREE_OSNAME} ${ostree_target_hash} | 77 | # Create the same reference on the device we use in the archive OSTree |
78 | # repo in ${OSTREE_REPO}. This reference will show up when showing the | ||
79 | # deployment on the device: | ||
80 | # ostree admin status | ||
81 | # If a remote with the name ${OSTREE_OSNAME} is configured, this also | ||
82 | # will allow to use: | ||
83 | # ostree admin upgrade | ||
84 | ostree --repo=${OTA_SYSROOT}/ostree/repo refs --create=${OSTREE_OSNAME}:${OSTREE_BRANCHNAME} ${ostree_target_hash} | ||
85 | ostree admin --sysroot=${OTA_SYSROOT} deploy ${kargs_list} --os=${OSTREE_OSNAME} ${OSTREE_OSNAME}:${OSTREE_BRANCHNAME} | ||
72 | 86 | ||
73 | cp -a ${IMAGE_ROOTFS}/var/sota ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true | 87 | cp -a ${IMAGE_ROOTFS}/var/sota ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true |
74 | # Create /var/sota if it doesn't exist yet | 88 | # Create /var/sota if it doesn't exist yet |
@@ -76,8 +90,8 @@ IMAGE_CMD_ota () { | |||
76 | # Ensure the permissions are correctly set | 90 | # Ensure the permissions are correctly set |
77 | chmod 700 ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota | 91 | chmod 700 ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota |
78 | 92 | ||
79 | cp -a ${OSTREE_ROOTFS}/var/local ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true | 93 | cp -a ${IMAGE_ROOTFS}/var/local ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true |
80 | cp -a ${OSTREE_ROOTFS}/usr/homedirs/home ${OTA_SYSROOT}/ || true | 94 | cp -a ${IMAGE_ROOTFS}/home ${OTA_SYSROOT}/ || true |
81 | # Ensure that /var/local exists (AGL symlinks /usr/local to /var/local) | 95 | # Ensure that /var/local exists (AGL symlinks /usr/local to /var/local) |
82 | install -d ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/local | 96 | install -d ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/local |
83 | # Set package version for the first deployment | 97 | # Set package version for the first deployment |