~ilya-yanok/ubuntu/precise/grub2/fix-for-948716

« back to all changes in this revision

Viewing changes to util/grub.d/10_linux.in

  • Committer: Bazaar Package Importer
  • Author(s): Robert Millan
  • Date: 2009-07-25 19:00:53 UTC
  • mfrom: (1.6.3 upstream)
  • mto: (17.4.13 sid)
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: james.westby@ubuntu.com-20090725190053-uv3lm6ya3zxs77ep
ImportĀ upstreamĀ versionĀ 1.96+20090725

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /bin/sh -e
2
2
 
3
 
# grub-mkconfig helper script.
 
3
# update-grub helper script.
4
4
# Copyright (C) 2006,2007,2008,2009  Free Software Foundation, Inc.
5
5
#
6
6
# GRUB is free software: you can redistribute it and/or modify
42
42
  LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
43
43
fi
44
44
 
 
45
test_numeric ()
 
46
{
 
47
  local a=$1
 
48
  local cmp=$2
 
49
  local b=$3
 
50
  if [ "$a" = "$b" ] ; then
 
51
    case $cmp in
 
52
      ge|eq|le) return 0 ;;
 
53
      gt|lt) return 1 ;;
 
54
    esac
 
55
  fi
 
56
  if [ "$cmp" = "lt" ] ; then
 
57
    c=$a
 
58
    a=$b
 
59
    b=$c
 
60
  fi
 
61
  if (echo $a ; echo $b) | sort -n | head -n 1 | grep -qx $b ; then
 
62
    return 0
 
63
  else
 
64
    return 1
 
65
  fi
 
66
}
 
67
 
 
68
test_gt ()
 
69
{
 
70
  local a=`echo $1 | sed -e "s/vmlinu[zx]-//g"`
 
71
  local b=`echo $2 | sed -e "s/vmlinu[zx]-//g"`
 
72
  local cmp=gt
 
73
  if [ "x$b" = "x" ] ; then
 
74
    return 0
 
75
  fi
 
76
  case $a:$b in
 
77
    *.old:*.old) ;;
 
78
    *.old:*) a=`echo -n $a | sed -e s/\.old$//g` ; cmp=gt ;;
 
79
    *:*.old) b=`echo -n $b | sed -e s/\.old$//g` ; cmp=ge ;;
 
80
  esac
 
81
  test_numeric $a $cmp $b
 
82
  return $?
 
83
}
 
84
 
 
85
find_latest ()
 
86
{
 
87
  local a=""
 
88
  for i in $@ ; do
 
89
    if test_gt "$i" "$a" ; then
 
90
      a="$i"
 
91
    fi
 
92
  done
 
93
  echo "$a"
 
94
}
 
95
 
45
96
linux_entry ()
46
97
{
47
98
  cat << EOF
66
117
      done`
67
118
 
68
119
while [ "x$list" != "x" ] ; do
69
 
  linux=`version_find_latest $list`
 
120
  linux=`find_latest $list`
70
121
  echo "Found linux image: $linux" >&2
71
122
  basename=`basename $linux`
72
123
  dirname=`dirname $linux`
91
142
    linux_root_device_thisversion=${GRUB_DEVICE}
92
143
  fi
93
144
 
94
 
  linux_entry "${OS}, with Linux ${version}" \
 
145
  linux_entry "${OS}, Linux ${version}" \
95
146
      "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
96
147
  if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
97
 
    linux_entry "${OS}, with Linux ${version} (recovery mode)" \
 
148
    linux_entry "${OS}, Linux ${version} (recovery mode)" \
98
149
        "single ${GRUB_CMDLINE_LINUX}"
99
150
  fi
100
151