summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorPatrick Vacek <patrickvacek@gmail.com>2020-05-05 14:11:26 +0200
committerGitHub <noreply@github.com>2020-05-05 14:11:26 +0200
commit82d7e04924f847bccba3136d1602d5646486a926 (patch)
treeeaab4e83881eaf69ca6dbeedfe8189d02c784959 /classes
parent7b7392c10d7c41a0cd13b20da90837303b01b711 (diff)
parentfb058bb8eedd9a3a168fa87534f55d1ea610a90a (diff)
downloadmeta-updater-82d7e04924f847bccba3136d1602d5646486a926.tar.gz
Merge pull request #713 from agners/master-ostree-improvements
OSTree task improvements
Diffstat (limited to 'classes')
-rw-r--r--classes/image_types_ostree.bbclass37
-rw-r--r--classes/image_types_ota.bbclass16
2 files changed, 31 insertions, 22 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass
index ce9f984..a8a6c39 100644
--- a/classes/image_types_ostree.bbclass
+++ b/classes/image_types_ostree.bbclass
@@ -20,14 +20,24 @@ CONVERSION_CMD_tar = "touch ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${
20CONVERSIONTYPES_append = " tar" 20CONVERSIONTYPES_append = " tar"
21 21
22TAR_IMAGE_ROOTFS_task-image-ostree = "${OSTREE_ROOTFS}" 22TAR_IMAGE_ROOTFS_task-image-ostree = "${OSTREE_ROOTFS}"
23
24python prepare_ostree_rootfs() {
25 import oe.path
26 import shutil
27
28 ostree_rootfs = d.getVar("OSTREE_ROOTFS")
29 if os.path.lexists(ostree_rootfs):
30 bb.utils.remove(ostree_rootfs, True)
31
32 # Copy required as we change permissions on some files.
33 image_rootfs = d.getVar("IMAGE_ROOTFS")
34 oe.path.copyhardlinktree(image_rootfs, ostree_rootfs)
35}
36
23do_image_ostree[dirs] = "${OSTREE_ROOTFS}" 37do_image_ostree[dirs] = "${OSTREE_ROOTFS}"
24do_image_ostree[cleandirs] = "${OSTREE_ROOTFS}" 38do_image_ostree[prefuncs] += "prepare_ostree_rootfs"
25do_image_ostree[depends] = "coreutils-native:do_populate_sysroot virtual/kernel:do_deploy ${INITRAMFS_IMAGE}:do_image_complete" 39do_image_ostree[depends] = "coreutils-native:do_populate_sysroot virtual/kernel:do_deploy ${INITRAMFS_IMAGE}:do_image_complete"
26IMAGE_CMD_ostree () { 40IMAGE_CMD_ostree () {
27 cp -a ${IMAGE_ROOTFS}/* ${OSTREE_ROOTFS}
28 chmod a+rx ${OSTREE_ROOTFS}
29 sync
30
31 for d in var/*; do 41 for d in var/*; do
32 if [ "${d}" != "var/local" ]; then 42 if [ "${d}" != "var/local" ]; then
33 rm -rf ${d} 43 rm -rf ${d}
@@ -38,9 +48,6 @@ IMAGE_CMD_ostree () {
38 mkdir sysroot 48 mkdir sysroot
39 ln -sf sysroot/ostree ostree 49 ln -sf sysroot/ostree ostree
40 50
41 rm -rf tmp/*
42 ln -sf sysroot/tmp tmp
43
44 mkdir -p usr/rootdirs 51 mkdir -p usr/rootdirs
45 52
46 mv etc usr/ 53 mv etc usr/
@@ -49,13 +56,11 @@ IMAGE_CMD_ostree () {
49 mkdir -p usr/etc/tmpfiles.d 56 mkdir -p usr/etc/tmpfiles.d
50 tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf 57 tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf
51 echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf} 58 echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf}
52 echo "L /var/rootdirs/home - - - - /sysroot/home" >>${tmpfiles_conf}
53 else 59 else
54 mkdir -p usr/etc/init.d 60 mkdir -p usr/etc/init.d
55 tmpfiles_conf=usr/etc/init.d/tmpfiles.sh 61 tmpfiles_conf=usr/etc/init.d/tmpfiles.sh
56 echo '#!/bin/sh' > ${tmpfiles_conf} 62 echo '#!/bin/sh' > ${tmpfiles_conf}
57 echo "mkdir -p /var/rootdirs; chmod 755 /var/rootdirs" >> ${tmpfiles_conf} 63 echo "mkdir -p /var/rootdirs; chmod 755 /var/rootdirs" >> ${tmpfiles_conf}
58 echo "ln -sf /sysroot/home /var/rootdirs/home" >> ${tmpfiles_conf}
59 64
60 ln -s ../init.d/tmpfiles.sh usr/etc/rcS.d/S20tmpfiles.sh 65 ln -s ../init.d/tmpfiles.sh usr/etc/rcS.d/S20tmpfiles.sh
61 fi 66 fi
@@ -64,13 +69,11 @@ IMAGE_CMD_ostree () {
64 mkdir -p usr/share/sota/ 69 mkdir -p usr/share/sota/
65 echo -n "${OSTREE_BRANCHNAME}" > usr/share/sota/branchname 70 echo -n "${OSTREE_BRANCHNAME}" > usr/share/sota/branchname
66 71
67 # Preserve data in /home to be later copied to /sysroot/home by sysroot 72 # home directories get copied from the OE root later to the final sysroot
68 # generating procedure 73 # Create a symlink to var/rootdirs/home to make sure the OSTree deployment
69 mkdir -p usr/homedirs 74 # redirects /home to /var/rootdirs/home.
70 if [ -d "home" ] && [ ! -L "home" ]; then 75 rm -rf home/
71 mv home usr/homedirs/home 76 ln -sf var/rootdirs/home home
72 ln -sf var/rootdirs/home home
73 fi
74 77
75 # Move persistent directories to /var 78 # Move persistent directories to /var
76 dirs="opt mnt media srv" 79 dirs="opt mnt media srv"
diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass
index 2cc8913..374ddc2 100644
--- a/classes/image_types_ota.bbclass
+++ b/classes/image_types_ota.bbclass
@@ -45,14 +45,17 @@ do_image_ota[cleandirs] = "${OTA_SYSROOT}"
45do_image_ota[depends] = "${@'grub:do_populate_sysroot' if d.getVar('OSTREE_BOOTLOADER') == 'grub' else ''} \ 45do_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 ''}"
47IMAGE_CMD_ota () { 47IMAGE_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
@@ -77,8 +80,11 @@ IMAGE_CMD_ota () {
77 # Ensure the permissions are correctly set 80 # Ensure the permissions are correctly set
78 chmod 700 ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota 81 chmod 700 ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota
79 82
80 cp -a ${OSTREE_ROOTFS}/var/local ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true 83 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 84
85 mkdir -p ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/rootdirs
86 cp -a ${IMAGE_ROOTFS}/home ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/rootdirs/home || true
87
82 # Ensure that /var/local exists (AGL symlinks /usr/local to /var/local) 88 # Ensure that /var/local exists (AGL symlinks /usr/local to /var/local)
83 install -d ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/local 89 install -d ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/local
84 # Set package version for the first deployment 90 # Set package version for the first deployment