From 8c2b0f4d76d5e382016edf6212d97c2a8a38b64d Mon Sep 17 00:00:00 2001
From: Andrei Gherzan <andrei.gherzan@huawei.com>
Date: Mon, 2 Aug 2021 16:14:46 +0100
Subject: [PATCH] x-wic.inc: Use a copy of the rootfs in ROOTB

The root b partition was initially set up using the assumption that a
wic part configuration without fstype would leave the partition empty
(no filesystem). Checking a bit deeper the wic implementation, that
never worked as expected as the tool defaults to a vfat partition[1] (when
no fstype is provided). Also, squashfs doesn't support an empty
filesystem.

Given the above, we switch the second rootfs (B) to using the same
content as the default one (A). This has an added advantage that we can
test switching the root filesystem A-B without any additional
operations.

[1] https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/scripts/lib/wic/ksparser.py?h=dunfell#n158

Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com>
---
 meta-ohos-core/conf/distro/include/x-wic.inc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/meta-ohos-core/conf/distro/include/x-wic.inc b/meta-ohos-core/conf/distro/include/x-wic.inc
index a110a705..62a339fb 100644
--- a/meta-ohos-core/conf/distro/include/x-wic.inc
+++ b/meta-ohos-core/conf/distro/include/x-wic.inc
@@ -32,7 +32,9 @@ WIC_ROOTA_PARTITION ?= "part / --source rootfs --use-uuid --fstype=${ROOT_FSTYPE
                         ${@bb.utils.contains('ROOT_FSTYPE', 'ext4', '--mkfs-extraopts \'-T default\'', '', d)} \
                         --align 4096 --fixed-size ${ROOTA_PARTITION_SIZE} \
 			${WIC_ROOTA_PARTITION_EXTRA_ARGS}"
-WIC_ROOTB_PARTITION ?= "part --align 4096 --fixed-size ${ROOTB_PARTITION_SIZE} \
+WIC_ROOTB_PARTITION ?= "part / --source rootfs --use-uuid --fstype=${ROOT_FSTYPE} \
+                        ${@bb.utils.contains('ROOT_FSTYPE', 'ext4', '--mkfs-extraopts \'-T default\'', '', d)} \
+                        --align 4096 --fixed-size ${ROOTB_PARTITION_SIZE} \
                         ${WIC_ROOTB_PARTITION_EXTRA_ARGS}"
 WIC_DEVDATA_PARTITION ?= "part --fstype=ext4 --label x-dev-data --mkfs-extraopts '-T default' --align 4096 --fixed-size ${DEVDATA_PARTITION_SIZE} ${WIC_DEVDATA_PARTITION_EXTRA_ARGS}"
 WIC_SYSDATA_PARTITION ?= "part --fstype=ext4 --label x-sys-data --mkfs-extraopts '-T default' --align 4096 --fixed-size ${SYSDATA_PARTITION_SIZE} ${WIC_SYSDATA_PARTITION_EXTRA_ARGS}"
-- 
GitLab