Magellan Linux

Contents of /smage/branches/alx-0_6_0/core/grub/alx/files/10_alx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5573 - (show annotations) (download)
Tue Apr 22 10:51:38 2014 UTC (10 years ago) by niro
File size: 8062 byte(s)
-hwinfo: search gfxcards too and fixed kms support for i845 devices
1 #! /bin/sh
2 set -e
3
4 # grub-mkconfig helper script.
5 # Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
6 #
7 # GRUB is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # GRUB is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19
20 prefix=/usr
21 exec_prefix=${prefix}
22 bindir=/bin
23 libdir=/lib
24 . ${libdir}/grub/grub-mkconfig_lib
25
26 export TEXTDOMAIN=grub
27 export TEXTDOMAINDIR=${prefix}/share/locale
28
29 CLASS="--class gnu-linux --class gnu --class os"
30
31 if [ "x${GRUB_CMDLINE_ALX_HWDETECT}" = "x" ]; then
32 GRUB_CMDLINE_ALX_HWDETECT="splash=verbose,theme=default hardware-auto-detection"
33 fi
34
35 if [ "x${GRUB_CMDLINE_ALX_RESET}" = "x" ]; then
36 GRUB_CMDLINE_ALX_RESET="splash=verbose,theme=default alx-reset-settings"
37 fi
38
39 if [ "x${GRUB_ALX_FB_FALLBACK}" = "x" ]; then
40 # use vesafb instead of uvesafb, 1024x768-16@60
41 GRUB_ALX_FB_FALLBACK="video=vesafb:mtrr:3,ywrap vga=791"
42 fi
43
44 if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
45 OS=ALX
46 else
47 OS="${GRUB_DISTRIBUTOR}"
48 CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}"
49 fi
50
51 if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
52 || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
53 || uses_abstraction "${GRUB_DEVICE}" lvm; then
54 LINUX_ROOT_DEVICE=${GRUB_DEVICE}
55 else
56 LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
57 fi
58
59 if [ "x`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null || true`" = xbtrfs ]; then
60 rootsubvol="`make_system_path_relative_to_its_root /`"
61 rootsubvol="${rootsubvol#/}"
62 if [ "x${rootsubvol}" != x ]; then
63 GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
64 fi
65 fi
66
67 # check for special hardware
68 if [ -x "`which hwinfo`" ]
69 then
70 hwinfo="`hwinfo --bios --storage --pci --gfxcard`"
71
72 # zotac
73 if [ "x`echo ${hwinfo} | grep -i zotac 2> /dev/null || true`" != x ]
74 then
75 GRUB_CMDLINE_LINUX="rootdelay=8 ${GRUB_CMDLINE_LINUX}"
76 # use noop scheduler on flash memory drivers for better i/o perfomance
77 GRUB_CMDLINE_LINUX="elevator=noop ${GRUB_CMDLINE_LINUX}"
78 fi
79
80 # rangee / VIA CLE-266 chipset
81 if [ "x`echo ${hwinfo} | grep -i CLE266 2> /dev/null || true`" != x ]
82 then
83 # use fallback
84 GRUB_CMDLINE_LINUX="${GRUB_ALX_FB_FALLBACK} ${GRUB_CMDLINE_LINUX}"
85 # use noop scheduler on flash memory drivers for better i/o perfomance
86 GRUB_CMDLINE_LINUX="elevator=noop ${GRUB_CMDLINE_LINUX}"
87 fi
88
89 # maxdata / Intel i810 / i815 chipset
90 if [ "x`echo ${hwinfo} | grep -i i810 2> /dev/null || true`" != x ]
91 then
92 # disable KMS
93 GRUB_CMDLINE_LINUX="nomodeset ${GRUB_CMDLINE_LINUX}"
94 fi
95 if [ "x`echo ${hwinfo} | grep -i i815 2> /dev/null || true`" != x ]
96 then
97 # disable KMS
98 GRUB_CMDLINE_LINUX="nomodeset ${GRUB_CMDLINE_LINUX}"
99 fi
100
101 # disable bootsplash for i845, which must have kms, but fbmode is not supported with kms
102 if [ "x`echo ${hwinfo} | grep -i i845 2> /dev/null || true`" != x ]
103 then
104 # remove "video=" opt from cmdline
105 for i in ${GRUB_CMDLINE_LINUX_DEFAULT}
106 do
107 case ${i} in
108 video=*) continue ;;
109 *) __grub_opts="${__grub_opts} ${i}" ;;
110 esac
111 done
112 GRUB_CMDLINE_LINUX_DEFAULT="${__grub_opts}"
113 # enable full kms support
114 GRUB_GFXPAYLOAD_LINUX="keep"
115 fi
116
117 # disable KMS for Radeon RV250
118 if [ "x`echo ${hwinfo} | grep -i rv250 2> /dev/null || true`" != x ]
119 then
120 GRUB_CMDLINE_LINUX="nomodeset ${GRUB_CMDLINE_LINUX}"
121 fi
122 fi
123 # check for kms
124 if [ -e /proc/fb ]
125 then
126 if [ x"`grep inteldrmfb /proc/fb`" != "x" ]
127 then
128 # unset framebuffer, use KMS
129 export GRUB_GFXPAYLOAD_LINUX=""
130 elif [ x"`grep radeondrmfb /proc/fb`" != "x" ]
131 then
132 # unset framebuffer, use KMS
133 export GRUB_GFXPAYLOAD_LINUX=""
134 elif [ x"`grep nouveaufb /proc/fb`" != "x" ]
135 then
136 # unset framebuffer, use KMS
137 export GRUB_GFXPAYLOAD_LINUX=""
138 fi
139 fi
140
141 linux_entry ()
142 {
143 os="$1"
144 version="$2"
145 recovery="$3"
146 args="$4"
147 entry_args="$5"
148 if ${recovery} ; then
149 title="$(gettext_quoted "%s [ %s ] (recovery mode)")"
150 else
151 title="$(gettext_quoted "%s [ %s ]")"
152 fi
153 printf "menuentry '${title}' ${CLASS} ${entry_args} {\n" "${os}" "${version}"
154 if ! ${recovery} ; then
155 save_default_entry | sed -e "s/^/\t/"
156 fi
157
158 # Use ELILO's generic "efifb" when it's known to be available.
159 # FIXME: We need an interface to select vesafb in case efifb can't be used.
160 if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
161 cat << EOF
162 load_video
163 EOF
164 else
165 if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then
166 cat << EOF
167 load_video
168 EOF
169 fi
170 cat << EOF
171 set gfxpayload=$GRUB_GFXPAYLOAD_LINUX
172 EOF
173 fi
174
175 cat << EOF
176 insmod gzio
177 EOF
178
179 if [ x$dirname = x/ ]; then
180 if [ -z "${prepare_root_cache}" ]; then
181 prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/")"
182 fi
183 printf '%s\n' "${prepare_root_cache}"
184 else
185 if [ -z "${prepare_boot_cache}" ]; then
186 prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
187 fi
188 printf '%s\n' "${prepare_boot_cache}"
189 fi
190 message="$(gettext_printf "Loading Linux %s ..." ${version})"
191 cat << EOF
192 echo '$message'
193 linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
194 EOF
195 if test -n "${initrd}" ; then
196 message="$(gettext_printf "Loading initial ramdisk ...")"
197 cat << EOF
198 echo '$message'
199 initrd ${rel_dirname}/${initrd}
200 EOF
201 fi
202 cat << EOF
203 }
204 EOF
205 }
206
207 case x`uname -m` in
208 xi?86 | xx86_64)
209 list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
210 if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
211 done` ;;
212 *)
213 list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
214 if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
215 done` ;;
216 esac
217
218 prepare_boot_cache=
219 prepare_root_cache=
220
221 while [ "x$list" != "x" ] ; do
222 linux=`version_find_latest $list`
223 echo "Found linux image: $linux" >&2
224 basename=`basename $linux`
225 dirname=`dirname $linux`
226 rel_dirname=`make_system_path_relative_to_its_root $dirname`
227 version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
228 alt_version=`echo $version | sed -e "s,\.old$,,g"`
229 linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
230
231 initrd=
232 for i in "initrd-${version}.img" \
233 "initramfs-${version}.img" \
234 "initrd-${alt_version}.img" \
235 "initramfs-${alt_version}.img"; do
236 if test -e "${dirname}/${i}" ; then
237 initrd="$i"
238 break
239 fi
240 done
241
242 config=
243 for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
244 if test -e "${i}" ; then
245 config="${i}"
246 break
247 fi
248 done
249
250 initramfs=
251 if test -n "${config}" ; then
252 initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"`
253 fi
254
255 if test -n "${initrd}" ; then
256 echo "Found initrd image: ${dirname}/${initrd}" >&2
257 elif test -z "${initramfs}" ; then
258 # "UUID=" magic is parsed by initrd or initramfs. Since there's
259 # no initrd or builtin initramfs, it can't work here.
260 linux_root_device_thisversion=${GRUB_DEVICE}
261 fi
262
263 linux_entry "${OS}" "${version}" false \
264 "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ""
265
266 linux_entry "${OS} - Re-run hardware detection" "${version}" false \
267 "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_ALX_HWDETECT}" "--users alx"
268
269 linux_entry "${OS} - Reset *all* local settings" "${version}" false \
270 "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_ALX_RESET}" "--users alx"
271
272 list=`echo $list | tr ' ' '\n' | grepvx $linux | tr '\n' ' '`
273 done