From 74f1102e180e26d4b99d15c88cf9eab4d694d112 Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Tue, 3 Mar 2026 12:44:51 +0100 Subject: [PATCH 01/20] chore(omnect-is-int): replaces legacy initramfs scripts with Rust init --- classes/omnect_initramfs.bbclass | 12 - recipes-omnect/images/omnect-os-initramfs.bb | 32 +- .../omnect-os-initramfs-scripts.bb | 94 ----- .../omnect-os-initramfs/common-sh | 392 ------------------ .../omnect-os-initramfs/factory-reset | 337 --------------- .../omnect-os-initramfs/flash-mode-1 | 256 ------------ .../omnect-os-initramfs/flash-mode-2 | 125 ------ .../omnect-os-initramfs/flash-mode-3 | 110 ----- .../initrdscripts/omnect-os-initramfs/fs-link | 28 -- .../omnect-os-initramfs/fs-mount | 69 --- .../initrdscripts/omnect-os-initramfs/grub-sh | 144 ------- .../omnect-os-initramfs/imx-sdma | 20 - .../omnect-device-service-setup | 108 ----- .../omnect-os-initramfs/persistent-var-log | 15 - .../omnect-os-initramfs/resize-data | 69 --- .../omnect-os-initramfs/rootblk-dev | 12 - .../omnect-os-initramfs/uboot-sh | 96 ----- .../omnect-base-files/omnect-base-files.bb | 2 + .../omnect-os-init/omnect-os-init.inc | 17 + .../omnect-os-init/omnect-os-init_0.1.0.bb | 153 +++++++ 20 files changed, 175 insertions(+), 1916 deletions(-) delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs-scripts.bb delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/common-sh delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/factory-reset delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/flash-mode-1 delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/flash-mode-2 delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/flash-mode-3 delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/fs-link delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/fs-mount delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/grub-sh delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/imx-sdma delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/omnect-device-service-setup delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/persistent-var-log delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/resize-data delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/rootblk-dev delete mode 100644 recipes-omnect/initrdscripts/omnect-os-initramfs/uboot-sh create mode 100644 recipes-omnect/omnect-os-init/omnect-os-init.inc create mode 100644 recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb diff --git a/classes/omnect_initramfs.bbclass b/classes/omnect_initramfs.bbclass index 3bf205666..b7a0c8b78 100644 --- a/classes/omnect_initramfs.bbclass +++ b/classes/omnect_initramfs.bbclass @@ -11,15 +11,3 @@ IMAGE_FEATURES = "" IMAGE_LINGUAS = "" KERNELDEPMODDEPEND = "" IMAGE_NAME_SUFFIX = "" - -# don't use rootfs module initramfs-framework-base -BAD_RECOMMENDATIONS += "initramfs-module-rootfs" - -# check consistency of script ordering -ROOTFS_POSTPROCESS_COMMAND:append = " omnect_initramfs_check;" -omnect_initramfs_check() { - file_numbers=$(ls -1 ${IMAGE_ROOTFS}/init.d/ | sed 's/^\([0-9]\+\)-.*$/\1/g') - if [ "$(echo ${file_numbers})" != "$(echo ${file_numbers} | sort -u)" ]; then - bbfatal "wrong script ordering in ${IMAGE_ROOTFS}/init.d/" - fi -} diff --git a/recipes-omnect/images/omnect-os-initramfs.bb b/recipes-omnect/images/omnect-os-initramfs.bb index bf8287811..29f9b95bc 100644 --- a/recipes-omnect/images/omnect-os-initramfs.bb +++ b/recipes-omnect/images/omnect-os-initramfs.bb @@ -13,51 +13,25 @@ inherit omnect_initramfs IMAGE_NAME = "${OMNECT_INITRAMFS_IMAGE_NAME}" -FLASH_MODE_X_PACKAGES = " \ - bmaptool \ - dhcpcd \ - xz \ -" - GRUB_SUPPORT_PACKAGES = " \ grub-editenv \ grub-env \ " -RESIZE_DATA_PACKAGES = "\ - e2fsprogs-resize2fs \ - gptfdisk \ - parted \ -" - UBOOT_SUPPORT_PACKAGES = " \ libubootenv \ libubootenv-bin \ " PACKAGE_INSTALL = "\ - base-passwd \ + bash \ coreutils \ - dosfstools \ - e2fsprogs \ - e2fsprogs-mke2fs \ - e2fsprogs-tune2fs \ - initramfs-framework-base \ - initramfs-module-debug \ - jq \ - kmod \ - omnect-os-initramfs-scripts \ + omnect-os-init \ os-release \ util-linux-fsck \ util-linux-sfdisk \ - util-linux-uuidgen \ ${ROOTFS_BOOTSTRAP_INSTALL} \ ${VIRTUAL-RUNTIME_base-utils} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'flash-mode-2', '${FLASH_MODE_X_PACKAGES} dropbear', '', d)} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'flash-mode-3', '${FLASH_MODE_X_PACKAGES} curl', '', d)} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'resize-data', '${RESIZE_DATA_PACKAGES}', '', d)} \ - ${@bb.utils.contains('MACHINE_FEATURES', 'efi', 'efibootmgr', '', d)} \ - ${@bb.utils.contains('OMNECT_RELEASE_IMAGE', '1', '', 'initramfs-module-debug', d)} \ " PACKAGE_INSTALL:append:omnect_grub = " ${GRUB_SUPPORT_PACKAGES}" @@ -77,4 +51,4 @@ add_fsck_vfat_support() { inherit ${@bb.utils.contains('DISTRO_FEATURES', 'flash-mode-2', 'omnect_user', '', d)} inherit ${@bb.utils.contains('DISTRO_FEATURES', 'efi-secure-boot', 'user-key-store', '', d)} -inherit omnect-initramfs-sign \ No newline at end of file +inherit omnect-initramfs-sign diff --git a/recipes-omnect/initrdscripts/omnect-os-initramfs-scripts.bb b/recipes-omnect/initrdscripts/omnect-os-initramfs-scripts.bb deleted file mode 100644 index c90787e28..000000000 --- a/recipes-omnect/initrdscripts/omnect-os-initramfs-scripts.bb +++ /dev/null @@ -1,94 +0,0 @@ -FILESEXTRAPATHS:prepend := "${THISDIR}/omnect-os-initramfs:" - -LICENSE = "MIT | Apache-2.0" - -LIC_FILES_CHKSUM = "\ - file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302 \ - file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10 \ -" -SRC_URI = "\ - file://rootblk-dev \ - file://common-sh \ - file://factory-reset \ - file://flash-mode-1 \ - file://fs-link \ - file://fs-mount \ - file://omnect-device-service-setup \ -" -SRC_URI:append = "${@bb.utils.contains('DISTRO_FEATURES', 'flash-mode-2', ' file://flash-mode-2', '', d)}" -SRC_URI:append = "${@bb.utils.contains('DISTRO_FEATURES', 'flash-mode-3', ' file://flash-mode-3', '', d)}" -SRC_URI:append = "${@bb.utils.contains('DISTRO_FEATURES', 'resize-data', ' file://resize-data', '', d)}" -SRC_URI:append = "${@bb.utils.contains('DISTRO_FEATURES', 'persistent-var-log', ' file://persistent-var-log', '', d)}" -SRC_URI:append:mx8mm-nxp-bsp = " file://imx-sdma" -SRC_URI:append:omnect_grub = " file://grub-sh" -SRC_URI:append:omnect_uboot = " file://uboot-sh" - -DEPENDS = "bc-native" -RDEPENDS:${PN} = "bash" - -do_install() { - install -m 0755 -D ${WORKDIR}/common-sh ${D}/init.d/05-common_sh - install -m 0755 -D ${WORKDIR}/rootblk-dev ${D}/init.d/10-rootblk_dev - - install -m 0755 -D ${WORKDIR}/factory-reset ${D}/init.d/86-factory_reset - - install -m 0755 -D ${WORKDIR}/flash-mode-1 ${D}/init.d/87-flash_mode_1 - # set variables templates - sed -i -e 's|^\(UBOOT_ENV1_START\)="UNDEFINED"|\1="${OMNECT_PART_OFFSET_UBOOT_ENV1}"|' \ - -e 's|^\(UBOOT_ENV2_START\)="UNDEFINED"|\1="${OMNECT_PART_OFFSET_UBOOT_ENV2}"|' \ - -e 's|^\(UBOOT_ENV_SIZE\)="UNDEFINED"|\1="${OMNECT_PART_SIZE_UBOOT_ENV}"|' \ - -e 's|^\(DATA_SIZE\)="UNDEFINED"|\1="${OMNECT_PART_SIZE_DATA}"|' \ - ${D}/init.d/87-flash_mode_1 - if [ -n "${BOOTLOADER_SEEK}" ]; then - sed -i -e 's|^\(BOOTLOADER_START\)="UNDEFINED"|\1="${BOOTLOADER_SEEK}"|' ${D}/init.d/87-flash_mode_1 - fi - - if ${@bb.utils.contains('DISTRO_FEATURES', 'flash-mode-2', 'true', 'false', d)}; then - install -m 0755 -D ${WORKDIR}/flash-mode-2 ${D}/init.d/87-flash_mode_2 - # bitbake doesn't parse bash arithmetic expression, so we use bc - dd_zero_size=$(echo "${OMNECT_PART_OFFSET_BOOT} + ${OMNECT_PART_SIZE_BOOT}" | bc) - sed -i -e "s/@@DD_ZERO_SIZE@@/${dd_zero_size}/g" \ - -e "s/@@DIRECT_FLASHING@@/${@oe.utils.conditional('OMNECT_FLASH_MODE_2_DIRECT_FLASHING', '1', 'true', 'false', d)}/g" \ - ${D}/init.d/87-flash_mode_2 - fi - if ${@bb.utils.contains('DISTRO_FEATURES', 'flash-mode-3', 'true', 'false', d)}; then - install -m 0755 -D ${WORKDIR}/flash-mode-3 ${D}/init.d/87-flash_mode_3 - fi - if ${@bb.utils.contains('DISTRO_FEATURES', 'resize-data', 'true', 'false', d)}; then - install -m 0755 -D ${WORKDIR}/resize-data ${D}/init.d/88-resize_data - fi - install -m 0755 -D ${WORKDIR}/fs-mount ${D}/init.d/89-fs_mount - if ${@bb.utils.contains('DISTRO_FEATURES', 'persistent-var-log', 'true', 'false', d)}; then - install -m 0755 -D ${WORKDIR}/persistent-var-log ${D}/init.d/90-persistent_var_log - fi - install -m 0755 -D ${WORKDIR}/omnect-device-service-setup ${D}/init.d/95-omnect_device_service_setup - install -m 0755 -D ${WORKDIR}/fs-link ${D}/init.d/96-fs_link -} - -do_install:append:mx8mm-nxp-bsp () { - install -m 0755 -D ${WORKDIR}/imx-sdma ${D}/init.d/90-imx_sdma -} - -do_install:append:omnect_grub () { - install -m 0755 -D ${WORKDIR}/grub-sh ${D}/init.d/09-bootloader_sh -} - -do_install:append:omnect_uboot () { - install -m 0755 -D ${WORKDIR}/uboot-sh ${D}/init.d/09-bootloader_sh -} - -FILES:${PN} = "\ - /init.d/05-common_sh \ - /init.d/09-bootloader_sh \ - /init.d/10-rootblk_dev \ - /init.d/86-factory_reset \ - /init.d/87-flash_mode_1 \ - /init.d/89-fs_mount \ - /init.d/95-omnect_device_service_setup \ - /init.d/96-fs_link \ -" -FILES:${PN}:append = "${@bb.utils.contains('DISTRO_FEATURES', 'flash-mode-2', ' /init.d/87-flash_mode_2', '', d)}" -FILES:${PN}:append = "${@bb.utils.contains('DISTRO_FEATURES', 'flash-mode-3', ' /init.d/87-flash_mode_3', '', d)}" -FILES:${PN}:append = "${@bb.utils.contains('DISTRO_FEATURES', 'resize-data', ' /init.d/88-resize_data', '', d)}" -FILES:${PN}:append = "${@bb.utils.contains('DISTRO_FEATURES', 'persistent-var-log', ' /init.d/90-persistent_var_log', '', d)}" -FILES:${PN}:append:mx8mm-nxp-bsp = " /init.d/90-imx_sdma" diff --git a/recipes-omnect/initrdscripts/omnect-os-initramfs/common-sh b/recipes-omnect/initrdscripts/omnect-os-initramfs/common-sh deleted file mode 100644 index 06682bee2..000000000 --- a/recipes-omnect/initrdscripts/omnect-os-initramfs/common-sh +++ /dev/null @@ -1,392 +0,0 @@ -# -# common helper functions -# - -common_sh_enabled() -{ - return 1 # there is no entry point in this library -} - -# - overwrites msg from initramfs-framework -# - we write to kmsg, so we can respect the kernel cmdline "quiet" argument -# and we're able to find the initramfs output in the journal -msg() { - echo "<6>omnect-os-initramfs: ${@}" > /dev/kmsg -} - -msg_fatal() { - echo "<2>omnect-os-initramfs: FATAL ERROR: ${@}" > /dev/kmsg -} - -msg_error() { - echo "<3>omnect-os-initramfs: ERROR: ${@}" > /dev/kmsg -} - -msg_warning() { - echo "<4>omnect-os-initramfs: WARNING: ${@}" > /dev/kmsg -} - -stderr_error() { - echo "ERROR: $@" >&2 -} - -stderr_fatal() { - echo "FATAL ERROR: $@" >&2 -} - -run_cmd() { - msg "$@" - # avoid errors with directly redirecting too long output to /dev/kmsg - out=$(eval "$@" 2>&1) - local result=$? - while read l; do echo -n "$l" > /dev/kmsg; done <<<"$out" - if [ ${result} -ne 0 ]; then msg_error "command \"$@\" failed: ${result}"; return ${result}; fi - return 0 -} - -run_cmd_stdout() { - echo "$@" - eval "$@" - local result=$? - if [ ${result} -ne 0 ]; then stderr_error "command \"$@\" failed: ${result}"; return ${result}; fi - return 0 -} - -# check filesystem -# re-format partition in the case of uncorrectable fsck errors or enforced flag -check_fs() -{ - local label=$1 # label - local fsck_res=0 - local kmsg_ratelimit=$(cat /proc/sys/kernel/printk_devkmsg) - - msg "check_fs /dev/omnect/${label}" - echo "on" > /proc/sys/kernel/printk_devkmsg - - # in case of EFI the boot partition gets checked multiple times - if [ -f /tmp/fsck_out.${label} ]; then - msg "already run fsck for \"${label}\"" - return 0 - fi - - fsck -y /dev/omnect/${label} &> /tmp/fsck_out.${label} - fsck_res=$? - msg "fsck result for \"${label}\" is ${fsck_res}" - msg "$( /proc/sys/kernel/printk_devkmsg - return 0 -} - -reformat_ext4_fs() { - local path="${1}" # filesystem - local label="${2}" - - # -- mkfs enforced OR uncorrectable fsck errors -- - msg "reformatting ${path} ..." - run_cmd mkfs.ext4 -F -q ${path} || return 1 - - # set ext4 label; disable enforced fsck - run_cmd tune2fs ${path} -c -1 -i 0 -L ${label} || return 1 - run_cmd sync -} - -# mount filesystem of partition -mount_partition() -{ - local fs_type="$1" # filesystem type - local blk_dev="$2" # block device name - local mnt_dir="$3" # mount point - local mnt_opts="$4" # mount options - - if [ -z "${blk_dev}" ] || [ ! -b "${blk_dev}" ]; then - msg_fatal "\"${blk_dev}\" not a valid block device" - return 1 - fi - - run_cmd mount -t "${fs_type}" -o "${mnt_opts}" "${blk_dev} " "${mnt_dir}" - return $? -} - -# mount overlay filesystem -mount_overlayfs() -{ - local lowerdir="$1" - local upperdir="$2" - local workdir="$3" - local mnt_opts="$4" # mount options - local mnt_dir="$5" # mount point - - run_cmd mount -t overlay \ - -o ${mnt_opts},lowerdir=${lowerdir},upperdir=${upperdir},workdir=${workdir} \ - overlay ${mnt_dir} -} - -# if etc partition is empty, copy the etc dir from factory partition -setup_etc_from_factory() -{ - local rootfs_dir="$1" - - if [ ! -d "${rootfs_dir}/mnt/etc/upper" ]; then - msg "first boot detected" - run_cmd mkdir -p "${rootfs_dir}/mnt/etc/upper" - run_cmd mkdir -p "${rootfs_dir}/mnt/etc/work" - if [ -d "${rootfs_dir}/mnt/factory/etc" ]; then - msg "setup etc from factory partition" - run_cmd cp -av "${rootfs_dir}/mnt/factory/etc/." "${rootfs_dir}/mnt/etc/upper" - fi - - # below has nothing to do with etc setup, but we only want to do this after flash-mode-1 - if [[ -f /run/factory-reset ]]; then - # unlikely case that the env changes during factory-reset, since we don't reset environment - # Note: if we would handle this case, we would have to reboot after factory-reset is done and thus - # lose the omnect-os-initramfs.json result - return 0 - fi - - local mounted=0 - if ! mountpoint -q ${ROOTFS_DIR}/boot; then - mkdir -p ${ROOTFS_DIR}/boot - check_fs "boot" - # Dangerous: This function gets potentially called when /dev/omnect/* doesn't exist yet (caused by the init script system) - # Currently it is safe - mount -t vfat /dev/omnect/boot ${ROOTFS_DIR}/boot && msg "mounted ${ROOTFS_DIR}/boot" || return 1 - mounted=1 - fi - local current_bootargs="$(get_bootloader_env_var "omnect_extra_bootargs")" - local new_bootargs="$(< ${ROOTFS_DIR}/boot/omnect_extra_bootargs_omnect)" - [ -r "${ROOTFS_DIR}/boot/omnect_extra_bootargs_custom" ] \ - && new_bootargs="${new_bootargs} $(< ${ROOTFS_DIR}/boot/omnect_extra_bootargs_custom)" - new_bootargs="$(echo ${new_bootargs} | awk '{$1=$1};1')" # remove possibly trailing space - msg "current_bootargs=${current_bootargs} new_bootargs=${new_bootargs}" - if [[ "${current_bootargs}" != "${new_bootargs}" ]]; then - set_bootloader_env_var "omnect_extra_bootargs" "${new_bootargs}" - msg "reboot by omnect_extra_bootargs handling on first boot" - sync - umount ${ROOTFS_DIR}/mnt/cert - umount ${ROOTFS_DIR}/mnt/etc - run_cmd reboot -f - fi - [[ ${mounted} -eq 1 ]] && umount ${ROOTFS_DIR}/boot - fi -} - -umount_rootfs_partition() -{ - local rootfs_dir="$1" - run_cmd umount "${rootfs_dir}" -} - -setup_etc_partition() -{ - local rootfs_dir="$1" - local mnt_opts="$2" - - msg "setup etc partition" - - # check etc partition to handle unclean (not unmounted) state - check_fs etc - - # mount etc partition - mount_partition "ext4" /dev/omnect/etc "${rootfs_dir}/mnt/etc" "${mnt_opts}" - - setup_etc_from_factory "${rootfs_dir}" - - # mount etc overlay - mount_overlayfs "${rootfs_dir}/etc" "${rootfs_dir}/mnt/etc/upper" "${rootfs_dir}/mnt/etc/work" \ - "${mnt_opts}",index=off "${rootfs_dir}/etc" -} - -umount_etc_partition() -{ - local rootfs_dir="$1" - - run_cmd umount "${rootfs_dir}/etc" - run_cmd umount "${rootfs_dir}/mnt/etc" -} - -setup_data_partition() -{ - local rootfs_dir="$1" - local mnt_opts="$2" - - msg "setup data partition" - - # check data partition to handle unclean (not unmounted) state - check_fs data - - # mount data partition - mount_partition "ext4" "/dev/omnect/data" "${rootfs_dir}/mnt/data" "${mnt_opts}" - - # mount home overlay - run_cmd mkdir -p "${rootfs_dir}/mnt/data/home/work" - run_cmd mkdir -p "${rootfs_dir}/mnt/data/home/upper" - run_cmd mkdir -p "${rootfs_dir}/mnt/data/var/lib" - run_cmd mkdir -p "${rootfs_dir}/mnt/data/local" - mount_overlayfs "${rootfs_dir}/home" "${rootfs_dir}/mnt/data/home/upper" "${rootfs_dir}/mnt/data/home/work" \ - "${mnt_opts}",index=off "${rootfs_dir}/home" - - # bind mount /var/lib - run_cmd mkdir -p "${rootfs_dir}/mnt/data/var/lib" - run_cmd mount -o bind "${rootfs_dir}/mnt/data/var/lib" "${rootfs_dir}/var/lib" - - # bind mount /usr/local - run_cmd mkdir -p "${rootfs_dir}/mnt/data/local" - run_cmd mount -o bind "${rootfs_dir}/mnt/data/local" "${rootfs_dir}/usr/local" -} - -umount_data_partition() -{ - local rootfs_dir="$1" - - run_cmd umount "${rootfs_dir}/usr/local" - run_cmd umount "${rootfs_dir}/var/lib" - run_cmd umount "${rootfs_dir}/home" - run_cmd umount "${rootfs_dir}/mnt/data" -} - -setup_persistent_var_log() -{ - local rootfs_dir="$1" - - if grep ^DISTRO_FEATURES ${rootfs_dir}/etc/os-release | grep -q '[" ]persistent-var-log[ "]'; then - msg "setup persistent var log" - run_cmd mkdir -p ${rootfs_dir}/mnt/data/log || return 1 - run_cmd mount -o bind ${rootfs_dir}/mnt/data/log ${rootfs_dir}/var/log || return 1 - fi - return $? -} - -umount_persistent_var_log() -{ - local rootfs_dir="$1" - - if grep ^DISTRO_FEATURES ${rootfs_dir}/etc/os-release | grep -q '[" ]persistent-var-log[ "]'; then - run_cmd umount ${rootfs_dir}/var/log - fi -} - -get_partition_type() -{ - local value=$(sfdisk -l /dev/omnect/rootblk 2>&1 | grep "^Disklabel type:" | awk '{print $NF}') - debug "get_partition_type: ${value}" - echo ${value} -} - -on_exit_debug_image() -{ - if [ "${return}" != "0" ]; then - echo "clear" >> /tmp/debug_init - echo "echo \"initramfs failed: ${1}\"" >> /tmp/debug_init - /bin/bash --init-file /tmp/debug_init - fi -} - -on_exit_release_image() -{ - # todo: as soon we have failure handling in the boot process, we should reboot here. - # for now, it would probably result in a reboot loop. so we don't. - if [ "${return}" != "0" ]; then - while true; do - msg_fatal "iniramfs failed: ${1}" - sleep 60 - done - fi -} - -on_exit() -{ - local release=$(grep ^OMNECT_RELEASE_IMAGE= /etc/os-release | awk -F'"' '{print $2}') - if [ "${release}" = "1" ]; then - on_exit_release_image ${2} - else - on_exit_debug_image ${2} - fi -} - -flash_mode_efi_handling() -{ - local dest_dev=${1} - local p=${2} - local machine_features=$(grep ^MACHINE_FEATURES= /etc/os-release | awk -F'"' '{print $2}') - local boot_dev="/dev/omnect/boot" - local ret=0 - - if [ -n "${dest_dev}" ]; then - boot_dev="${dest_dev}${p}1" - else - dest_dev="/dev/omnect/rootblk" - fi - - if [[ " ${machine_features} " =~ " efi " ]]; then - echo "Configuring efi" - # delete all efi entries - local efi_entries=$(efibootmgr | grep ^Boot[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]\* | awk '{print $1}') - for i in ${efi_entries}; do - i=${i#Boot} - i=${i%\*} - run_cmd_stdout efibootmgr --bootnum ${i} --delete-bootnum || return 1 - done - - run_cmd_stdout mkdir -p /tmp/boot - run_cmd_stdout mount ${boot_dev} /tmp/boot - run_cmd_stdout efibootmgr --create --disk ${dest_dev} --part 1 --label "omnect_os" --loader \\\\EFI\\\\BOOT\\\\bootx64.efi - # same entry with another label ... for debug purposes, when booting after flash-mode-{1,2} fails - run_cmd_stdout efibootmgr --create --disk ${dest_dev} --part 1 --label "omnect_os " --loader \\\\EFI\\\\BOOT\\\\bootx64.efi - efibootmgr -v > /tmp/boot/EFI/BOOT/efibootmgr_entry - run_cmd_stdout umount /tmp/boot - fi - return $ret -} - -flash_mode_setup_network() { - local if_name="$1" - local ip_addr="" - - # get network interface up - while true; do - ifconfig ${if_name} up >/dev/null 2>&1 - if [ $? -eq 0 ]; then break; fi - msg "Waiting for ${if_name} ..." - sleep 1 - done - - # start dhcp client; it is backgrounding in the case the IP address was assigned or timeout - run_cmd mkdir -p /tmp || return 1 - run_cmd dhcpcd ${if_name} || return 1 - - # wait for IPv4 address - while true; do - msg "Waiting for IP address... on ${if_name}" - ip_addr=$(ip addr show dev ${if_name} | grep "inet " | awk '{print $2}') - if [ -n "${ip_addr}" ]; then break; fi - sleep 1 - done - FLASH_MODE_IP_ADDR="${ip_addr%/*}" - - # setup PTY - run_cmd mkdir -p /dev/pts || return 1 - run_cmd mount -t devpts devpts /dev/pts || return 1 - - # start SSH server; generate host key on the fly - mkdir -p /etc/dropbear - run_cmd dropbear -R || return 1 -} - -# get ID field from group file -get_id() { - local name="$1" - local file="$2" - - grep -E "^${name}:" "${file}" | awk -F: '{print $3}' -} diff --git a/recipes-omnect/initrdscripts/omnect-os-initramfs/factory-reset b/recipes-omnect/initrdscripts/omnect-os-initramfs/factory-reset deleted file mode 100644 index e6cf37b08..000000000 --- a/recipes-omnect/initrdscripts/omnect-os-initramfs/factory-reset +++ /dev/null @@ -1,337 +0,0 @@ -#!/bin/sh - -# -# handle triggered factory reset -# -# + The factory reset has to be performed before mounting the logical filesystem tree, -# because it re-formats the filesystems part of the partitions etc and data. - -factory_reset_backup_dir="/tmp/factory_reset/backup" -factory_reset="" -warnings="" -mount=0 - -# called by generic INITRAMFS -factory_reset_enabled() { - ret=0 - factory_reset=$(get_bootloader_env_var "factory-reset") - echo "null" > /tmp/factory-reset.json - if [ -z "${factory_reset}" ]; then - ret=1 # no factory reset triggered; normal boot - else - set_bootloader_env_var "factory-reset" "" - touch /run/factory-reset - fi - - # we already mounted /dev/omnect/boot when we're using grub. so we unmount so we don't disturb the restore mount/umount handling - if [ -f /usr/bin/grub-editenv ]; then - sync - run_cmd umount ${ROOTFS_DIR}/boot - fi - - return ${ret} -} - -# wipe a partition using dd command -# in the case of wear leveling, it does not guarantee strict privacy -wipe_partition_dd() { - local part="$1" - local seek_bytes=$((1024+1024)) # alignment + superblock - - if [ -z "${part}" ]; then return 1; fi - - # skip superblock, to keep label in the case of interruption; may take a longer time - run_cmd dd bs=1M if=/dev/urandom iflag=fullblock oflag=direct oflag=seek_bytes seek=${seek_bytes} of=${part} status=progress - sync - return 0 -} - -# wipe based on commands rm and fstrim -# assumption: the disk supports the ATA TRIM command -# in the case of wear leveling, it does not guarantee strict privacy -wipe_partition_fstrim() { - local part="$1" - local mnt_point="/tmp/mnt" - - if [ -z "${part}" ]; then return 1; fi - - run_cmd mkdir -p ${mnt_point} - run_cmd mount ${part} ${mnt_point} || return 0 # abort in case of failed mount - cd ${mnt_point} || return 1 - # 1st: remove all - run_cmd /bin/rm -rf * - cd - >/dev/null - # 2nd: tell the disk the removed blocks - run_cmd fstrim -v ${mnt_point} - run_cmd umount ${mnt_point} - return 0 -} - -factory_reset_wipe_dd() { - local ret=0 - - msg "wipe method 1" - wipe_partition_dd /dev/omnect/etc || ret=$? - wipe_partition_dd /dev/omnect/data || ret=$? - return ${ret} -} - -factory_reset_wipe_fstrim() { - local ret=0 - - msg "wipe method 2" - wipe_partition_fstrim /dev/omnect/etc || ret=$? - wipe_partition_fstrim /dev/omnect/data || ret=$? - return ${ret} -} - -factory_reset_wipe_custom() { - local custom_wipe="/opt/factory_reset/custom-wipe" - - if [ ! -x ${custom_wipe} ]; then - msg "ERROR: custom wipe \"${custom_wipe}\" not found or executable; abort..." - return 2 - fi - msg "Running custom wipe ${custom_wipe}..." - run_cmd ${custom_wipe} - if [ $? -ne 0 ]; then - msg "ERROR: custom wipe \"${custom_wipe}\" failed; abort..." - return 1 - fi - return 0 -} - -# backup file or directory -factory_reset_backup() { - local path_name="$1" # file or directory - local ret=0 - - msg "backup: ${path_name}" - - if [ ! -e "${ROOTFS_DIR}/${path_name}" ]; then - msg "->does not exist; ignore..." - return 0 - fi - - # do backup, keep permissions and ownership - run_cmd cp --parents -av "${ROOTFS_DIR}/${path_name}" "${factory_reset_backup_dir}" - ret=$? - - sync - return ${ret} -} - -factory_reset_restore() { - local path_name="$1" # file or directory - local ret=0 - local destpath=$(dirname ${ROOTFS_DIR}${path_name}) - local nested_mount="" - - msg "restore: ${path_name}" - - if [ ! -e "${factory_reset_backup_dir}/${ROOTFS_DIR}/${path_name}" ]; then - msg "->does not exist; ignore..." - return 0 - fi - - while [[ "${destpath}" != "${ROOTFS_DIR}" ]]; do - mountpoint -q ${destpath} && nested_mount=${destpath/${ROOTFS_DIR}} && break - destpath=$(dirname ${destpath}) - done - - # do restore, keep permissions and ownership - if [ -n "${nested_mount}" ]; then - msg "nested mount: ${factory_reset_backup_dir}/${ROOTFS_DIR}${nested_mount}" - cd ${factory_reset_backup_dir}/${ROOTFS_DIR}${nested_mount} - path_name=${path_name#${nested_mount}\/} - run_cmd cp --parents -av "${path_name}" "${ROOTFS_DIR}${nested_mount}" - ret=$? - cd - &>/dev/null - else - msg_error "restore: no mountpoint found in destination path: ${destpath}" - ret=66 - fi - - - sync - return ${ret} -} - -iterate_restore_list() { - local do_backup="${1}" - local restore_list=( "${@:2}" ) - - local ret=0 - local status=0 - local context="" - - for i in ${restore_list[@]}; do - if [ ${do_backup} -eq 1 ]; then - factory_reset_backup "${i}"; ret=$? - [[ ${ret} -ne 0 ]] && { handle_status "2" "${ret}" "${i}:backup" "${restore_list[@]}"; return ${ret}; } - else - factory_reset_restore "${i}"; ret=$? - if [ ${ret} -ne 0 ]; then - status=2; - context+="${i};" - fi # continue restoring next paths; deliver failure - fi - done - - if [ 2 -eq ${status} ]; then - context="${context%?}:restore" - handle_status "${status}" "${ret}" "${context}" "${restore_list[@]}" - return ${ret} - fi - - # ToDO reflect possible wiper error in status? - [[ 0 -eq ${do_backup} ]] && handle_status "0" "0" "" "${restore_list[@]}" - sync - return 0 -} - -factory_reset_mount() { - mount=1 - mount_partition "ext4" "/dev/omnect/rootCurrent" "${ROOTFS_DIR}" "defaults,ro" - mount_partition "ext4" "/dev/omnect/factory" "${ROOTFS_DIR}/mnt/factory" "defaults,ro" - setup_etc_partition "${ROOTFS_DIR}" "defaults,rw" - setup_data_partition "${ROOTFS_DIR}" "defaults,rw" - setup_persistent_var_log "${ROOTFS_DIR}" -} - -factory_reset_umount() { - mount=0 - umount_persistent_var_log "${ROOTFS_DIR}" - umount_data_partition "${ROOTFS_DIR}" - umount_etc_partition "${ROOTFS_DIR}" - run_cmd umount "${ROOTFS_DIR}/mnt/factory" - umount_rootfs_partition "${ROOTFS_DIR}" - msg "mount: " - run_cmd mount -} - -handle_status() { - local status=${1} - local error=${2} - local context=${3} - local preserve_paths=( "${@:4}" ) - - msg "status: status=${status}, error=${error}, context=${context}, preserve_path=${preserve_paths[@]}" - if [ -n "${warnings}" ]; then - [[ -n "${context}" ]] && context+=";" - context+="${warnings}" - fi - - if [ -n "${context}" ]; then - echo "{}" | jq -e \ - --argjson status "${status}" \ - --arg error "${error}" \ - --arg context "${context}" \ - '.status=$status | .error=$error | .context=$context | .paths=$ARGS.positional' --args ${preserve_paths[@]} > \ - /tmp/factory-reset.json - else - echo "{}" | jq -e \ - --argjson status "${status}" \ - --arg error "${error}" \ - '.status=$status | .error=$error | .paths=$ARGS.positional' --args ${preserve_paths[@]} > \ - /tmp/factory-reset.json - fi -} - -factory_reset_post () { - [[ ${mount} -eq 1 ]] && factory_reset_umount -} - -# main entry point -factory_reset_run() { - local mode="" - local preserve="" - - add_module_post_hook factory_reset_post - - if [ -z "${ROOTFS_DIR}" ]; then - fatal "no ROOTFS_DIR" - return 1 - fi - mode=$(echo "${factory_reset}" | jq -e -r '.mode') || { handle_status "1" "-" "mode not set" ""; return; } - preserve=$(echo "${factory_reset}" | jq -e -r '.preserve') || { handle_status "3" "-" "preserve object not set" ""; return; } - if [ "[]" != "${preserve}" ]; then - preserve=($(echo "${factory_reset}" | jq -e -r '.preserve | .[]')) || { handle_status "3" "-" "could_not_parse_preserve_array" ""; return; } - else - preserve=() - fi - - msg "Running factory-reset [mode=${mode}, preserve=${preserve[@]}]..." - factory_reset_mount - - # create preserve_list - declare -a preserve_list - preserve_list+=("/etc/omnect/factory-reset.d/") - if [[ " ${preserve[@]} " =~ " applications " ]]; then - preserve=( ${preserve[@]/applications} ) - local preserve_path=""; - for i in $(find ${ROOTFS_DIR}/etc/omnect/factory-reset.d/ -iname *.json); do - preserve_path=$(jq -r -e '.paths' ${i}) || \ - { handle_status "3" "-" "${i/${ROOTFS_DIR}}: no path object" "${preserve_list[@]}"; return; } - if [ "[]" != "${preserve_path}" ]; then - preserve_list+=( $(jq -r -e '.paths[]' ${i}) ) || \ - { handle_status "3" "${?}" "${i/${ROOTFS_DIR}}: couldn't parse paths array" "${preserve_list[@]}"; return; } - fi - done - fi - - for key in "${preserve[@]}"; do - preserve_path=$(jq -r -e --arg key "${key}" .$key ${ROOTFS_DIR}/etc/omnect/factory-reset.json) || \ - { handle_status "3" "-" "${i/${ROOTFS_DIR}}: no ${key} object" "${preserve_list[@]}"; return; } - if [ "[]" != "${preserve_path}" ]; then - preserve_list+=( $(jq -r -e --arg key "${key}" .$key[] ${ROOTFS_DIR}/etc/omnect/factory-reset.json) ) || \ - { handle_status "3" "${?}" "${ROOTFS_DIR}/etc/omnect/factory-reset.json:${key}" "${preserve_list[@]}"; return; } - fi - done - - msg "factor-reset preserve_list=${preserve_list[@]}" - - # do the backup - run_cmd mkdir -p ${factory_reset_backup_dir} - iterate_restore_list 1 "${preserve_list[@]}" || return; - factory_reset_umount - - # possibly wipe - wipe_ret=0 - case ${mode} in - 1) wipe_ret=0 # no wipe - ;; - 2) factory_reset_wipe_dd - wipe_ret=$? - ;; - 3) factory_reset_wipe_fstrim - wipe_ret=$? - ;; - 4) factory_reset_wipe_custom - wipe_ret=$? - ;; - *) msg "ERROR: factory reset mode \"${mode}\" not supported; abort..." - handle_status "1" "-" "" "${preserve_list[@]}" - return 0 - ;; - esac - - # if we had a wipe error, we will try to continue anyway - if [ 0 -ne ${wipe_ret} ]; then - warning_wipe="warning: wipe failed with \"${wipe_ret}\"" - [[ -n "${warnings}" ]] && warnings+=";" - warnings+="${warning_wipe}" - msg_warning "${warning_wipe/"warning: "}" - fi - - # enforce mkfs - reformat_ext4_fs "/dev/omnect/data" "data" - reformat_ext4_fs "/dev/omnect/etc" "etc" - - # restore - factory_reset_mount # logical filesystem tree - iterate_restore_list 0 "${preserve_list[@]}" - factory_reset_umount - rm -f /run/factory-reset - msg "factory-reset done" -} diff --git a/recipes-omnect/initrdscripts/omnect-os-initramfs/flash-mode-1 b/recipes-omnect/initrdscripts/omnect-os-initramfs/flash-mode-1 deleted file mode 100644 index acb5053d7..000000000 --- a/recipes-omnect/initrdscripts/omnect-os-initramfs/flash-mode-1 +++ /dev/null @@ -1,256 +0,0 @@ -#!/bin/bash - -# -# optionally provide flashing whole disk image in INITRAMFS context -# - -# Flash Mode -# 1 clone disk image from active block device to other one -# -FLASH_MODE="" - -FLASH_MODE_VAR="flash-mode" -FLASH_MODE_DEVPATH_VAR="flash-mode-devpath" - -# variable templates, which are replaced at build time -BOOTLOADER_START="UNDEFINED" # optionally, start of bootloader area -UBOOT_ENV1_START="UNDEFINED" # start of first u-boot environment -UBOOT_ENV2_START="UNDEFINED" # start of second u-boot environment -UBOOT_ENV_SIZE="UNDEFINED" # size of u-boot environment -DATA_SIZE="UNDEFINED" # initial size of data partition (in KB) - -# called by generic INITRAMFS -flash_mode_1_enabled() { - debug "flash mode 1: ${FLASH_MODE} - ${FLASH_MODE_VAR}" - - # flash mode triggered at runtime - FLASH_MODE=$(get_bootloader_env_var ${FLASH_MODE_VAR}) - if [ "${FLASH_MODE}" == "1" ] && [ -n "${FLASH_MODE_VAR}" ]; then - return 0 # enable flash mode; call main entry point - fi - - return 1 # disable flash mode; normal boot; main entry point _NOT_ called -} - -get_start_sector() -{ - local part_dev="$(readlink -f $1)" - - sfdisk -d $(readlink -f /dev/omnect/rootblk) | \ - sed -n "s|^${part_dev}.*start=[[:space:]]\+\([[:digit:]]\+\),.*$|\1|p" -} - -# clone active disk image to other block device -run_flash_mode_1() { - local blk_dev_dst="" - local blk_dev_src="" - local data_partition="" - local data_partition_size="" - local data_partition_start="" - local efi_entries="" - local extended_partition="" - local extended_partition_size="" - local extended_partition_start="" - local last_lba="" - local machine_features=$(grep ^MACHINE_FEATURES= /etc/os-release | awk -F'"' '{print $2}') - local p="" - local part_type="" - - echo "Entering omnect flashing mode 1 ..." - - # detect destination block device from environment variable - blk_dev_dst=$(get_bootloader_env_var ${FLASH_MODE_DEVPATH_VAR} | cut -d= -f2) - blk_dev_dst=$(readlink -f ${blk_dev_dst}) - - # disable flash mode for subsequent restarts - set_bootloader_env_var ${FLASH_MODE_VAR} - set_bootloader_env_var ${FLASH_MODE_DEVPATH_VAR} - - # we already mounted /dev/omnect/boot when we're using grub. so we unmount before copying boot. - if [ -f /usr/bin/grub-editenv ]; then - sync - run_cmd umount ${ROOTFS_DIR}/boot - fi - - # check for (mandatory) substitutions of variable templates - if [[ ! " ${machine_features} " =~ " grub " ]]; then - if [ "${UBOOT_ENV1_START}" == "UNDEFINED" ]; then stderr_fatal "missing definition UBOOT_ENV1_START"; return 1; fi - if [ "${UBOOT_ENV2_START}" == "UNDEFINED" ]; then stderr_fatal "missing definition UBOOT_ENV2_START"; return 1; fi - if [ "${UBOOT_ENV_SIZE}" == "UNDEFINED" ]; then stderr_fatal "missing definition UBOOT_ENV_SIZE"; return 1; fi - fi - - if [ "${DATA_SIZE}" == "UNDEFINED" ]; then stderr_fatal "missing definition DATA_SIZE"; return 1; fi - - if [ -z "${blk_dev_dst}" ]; then - stderr_fatal "bootloader environment variable \"${FLASH_MODE_DEVPATH_VAR}\" not set" - return 1 - fi - for i in $(seq 1 30); do - if [ -b "${blk_dev_dst}" ]; then break; fi - echo "WAITING FOR destination block device \"${blk_dev_dst}\"..." - sleep 1 - done - if [ ${i} -eq 30 ]; then - stderr_fatal "cannot find destination block device \"${blk_dev_dst}\"" - return 1 - fi - - # detect source block device - blk_dev_src=$(readlink -f /dev/omnect/rootblk) - - if [ ! -b "${blk_dev_src}" ]; then stderr_fatal "${blk_dev_src} does not exist or not a block device"; return 1; fi - - if [ "${blk_dev_dst}" == "${blk_dev_src}" ]; then - stderr_fatal "identical source and destination: \"${blk_dev_dst}\"" - return 1 - fi - - data_partition=$(readlink -f /dev/omnect/data) - if [ -z "${data_partition}" ]; then - stderr_fatal "cannot detect data partition" - return 1 - fi - # adapt size of data partition to initial value, before (optional) resize of data partition - data_partition_size=$((DATA_SIZE * 2)) # 1024 (yocto) -> 512 (sfdisk) - - # check for partition type - part_type=$(get_partition_type) - if [ "${part_type}" = "gpt" ]; then - echo "DUMP gpt / partition table..." - data_partition_start=$(get_start_sector ${data_partition}) - last_lba=$((data_partition_start+data_partition_size-1)) - sfdisk --dump "${blk_dev_src}" | \ - sed "s|^last-lba: \(.*\)$|last-lba: ${last_lba}|g" | \ - sed "s|\(^${data_partition}.*size=[[:space:]]\+\)\([[:digit:]]\+,\)\(.*\)$|\1 ${data_partition_size}, \3|g" >/tmp/sfdisk.txt - elif [ "${part_type}" = "dos" ]; then - echo "DUMP mbr / partition table..." - extended_partition=$(readlink -f /dev/omnect/extended) - if [ -z "${extended_partition}" ]; then - stderr_fatal "cannot detect extended partition" - return 1 - fi - # calculate size of extended partition, not affected by (optional) resize of data partition - extended_partition_start=$(get_start_sector $(readlink -f extended)) - data_partition_start=$(get_start_sector ${data_partition}) - extended_partition_size=$((data_partition_start - extended_partition_start + data_partition_size)) - if [ -z "${extended_partition_size}" ]; then - stderr_fatal "cannot detect extended partition size" - return 1 - fi - - sfdisk --dump "${blk_dev_src}" | \ - sed "s|\(^${data_partition}.*size=[[:space:]]\+\)\([[:digit:]]\+,\)\(.*\)$|\1 ${data_partition_size}, \3|g" | \ - sed "s|\(^${extended_partition}.*size=[[:space:]]\+\)\([[:digit:]]\+,\)\(.*\)$|\1 ${extended_partition_size}, \3|g" >/tmp/sfdisk.txt - else - stderr_fatal "unhandled partition type: \"${part_type}\"" - return 1 - fi - - echo "######## cloning disk: ${blk_dev_src} -> ${blk_dev_dst} ########" - cat /tmp/sfdisk.txt - run_cmd_stdout "sfdisk ${blk_dev_dst} rootblk=/dev/sda vs root=/dev/mmcblk1p2 -> rootblk=/dev/mmcblk1 - if [ ! -b "${blk_dev_dst}1" ]; then - p="p" - fi - - echo "CHECK for new partition scheme.." - if [ ! -b "${blk_dev_dst}${p}1" ]; then stderr_fatal "\"${blk_dev_dst}${p}1\" is not a block device"; return 1; fi - if [ ! -b "${blk_dev_dst}${p}2" ]; then stderr_fatal "\"${blk_dev_dst}${p}2\" is not a block device"; return 1; fi - if [ ! -b "${blk_dev_dst}${p}3" ]; then stderr_fatal "\"${blk_dev_dst}${p}3\" is not a block device"; return 1; fi - if [ ! -b "${blk_dev_dst}${p}4" ]; then stderr_fatal "\"${blk_dev_dst}${p}4\" is not a block device"; return 1; fi - if [ ! -b "${blk_dev_dst}${p}5" ]; then stderr_fatal "\"${blk_dev_dst}${p}5\" is not a block device"; return 1; fi - if [ ! -b "${blk_dev_dst}${p}6" ]; then stderr_fatal "\"${blk_dev_dst}${p}6\" is not a block device"; return 1; fi - if [ ! -b "${blk_dev_dst}${p}7" ]; then stderr_fatal "\"${blk_dev_dst}${p}7\" is not a block device"; return 1; fi - if [ "${part_type}" = "dos" ]; then - if [ ! -b "${blk_dev_dst}${p}8" ]; then stderr_fatal "\"${blk_dev_dst}${p}8\" is not a block device"; return 1; fi - fi - - # handle u-boot not stored inside the boot partition - # e.g. not UNDEFINED if BOOTLOADER_SEEK is set (phytec boards) - if [ "${BOOTLOADER_START}" != "UNDEFINED" ]; then - echo "COPY u-boot..." - run_cmd_stdout dd if=${blk_dev_src} iflag=skip_bytes skip=$((BOOTLOADER_START*1024)) \ - of=${blk_dev_dst} oflag=seek_bytes seek=$((BOOTLOADER_START*1024)) \ - bs=1024 count=$((UBOOT_ENV1_START - BOOTLOADER_START)) || return 1 - fi - - # enforce first boot condition - echo "MKFS etc and data..." - - if [ "${part_type}" = "gpt" ]; then - reformat_ext4_fs "${blk_dev_dst}${p}6" "etc" - reformat_ext4_fs "${blk_dev_dst}${p}7" "data" - elif [ "${part_type}" = "dos" ]; then - reformat_ext4_fs "${blk_dev_dst}${p}7" "etc" - reformat_ext4_fs "${blk_dev_dst}${p}8" "data" - else - echo "unhandled partition type: ${part_type}" - fi - - echo "COPY boot, factory and cert..." - run_cmd_stdout dd if=/dev/omnect/boot of="$(readlink -f ${blk_dev_dst}${p}1)" bs=10M || return 1 - if [ "${part_type}" = "gpt" ]; then - run_cmd_stdout dd if=/dev/omnect/factory of="$(readlink -f ${blk_dev_dst}${p}4)" bs=10M || return 1 - run_cmd_stdout dd if=/dev/omnect/cert of="$(readlink -f ${blk_dev_dst}${p}5)" bs=10M || return 1 - elif [ "${part_type}" = "dos" ]; then - run_cmd_stdout dd if=/dev/omnect/factory of="$(readlink -f ${blk_dev_dst}${p}5)" bs=10M || return 1 - run_cmd_stdout dd if=/dev/omnect/cert of="$(readlink -f ${blk_dev_dst}${p}6)" bs=10M || return 1 - fi - - orig_uuid=$(sfdisk --part-uuid ${blk_dev_dst} 1) - new_uuid=$(uuidgen) - echo "Make partition UUID of copied boot partition unique (${orig_uuid} -> ${new_uuid})" - run_cmd_stdout sfdisk --part-uuid ${blk_dev_dst} 1 ${new_uuid} || return 1 - - echo "COPY current rootfs to rootfsA..." - run_cmd_stdout e2image -ra -p "/dev/omnect/rootCurrent" "$(readlink -f ${blk_dev_dst}${p}2)" || return 1 - - orig_uuid=$(sfdisk --part-uuid ${blk_dev_dst} 2) - new_uuid=$(uuidgen) - echo "Make partition UUID of copied rootfs partition unique (${orig_uuid} -> ${new_uuid})" - run_cmd_stdout sfdisk --part-uuid ${blk_dev_dst} 2 ${new_uuid} || return 1 - - if [[ " ${machine_features} " =~ " grub " ]]; then - echo "Configuring grub" - run_cmd_stdout mkdir -p /tmp/boot - run_cmd_stdout mount ${blk_dev_dst}${p}1 /tmp/boot - cp /etc/omnect/grubenv.in /tmp/boot/EFI/BOOT/grubenv - run_cmd_stdout umount /tmp/boot - else - echo "ENFORCE default bootloader environment..." - # Warning: we enforce here that there is a redundant uboot env available, even if the initial wic did'nt have one - run_cmd_stdout dd if=/etc/omnect/uboot-env.bin of="${blk_dev_dst}" oflag=seek_bytes seek=$((UBOOT_ENV1_START*1024)) || return 1 - run_cmd_stdout dd if=/etc/omnect/uboot-env.bin of="${blk_dev_dst}" oflag=seek_bytes seek=$((UBOOT_ENV2_START*1024)) || return 1 - fi - - flash_mode_efi_handling ${blk_dev_dst} ${p} - - echo "flash mode 1 successfully finished" - run_cmd_stdout sync - return 0 -} - -# main entry point -flash_mode_1_run() { - add_module_post_hook on_exit - set -o pipefail - local blk_dev_data="" - - run_flash_mode_1 2>&1 | tee /tmp/flash-mode-1.log >/dev/console 2>&1; - return=${?} - blk_dev_data=$(readlink -f /dev/omnect/data) - if [ -b "${blk_dev_data}" ]; then - # store log file - mkdir -p /tmp/mnt_data - check_fs "data" - mount_partition "ext4" "${blk_dev_data}" "/tmp/mnt_data" "defaults,rw" - run_cmd cp /tmp/flash-mode-1.log "/tmp/mnt_data" - run_cmd sync - run_cmd umount "/tmp/mnt_data" - fi - if [ ${return} -eq 0 ]; then poweroff -f; fi -} diff --git a/recipes-omnect/initrdscripts/omnect-os-initramfs/flash-mode-2 b/recipes-omnect/initrdscripts/omnect-os-initramfs/flash-mode-2 deleted file mode 100644 index 0c0521ba3..000000000 --- a/recipes-omnect/initrdscripts/omnect-os-initramfs/flash-mode-2 +++ /dev/null @@ -1,125 +0,0 @@ -#!/bin/bash - -# -# optionally provide flashing whole disk image in INITRAMFS context -# - -# Flash Mode -# 2 flash disk image from network to active block device -# -FLASH_MODE="" -FLAG_FILE="/etc/enforce_flash_mode" -DIRECT_FLASHING=@@DIRECT_FLASHING@@ - -# called by generic INITRAMFS -flash_mode_2_enabled() { - debug "flash mode 2: ${FLASH_MODE}" - - # flag file (part of "omnect-os-initramfs-test") - if [ -f ${FLAG_FILE} ]; then - msg "enable flash mode: by ${FLAG_FILE}" - FLASH_MODE=2 - return 0 # enable flash mode; call main entry point - fi - - # flash mode triggered at runtime - FLASH_MODE=$(get_bootloader_env_var flash-mode) - if [ "${FLASH_MODE}" == "2" ]; then - return 0 # enable flash mode; call main entry point - fi - - return 1 # disable flash mode; normal boot; main entry point _NOT_ called -} - -run_bmap_tool() { - local umount_dev="" - local bmap_ret="" - - # umount, if necessary - mkdir -p /tmp - cp /proc/mounts /tmp/all_mounts # make snapshot - while read umount_dev ignore; do - if [[ ${umount_dev} =~ /${blkdev##*/} ]]; then - echo "umount ${umount_dev}" - umount ${umount_dev} 2>/dev/null - fi - done omnect@${FLASH_MODE_IP_ADDR}:wic.bmap" - while true; do - if [ -f /home/omnect/wic.bmap ]; then break; fi - sleep 1 - done - - msg "please run scp omnect@${FLASH_MODE_IP_ADDR}:wic.xz" - export PATH - if ! ${DIRECT_FLASHING}; then - # wait until scp is complete, resp. uncompress+verify wic image before writing - msg "verifying input wic.xz ..." - run_cmd_stdout bmaptool copy --bmap /home/omnect/wic.bmap \ - /home/omnect/wic.xz /home/omnect/wic || return 1 - msg "successfully verified input wic.xz" - fi - non_bmap_dd_handling - msg "start flashing ..." - if ! ${DIRECT_FLASHING}; then - run_cmd_stdout bmaptool copy --bmap /home/omnect/wic.bmap \ - /home/omnect/wic /dev/omnect/rootblk || return 1 - else - run_cmd_stdout bmaptool copy --bmap /home/omnect/wic.bmap \ - /home/omnect/wic.xz /dev/omnect/rootblk || return 1 - fi - msg "successfully flashed input wic.xz" -} - -non_bmap_dd_handling() -{ - # grub: - # we encountered situations where the device could not boot after - # flash-mode-2 and could boot if flash-mode-2 did run again. - # it also could be fixed by manually copying the to be flashed - # grub binary bootx64.efi again. (in the error case checksums - # of bootx64.efi on the device and in the wic image differed.) - - # u-boot: - # we encountered situations where the boot partition has errors - # after flash-mode-2 with bmaptool. - - dd if=/dev/zero of=/dev/omnect/rootblk bs=@@DD_ZERO_SIZE@@K count=1 -} - -# deploy WIC image via network to (same) active block device -run_flash_mode_2() { - msg "Entering omnect flashing mode 2 ..." - - # disable flash mode for subsequent restarts - set_bootloader_env_var flash-mode - - # we already mounted /dev/omnect/boot when we're using grub. so we unmount before copying boot. - if [ -f /usr/bin/grub-editenv ]; then - sync - run_cmd umount ${ROOTFS_DIR}/boot - fi - - flash_mode_setup_network eth0 || return 1 - run_bmap_tool || return 1 - flash_mode_efi_handling - - msg "Rebooting system..." - sync - run_cmd reboot -f - # -- never reached -- -} - -# main entry point -flash_mode_2_run() { - add_module_post_hook on_exit - run_flash_mode_2 - return=${?} - echo flash_mode_2_run return=${return} - return ${return} -} diff --git a/recipes-omnect/initrdscripts/omnect-os-initramfs/flash-mode-3 b/recipes-omnect/initrdscripts/omnect-os-initramfs/flash-mode-3 deleted file mode 100644 index 1aaaf1c99..000000000 --- a/recipes-omnect/initrdscripts/omnect-os-initramfs/flash-mode-3 +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash - -# -# optionally provide flashing whole disk image in INITRAMFS context -# - -# Flash Mode -# 3 flash disk image from network to active block device -# -FLASH_MODE="" - -# called by generic INITRAMFS -flash_mode_3_enabled() { - debug "flash mode 3: ${FLASH_MODE}" - - # flash mode triggered at runtime - FLASH_MODE=$(get_bootloader_env_var flash-mode) - if [ "${FLASH_MODE}" == "3" ]; then - return 0 # enable flash mode; call main entry point - fi - - return 1 # disable flash mode; normal boot; main entry point _NOT_ called -} - -run_bmap_tool() { - local url="${1}" - local url_sha256="${2}" - local umount_dev="" - local bmap_ret="" - - # umount, if necessary - mkdir -p /tmp - cp /proc/mounts /tmp/all_mounts # make snapshot - while read umount_dev ignore; do - if [[ ${umount_dev} =~ /${blkdev##*/} ]]; then - echo "umount ${umount_dev}" - umount ${umount_dev} 2>/dev/null - fi - done /dev/null) || return 1 - fi - echo -n "${return}" -} - - -rootblk_dev_generate_dev_omnect() { - # we assume there is only one internal harddrive device - # we assume /dev/sdb is usb when sata device is /dev/sda (no verification though) - # we assume /dev/sda is usb when nvme device exists (no verification though) - local search_rootblk=("/dev/sdb" "/dev/sda" "/dev/nvme0n1p") - local rootblk="" - local rootpart=${bootparam_rootpart} - local part="" - - [ -z "${bootparam_rootpart}" ] && msg "no rootpart set" && return 1 - - mkdir -p /dev/omnect - cd /dev/omnect - - # get rootblk via kernel param ... if not set, we search - rootblk=${bootparam_rootblk} - msg "env rootblk=${bootparam_rootblk}" - if [ -z "${rootblk}" ]; then - for i in "${search_rootblk[@]}" - do - msg "probing \"${i}${rootpart}\"" - # we wait for max 2sec - make it configurable? - local sleep_cnt=0 - while [ ! -b "${i}${rootpart}" ] && [ ${sleep_cnt} -le 20 ]; do - debug "waiting for \"${i}${rootpart}\"" - sleep 0.1 - sleep_cnt=$((${sleep_cnt}+1)) - done - - if [ -b "${i}${rootpart}" ]; then - rootblk="${i}" - msg "found \"${rootblk}\"" - break; - fi - done - else - while [ ! -b "${rootblk}1" ]; do - debug "waiting for rootblk=${rootblk}" - sleep 0.1 - done - fi - - if [ ! -b ${rootblk} ]; then - part="p" - rootblk=${rootblk%p*} - if [ ! -b ${rootblk} ]; then - msg_fatal "failed to detect root blk device" && return 1 - fi - fi - - debug part=${part} - debug rootblk=${rootblk} - - ln -sf ${rootblk} rootblk - ln -sf ${rootblk}${part}1 boot - ln -sf ${rootblk}${part}2 rootA - ln -sf ${rootblk}${part}3 rootB - ln -sf ${rootblk}${part}${rootpart} rootCurrent - ln -sf ${rootblk}${part}4 factory - ln -sf ${rootblk}${part}5 cert - ln -sf ${rootblk}${part}6 etc - ln -sf ${rootblk}${part}7 data - - # save so next boot has bootparam_rootblk and we can skip search - if [ -z "${bootparam_rootblk}" ]; then - set_bootloader_env_var "omnect_rootblk" "${rootblk}${part}" - fi -} diff --git a/recipes-omnect/initrdscripts/omnect-os-initramfs/imx-sdma b/recipes-omnect/initrdscripts/omnect-os-initramfs/imx-sdma deleted file mode 100644 index 207bb3e2d..000000000 --- a/recipes-omnect/initrdscripts/omnect-os-initramfs/imx-sdma +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -imx_sdma_enabled() { - return 0 -} - -imx_sdma_run() { - # explictly no exit hook handling here - - # load imx_sdma as early as possible with firmware available - mkdir -p /lib/firmware - mkdir -p /lib/modules - mount -o bind /rootfs/lib/modules /lib/modules - mount -o bind /rootfs/lib/firmware /lib/firmware - modprobe imx_sdma - # umount deactivated on purpose: umount: can't unmount /lib/firmware: Device or resource busy - # it isn't mounted in omnect-os anyway - #umount /lib/firmware - #umount /lib/modules -} diff --git a/recipes-omnect/initrdscripts/omnect-os-initramfs/omnect-device-service-setup b/recipes-omnect/initrdscripts/omnect-os-initramfs/omnect-device-service-setup deleted file mode 100644 index f93156b92..000000000 --- a/recipes-omnect/initrdscripts/omnect-os-initramfs/omnect-device-service-setup +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/sh - -# -# Setup files used to trigger factory reset and reboot -# - -omnect_device_service_group="not set yet" -omnect_device_service_user="not set yet" -omnect_run_dir="${ROOTFS_DIR}/run/omnect-device-service" -omnect_os_initramfs_json="${omnect_run_dir}/omnect-os-initramfs.json" - -omnect_device_service_setup_enabled() { - return 0 -} - -fsck_handling() { - local labels=("boot" "cert" "data" "etc") - - echo "{}" > /tmp/fsck.json - for i in ${labels[@]}; do - local content=$(get_fsck_status ${i}) - if [ -n "${content}" ]; then - jq --arg i "${i}" --arg content "${content}" '. += {($i): ($content)}' /tmp/fsck.json > /tmp/fsck.json.tmp || { msg "omnect_fsck_${i} json handling error"; return 1; } - mv /tmp/fsck.json.tmp /tmp/fsck.json - set_bootloader_env_var omnect_fsck_${i} "" - else - msg "no omnect_fsck_${i} available" - fi - done - - cat ${omnect_os_initramfs_json} | jq --argjson fsck "$(cat /tmp/fsck.json)" '.fsck=$fsck' > /tmp/omnect-os-initramfs.json - [ 0 -ne $? ] && msg "fsck_handling set json failed" - mv /tmp/omnect-os-initramfs.json ${omnect_os_initramfs_json} - rm /tmp/fsck.json -} - -factory_reset_status_handling() { - cat ${omnect_os_initramfs_json} | jq --argjson factory_reset "$(cat /tmp/factory-reset.json)" '."factory-reset"=$factory_reset' > /tmp/omnect-os-initramfs.json - [ 0 -ne $? ] && msg "factory_reset_status_handling set json failed" - mv /tmp/omnect-os-initramfs.json ${omnect_os_initramfs_json} - rm /tmp/factory-reset.json -} - -# setup conditional temp files for omnect-device-service, e.g. for the update workflow handling; -# (static temp files for omnect-device-service are created via systemd-tmpfiles.d) -run_omnect_device_service_setup () { - local omnect_validate_update_failed_file="${omnect_run_dir}/omnect_validate_update_failed" - local omnect_validate_update_failed_flag="$(get_bootloader_env_var omnect_validate_update_failed)" - local omnect_validate_update_file="${omnect_run_dir}/omnect_validate_update" - local omnect_validate_update_flag="$(get_bootloader_env_var omnect_validate_update)" - local omnect_bootloader_updated_file="${omnect_run_dir}/omnect_bootloader_updated" - local omnect_bootloader_updated_flag="$(get_bootloader_env_var omnect_bootloader_updated)" - - omnect_device_service_group="$(get_id omnect_device_service ${ROOTFS_DIR}/etc/group)" - omnect_device_service_user="$(get_id omnect_device_service ${ROOTFS_DIR}/etc/passwd)" - - [ -z "${omnect_device_service_user}" ] && msg "ERROR: user omnect_device_service not found in rootfs" && return 1 - [ -z "${omnect_device_service_group}" ] && msg "ERROR: group omnect_device_service not found in rootfs" && return 1 - - run_cmd mkdir -p ${omnect_run_dir} \ - && run_cmd chown ${omnect_device_service_user}:${omnect_device_service_group} ${omnect_run_dir} \ - && run_cmd chmod 775 ${omnect_run_dir} - - if [ -n "${omnect_validate_update_flag}" ] && [ -n "${omnect_validate_update_failed_flag}" ]; then - msg_fatal "both flags are set \"omnect_validate_update\" and \"omnect_validate_update_failed\"" - return 1 - fi - - # omnect update workflow handling - if [ -n "${omnect_validate_update_flag}" ]; then - run_cmd touch ${omnect_validate_update_file} \ - && run_cmd chown ${omnect_device_service_user}:${omnect_device_service_group} ${omnect_validate_update_file} \ - && run_cmd chmod 644 ${omnect_validate_update_file} - fi - if [ -n "${omnect_validate_update_failed_flag}" ]; then - run_cmd touch ${omnect_validate_update_failed_file} \ - && run_cmd chown ${omnect_device_service_user}:${omnect_device_service_group} ${omnect_validate_update_failed_file} \ - && run_cmd chmod 644 ${omnect_validate_update_failed_file} \ - && set_bootloader_env_var omnect_validate_update_failed "" - # ToDo: discuss if we want to unset `omnect_validate_update_failed` - # here or reset it via omnect-device-service; - # a possible reason to not do it here could be that we never - # reach aziot-identityd-precondition - fi - if [ -n "${omnect_bootloader_updated_flag}" ]; then - run_cmd touch ${omnect_bootloader_updated_file} \ - && run_cmd chown ${omnect_device_service_user}:${omnect_device_service_group} ${omnect_bootloader_updated_file} \ - && run_cmd chmod 600 ${omnect_bootloader_updated_file} \ - && set_bootloader_env_var omnect_bootloader_updated "" - fi - - run_cmd "echo \"{}\" > ${omnect_os_initramfs_json}" - - fsck_handling || return 1 - factory_reset_status_handling || return 1 - - run_cmd chown ${omnect_device_service_user}:${omnect_device_service_group} ${omnect_os_initramfs_json} \ - && run_cmd chmod 600 ${omnect_os_initramfs_json} - - return 0 -} - -omnect_device_service_setup_run() { - add_module_post_hook on_exit - msg omnect_device_service_setup - run_omnect_device_service_setup - return=${?} -} diff --git a/recipes-omnect/initrdscripts/omnect-os-initramfs/persistent-var-log b/recipes-omnect/initrdscripts/omnect-os-initramfs/persistent-var-log deleted file mode 100644 index 8da90ccb1..000000000 --- a/recipes-omnect/initrdscripts/omnect-os-initramfs/persistent-var-log +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -persistent_var_log_enabled() { - return 0 -} - -persistent_var_log_run() { - add_module_post_hook on_exit - if [ -z "${ROOTFS_DIR}" ]; then - fatal "no ROOTFS_DIR" - return 1 - fi - setup_persistent_var_log "${ROOTFS_DIR}" - return=${?} -} diff --git a/recipes-omnect/initrdscripts/omnect-os-initramfs/resize-data b/recipes-omnect/initrdscripts/omnect-os-initramfs/resize-data deleted file mode 100644 index f125b2ce4..000000000 --- a/recipes-omnect/initrdscripts/omnect-os-initramfs/resize-data +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh - -resize_data_enabled() { - return 0 -} - -# true if the data partition already fills the disk (no resize needed) -data_already_resized() { - local root_disk="$1" - local free_sectors=$(sfdisk -F ${root_disk} 2>/dev/null | sed -n 's/^Unpartitioned space[^,]*, [0-9]* bytes, \([0-9][0-9]*\) sectors$/\1/p') - # can't read free space: assume not resized and let the (idempotent) grow - # path run rather than risk leaving the partition small - [ -z "${free_sectors}" ] && return 1 - debug "data_already_resized: ${free_sectors} free sectors" - # tolerate alignment / GPT-tail slack; genuine unallocated space is GB-scale - [ "${free_sectors}" -le 4096 ] -} - -run_resize_data() { - local resized_data=$(get_bootloader_env_var "resized-data") - - [ -n "${resized_data}" ] && return 0 - - data_part=$(readlink -f /dev/omnect/data) - [[ $(cat /proc/mounts | grep ${data_part} | wc -l) -ne 0 ]] && msg "error: resize_data: \"${data_part}\" is mounted." && return - - root_disk=$(readlink -f /dev/omnect/rootblk) - data_part_nr=${data_part:0-1} - - # the flag is gone but the partition was already grown on an earlier boot - # (e.g. a bootloader update wiped the env): just restore the flag - if data_already_resized ${root_disk}; then - msg "omnect-os data partition already resized" - set_bootloader_env_var resized-data 1 - return 0 - fi - - local ptype=$(get_partition_type) - msg "omnect-os resize data partition: ${root_disk} partition ${data_part_nr}" - - if [ "${ptype}" = "gpt" ]; then - run_cmd sgdisk ${root_disk} -e - elif [ "${ptype}" = "dos" ]; then - [[ $(parted -s ${root_disk} print | grep extended | wc -l) -ne 1 ]] && msg_error "resize_data: couldn't determine extended partion" && return 1 - extended_part_nr=$(parted -s ${root_disk} print | grep extended | awk '{print $1}') - run_cmd parted -s ${root_disk} resizepart ${extended_part_nr} 100% || return 1 - else - msg_fatal "unhandled partition type: \"${ptype}\"" && return 1 - fi - - run_cmd parted -s ${root_disk} resizepart ${data_part_nr} 100% || return 1 - - run_cmd ln -sf /proc/self/mounts /etc/mtab || return 1 - # e2fsck exit 1 means it corrected errors, which is not a failure here - run_cmd e2fsck -y ${data_part} - [ $? -gt 1 ] && return 1 - run_cmd resize2fs -f ${data_part} || return 1 - run_cmd sync - - set_bootloader_env_var resized-data 1 - - return 0 -} - -resize_data_run() { - add_module_post_hook on_exit - run_resize_data - return=${?} -} diff --git a/recipes-omnect/initrdscripts/omnect-os-initramfs/rootblk-dev b/recipes-omnect/initrdscripts/omnect-os-initramfs/rootblk-dev deleted file mode 100644 index cd97d5b92..000000000 --- a/recipes-omnect/initrdscripts/omnect-os-initramfs/rootblk-dev +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -rootblk_dev_enabled() { - return 0 -} - -rootblk_dev_run() { - add_module_post_hook on_exit - msg "$(grep ^PRETTY_NAME= /etc/os-release | cut -d= -f2) initramfs" - rootblk_dev_generate_dev_omnect - return=${?} -} diff --git a/recipes-omnect/initrdscripts/omnect-os-initramfs/uboot-sh b/recipes-omnect/initrdscripts/omnect-os-initramfs/uboot-sh deleted file mode 100644 index b48cb96db..000000000 --- a/recipes-omnect/initrdscripts/omnect-os-initramfs/uboot-sh +++ /dev/null @@ -1,96 +0,0 @@ -bootloader_sh_enabled() -{ - return 1 # there is no entry point in this library -} - -# get value of bootloader environment variable -get_bootloader_env_var() -{ - local var_name="$1" - local value="$(fw_printenv -n "${var_name}")" - debug "get_bootloader_env_var ${var_name}=${value}" - echo "${value}" -} - -# set/delete bootloader environment variable -set_bootloader_env_var() -{ - local var_name="$1" - local var_value="$2" # empty string to delete variable - debug "set_bootloader_env_var" "${var_name}" "${var_value}" - - if [ -n "${var_value}" ];then - fw_setenv "${var_name}" "${var_value}" || return 1 - else - fw_setenv "${var_name}" || return 1 - fi -} - -save_fsck_status() -{ - local part_name="${1}" - local source_file="${2}" - local fsck_res="${3}" #ignored here - set_bootloader_env_var omnect_fsck_${part_name} $(gzip -9c ${source_file} | base64 -w0 -) -} - -get_fsck_status() -{ - local part_name="${1}" - echo -n "$(fw_printenv -n omnect_fsck_${part_name} | base64 -d - | zcat - 2>/dev/null)" -} - -rootblk_dev_generate_dev_omnect() { - [ -z "${bootparam_root}" ] && msg "no root device set" && return 1 - - # waiting for root device to show up, e.g. needed by welotec boot from usb - while [ ! -b "${bootparam_root}" ]; do - debug "waiting for root=${bootparam_root}" - sleep 0.1 - done - - mkdir -p /dev/omnect - cd /dev/omnect - - rootblk=${bootparam_root} - rootblk=${rootblk##*/} - rootblk=${rootblk%[0-9]*} - - # do we need partition handling? - # eg root=/dev/sda2 -> rootblk=/dev/sda vs root=/dev/mmcblk1p2 -> rootblk=/dev/mmcblk1 - part="" - if [ ! -b /dev/${rootblk} ]; then - part="p" - rootblk=${rootblk%p*} - if [ ! -b /dev/${rootblk} ]; then - msg_fatal "failed to detect root blk device" && return 1 - fi - fi - - debug part=${part} - debug rootblk=${rootblk} - - ln -sf /dev/${rootblk} rootblk - ln -sf /dev/${rootblk}${part}1 boot - ln -sf /dev/${rootblk}${part}2 rootA - ln -sf /dev/${rootblk}${part}3 rootB - ln -sf ${bootparam_root} rootCurrent - - #gpt vs mbr - local ptype=$(get_partition_type) - if [ "${ptype}" = "gpt" ]; then - ln -sf /dev/${rootblk}${part}4 factory - ln -sf /dev/${rootblk}${part}5 cert - ln -sf /dev/${rootblk}${part}6 etc - ln -sf /dev/${rootblk}${part}7 data - elif [ "${ptype}" = "dos" ]; then - ln -sf /dev/${rootblk}${part}4 extended - ln -sf /dev/${rootblk}${part}5 factory - ln -sf /dev/${rootblk}${part}6 cert - ln -sf /dev/${rootblk}${part}7 etc - ln -sf /dev/${rootblk}${part}8 data - else - msg_fatal "unhandled partition type: \"${ptype}\"" && return 1 - fi - return 0 -} diff --git a/recipes-omnect/omnect-base-files/omnect-base-files.bb b/recipes-omnect/omnect-base-files/omnect-base-files.bb index d63f9136c..1821d90e7 100644 --- a/recipes-omnect/omnect-base-files/omnect-base-files.bb +++ b/recipes-omnect/omnect-base-files/omnect-base-files.bb @@ -34,6 +34,7 @@ FILES:${PN} = "\ /mnt/etc \ /mnt/factory \ /mnt/rootCurrent \ + /mnt/rootCurrentPrivate \ /usr/bin/omnect_extra_bootargs.sh \ /usr/bin/omnect_get_deviceid.sh \ /usr/bin/omnect_get_dps_tpm_enrollment.sh \ @@ -61,6 +62,7 @@ do_install() { install -d -D ${D}/mnt/etc \ install -d -D ${D}/mnt/factory \ install -d -D ${D}/mnt/rootCurrent \ + install -d -D ${D}/mnt/rootCurrentPrivate \ install -d -D ${D}/var/lib \ install -d -D ${D}${exec_prefix}/local diff --git a/recipes-omnect/omnect-os-init/omnect-os-init.inc b/recipes-omnect/omnect-os-init/omnect-os-init.inc new file mode 100644 index 000000000..4a3f15dd8 --- /dev/null +++ b/recipes-omnect/omnect-os-init/omnect-os-init.inc @@ -0,0 +1,17 @@ +LICENSE = "MIT | Apache-2.0" + +LIC_FILES_CHKSUM = "\ + file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302 \ + file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10 \ +" +INSANE_SKIP:${PN} += "already-stripped" + +do_compile:prepend() { + export LIBCLANG_PATH="${STAGING_LIBDIR_NATIVE}/llvm-rust/lib" +} + +do_install:append() { + mv ${D}/usr/bin/omnect-os-init ${D}/init + rmdir ${D}/usr/bin +} +FILES:${PN} += "init" \ No newline at end of file diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb new file mode 100644 index 000000000..fc41ae382 --- /dev/null +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -0,0 +1,153 @@ +# Auto-Generated by cargo-bitbake 0.3.16-alpha.0 +# +inherit cargo + +# If this is git based prefer versioned ones if they exist +# DEFAULT_PREFERENCE = "-1" + +# how to get omnect-os-init could be as easy as but default to a git checkout: +# SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" +SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=bootable_omnect_os" +SRCREV = "752575748e34dcc5fceef6f7e81fe3f99754905e" +S = "${WORKDIR}/git" +CARGO_SRC_DIR = "" +PV:append = ".AUTOINC+752575748e" + +# please note if you have entries that do not begin with crate:// +# you must change them to how that package can be fetched +SRC_URI += " \ + crate://crates.io/adler2/2.0.1 \ + crate://crates.io/aho-corasick/1.1.4 \ + crate://crates.io/anyhow/1.0.100 \ + crate://crates.io/base64/0.22.1 \ + crate://crates.io/bindgen/0.72.1 \ + crate://crates.io/bitflags/2.10.0 \ + crate://crates.io/cexpr/0.6.0 \ + crate://crates.io/cfg-if/1.0.4 \ + crate://crates.io/cfg_aliases/0.2.1 \ + crate://crates.io/clang-sys/1.8.1 \ + crate://crates.io/crc32fast/1.5.0 \ + crate://crates.io/either/1.15.0 \ + crate://crates.io/errno/0.3.14 \ + crate://crates.io/fastrand/2.3.0 \ + crate://crates.io/flate2/1.1.8 \ + crate://crates.io/glob/0.3.3 \ + crate://crates.io/itertools/0.13.0 \ + crate://crates.io/itoa/1.0.17 \ + crate://crates.io/libc/0.2.180 \ + crate://crates.io/libloading/0.8.9 \ + crate://crates.io/linux-raw-sys/0.11.0 \ + crate://crates.io/log/0.4.29 \ + crate://crates.io/loopdev-3/0.5.3 \ + crate://crates.io/memchr/2.7.6 \ + crate://crates.io/minimal-lexical/0.2.1 \ + crate://crates.io/miniz_oxide/0.8.9 \ + crate://crates.io/nix/0.29.0 \ + crate://crates.io/nom/7.1.3 \ + crate://crates.io/once_cell/1.21.3 \ + crate://crates.io/pin-project-lite/0.2.16 \ + crate://crates.io/prettyplease/0.2.37 \ + crate://crates.io/proc-macro2/1.0.105 \ + crate://crates.io/quote/1.0.43 \ + crate://crates.io/regex-automata/0.4.13 \ + crate://crates.io/regex-syntax/0.8.8 \ + crate://crates.io/regex/1.12.2 \ + crate://crates.io/rustc-hash/2.1.1 \ + crate://crates.io/rustix/1.1.3 \ + crate://crates.io/serde/1.0.228 \ + crate://crates.io/serde_core/1.0.228 \ + crate://crates.io/serde_derive/1.0.228 \ + crate://crates.io/serde_json/1.0.149 \ + crate://crates.io/shlex/1.3.0 \ + crate://crates.io/simd-adler32/0.3.8 \ + crate://crates.io/smart-default/0.7.1 \ + crate://crates.io/syn/2.0.114 \ + crate://crates.io/sys-mount/3.0.1 \ + crate://crates.io/tempfile/3.24.0 \ + crate://crates.io/thiserror-impl/1.0.69 \ + crate://crates.io/thiserror-impl/2.0.18 \ + crate://crates.io/thiserror/1.0.69 \ + crate://crates.io/thiserror/2.0.18 \ + crate://crates.io/tracing-attributes/0.1.31 \ + crate://crates.io/tracing-core/0.1.36 \ + crate://crates.io/tracing/0.1.44 \ + crate://crates.io/unicode-ident/1.0.22 \ + crate://crates.io/windows-link/0.2.1 \ + crate://crates.io/windows-sys/0.61.2 \ + crate://crates.io/zmij/1.0.16 \ +" + +SRC_URI[adler2-2.0.1.sha256sum] = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +SRC_URI[aho-corasick-1.1.4.sha256sum] = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +SRC_URI[anyhow-1.0.100.sha256sum] = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +SRC_URI[base64-0.22.1.sha256sum] = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +SRC_URI[bindgen-0.72.1.sha256sum] = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" +SRC_URI[bitflags-2.10.0.sha256sum] = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +SRC_URI[cexpr-0.6.0.sha256sum] = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +SRC_URI[cfg-if-1.0.4.sha256sum] = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +SRC_URI[cfg_aliases-0.2.1.sha256sum] = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +SRC_URI[clang-sys-1.8.1.sha256sum] = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +SRC_URI[crc32fast-1.5.0.sha256sum] = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +SRC_URI[either-1.15.0.sha256sum] = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +SRC_URI[errno-0.3.14.sha256sum] = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +SRC_URI[fastrand-2.3.0.sha256sum] = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +SRC_URI[flate2-1.1.8.sha256sum] = "b375d6465b98090a5f25b1c7703f3859783755aa9a80433b36e0379a3ec2f369" +SRC_URI[glob-0.3.3.sha256sum] = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" +SRC_URI[itertools-0.13.0.sha256sum] = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +SRC_URI[itoa-1.0.17.sha256sum] = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" +SRC_URI[libc-0.2.180.sha256sum] = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" +SRC_URI[libloading-0.8.9.sha256sum] = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +SRC_URI[linux-raw-sys-0.11.0.sha256sum] = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" +SRC_URI[log-0.4.29.sha256sum] = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" +SRC_URI[loopdev-3-0.5.3.sha256sum] = "ff3f91f417dba260dff8932ea5ebc1eeaf8c74842555da5eb0ac7ef41176ce2b" +SRC_URI[memchr-2.7.6.sha256sum] = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +SRC_URI[minimal-lexical-0.2.1.sha256sum] = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +SRC_URI[miniz_oxide-0.8.9.sha256sum] = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +SRC_URI[nix-0.29.0.sha256sum] = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +SRC_URI[nom-7.1.3.sha256sum] = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +SRC_URI[once_cell-1.21.3.sha256sum] = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +SRC_URI[pin-project-lite-0.2.16.sha256sum] = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +SRC_URI[prettyplease-0.2.37.sha256sum] = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +SRC_URI[proc-macro2-1.0.105.sha256sum] = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" +SRC_URI[quote-1.0.43.sha256sum] = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" +SRC_URI[regex-1.12.2.sha256sum] = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +SRC_URI[regex-automata-0.4.13.sha256sum] = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +SRC_URI[regex-syntax-0.8.8.sha256sum] = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" +SRC_URI[rustc-hash-2.1.1.sha256sum] = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" +SRC_URI[rustix-1.1.3.sha256sum] = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" +SRC_URI[serde-1.0.228.sha256sum] = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +SRC_URI[serde_core-1.0.228.sha256sum] = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +SRC_URI[serde_derive-1.0.228.sha256sum] = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +SRC_URI[serde_json-1.0.149.sha256sum] = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +SRC_URI[shlex-1.3.0.sha256sum] = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +SRC_URI[simd-adler32-0.3.8.sha256sum] = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" +SRC_URI[smart-default-0.7.1.sha256sum] = "0eb01866308440fc64d6c44d9e86c5cc17adfe33c4d6eed55da9145044d0ffc1" +SRC_URI[syn-2.0.114.sha256sum] = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +SRC_URI[sys-mount-3.0.1.sha256sum] = "a6acb8bb63826062d5a44b68298cf2e25b84bc151bc0c31c35a83b61f818682a" +SRC_URI[tempfile-3.24.0.sha256sum] = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" +SRC_URI[thiserror-1.0.69.sha256sum] = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +SRC_URI[thiserror-2.0.18.sha256sum] = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +SRC_URI[thiserror-impl-1.0.69.sha256sum] = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +SRC_URI[thiserror-impl-2.0.18.sha256sum] = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +SRC_URI[tracing-0.1.44.sha256sum] = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +SRC_URI[tracing-attributes-0.1.31.sha256sum] = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +SRC_URI[tracing-core-0.1.36.sha256sum] = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +SRC_URI[unicode-ident-1.0.22.sha256sum] = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +SRC_URI[windows-link-0.2.1.sha256sum] = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +SRC_URI[windows-sys-0.61.2.sha256sum] = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +SRC_URI[zmij-1.0.16.sha256sum] = "dfcd145825aace48cff44a8844de64bf75feec3080e0aa5cdbde72961ae51a65" + +# FIXME: update generateme with the real MD5 of the license file +LIC_FILES_CHKSUM = " \ + file://MIT OR Apache-2.0;md5=generateme \ +" + +SUMMARY = "Rust-based init process for omnect-os initramfs" +HOMEPAGE = "https://github.com/omnect/omnect-os-init" +LICENSE = "MIT OR Apache-2.0" + +# includes this file if it exists but does not fail +# this is useful for anything you may want to override from +# what cargo-bitbake generates. +include omnect-os-init-${PV}.inc +include omnect-os-init.inc From f22e85b72b2180e29ce637261d48dd73f7f8d7f6 Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Tue, 17 Mar 2026 16:21:07 +0100 Subject: [PATCH 02/20] chore(omnect-os-init): enables UUID-based root partition detection Refactors GRUB's root partition identification by transitioning from a static `rootblk` parameter to a dynamic filesystem UUID. This enhances boot reliability by eliminating dependency on potentially unstable block device names. The GRUB `probe` command is leveraged to detect the boot partition's UUID and pass it to the kernel as `bootpart_fsuuid`. --- recipes-bsp/grub/grub-efi/omnect.inc.in | 8 ++------ recipes-bsp/grub/grub-efi_%.bbappend | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/recipes-bsp/grub/grub-efi/omnect.inc.in b/recipes-bsp/grub/grub-efi/omnect.inc.in index 0001a1101..95769f0d4 100644 --- a/recipes-bsp/grub/grub-efi/omnect.inc.in +++ b/recipes-bsp/grub/grub-efi/omnect.inc.in @@ -32,17 +32,13 @@ else save_env omnect_validate_update_failed fi -if [ "x${omnect_rootblk}" != "x" ]; then - set kernel_param_rootblk=rootblk=${omnect_rootblk} - export kernel_param_rootblk -fi - if [ "${default}" != "Certificate Provision" ]; then set default="omnect-os" fi menuentry 'omnect-os' --unrestricted { set root=(hd0,gpt${omnect_os_bootpart}) - linux /boot/bzImage rootpart=${omnect_os_bootpart} ${kernel_param_rootblk} ${omnect_extra_bootargs} @@OMNECT_APPEND_1ST_BOOT@@ + probe --set=bootpart_fsuuid --fs-uuid ${root} + linux /boot/bzImage rootpart=${omnect_os_bootpart} bootpart_fsuuid=${bootpart_fsuuid} ${kernel_param_rootblk} ${omnect_extra_bootargs} @@OMNECT_APPEND_1ST_BOOT@@ initrd /boot/initramfs.cpio.gz } diff --git a/recipes-bsp/grub/grub-efi_%.bbappend b/recipes-bsp/grub/grub-efi_%.bbappend index 71d28ded1..1a1020c83 100644 --- a/recipes-bsp/grub/grub-efi_%.bbappend +++ b/recipes-bsp/grub/grub-efi_%.bbappend @@ -25,4 +25,4 @@ do_install:append:class-target() { install -m 0644 ${WORKDIR}/grubenv ${D}${EFI_BOOT_PATH}/grubenv } -GRUB_BUILDIN:append = " echo sleep" +GRUB_BUILDIN:append = " echo sleep probe" From 7e89e6e30fdc9fac344a641a1a862c377adf2388 Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Mon, 23 Mar 2026 12:17:50 +0100 Subject: [PATCH 03/20] chore(initramfs): enhances ifor diverse boot environments Adds `util-linux-blkid` to the initramfs, providing essential tools for robust identification of block devices, which is crucial for locating and mounting the root filesystem. Introduces conditional Cargo features for the Rust-based `omnect-os-init` based on the detected bootloader (`grub` for EFI, `uboot` otherwise). This allows the init process to be compiled with bootloader-specific logic, improving its adaptability and ensuring correct behavior across different boot environments. --- recipes-omnect/images/omnect-os-initramfs.bb | 1 + recipes-omnect/omnect-os-init/omnect-os-init.inc | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/recipes-omnect/images/omnect-os-initramfs.bb b/recipes-omnect/images/omnect-os-initramfs.bb index 29f9b95bc..64799eb74 100644 --- a/recipes-omnect/images/omnect-os-initramfs.bb +++ b/recipes-omnect/images/omnect-os-initramfs.bb @@ -28,6 +28,7 @@ PACKAGE_INSTALL = "\ coreutils \ omnect-os-init \ os-release \ + util-linux-blkid \ util-linux-fsck \ util-linux-sfdisk \ ${ROOTFS_BOOTSTRAP_INSTALL} \ diff --git a/recipes-omnect/omnect-os-init/omnect-os-init.inc b/recipes-omnect/omnect-os-init/omnect-os-init.inc index 4a3f15dd8..a5f88f4f3 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init.inc +++ b/recipes-omnect/omnect-os-init/omnect-os-init.inc @@ -6,6 +6,9 @@ LIC_FILES_CHKSUM = "\ " INSANE_SKIP:${PN} += "already-stripped" +CARGO_FEATURES:append = "${@'grub' if 'efi' in d.getVar('MACHINE_FEATURES') else 'uboot'}" +CARGO_BUILD_FLAGS += "--features ${CARGO_FEATURES}" + do_compile:prepend() { export LIBCLANG_PATH="${STAGING_LIBDIR_NATIVE}/llvm-rust/lib" } @@ -14,4 +17,4 @@ do_install:append() { mv ${D}/usr/bin/omnect-os-init ${D}/init rmdir ${D}/usr/bin } -FILES:${PN} += "init" \ No newline at end of file +FILES:${PN} += "init" From b60d1e9adf6b8965e0cb0d64a01f2270ecd1a6da Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Mon, 23 Mar 2026 19:00:27 +0100 Subject: [PATCH 04/20] chore(omnect-os-init): updates omnect-os-init Bitbake recipe Refreshes the recipe to align with the latest upstream changes in the omnect-os-init repository. Bumps the SRCREV for the primary source. Significantly reduces the number of Rust crate dependencies and their checksums, resulting in a leaner dependency footprint for the project. --- .../omnect-os-init/omnect-os-init_0.1.0.bb | 68 +------------------ 1 file changed, 2 insertions(+), 66 deletions(-) diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb index fc41ae382..c3e486b2f 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -8,130 +8,66 @@ inherit cargo # how to get omnect-os-init could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=bootable_omnect_os" -SRCREV = "752575748e34dcc5fceef6f7e81fe3f99754905e" +SRCREV = "8e776b0ff6645e1487dfdbc9048e253ea8ced344" S = "${WORKDIR}/git" CARGO_SRC_DIR = "" -PV:append = ".AUTOINC+752575748e" +PV:append = ".AUTOINC+8e776b0ff6" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched SRC_URI += " \ - crate://crates.io/adler2/2.0.1 \ - crate://crates.io/aho-corasick/1.1.4 \ - crate://crates.io/anyhow/1.0.100 \ - crate://crates.io/base64/0.22.1 \ - crate://crates.io/bindgen/0.72.1 \ crate://crates.io/bitflags/2.10.0 \ - crate://crates.io/cexpr/0.6.0 \ crate://crates.io/cfg-if/1.0.4 \ crate://crates.io/cfg_aliases/0.2.1 \ - crate://crates.io/clang-sys/1.8.1 \ - crate://crates.io/crc32fast/1.5.0 \ - crate://crates.io/either/1.15.0 \ crate://crates.io/errno/0.3.14 \ crate://crates.io/fastrand/2.3.0 \ - crate://crates.io/flate2/1.1.8 \ - crate://crates.io/glob/0.3.3 \ - crate://crates.io/itertools/0.13.0 \ crate://crates.io/itoa/1.0.17 \ crate://crates.io/libc/0.2.180 \ - crate://crates.io/libloading/0.8.9 \ crate://crates.io/linux-raw-sys/0.11.0 \ crate://crates.io/log/0.4.29 \ - crate://crates.io/loopdev-3/0.5.3 \ crate://crates.io/memchr/2.7.6 \ - crate://crates.io/minimal-lexical/0.2.1 \ - crate://crates.io/miniz_oxide/0.8.9 \ crate://crates.io/nix/0.29.0 \ - crate://crates.io/nom/7.1.3 \ crate://crates.io/once_cell/1.21.3 \ - crate://crates.io/pin-project-lite/0.2.16 \ - crate://crates.io/prettyplease/0.2.37 \ crate://crates.io/proc-macro2/1.0.105 \ crate://crates.io/quote/1.0.43 \ - crate://crates.io/regex-automata/0.4.13 \ - crate://crates.io/regex-syntax/0.8.8 \ - crate://crates.io/regex/1.12.2 \ - crate://crates.io/rustc-hash/2.1.1 \ crate://crates.io/rustix/1.1.3 \ crate://crates.io/serde/1.0.228 \ crate://crates.io/serde_core/1.0.228 \ crate://crates.io/serde_derive/1.0.228 \ crate://crates.io/serde_json/1.0.149 \ - crate://crates.io/shlex/1.3.0 \ - crate://crates.io/simd-adler32/0.3.8 \ - crate://crates.io/smart-default/0.7.1 \ crate://crates.io/syn/2.0.114 \ - crate://crates.io/sys-mount/3.0.1 \ crate://crates.io/tempfile/3.24.0 \ - crate://crates.io/thiserror-impl/1.0.69 \ crate://crates.io/thiserror-impl/2.0.18 \ - crate://crates.io/thiserror/1.0.69 \ crate://crates.io/thiserror/2.0.18 \ - crate://crates.io/tracing-attributes/0.1.31 \ - crate://crates.io/tracing-core/0.1.36 \ - crate://crates.io/tracing/0.1.44 \ crate://crates.io/unicode-ident/1.0.22 \ crate://crates.io/windows-link/0.2.1 \ crate://crates.io/windows-sys/0.61.2 \ crate://crates.io/zmij/1.0.16 \ " -SRC_URI[adler2-2.0.1.sha256sum] = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" -SRC_URI[aho-corasick-1.1.4.sha256sum] = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" -SRC_URI[anyhow-1.0.100.sha256sum] = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" -SRC_URI[base64-0.22.1.sha256sum] = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -SRC_URI[bindgen-0.72.1.sha256sum] = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" SRC_URI[bitflags-2.10.0.sha256sum] = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" -SRC_URI[cexpr-0.6.0.sha256sum] = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" SRC_URI[cfg-if-1.0.4.sha256sum] = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" SRC_URI[cfg_aliases-0.2.1.sha256sum] = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" -SRC_URI[clang-sys-1.8.1.sha256sum] = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" -SRC_URI[crc32fast-1.5.0.sha256sum] = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" -SRC_URI[either-1.15.0.sha256sum] = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" SRC_URI[errno-0.3.14.sha256sum] = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" SRC_URI[fastrand-2.3.0.sha256sum] = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" -SRC_URI[flate2-1.1.8.sha256sum] = "b375d6465b98090a5f25b1c7703f3859783755aa9a80433b36e0379a3ec2f369" -SRC_URI[glob-0.3.3.sha256sum] = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" -SRC_URI[itertools-0.13.0.sha256sum] = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" SRC_URI[itoa-1.0.17.sha256sum] = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" SRC_URI[libc-0.2.180.sha256sum] = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" -SRC_URI[libloading-0.8.9.sha256sum] = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" SRC_URI[linux-raw-sys-0.11.0.sha256sum] = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" SRC_URI[log-0.4.29.sha256sum] = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" -SRC_URI[loopdev-3-0.5.3.sha256sum] = "ff3f91f417dba260dff8932ea5ebc1eeaf8c74842555da5eb0ac7ef41176ce2b" SRC_URI[memchr-2.7.6.sha256sum] = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" -SRC_URI[minimal-lexical-0.2.1.sha256sum] = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -SRC_URI[miniz_oxide-0.8.9.sha256sum] = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" SRC_URI[nix-0.29.0.sha256sum] = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" -SRC_URI[nom-7.1.3.sha256sum] = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" SRC_URI[once_cell-1.21.3.sha256sum] = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" -SRC_URI[pin-project-lite-0.2.16.sha256sum] = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" -SRC_URI[prettyplease-0.2.37.sha256sum] = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" SRC_URI[proc-macro2-1.0.105.sha256sum] = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" SRC_URI[quote-1.0.43.sha256sum] = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" -SRC_URI[regex-1.12.2.sha256sum] = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" -SRC_URI[regex-automata-0.4.13.sha256sum] = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" -SRC_URI[regex-syntax-0.8.8.sha256sum] = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" -SRC_URI[rustc-hash-2.1.1.sha256sum] = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" SRC_URI[rustix-1.1.3.sha256sum] = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" SRC_URI[serde-1.0.228.sha256sum] = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" SRC_URI[serde_core-1.0.228.sha256sum] = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" SRC_URI[serde_derive-1.0.228.sha256sum] = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" SRC_URI[serde_json-1.0.149.sha256sum] = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" -SRC_URI[shlex-1.3.0.sha256sum] = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" -SRC_URI[simd-adler32-0.3.8.sha256sum] = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" -SRC_URI[smart-default-0.7.1.sha256sum] = "0eb01866308440fc64d6c44d9e86c5cc17adfe33c4d6eed55da9145044d0ffc1" SRC_URI[syn-2.0.114.sha256sum] = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" -SRC_URI[sys-mount-3.0.1.sha256sum] = "a6acb8bb63826062d5a44b68298cf2e25b84bc151bc0c31c35a83b61f818682a" SRC_URI[tempfile-3.24.0.sha256sum] = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" -SRC_URI[thiserror-1.0.69.sha256sum] = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" SRC_URI[thiserror-2.0.18.sha256sum] = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" -SRC_URI[thiserror-impl-1.0.69.sha256sum] = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" SRC_URI[thiserror-impl-2.0.18.sha256sum] = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" -SRC_URI[tracing-0.1.44.sha256sum] = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" -SRC_URI[tracing-attributes-0.1.31.sha256sum] = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" -SRC_URI[tracing-core-0.1.36.sha256sum] = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" SRC_URI[unicode-ident-1.0.22.sha256sum] = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" SRC_URI[windows-link-0.2.1.sha256sum] = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" SRC_URI[windows-sys-0.61.2.sha256sum] = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" From 3729acce858ae6bd412495cecbc0d8b38ac5ad52 Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Tue, 24 Mar 2026 15:21:23 +0100 Subject: [PATCH 05/20] chore(omnect-os-init): update omnect-os-init recipe --- recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb index c3e486b2f..b0331bd22 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -8,10 +8,10 @@ inherit cargo # how to get omnect-os-init could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=bootable_omnect_os" -SRCREV = "8e776b0ff6645e1487dfdbc9048e253ea8ced344" +SRCREV = "c238af8314d9eac02f9f0bcf947cb7a8b865dfea" S = "${WORKDIR}/git" CARGO_SRC_DIR = "" -PV:append = ".AUTOINC+8e776b0ff6" +PV:append = ".AUTOINC+c238af8314" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched From a346bf5354fa09e9be03b69c336b84ad27143ecf Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Wed, 25 Mar 2026 15:44:04 +0100 Subject: [PATCH 06/20] chore(omnect-os-init): added resize-data handling --- recipes-omnect/images/omnect-os-initramfs.bb | 6 ++++++ recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/recipes-omnect/images/omnect-os-initramfs.bb b/recipes-omnect/images/omnect-os-initramfs.bb index 64799eb74..083c5af33 100644 --- a/recipes-omnect/images/omnect-os-initramfs.bb +++ b/recipes-omnect/images/omnect-os-initramfs.bb @@ -22,6 +22,11 @@ UBOOT_SUPPORT_PACKAGES = " \ libubootenv \ libubootenv-bin \ " +RESIZE_DATA_PACKAGES = "\ + e2fsprogs-resize2fs \ + gptfdisk \ + parted \ +" PACKAGE_INSTALL = "\ bash \ @@ -33,6 +38,7 @@ PACKAGE_INSTALL = "\ util-linux-sfdisk \ ${ROOTFS_BOOTSTRAP_INSTALL} \ ${VIRTUAL-RUNTIME_base-utils} \ + ${@bb.utils.contains('DISTRO_FEATURES', 'resize-data', '${RESIZE_DATA_PACKAGES}', '', d)} \ " PACKAGE_INSTALL:append:omnect_grub = " ${GRUB_SUPPORT_PACKAGES}" diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb index b0331bd22..72c884d8e 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -7,11 +7,11 @@ inherit cargo # how to get omnect-os-init could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" -SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=bootable_omnect_os" -SRCREV = "c238af8314d9eac02f9f0bcf947cb7a8b865dfea" +SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=resize_data" +SRCREV = "1c5e762ed72b77c4bac8ed26d46f82423615c44c" S = "${WORKDIR}/git" CARGO_SRC_DIR = "" -PV:append = ".AUTOINC+c238af8314" +PV:append = ".AUTOINC+1c5e762ed7" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched From cc40cb7c76f2e5c65a4a341e41ce03ff585e682c Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Wed, 25 Mar 2026 16:39:27 +0100 Subject: [PATCH 07/20] fix(omnect-os-init): enable resize-data feature --- recipes-omnect/omnect-os-init/omnect-os-init.inc | 1 + recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes-omnect/omnect-os-init/omnect-os-init.inc b/recipes-omnect/omnect-os-init/omnect-os-init.inc index a5f88f4f3..7fc0cbf70 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init.inc +++ b/recipes-omnect/omnect-os-init/omnect-os-init.inc @@ -7,6 +7,7 @@ LIC_FILES_CHKSUM = "\ INSANE_SKIP:${PN} += "already-stripped" CARGO_FEATURES:append = "${@'grub' if 'efi' in d.getVar('MACHINE_FEATURES') else 'uboot'}" +CARGO_FEATURES:append = "${@bb.utils.contains('DISTRO_FEATURES', 'resize-data', ' resize-data', '', d)}" CARGO_BUILD_FLAGS += "--features ${CARGO_FEATURES}" do_compile:prepend() { diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb index 72c884d8e..d8ac2a9c5 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -8,10 +8,10 @@ inherit cargo # how to get omnect-os-init could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=resize_data" -SRCREV = "1c5e762ed72b77c4bac8ed26d46f82423615c44c" +SRCREV = "02d66d2040f283255a0644cf355ab39320abd8e3" S = "${WORKDIR}/git" CARGO_SRC_DIR = "" -PV:append = ".AUTOINC+1c5e762ed7" +PV:append = ".AUTOINC+02d66d2040" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched From 61eb0561338fcb1b45ee85593abb645419e257a2 Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Wed, 25 Mar 2026 16:50:59 +0100 Subject: [PATCH 08/20] fix: cargo feature delimiter Ensures the `resize-data` feature is appended with a comma as a prefix, aligning with the expected comma-separated format for Cargo features. This consistency prevents incorrect parsing of build features. --- recipes-omnect/omnect-os-init/omnect-os-init.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes-omnect/omnect-os-init/omnect-os-init.inc b/recipes-omnect/omnect-os-init/omnect-os-init.inc index 7fc0cbf70..fac468a60 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init.inc +++ b/recipes-omnect/omnect-os-init/omnect-os-init.inc @@ -7,7 +7,7 @@ LIC_FILES_CHKSUM = "\ INSANE_SKIP:${PN} += "already-stripped" CARGO_FEATURES:append = "${@'grub' if 'efi' in d.getVar('MACHINE_FEATURES') else 'uboot'}" -CARGO_FEATURES:append = "${@bb.utils.contains('DISTRO_FEATURES', 'resize-data', ' resize-data', '', d)}" +CARGO_FEATURES:append = "${@bb.utils.contains('DISTRO_FEATURES', 'resize-data', ',resize-data', '', d)}" CARGO_BUILD_FLAGS += "--features ${CARGO_FEATURES}" do_compile:prepend() { From 612dc0b06bab7cab8a764b7d6e68627fc6758da4 Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Wed, 25 Mar 2026 17:39:07 +0100 Subject: [PATCH 09/20] chore(omnect-os-init): update omnect-os-init recipe --- recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb index d8ac2a9c5..892370404 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -8,10 +8,10 @@ inherit cargo # how to get omnect-os-init could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=resize_data" -SRCREV = "02d66d2040f283255a0644cf355ab39320abd8e3" +SRCREV = "1e40f114463235b27df48abdce60948708812653" S = "${WORKDIR}/git" CARGO_SRC_DIR = "" -PV:append = ".AUTOINC+02d66d2040" +PV:append = ".AUTOINC+1e40f11446" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched From c06072a1f0ea95d562ebc97ae3add52e858dc107 Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Thu, 26 Mar 2026 16:01:58 +0100 Subject: [PATCH 10/20] chore(omnect-os-init): add e2fsprogs-e2fsck Updates the `omnect-os-init` Rust component to a newer commit. Includes `e2fsprogs-e2fsck` in the initramfs image to enable filesystem checks, likely required by the updated init for enhanced system integrity and recovery. --- recipes-omnect/images/omnect-os-initramfs.bb | 1 + recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes-omnect/images/omnect-os-initramfs.bb b/recipes-omnect/images/omnect-os-initramfs.bb index 083c5af33..802133447 100644 --- a/recipes-omnect/images/omnect-os-initramfs.bb +++ b/recipes-omnect/images/omnect-os-initramfs.bb @@ -31,6 +31,7 @@ RESIZE_DATA_PACKAGES = "\ PACKAGE_INSTALL = "\ bash \ coreutils \ + e2fsprogs-e2fsck \ omnect-os-init \ os-release \ util-linux-blkid \ diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb index 892370404..9b53d8a7d 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -8,10 +8,10 @@ inherit cargo # how to get omnect-os-init could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=resize_data" -SRCREV = "1e40f114463235b27df48abdce60948708812653" +SRCREV = "abf34f9d06aebc77b0da4cc03c585d754c648171" S = "${WORKDIR}/git" CARGO_SRC_DIR = "" -PV:append = ".AUTOINC+1e40f11446" +PV:append = ".AUTOINC+abf34f9d06" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched From eda9d0b39dc94c19446a353a32e5e805f8a8e2e8 Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Fri, 27 Mar 2026 13:25:12 +0100 Subject: [PATCH 11/20] chore(omnect-os-init): update omnect-os-init recipe --- recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb index 9b53d8a7d..8a1204029 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -8,10 +8,10 @@ inherit cargo # how to get omnect-os-init could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=resize_data" -SRCREV = "abf34f9d06aebc77b0da4cc03c585d754c648171" +SRCREV = "b2f2c1890a435381e4f02281a401f815b96197c7" S = "${WORKDIR}/git" CARGO_SRC_DIR = "" -PV:append = ".AUTOINC+abf34f9d06" +PV:append = ".AUTOINC+b2f2c1890a" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched From 2bea87b7d0c28e6d6f3550fc9c2fdb0c69ea9808 Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Mon, 30 Mar 2026 12:48:16 +0200 Subject: [PATCH 12/20] chore(omnect-os-init): add factory-reset handling --- recipes-omnect/images/omnect-os-initramfs.bb | 2 ++ recipes-omnect/omnect-os-init/omnect-os-init.inc | 1 + recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb | 6 +++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/recipes-omnect/images/omnect-os-initramfs.bb b/recipes-omnect/images/omnect-os-initramfs.bb index 802133447..d9f93c663 100644 --- a/recipes-omnect/images/omnect-os-initramfs.bb +++ b/recipes-omnect/images/omnect-os-initramfs.bb @@ -32,6 +32,8 @@ PACKAGE_INSTALL = "\ bash \ coreutils \ e2fsprogs-e2fsck \ + e2fsprogs-mke2fs \ + e2fsprogs-tune2fs \ omnect-os-init \ os-release \ util-linux-blkid \ diff --git a/recipes-omnect/omnect-os-init/omnect-os-init.inc b/recipes-omnect/omnect-os-init/omnect-os-init.inc index fac468a60..d84958d8f 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init.inc +++ b/recipes-omnect/omnect-os-init/omnect-os-init.inc @@ -8,6 +8,7 @@ INSANE_SKIP:${PN} += "already-stripped" CARGO_FEATURES:append = "${@'grub' if 'efi' in d.getVar('MACHINE_FEATURES') else 'uboot'}" CARGO_FEATURES:append = "${@bb.utils.contains('DISTRO_FEATURES', 'resize-data', ',resize-data', '', d)}" +CARGO_FEATURES:append = ",factory-reset" CARGO_BUILD_FLAGS += "--features ${CARGO_FEATURES}" do_compile:prepend() { diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb index 8a1204029..c02550f45 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -7,11 +7,11 @@ inherit cargo # how to get omnect-os-init could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" -SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=resize_data" -SRCREV = "b2f2c1890a435381e4f02281a401f815b96197c7" +SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=factory_reset" +SRCREV = "8a8cc64d06b726ecdb7d30cf656a0081d03064e9" S = "${WORKDIR}/git" CARGO_SRC_DIR = "" -PV:append = ".AUTOINC+b2f2c1890a" +PV:append = ".AUTOINC+8a8cc64d06" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched From b3a5f56186b1835f550223031eee100a3fb45462 Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Mon, 30 Mar 2026 15:59:04 +0200 Subject: [PATCH 13/20] chore(omnect-os-init): update omnect-os-init recipe --- recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb index c02550f45..20309cfe4 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -8,10 +8,10 @@ inherit cargo # how to get omnect-os-init could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=factory_reset" -SRCREV = "8a8cc64d06b726ecdb7d30cf656a0081d03064e9" +SRCREV = "16cbf39ab75923adbe204f4a174a8987e160a0b1" S = "${WORKDIR}/git" CARGO_SRC_DIR = "" -PV:append = ".AUTOINC+8a8cc64d06" +PV:append = ".AUTOINC+16cbf39ab7" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched From bb5aa5d8f9a90016239abe492fe3703a7707bfbb Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Tue, 31 Mar 2026 17:06:13 +0200 Subject: [PATCH 14/20] chore(omnect-os-init): update omnect-os-init recipe --- recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb index 20309cfe4..ef2400c76 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -8,10 +8,10 @@ inherit cargo # how to get omnect-os-init could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=factory_reset" -SRCREV = "16cbf39ab75923adbe204f4a174a8987e160a0b1" +SRCREV = "57db3610cd05e5dab5fadc6088e7497bc870aa04" S = "${WORKDIR}/git" CARGO_SRC_DIR = "" -PV:append = ".AUTOINC+16cbf39ab7" +PV:append = ".AUTOINC+57db3610cd" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched From 918dd97b0adf0748f11076c225e28fb79c869e3a Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Thu, 9 Apr 2026 13:48:01 +0200 Subject: [PATCH 15/20] chore(omnect-os-init): add gpt, release-image and persistent-var-log features Enable GPT support by default for all targets and conditionally enable features for release images and persistent logging based on build configuration. --- recipes-omnect/omnect-os-init/omnect-os-init.inc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes-omnect/omnect-os-init/omnect-os-init.inc b/recipes-omnect/omnect-os-init/omnect-os-init.inc index d84958d8f..12ba70194 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init.inc +++ b/recipes-omnect/omnect-os-init/omnect-os-init.inc @@ -9,6 +9,10 @@ INSANE_SKIP:${PN} += "already-stripped" CARGO_FEATURES:append = "${@'grub' if 'efi' in d.getVar('MACHINE_FEATURES') else 'uboot'}" CARGO_FEATURES:append = "${@bb.utils.contains('DISTRO_FEATURES', 'resize-data', ',resize-data', '', d)}" CARGO_FEATURES:append = ",factory-reset" +# All current omnect-os targets use GPT partition tables (see wic/*.wks.in) +CARGO_FEATURES:append = ",gpt" +CARGO_FEATURES:append = "${@bb.utils.contains('OMNECT_RELEASE_IMAGE', '1', ',release-image', '', d)}" +CARGO_FEATURES:append = "${@bb.utils.contains('DISTRO_FEATURES', 'persistent-var-log', ',persistent-var-log', '', d)}" CARGO_BUILD_FLAGS += "--features ${CARGO_FEATURES}" do_compile:prepend() { From 887d1ce7363920a2e09b69b20aac2b0a8ce390e0 Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Tue, 30 Jun 2026 08:53:40 +0200 Subject: [PATCH 16/20] feat(omnect-os-init): update to integrate factory-reset-mode1 --- recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb index ef2400c76..d86420c55 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -7,11 +7,11 @@ inherit cargo # how to get omnect-os-init could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" -SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=factory_reset" -SRCREV = "57db3610cd05e5dab5fadc6088e7497bc870aa04" +SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=feat/factory-reset-mode1" +SRCREV = "8e333919154916942041260690ff1f13cb110118" S = "${WORKDIR}/git" CARGO_SRC_DIR = "" -PV:append = ".AUTOINC+57db3610cd" +PV:append = ".AUTOINC+8e33391915" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched From 9b3b1b92fbb11d8eefd5ebd979ff069ddf14cf0a Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Thu, 2 Jul 2026 08:19:49 +0200 Subject: [PATCH 17/20] chore(omnect-os-init): update SRCREV for omnect-os-init recipe --- recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb index d86420c55..aed43ea68 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -8,10 +8,10 @@ inherit cargo # how to get omnect-os-init could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=feat/factory-reset-mode1" -SRCREV = "8e333919154916942041260690ff1f13cb110118" +SRCREV = "6f2b1c0fd91316cb7eaf59953a066a0a7e37c709" S = "${WORKDIR}/git" CARGO_SRC_DIR = "" -PV:append = ".AUTOINC+8e33391915" +PV:append = ".AUTOINC+6f2b1c0fd9" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched From 836ac26407e8dc24a83a7575d54369a5ede4d94b Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Tue, 28 Jul 2026 07:17:52 +0200 Subject: [PATCH 18/20] chore(omnect-os-init): update recipe source --- recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb index aed43ea68..5eced0a37 100644 --- a/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb +++ b/recipes-omnect/omnect-os-init/omnect-os-init_0.1.0.bb @@ -7,11 +7,11 @@ inherit cargo # how to get omnect-os-init could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/omnect-os-init/0.1.0" -SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=feat/factory-reset-mode1" -SRCREV = "6f2b1c0fd91316cb7eaf59953a066a0a7e37c709" +SRC_URI += "git://git@github.com/JoergZeidler/omnect-os-init.git;protocol=ssh;nobranch=1;branch=smoke-test-fixes" +SRCREV = "fef79e5151bce8cd1c5a61157593cc60cdee0392" S = "${WORKDIR}/git" CARGO_SRC_DIR = "" -PV:append = ".AUTOINC+6f2b1c0fd9" +PV:append = ".AUTOINC+fef79e5151" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched From 8bdde53c610f615d2e515482e7721aee4392fe94 Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Tue, 28 Jul 2026 16:17:30 +0200 Subject: [PATCH 19/20] fix(u-boot): declare every env variable the rust initramfs writes omnect_first_boot_done, omnect_factory_reset_last_error and omnect_fsck_ were missing from the writeable env flags list. Unlisted variables are not guaranteed to survive a u-boot saveenv, and omnect_update_flow calls saveenv on both update paths, so the variables are lost across an update boot while omnect_extra_bootargs and the other listed ones survive. Observed effect: after an A/B update the device reports first_boot true again and repeats the first-boot work (resize preflight, extra-bootargs sync). The same applies to a stored fsck record, which is exactly the case the env is meant to carry across a reboot. The list now matches BootEnvKey::as_str() in omnect-os-init. The fsck entries name the partitions the initramfs runs fsck on; the flags syntax takes exact names, so they are enumerated. No change needed for grub: it persists named variables via save_env and keeps the rest of the block, so it has no equivalent drop. Signed-off-by: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> --- recipes-bsp/u-boot/u-boot/omnect_env.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/recipes-bsp/u-boot/u-boot/omnect_env.h b/recipes-bsp/u-boot/u-boot/omnect_env.h index f4249c0aa..d1dc3744d 100644 --- a/recipes-bsp/u-boot/u-boot/omnect_env.h +++ b/recipes-bsp/u-boot/u-boot/omnect_env.h @@ -6,6 +6,10 @@ /* Attention: if vars are already part of CONFIG_EXTRA_ENV_SETTINGS * this doesnt work; these vars are shown correctly via userland fw_printenv, * but u-boot takes the default env value + * + * Every variable the OS writes at runtime belongs in this list. An unlisted + * variable is not guaranteed to survive a u-boot saveenv, which + * omnect_update_flow performs on the update paths. */ #define OMNECT_REQUIRED_WRITEABLE_ENV_FLAGS_EXTRA #define OMNECT_REQUIRED_WRITEABLE_ENV_FLAGS \ @@ -15,6 +19,13 @@ "flash-mode-devpath:sw," \ "omnect_bootloader_updated:bw," \ "omnect_extra_bootargs:sw," \ + "omnect_factory_reset_last_error:sw," \ + "omnect_first_boot_done:bw," \ + "omnect_fsck_boot:sw," \ + "omnect_fsck_cert:sw," \ + "omnect_fsck_data:sw," \ + "omnect_fsck_etc:sw," \ + "omnect_fsck_factory:sw," \ "omnect_os_bootpart:dw," \ "omnect_validate_extra_bootargs:sw," \ "omnect_validate_update:bw," \ From 219cbd4ee290eaa75a0905eaa6f58b71422752a2 Mon Sep 17 00:00:00 2001 From: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> Date: Tue, 28 Jul 2026 16:17:30 +0200 Subject: [PATCH 20/20] fix(u-boot): declare every env variable the rust initramfs writes omnect_first_boot_done, omnect_factory_reset_last_error and omnect_fsck_ were missing from the writeable env flags list. Unlisted variables are not guaranteed to survive a u-boot saveenv, and omnect_update_flow calls saveenv on both update paths, so the variables are lost across an update boot while omnect_extra_bootargs and the other listed ones survive. Observed effect: after an A/B update the device reports first_boot true again and repeats the first-boot work (resize preflight, extra-bootargs sync). The same applies to a stored fsck record, which is exactly the case the env is meant to carry across a reboot. The list now matches BootEnvKey::as_str() in omnect-os-init. The fsck entries name the partitions the initramfs runs fsck on; the flags syntax takes exact names, so they are enumerated. No change needed for grub: it persists named variables via save_env and keeps the rest of the block, so it has no equivalent drop. Signed-off-by: Joerg Zeidler <62105035+JoergZeidler@users.noreply.github.com> --- conf/machine/include/phytec-imx8mm.inc | 2 +- recipes-bsp/u-boot/u-boot/omnect_env.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/conf/machine/include/phytec-imx8mm.inc b/conf/machine/include/phytec-imx8mm.inc index 5346008c8..e4fda0960 100644 --- a/conf/machine/include/phytec-imx8mm.inc +++ b/conf/machine/include/phytec-imx8mm.inc @@ -112,4 +112,4 @@ OMNECT_BOOTLOADER_RECIPE_PATH = "${LAYERDIR_phytec}/recipes-bsp/u-boot/u-boot-ph # OMNECT_BOOTLOADER_CHECKSUM_EXPTECTED:pn-bootloader-versioned - build will fail, if the # computed checksum is different to this; set to when # OMNECT_BOOTLOADER_CHECKSUM_COMPATIBLE:pn-bootloader-versioned is set -OMNECT_BOOTLOADER_CHECKSUM_EXPECTED:pn-bootloader-versioned = "5165f005922e91b9513e4316db9316097f421109e2e678f6aed21f3a5cfbff51" +OMNECT_BOOTLOADER_CHECKSUM_EXPECTED:pn-bootloader-versioned = "73d490ae9bf6014a6c18c34d002a4cd07d00587afb4a3b84cae957466df3fbad" diff --git a/recipes-bsp/u-boot/u-boot/omnect_env.h b/recipes-bsp/u-boot/u-boot/omnect_env.h index f4249c0aa..d1dc3744d 100644 --- a/recipes-bsp/u-boot/u-boot/omnect_env.h +++ b/recipes-bsp/u-boot/u-boot/omnect_env.h @@ -6,6 +6,10 @@ /* Attention: if vars are already part of CONFIG_EXTRA_ENV_SETTINGS * this doesnt work; these vars are shown correctly via userland fw_printenv, * but u-boot takes the default env value + * + * Every variable the OS writes at runtime belongs in this list. An unlisted + * variable is not guaranteed to survive a u-boot saveenv, which + * omnect_update_flow performs on the update paths. */ #define OMNECT_REQUIRED_WRITEABLE_ENV_FLAGS_EXTRA #define OMNECT_REQUIRED_WRITEABLE_ENV_FLAGS \ @@ -15,6 +19,13 @@ "flash-mode-devpath:sw," \ "omnect_bootloader_updated:bw," \ "omnect_extra_bootargs:sw," \ + "omnect_factory_reset_last_error:sw," \ + "omnect_first_boot_done:bw," \ + "omnect_fsck_boot:sw," \ + "omnect_fsck_cert:sw," \ + "omnect_fsck_data:sw," \ + "omnect_fsck_etc:sw," \ + "omnect_fsck_factory:sw," \ "omnect_os_bootpart:dw," \ "omnect_validate_extra_bootargs:sw," \ "omnect_validate_update:bw," \