Split in two commits. This one's the second.
2009-08-07 Robert Millan <rmh.grub@aybabtu.com> * util/grub.d/10_linux.in (test_numeric): Moved from here ... * util/grub-mkconfig_lib.in (version_test_numeric): ... to here. Update all users. * util/grub.d/10_linux.in (test_gt): Strip any basename prefix, not just "vmlinu[zx]". Moved from here ... * util/grub-mkconfig_lib.in (version_test_gt): ... to here. Update all users. * util/grub.d/10_linux.in (find_latest): Moved from here ... * util/grub-mkconfig_lib.in (version_find_latest): ... to here. Update all users.
This commit is contained in:
parent
7a4894cc99
commit
9d5bdd2cf6
2 changed files with 52 additions and 52 deletions
|
@ -176,3 +176,54 @@ grub_file_is_not_garbage ()
|
|||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
version_test_numeric ()
|
||||
{
|
||||
local a=$1
|
||||
local cmp=$2
|
||||
local b=$3
|
||||
if [ "$a" = "$b" ] ; then
|
||||
case $cmp in
|
||||
ge|eq|le) return 0 ;;
|
||||
gt|lt) return 1 ;;
|
||||
esac
|
||||
fi
|
||||
if [ "$cmp" = "lt" ] ; then
|
||||
c=$a
|
||||
a=$b
|
||||
b=$c
|
||||
fi
|
||||
if (echo $a ; echo $b) | sort -n | head -n 1 | grep -qx $b ; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
version_test_gt ()
|
||||
{
|
||||
local a=`echo $1 | sed -e "s/[^-]*-//g"`
|
||||
local b=`echo $2 | sed -e "s/[^-]*-//g"`
|
||||
local cmp=gt
|
||||
if [ "x$b" = "x" ] ; then
|
||||
return 0
|
||||
fi
|
||||
case $a:$b in
|
||||
*.old:*.old) ;;
|
||||
*.old:*) a=`echo -n $a | sed -e s/\.old$//g` ; cmp=gt ;;
|
||||
*:*.old) b=`echo -n $b | sed -e s/\.old$//g` ; cmp=ge ;;
|
||||
esac
|
||||
version_test_numeric $a $cmp $b
|
||||
return $?
|
||||
}
|
||||
|
||||
version_find_latest ()
|
||||
{
|
||||
local a=""
|
||||
for i in $@ ; do
|
||||
if version_test_gt "$i" "$a" ; then
|
||||
a="$i"
|
||||
fi
|
||||
done
|
||||
echo "$a"
|
||||
}
|
||||
|
|
|
@ -42,57 +42,6 @@ else
|
|||
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
|
||||
fi
|
||||
|
||||
test_numeric ()
|
||||
{
|
||||
local a=$1
|
||||
local cmp=$2
|
||||
local b=$3
|
||||
if [ "$a" = "$b" ] ; then
|
||||
case $cmp in
|
||||
ge|eq|le) return 0 ;;
|
||||
gt|lt) return 1 ;;
|
||||
esac
|
||||
fi
|
||||
if [ "$cmp" = "lt" ] ; then
|
||||
c=$a
|
||||
a=$b
|
||||
b=$c
|
||||
fi
|
||||
if (echo $a ; echo $b) | sort -n | head -n 1 | grep -qx $b ; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
test_gt ()
|
||||
{
|
||||
local a=`echo $1 | sed -e "s/[^-]*-//g"`
|
||||
local b=`echo $2 | sed -e "s/[^-]*-//g"`
|
||||
local cmp=gt
|
||||
if [ "x$b" = "x" ] ; then
|
||||
return 0
|
||||
fi
|
||||
case $a:$b in
|
||||
*.old:*.old) ;;
|
||||
*.old:*) a=`echo -n $a | sed -e s/\.old$//g` ; cmp=gt ;;
|
||||
*:*.old) b=`echo -n $b | sed -e s/\.old$//g` ; cmp=ge ;;
|
||||
esac
|
||||
test_numeric $a $cmp $b
|
||||
return $?
|
||||
}
|
||||
|
||||
find_latest ()
|
||||
{
|
||||
local a=""
|
||||
for i in $@ ; do
|
||||
if test_gt "$i" "$a" ; then
|
||||
a="$i"
|
||||
fi
|
||||
done
|
||||
echo "$a"
|
||||
}
|
||||
|
||||
linux_entry ()
|
||||
{
|
||||
cat << EOF
|
||||
|
@ -117,7 +66,7 @@ list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
|
|||
done`
|
||||
|
||||
while [ "x$list" != "x" ] ; do
|
||||
linux=`find_latest $list`
|
||||
linux=`version_find_latest $list`
|
||||
echo "Found linux image: $linux" >&2
|
||||
basename=`basename $linux`
|
||||
dirname=`dirname $linux`
|
||||
|
|
Loading…
Reference in a new issue