diff options
Diffstat (limited to 'classes/image_types_ota.bbclass')
-rw-r--r-- | classes/image_types_ota.bbclass | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index 2cc8913..a8a19b5 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass | |||
@@ -45,14 +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} | 48 | ostree admin --sysroot=${OTA_SYSROOT} init-fs --modern ${OTA_SYSROOT} |
49 | |||
50 | ostree admin --sysroot=${OTA_SYSROOT} init-fs ${OTA_SYSROOT} | ||
51 | 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 | ||
52 | mkdir -p ${OTA_SYSROOT}/boot/loader.0 | 52 | mkdir -p ${OTA_SYSROOT}/boot/loader.0 |
53 | ln -s loader.0 ${OTA_SYSROOT}/boot/loader | 53 | ln -s loader.0 ${OTA_SYSROOT}/boot/loader |
54 | 54 | ||
55 | 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 | |||
56 | mkdir -p ${OTA_SYSROOT}/boot/grub2 | 59 | mkdir -p ${OTA_SYSROOT}/boot/grub2 |
57 | ln -s ../loader/grub.cfg ${OTA_SYSROOT}/boot/grub2/grub.cfg | 60 | ln -s ../loader/grub.cfg ${OTA_SYSROOT}/boot/grub2/grub.cfg |
58 | elif [ "${OSTREE_BOOTLOADER}" = "u-boot" ]; then | 61 | elif [ "${OSTREE_BOOTLOADER}" = "u-boot" ]; then |
@@ -61,15 +64,25 @@ IMAGE_CMD_ota () { | |||
61 | bbfatal "Invalid bootloader: ${OSTREE_BOOTLOADER}" | 64 | bbfatal "Invalid bootloader: ${OSTREE_BOOTLOADER}" |
62 | fi | 65 | fi |
63 | 66 | ||
64 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) | 67 | ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest) |
65 | 68 | ||
69 | # Use OSTree hash to avoid any potential race conditions between | ||
70 | # multiple builds accessing the same ${OSTREE_REPO}. | ||
66 | 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} |
67 | kargs_list="" | 72 | kargs_list="" |
68 | for arg in ${OSTREE_KERNEL_ARGS}; do | 73 | for arg in ${OSTREE_KERNEL_ARGS}; do |
69 | kargs_list="${kargs_list} --karg-append=$arg" | 74 | kargs_list="${kargs_list} --karg-append=$arg" |
70 | done | 75 | done |
71 | 76 | ||
72 | 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} | ||
73 | 86 | ||
74 | 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 |
75 | # Create /var/sota if it doesn't exist yet | 88 | # Create /var/sota if it doesn't exist yet |
@@ -77,8 +90,11 @@ IMAGE_CMD_ota () { | |||
77 | # Ensure the permissions are correctly set | 90 | # Ensure the permissions are correctly set |
78 | chmod 700 ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota | 91 | chmod 700 ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota |
79 | 92 | ||
80 | 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 |
81 | cp -a ${OSTREE_ROOTFS}/usr/homedirs/home ${OTA_SYSROOT}/ || true | 94 | |
95 | mkdir -p ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/rootdirs | ||
96 | cp -a ${IMAGE_ROOTFS}/home ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/rootdirs/home || true | ||
97 | |||
82 | # Ensure that /var/local exists (AGL symlinks /usr/local to /var/local) | 98 | # Ensure that /var/local exists (AGL symlinks /usr/local to /var/local) |
83 | install -d ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/local | 99 | install -d ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/local |
84 | # Set package version for the first deployment | 100 | # Set package version for the first deployment |