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 3520 - (show annotations) (download)
Fri Apr 20 14:00:21 2012 UTC (12 years ago) by niro
File size: 7439 byte(s)
-fixed a typo in 10_alx (--user -> --users)
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`"
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 i815 2> /dev/null || true`" != x ]
103 then
104 GRUB_CMDLINE_LINUX="splash=verbose,theme=default ${GRUB_CMDLINE_LINUX}"
105 fi
106
107 # disable KMS for Radeon RV250
108 if [ "x`echo ${hwinfo} | grep -i rv250 2> /dev/null || true`" != x ]
109 then
110 GRUB_CMDLINE_LINUX="nomodeset ${GRUB_CMDLINE_LINUX}"
111 fi
112 fi
113
114 linux_entry ()
115 {
116 os="$1"
117 version="$2"
118 recovery="$3"
119 args="$4"
120 entry_args="$5"
121 if ${recovery} ; then
122 title="$(gettext_quoted "%s [ %s ] (recovery mode)")"
123 else
124 title="$(gettext_quoted "%s [ %s ]")"
125 fi
126 printf "menuentry '${title}' ${CLASS} ${entry_args} {\n" "${os}" "${version}"
127 if ! ${recovery} ; then
128 save_default_entry | sed -e "s/^/\t/"
129 fi
130
131 # Use ELILO's generic "efifb" when it's known to be available.
132 # FIXME: We need an interface to select vesafb in case efifb can't be used.
133 if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
134 cat << EOF
135 load_video
136 EOF
137 else
138 if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then
139 cat << EOF
140 load_video
141 EOF
142 fi
143 cat << EOF
144 set gfxpayload=$GRUB_GFXPAYLOAD_LINUX
145 EOF
146 fi
147
148 cat << EOF
149 insmod gzio
150 EOF
151
152 if [ x$dirname = x/ ]; then
153 if [ -z "${prepare_root_cache}" ]; then
154 prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/")"
155 fi
156 printf '%s\n' "${prepare_root_cache}"
157 else
158 if [ -z "${prepare_boot_cache}" ]; then
159 prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
160 fi
161 printf '%s\n' "${prepare_boot_cache}"
162 fi
163 message="$(gettext_printf "Loading Linux %s ..." ${version})"
164 cat << EOF
165 echo '$message'
166 linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
167 EOF
168 if test -n "${initrd}" ; then
169 message="$(gettext_printf "Loading initial ramdisk ...")"
170 cat << EOF
171 echo '$message'
172 initrd ${rel_dirname}/${initrd}
173 EOF
174 fi
175 cat << EOF
176 }
177 EOF
178 }
179
180 case x`uname -m` in
181 xi?86 | xx86_64)
182 list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
183 if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
184 done` ;;
185 *)
186 list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
187 if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
188 done` ;;
189 esac
190
191 prepare_boot_cache=
192 prepare_root_cache=
193
194 while [ "x$list" != "x" ] ; do
195 linux=`version_find_latest $list`
196 echo "Found linux image: $linux" >&2
197 basename=`basename $linux`
198 dirname=`dirname $linux`
199 rel_dirname=`make_system_path_relative_to_its_root $dirname`
200 version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
201 alt_version=`echo $version | sed -e "s,\.old$,,g"`
202 linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
203
204 initrd=
205 for i in "initrd-${version}.img" \
206 "initramfs-${version}.img" \
207 "initrd-${alt_version}.img" \
208 "initramfs-${alt_version}.img"; do
209 if test -e "${dirname}/${i}" ; then
210 initrd="$i"
211 break
212 fi
213 done
214
215 config=
216 for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
217 if test -e "${i}" ; then
218 config="${i}"
219 break
220 fi
221 done
222
223 initramfs=
224 if test -n "${config}" ; then
225 initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"`
226 fi
227
228 if test -n "${initrd}" ; then
229 echo "Found initrd image: ${dirname}/${initrd}" >&2
230 elif test -z "${initramfs}" ; then
231 # "UUID=" magic is parsed by initrd or initramfs. Since there's
232 # no initrd or builtin initramfs, it can't work here.
233 linux_root_device_thisversion=${GRUB_DEVICE}
234 fi
235
236 linux_entry "${OS}" "${version}" false \
237 "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ""
238
239 linux_entry "${OS} - Re-run hardware detection" "${version}" false \
240 "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_ALX_HWDETECT}" "--users alx"
241
242 linux_entry "${OS} - Reset *all* local settings" "${version}" false \
243 "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_ALX_RESET}" "--users alx"
244
245 list=`echo $list | tr ' ' '\n' | grepvx $linux | tr '\n' ' '`
246 done