Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial support for splitting var as a separated partition #1422

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions meta-lmp-base/classes/lmp.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,18 @@ IMAGE_CMD:ota:append () {
if [ "${APP_PRELOAD_WITHIN_OE_BUILD}" = "1" ]; then
preload_apps
fi

# Split content /var into a separated folder so it can be consumed by WKS separately
if [ "${OSTREE_SPLIT_VAR}" = "1" ]; then
rm -rf ${OTA_VAR}
mv ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var ${OTA_VAR}
mkdir -p ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using mv will fail if we run this task more than one time because on the second one the ${OSTREE_OSNAME}/var is clean. It should be better to copy all the files with cp -a and we can drop the mkdir.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to have the content in ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var after this code.

But I agree we may need to move the content only once like

if [ "${OSTREE_SPLIT_VAR}" = "1" ] && ! -d ${OTA_VAR}; then
		mv ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var ${OTA_VAR}
		mkdir -p ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var
fi

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OTA_SYSROOT is already defined for dir and cleandirs:

do_image_ota[dirs] = "${OTA_SYSROOT}"
do_image_ota[cleandirs] = "${OTA_SYSROOT}"

So a re-run wouldn't be an issue here.

mkdir might not necessarily be needed indeed, will check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, best to let var in deploy as that is expected by ostree when creating .ostree-selabeled during deploy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't even taken into account possible dependencies that have more impact than running more than once

fi
}
OTA_BOOT = "${WORKDIR}/ota-boot"
do_image_ota[dirs] += "${OTA_BOOT}"
do_image_ota[cleandirs] += "${OTA_BOOT}"
OTA_VAR = "${WORKDIR}/ota-var"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be more logical and readable to place setting vars above using them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny enough most tasks end up defining the variables and cleaning actions after the task itself is defined (if you see the other tasks in this class). We can probably have a separated commit to move things around if needed (here I would prefer to just add the new variable to avoid a larger diff).

do_image_ota[dirs] += "${OTA_BOOT} ${OTA_VAR}"
do_image_ota[cleandirs] += "${OTA_BOOT} ${OTA_VAR}"

# Adapted from oe_mkext234fs in image_types.bbclass
oe_mkotaespfs() {
Expand Down
1 change: 1 addition & 0 deletions meta-lmp-base/conf/distro/lmp.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ OSTREE_KERNEL ?= "${@oe.utils.conditional('KERNEL_IMAGETYPE', 'fitImage', '${KER
OSTREE_KERNEL_ARGS_COMMON ?= "root=LABEL=otaroot rootfstype=ext4"
OSTREE_KERNEL_ARGS ?= "${OSTREE_KERNEL_ARGS_COMMON}"
OSTREE_SPLIT_BOOT ?= "0"
OSTREE_SPLIT_VAR ?= "0"
OSTREE_LOADER_LINK ?= "1"
OSTREE_DEPLOY_USR_OSTREE_BOOT ?= "0"
DISTRO_FEATURES:append = " sota"
Expand Down