diff options
-rw-r--r-- | README.adoc | 2 | ||||
-rw-r--r-- | classes/image_types_ostree.bbclass | 14 | ||||
-rw-r--r-- | classes/sota.bbclass | 4 | ||||
-rw-r--r-- | classes/sota_qemux86-64.bbclass | 2 | ||||
-rw-r--r-- | classes/sota_raspberrypi.bbclass | 2 | ||||
-rw-r--r-- | recipes-core/images/initramfs-ostree-image.bb | 2 | ||||
-rw-r--r-- | recipes-sota/ostree-initrd/files/init.sh | 22 | ||||
-rw-r--r-- | recipes-sota/ostree-initrd/ostree-initrd.bb | 10 |
8 files changed, 26 insertions, 32 deletions
diff --git a/README.adoc b/README.adoc index d2bd4b5..7ffdde2 100644 --- a/README.adoc +++ b/README.adoc | |||
@@ -78,7 +78,7 @@ Although we have used U-Boot so far, other boot loaders can be configured work w | |||
78 | 78 | ||
79 | * `OSTREE_REPO` - path to your OSTree repository. Defaults to `$\{DEPLOY_DIR_IMAGE}/ostree_repo` | 79 | * `OSTREE_REPO` - path to your OSTree repository. Defaults to `$\{DEPLOY_DIR_IMAGE}/ostree_repo` |
80 | * `OSTREE_OSNAME` - OS deployment name on your target device. For more information about deployments and osnames see the https://ostree.readthedocs.io/en/latest/manual/deployment/[OSTree documentation]. Defaults to "poky". | 80 | * `OSTREE_OSNAME` - OS deployment name on your target device. For more information about deployments and osnames see the https://ostree.readthedocs.io/en/latest/manual/deployment/[OSTree documentation]. Defaults to "poky". |
81 | * `OSTREE_INITRAMFS_IMAGE` - initramfs/initrd image that is used as a proxy while booting into OSTree deployment. Do not change this setting unless you are sure that your initramfs can serve as such a proxy. | 81 | * `INITRAMFS_IMAGE` - initramfs/initrd image that is used as a proxy while booting into OSTree deployment. Do not change this setting unless you are sure that your initramfs can serve as such a proxy. |
82 | * `SOTA_PACKED_CREDENTIALS` - when set, your ostree commit will be pushed to a remote repo as a bitbake step. This should be the path to a zipped credentials file in https://github.com/advancedtelematic/aktualizr/blob/master/docs/credentials.adoc[the format accepted by garage-push]. | 82 | * `SOTA_PACKED_CREDENTIALS` - when set, your ostree commit will be pushed to a remote repo as a bitbake step. This should be the path to a zipped credentials file in https://github.com/advancedtelematic/aktualizr/blob/master/docs/credentials.adoc[the format accepted by garage-push]. |
83 | * `SOTA_CLIENT_PROV` - which provisioning method to use. Valid options are https://github.com/advancedtelematic/aktualizr/blob/master/docs/automatic-provisioning.adoc[`aktualizr-auto-prov`], https://github.com/advancedtelematic/aktualizr/blob/master/docs/implicit-provisioning.adoc[`aktualizr-implicit-prov`], and https://github.com/advancedtelematic/aktualizr/blob/master/docs/hsm-provisioning.adoc[`aktualizr-hsm-prov`]. The default is `aktualizr-auto-prov`. This can also be set to an empty string to avoid using a provisioning recipe. | 83 | * `SOTA_CLIENT_PROV` - which provisioning method to use. Valid options are https://github.com/advancedtelematic/aktualizr/blob/master/docs/automatic-provisioning.adoc[`aktualizr-auto-prov`], https://github.com/advancedtelematic/aktualizr/blob/master/docs/implicit-provisioning.adoc[`aktualizr-implicit-prov`], and https://github.com/advancedtelematic/aktualizr/blob/master/docs/hsm-provisioning.adoc[`aktualizr-hsm-prov`]. The default is `aktualizr-auto-prov`. This can also be set to an empty string to avoid using a provisioning recipe. |
84 | * `SOTA_CLIENT_FEATURES` - extensions to aktualizr. The only valid options are `hsm` (to build with HSM support) and `secondary-network` (to set up a simulated 'in-vehicle' network with support for a primary node with a DHCP server and a secondary node with a DHCP client). | 84 | * `SOTA_CLIENT_FEATURES` - extensions to aktualizr. The only valid options are `hsm` (to build with HSM support) and `secondary-network` (to set up a simulated 'in-vehicle' network with support for a primary node with a DHCP server and a secondary node with a DHCP client). |
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index ca8aee3..b525738 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
@@ -5,14 +5,13 @@ do_image_ostree[depends] += "ostree-native:do_populate_sysroot \ | |||
5 | coreutils-native:do_populate_sysroot \ | 5 | coreutils-native:do_populate_sysroot \ |
6 | unzip-native:do_populate_sysroot \ | 6 | unzip-native:do_populate_sysroot \ |
7 | virtual/kernel:do_deploy \ | 7 | virtual/kernel:do_deploy \ |
8 | ${OSTREE_INITRAMFS_IMAGE}:do_image_complete" | 8 | ${INITRAMFS_IMAGE}:do_image_complete \ |
9 | " | ||
9 | 10 | ||
10 | export OSTREE_REPO | 11 | export OSTREE_REPO |
11 | export OSTREE_BRANCHNAME | 12 | export OSTREE_BRANCHNAME |
12 | export GARAGE_TARGET_NAME | 13 | export GARAGE_TARGET_NAME |
13 | 14 | ||
14 | RAMDISK_EXT ?= ".${OSTREE_INITRAMFS_FSTYPES}" | ||
15 | |||
16 | OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" | 15 | OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" |
17 | 16 | ||
18 | export SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 'systemd', 'true', '')}" | 17 | export SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 'systemd', 'true', '')}" |
@@ -124,7 +123,14 @@ IMAGE_CMD_ostree () { | |||
124 | checksum=`sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " "` | 123 | checksum=`sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " "` |
125 | 124 | ||
126 | cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} boot/vmlinuz-${checksum} | 125 | cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} boot/vmlinuz-${checksum} |
127 | cp ${DEPLOY_DIR_IMAGE}/${OSTREE_INITRAMFS_IMAGE}-${MACHINE}${RAMDISK_EXT} boot/initramfs-${checksum} | 126 | |
127 | if [ "${KERNEL_IMAGETYPE}" = "fitImage" ]; then | ||
128 | # this is a hack for ostree not to override init= in kernel cmdline - | ||
129 | # make it think that the initramfs is present (while it is in FIT image) | ||
130 | touch boot/initramfs-${checksum} | ||
131 | else | ||
132 | cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} boot/initramfs-${checksum} | ||
133 | fi | ||
128 | 134 | ||
129 | # Copy image manifest | 135 | # Copy image manifest |
130 | cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest | 136 | cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest |
diff --git a/classes/sota.bbclass b/classes/sota.bbclass index 3aca92c..f5c6247 100644 --- a/classes/sota.bbclass +++ b/classes/sota.bbclass | |||
@@ -23,13 +23,13 @@ WKS_FILE_sota ?= "sdimage-sota.wks" | |||
23 | 23 | ||
24 | EXTRA_IMAGEDEPENDS_append_sota = " parted-native mtools-native dosfstools-native" | 24 | EXTRA_IMAGEDEPENDS_append_sota = " parted-native mtools-native dosfstools-native" |
25 | 25 | ||
26 | OSTREE_INITRAMFS_FSTYPES ??= "${@oe.utils.ifelse(d.getVar('OSTREE_BOOTLOADER', True) == 'u-boot', 'ext4.gz.u-boot', 'ext4.gz')}" | 26 | INITRAMFS_FSTYPES ??= "${@oe.utils.ifelse(d.getVar('OSTREE_BOOTLOADER', True) == 'u-boot', 'cpio.gz.u-boot', 'cpio.gz')}" |
27 | 27 | ||
28 | # Please redefine OSTREE_REPO in order to have a persistent OSTree repo | 28 | # Please redefine OSTREE_REPO in order to have a persistent OSTree repo |
29 | OSTREE_REPO ?= "${DEPLOY_DIR_IMAGE}/ostree_repo" | 29 | OSTREE_REPO ?= "${DEPLOY_DIR_IMAGE}/ostree_repo" |
30 | OSTREE_BRANCHNAME ?= "${MACHINE}" | 30 | OSTREE_BRANCHNAME ?= "${MACHINE}" |
31 | OSTREE_OSNAME ?= "poky" | 31 | OSTREE_OSNAME ?= "poky" |
32 | OSTREE_INITRAMFS_IMAGE ?= "initramfs-ostree-image" | 32 | INITRAMFS_IMAGE ?= "initramfs-ostree-image" |
33 | OSTREE_BOOTLOADER ??= 'u-boot' | 33 | OSTREE_BOOTLOADER ??= 'u-boot' |
34 | 34 | ||
35 | GARAGE_SIGN_REPO ?= "${DEPLOY_DIR_IMAGE}/garage_sign_repo" | 35 | GARAGE_SIGN_REPO ?= "${DEPLOY_DIR_IMAGE}/garage_sign_repo" |
diff --git a/classes/sota_qemux86-64.bbclass b/classes/sota_qemux86-64.bbclass index 82efe52..0850af6 100644 --- a/classes/sota_qemux86-64.bbclass +++ b/classes/sota_qemux86-64.bbclass | |||
@@ -4,7 +4,7 @@ IMAGE_FSTYPES_remove = "wic" | |||
4 | PREFERRED_PROVIDER_virtual/bootloader_sota = "u-boot" | 4 | PREFERRED_PROVIDER_virtual/bootloader_sota = "u-boot" |
5 | UBOOT_MACHINE_sota = "qemu-x86_defconfig" | 5 | UBOOT_MACHINE_sota = "qemu-x86_defconfig" |
6 | OSTREE_BOOTLOADER ?= "u-boot" | 6 | OSTREE_BOOTLOADER ?= "u-boot" |
7 | OSTREE_INITRAMFS_FSTYPES ?= "ext4.gz" | 7 | INITRAMFS_FSTYPES ?= "cpio.gz" |
8 | 8 | ||
9 | OSTREE_KERNEL_ARGS ?= "ramdisk_size=16384 rw rootfstype=ext4 rootwait rootdelay=2 ostree_root=/dev/hda" | 9 | OSTREE_KERNEL_ARGS ?= "ramdisk_size=16384 rw rootfstype=ext4 rootwait rootdelay=2 ostree_root=/dev/hda" |
10 | 10 | ||
diff --git a/classes/sota_raspberrypi.bbclass b/classes/sota_raspberrypi.bbclass index a5558b4..e5f002d 100644 --- a/classes/sota_raspberrypi.bbclass +++ b/classes/sota_raspberrypi.bbclass | |||
@@ -2,6 +2,8 @@ RPI_USE_U_BOOT_sota = "1" | |||
2 | 2 | ||
3 | KERNEL_CLASSES_append_sota = " kernel-fitimage" | 3 | KERNEL_CLASSES_append_sota = " kernel-fitimage" |
4 | KERNEL_IMAGETYPE_sota = "fitImage" | 4 | KERNEL_IMAGETYPE_sota = "fitImage" |
5 | OSTREE_KERNEL = "${KERNEL_IMAGETYPE}-${INITRAMFS_IMAGE}-${MACHINE}.bin" | ||
6 | INITRAMFS_FSTYPES = "cpio.gz" | ||
5 | 7 | ||
6 | PREFERRED_PROVIDER_virtual/bootloader_sota ?= "u-boot" | 8 | PREFERRED_PROVIDER_virtual/bootloader_sota ?= "u-boot" |
7 | UBOOT_ENTRYPOINT_sota ?= "0x00008000" | 9 | UBOOT_ENTRYPOINT_sota ?= "0x00008000" |
diff --git a/recipes-core/images/initramfs-ostree-image.bb b/recipes-core/images/initramfs-ostree-image.bb index b2d9e27..e77499e 100644 --- a/recipes-core/images/initramfs-ostree-image.bb +++ b/recipes-core/images/initramfs-ostree-image.bb | |||
@@ -13,7 +13,7 @@ IMAGE_LINGUAS = "" | |||
13 | 13 | ||
14 | LICENSE = "MIT" | 14 | LICENSE = "MIT" |
15 | 15 | ||
16 | IMAGE_FSTYPES = "${OSTREE_INITRAMFS_FSTYPES}" | 16 | IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}" |
17 | 17 | ||
18 | inherit core-image | 18 | inherit core-image |
19 | 19 | ||
diff --git a/recipes-sota/ostree-initrd/files/init.sh b/recipes-sota/ostree-initrd/files/init.sh index d7e0429..4818a07 100644 --- a/recipes-sota/ostree-initrd/files/init.sh +++ b/recipes-sota/ostree-initrd/files/init.sh | |||
@@ -41,7 +41,6 @@ do_mount_fs sysfs /sys | |||
41 | do_mount_fs devtmpfs /dev | 41 | do_mount_fs devtmpfs /dev |
42 | do_mount_fs devpts /dev/pts | 42 | do_mount_fs devpts /dev/pts |
43 | do_mount_fs tmpfs /dev/shm | 43 | do_mount_fs tmpfs /dev/shm |
44 | do_mount_fs tmpfs /tmp | ||
45 | do_mount_fs tmpfs /run | 44 | do_mount_fs tmpfs /run |
46 | 45 | ||
47 | # check if smack is active (and if so, mount smackfs) | 46 | # check if smack is active (and if so, mount smackfs) |
@@ -63,23 +62,10 @@ mount "$ostree_sysroot" /sysroot || { | |||
63 | sleep 5 | 62 | sleep 5 |
64 | mount "$ostree_sysroot" /sysroot || bail_out "Unable to mount $ostree_sysroot as physical sysroot" | 63 | mount "$ostree_sysroot" /sysroot || bail_out "Unable to mount $ostree_sysroot as physical sysroot" |
65 | } | 64 | } |
66 | ostree-prepare-root /sysroot | ||
67 | |||
68 | # move mounted devices to new root | ||
69 | cd /sysroot | ||
70 | for x in dev proc run; do | ||
71 | log_info "Moving /$x to new rootfs" | ||
72 | mount -o move "/$x" "$x" | ||
73 | done | ||
74 | |||
75 | # switch to new rootfs | ||
76 | log_info "Switching to new rootfs" | ||
77 | mkdir -p run/initramfs | ||
78 | 65 | ||
79 | pivot_root . run/initramfs || bail_out "pivot_root failed." | 66 | ostree-prepare-root /sysroot |
80 | |||
81 | log_info "Launching target init" | ||
82 | 67 | ||
83 | exec chroot . sh -c 'umount /run/initramfs; exec /sbin/init' \ | 68 | log_info "Switching to rootfs" |
84 | <dev/console >dev/console 2>&1 | 69 | exec switch_root /sysroot /sbin/init |
85 | 70 | ||
71 | bail_out "Failed to switch_root to $ostree_sysroot" | ||
diff --git a/recipes-sota/ostree-initrd/ostree-initrd.bb b/recipes-sota/ostree-initrd/ostree-initrd.bb index 6046c81..26525c8 100644 --- a/recipes-sota/ostree-initrd/ostree-initrd.bb +++ b/recipes-sota/ostree-initrd/ostree-initrd.bb | |||
@@ -1,20 +1,20 @@ | |||
1 | SUMMARY = "Extremely basic live image init script" | 1 | SUMMARY = "Initramfs for booting into libostree managed system" |
2 | LICENSE = "MIT" | 2 | LICENSE = "MIT" |
3 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" | 3 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" |
4 | |||
4 | SRC_URI = "file://init.sh" | 5 | SRC_URI = "file://init.sh" |
5 | 6 | ||
6 | S = "${WORKDIR}" | 7 | S = "${WORKDIR}" |
7 | 8 | ||
8 | PV = "3" | 9 | PV = "4" |
9 | 10 | ||
10 | do_install() { | 11 | do_install() { |
11 | install -dm 0755 ${D}/etc | 12 | install -dm 0755 ${D}/etc |
12 | touch ${D}/etc/initrd-release | 13 | touch ${D}/etc/initrd-release |
13 | install -dm 0755 ${D}/dev | 14 | install -dm 0755 ${D}/dev |
14 | install -dm 0755 ${D}/sbin | 15 | install -m 0755 ${WORKDIR}/init.sh ${D}/init |
15 | install -m 0755 ${WORKDIR}/init.sh ${D}/sbin/init | ||
16 | } | 16 | } |
17 | 17 | ||
18 | inherit allarch | 18 | inherit allarch |
19 | 19 | ||
20 | FILES_${PN} += " /dev /etc/initrd-release /sbin/init " | 20 | FILES_${PN} += " /dev /etc/initrd-release /init " |