[meta-arm,4/5] arm-autonomy/xenguest-manager: keep user defined partition order

Submitted by Kamil Dziezyk on Nov. 20, 2020, 11:44 a.m. | Patch ID: 178142

Details

Message ID 20201120114404.730-4-kamil.dziezyk@arm.com
State New
Headers show

Commit Message

Kamil Dziezyk Nov. 20, 2020, 11:44 a.m.
If xenguest image does not define some partitions,
e.g second partition definition is skipped but 1st and 3rd are present,
xenguest-manager will create second partition(with small 2MB size),
to keep user defined partition order.

Change-Id: I8ff19fd9f25eb47ac37f80bec849387f6802aba3
Issue-Id: SCM-1515
Signed-off-by: Kamil Dziezyk <kamil.dziezyk@arm.com>

---
 .../xenguest/files/xenguest-manager           | 24 +++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

-- 
2.17.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#1412): https://lists.yoctoproject.org/g/meta-arm/message/1412
Mute This Topic: https://lists.yoctoproject.org/mt/78387205/1003190
Group Owner: meta-arm+owner@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/meta-arm/unsub [mhalstead@linuxfoundation.org]
-=-=-=-=-=-=-=-=-=-=-=-

Patch hide | download patch | download mbox

diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager
index eb7a3ce..edd9a89 100755
--- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager
+++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager
@@ -248,12 +248,32 @@  function xenguest_disk_init()
     # with a : separated list defining the partition:
     # DISK_PART3="4:ext4:disk.tgz" means that partition 3 should be 4G formated
     # with ext4 and initialized with the content of disk.tgz
-    for part in $(seq 1 4); do
-        eval partdesc="\${DISK_PART${part}:-0}"
+    # Keep user defined partition order,
+    # even if previous partitions are not defined.
+    # Create 2MB partitions in this case
+    lastpart="0"
+    for partidx in $(seq 1 4); do
+        local _part="DISK_PART${partidx}"
+        if [ -n "${!_part:=}" ]; then
+            lastpart="${partidx}"
+        fi
+    done
+
+    if [ "${lastpart}" -eq "0" ]; then
+        # Nothing to be added here
+        # No partition definition found
+        return
+    fi
+
+    for part in $(seq 1 "${lastpart}"); do
+        eval partdesc="\${DISK_PART${part}:=}"
         size=$(echo ${partdesc} | sed -e "s/\(.*\):.*:.*/\1/")
         fstype=$(echo ${partdesc} | sed -e "s/.*:\(.*\):.*/\1/")
         content=$(echo ${partdesc} | sed -e "s/.*:.*:\(.*\)/\1/")
 
+        local _part="DISK_PART${part}"
+        [ -n "${!_part:=}" ] || size="2M"
+
         size=$(check_size "${size}")
         if [ -n "${size}" ] && [ "${size}" != "0M" ]; then
             # size has appended M or G suffix, let's extract just the value