@@ -15,6 +15,50 @@ function scan_multipath_devices {
1515 systemctl start multipathd
1616}
1717
18+ function find_disk_entry {
19+ # """
20+ # lookup disk entry by name and echo the
21+ # associated entry parameter (size) when found
22+ # """
23+ local list_items=$1
24+ local search=$2
25+ local count=0
26+ local found=
27+ for entry in ${list_items} ; do
28+ if [ -n " ${found} " ]; then
29+ echo " ${entry} "
30+ return
31+ fi
32+ if [ $(( count % 2 )) -eq 0 ]; then
33+ if [ " ${entry} " = " ${search} " ]; then
34+ found=1
35+ fi
36+ fi
37+ count=$(( count + 1 ))
38+ done
39+ }
40+
41+ function sort_disk_entries {
42+ # """
43+ # sort the disk entry names
44+ # """
45+ local list_items=$1
46+ local count=0
47+ local device_index=0
48+ local device_array
49+ local list_items_sorted
50+ for entry in ${list_items} ; do
51+ if [ $(( count % 2 )) -eq 0 ]; then
52+ device_array[${device_index} ]=${entry}
53+ device_index=$(( device_index + 1 ))
54+ fi
55+ count=$(( count + 1 ))
56+ done
57+ readarray -td ' ' list_items_sorted \
58+ < <( printf ' %s\0' " ${device_array[@]} " | sort -z)
59+ echo " ${list_items_sorted[*]} "
60+ }
61+
1862function get_disk_list {
1963 declare kiwi_oemdevicefilter=${kiwi_oemdevicefilter}
2064 declare kiwi_oemmultipath_scan=${kiwi_oemmultipath_scan}
@@ -29,6 +73,7 @@ function get_disk_list {
2973 local disk_device_by_id
3074 local disk_meta
3175 local list_items
76+ local list_items_sorted
3277 local max_disk
3378 local kiwi_oem_maxdisk
3479 local blk_opts=" -p -n -r --sort NAME -o NAME,SIZE,TYPE"
@@ -39,9 +84,13 @@ function get_disk_list {
3984 disk_id=${kiwi_devicepersistency}
4085 fi
4186 max_disk=0
87+ kiwi_install_devicepersistency=$( getarg rd.kiwi.install.devicepersistency=)
4288 kiwi_oemmultipath_scan=$( bool " ${kiwi_oemmultipath_scan} " )
4389 kiwi_oem_maxdisk=$( getarg rd.kiwi.oem.maxdisk=)
4490 kiwi_oem_installdevice=$( getarg rd.kiwi.oem.installdevice=)
91+ if [ -n " ${kiwi_install_devicepersistency} " ]; then
92+ disk_id=${kiwi_install_devicepersistency}
93+ fi
4594 if [ -n " ${kiwi_oem_maxdisk} " ]; then
4695 max_disk=$( binsize_to_bytesize " ${kiwi_oem_maxdisk} " ) || max_disk=0
4796 fi
@@ -154,7 +203,13 @@ function get_disk_list {
154203 local no_device_text=" No device(s) for installation found"
155204 report_and_quit " ${no_device_text} "
156205 fi
157- echo " ${list_items} "
206+
207+ # apply final sorting for the used disk_device names
208+ list_items_sorted=$( sort_disk_entries " ${list_items} " )
209+ for entry in ${list_items_sorted[*]} ; do
210+ echo -n " ${entry} $( find_disk_entry " ${list_items} " " ${entry} " ) "
211+ done
212+ echo
158213}
159214
160215function validate_disk_selection {
@@ -207,7 +262,7 @@ function get_selected_disk {
207262 # unattended mode requested with target specifier
208263 # use this device if present
209264 local device
210- for device in ${device_array[*]} ; do
265+ for device in " ${device_array[@]} " ; do
211266 if [[ ${device} =~ ${kiwi_oemunattended_id} ]]; then
212267 echo " ${device} "
213268 return
@@ -217,8 +272,7 @@ function get_selected_disk {
217272 else
218273 # manually select from storage list
219274 if ! run_dialog \
220- --menu " \" Select Installation Disk\" " 20 75 15 \
221- " $( get_disk_list) "
275+ --menu " \" Select Installation Disk\" " 20 75 15 " ${disk_list} "
222276 then
223277 report_and_quit " System installation canceled"
224278 fi
0 commit comments