Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / common / boot / grub2 / util / grub.d / 10_linux.in
blob7cd5a9ed25f729492024bb6534cccfd70ff8f496
1 #! /bin/sh -e
3 # update-grub helper script.
4 # Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
6 # GRUB is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # GRUB is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 prefix=@prefix@
20 exec_prefix=@exec_prefix@
21 libdir=@libdir@
22 . ${libdir}/grub/grub-mkconfig_lib
24 if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
25 OS=GNU/Linux
26 else
27 OS="${GRUB_DISTRIBUTOR} GNU/Linux"
30 # loop-AES arranges things so that /dev/loop/X can be our root device, but
31 # the initrds that Linux uses don't like that.
32 case ${GRUB_DEVICE} in
33 /dev/loop/*|/dev/loop[0-9])
34 GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
36 esac
38 if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
39 || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then
40 LINUX_ROOT_DEVICE=${GRUB_DEVICE}
41 else
42 LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
45 test_numeric ()
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
56 if [ "$cmp" = "lt" ] ; then
57 c=$a
58 a=$b
59 b=$c
61 if (echo $a ; echo $b) | sort -n | head -n 1 | grep -qx $b ; then
62 return 0
63 else
64 return 1
68 test_gt ()
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
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 $?
85 find_latest ()
87 local a=""
88 for i in $@ ; do
89 if test_gt "$i" "$a" ; then
90 a="$i"
92 done
93 echo "$a"
96 list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
97 if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
98 done`
100 while [ "x$list" != "x" ] ; do
101 linux=`find_latest $list`
102 echo "Found linux image: $linux" >&2
103 basename=`basename $linux`
104 dirname=`dirname $linux`
105 rel_dirname=`make_system_path_relative_to_its_root $dirname`
106 version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
107 alt_version=`echo $version | sed -e "s,\.old$,,g"`
108 linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
110 initrd=
111 for i in "initrd.img-${version}" "initrd-${version}.img" \
112 "initrd.img-${alt_version}" "initrd-${alt_version}.img"; do
113 if test -e "${dirname}/${i}" ; then
114 initrd="$i"
115 break
117 done
118 if test -n "${initrd}" ; then
119 echo "Found initrd image: ${dirname}/${initrd}" >&2
120 else
121 # "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here.
122 linux_root_device_thisversion=${GRUB_DEVICE}
125 cat << EOF
126 menuentry "${OS}, linux ${version}" {
128 prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
129 cat << EOF
130 linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}
132 if test -n "${initrd}" ; then
133 cat << EOF
134 initrd ${rel_dirname}/${initrd}
137 cat << EOF
141 cat << EOF
142 menuentry "${OS}, linux ${version} (single-user mode)" {
144 prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
145 cat << EOF
146 linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro single ${GRUB_CMDLINE_LINUX}
148 if test -n "${initrd}" ; then
149 cat << EOF
150 initrd ${rel_dirname}/${initrd}
153 cat << EOF
157 list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
158 done