forked from Bitmessage/sysdeploy
fix: find_oldest and find_newest fixes
This commit is contained in:
parent
53450aaf5f
commit
da6118b6a0
28
drive.inc
28
drive.inc
|
@ -53,28 +53,24 @@ function find_oldest
|
|||
{
|
||||
local drive="$1"
|
||||
oldest="$(parted -m "$drive" -- print|awk -F: \
|
||||
'BEGIN
|
||||
{min="ZZZZ"}
|
||||
{if (NR > 2 && $1 >= 2 && $1 <= 4 &&
|
||||
$6 < min && $6 != "root unused") {
|
||||
min=$6; part=$1
|
||||
}}
|
||||
END
|
||||
{print part}')"
|
||||
'BEGIN {min="zzzzz"}
|
||||
{if (NR > 2 && $1 >= 2 && $1 <= 4 &&
|
||||
$6 < min && $6 != "root unused") {
|
||||
min=$6; part=$1
|
||||
}}
|
||||
END {print part}')"
|
||||
}
|
||||
|
||||
function find_newest
|
||||
{
|
||||
local drive="$1"
|
||||
newest="$(parted -m "$drive" -- print|awk -F: \
|
||||
'BEGIN
|
||||
{max=""}
|
||||
{if (NR > 2 && $1 >= 2 && $1 <= 4 &&
|
||||
$6 > max && $6 != "root unused") {
|
||||
max=$6; part=$1
|
||||
}}
|
||||
END
|
||||
{print part}')"
|
||||
'BEGIN {max=""}
|
||||
{if (NR > 2 && $1 >= 2 && $1 <= 4 &&
|
||||
$6 > max && $6 != "root unused") {
|
||||
max=$6; part=$1
|
||||
}}
|
||||
END {print part}')"
|
||||
}
|
||||
|
||||
function version_from_partnum
|
||||
|
|
|
@ -28,13 +28,13 @@ function test_partitioning()
|
|||
|
||||
rename_partition "$img" 3 "root $min_version"
|
||||
find_oldest "$img"
|
||||
assertEquals "find_oldest" "$min_version" "$oldest"
|
||||
assertEquals "find_oldest" 3 "$oldest"
|
||||
version_from_partnum "$img" 3
|
||||
assertEquals "version_from partnum 3" "$min_version" "$version"
|
||||
|
||||
rename_partition "$img" 4 "root $max_version"
|
||||
find_newest "$img"
|
||||
assertEquals "find_newest" "$max_version" "$newest"
|
||||
assertEquals "find_newest" 4 "$newest"
|
||||
version_from_partnum "$img" 4
|
||||
assertEquals "version_from_partnum 4" "$max_version" "$version"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user