Skip to content
Snippets Groups Projects
Commit cd3fe4f4 authored by Jonas Höppner's avatar Jonas Höppner
Browse files

fng-install: Fix get partition number function to return 0 for p1

parent 0a9eff5f
No related branches found
No related tags found
1 merge request!271fng-install-u-boot: Install updated u-boot-environment and fw_env.conf
......@@ -1198,13 +1198,22 @@ get_partition_bootable()
return 1
}
#=============================
# Returns the number of the partition by name pattern
# Working on /dev/mmclkYpX: p1 is 0, p2 is 1 ...
# TODO adapt for sda1 sdb2 ...
#=============================
get_partition_number()
{
__number="$1"
out=${2#/dev/}
out=${out#*p}
if string_begins_with "$out" "mmcblk";then
out=${out#*p} # get the last number of mmcblk0pX
else
return 1;
fi
is_number "$out" || return 1
out=$(( out - 1 ))
eval "$__number=$out"
return 0
}
......@@ -1229,8 +1238,7 @@ dont_keep_partition()
KEEP_PARTITIONS_CNT=$PARTITION_COUNT
fi
get_partition_number num "$1" || return
keep=$(( num - 1 ))
if [ "$keep" -lt "$KEEP_PARTITIONS_CNT" ];then
if [ "$num" -lt "$KEEP_PARTITIONS_CNT" ];then
KEEP_PARTITIONS_CNT="$keep"
fi
}
......
......@@ -232,7 +232,7 @@ if ! $REPARTITION_NEEDED;then
if ! $REPARTITION_NEEDED && [ -n "$TARGET_PARTITION" ];then
get_partition_number TARGET_PARTITION_NO "$TARGET_PARTITION"
if [ "$TARGET_PARTITION_NO" -gt "$KEEP_PARTITIONS_CNT" ];then
if [ "$TARGET_PARTITION_NO" -ge "$KEEP_PARTITIONS_CNT" ];then
# format if TARGET partition gets recreated
FORMAT_PARTITIONS=true
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment