Contents of /smage/branches/alx-0_6_0/core/grub/alx/files/10_alx
Parent Directory | Revision Log
Revision 2542 -
(show annotations)
(download)
Sat Jul 2 11:52:56 2011 UTC (12 years, 11 months ago) by niro
File size: 5162 byte(s)
Sat Jul 2 11:52:56 2011 UTC (12 years, 11 months ago) by niro
File size: 5162 byte(s)
-added injectable files
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_DISTRIBUTOR}" = "x" ] ; then |
32 | OS=ALX |
33 | else |
34 | OS="${GRUB_DISTRIBUTOR}" |
35 | CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}" |
36 | fi |
37 | |
38 | if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ |
39 | || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ |
40 | || uses_abstraction "${GRUB_DEVICE}" lvm; then |
41 | LINUX_ROOT_DEVICE=${GRUB_DEVICE} |
42 | else |
43 | LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} |
44 | fi |
45 | |
46 | if [ "x`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null || true`" = xbtrfs ]; then |
47 | rootsubvol="`make_system_path_relative_to_its_root /`" |
48 | rootsubvol="${rootsubvol#/}" |
49 | if [ "x${rootsubvol}" != x ]; then |
50 | GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" |
51 | fi |
52 | fi |
53 | |
54 | linux_entry () |
55 | { |
56 | os="$1" |
57 | version="$2" |
58 | recovery="$3" |
59 | args="$4" |
60 | if ${recovery} ; then |
61 | title="$(gettext_quoted "%s [ %s ] (recovery mode)")" |
62 | else |
63 | title="$(gettext_quoted "%s [ %s ]")" |
64 | fi |
65 | printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}" |
66 | if ! ${recovery} ; then |
67 | save_default_entry | sed -e "s/^/\t/" |
68 | fi |
69 | |
70 | # Use ELILO's generic "efifb" when it's known to be available. |
71 | # FIXME: We need an interface to select vesafb in case efifb can't be used. |
72 | if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then |
73 | cat << EOF |
74 | load_video |
75 | EOF |
76 | else |
77 | if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then |
78 | cat << EOF |
79 | load_video |
80 | EOF |
81 | fi |
82 | cat << EOF |
83 | set gfxpayload=$GRUB_GFXPAYLOAD_LINUX |
84 | EOF |
85 | fi |
86 | |
87 | cat << EOF |
88 | insmod gzio |
89 | EOF |
90 | |
91 | if [ x$dirname = x/ ]; then |
92 | if [ -z "${prepare_root_cache}" ]; then |
93 | prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/")" |
94 | fi |
95 | printf '%s\n' "${prepare_root_cache}" |
96 | else |
97 | if [ -z "${prepare_boot_cache}" ]; then |
98 | prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" |
99 | fi |
100 | printf '%s\n' "${prepare_boot_cache}" |
101 | fi |
102 | message="$(gettext_printf "Loading Linux %s ..." ${version})" |
103 | cat << EOF |
104 | echo '$message' |
105 | linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} |
106 | EOF |
107 | if test -n "${initrd}" ; then |
108 | message="$(gettext_printf "Loading initial ramdisk ...")" |
109 | cat << EOF |
110 | echo '$message' |
111 | initrd ${rel_dirname}/${initrd} |
112 | EOF |
113 | fi |
114 | cat << EOF |
115 | } |
116 | EOF |
117 | } |
118 | |
119 | case x`uname -m` in |
120 | xi?86 | xx86_64) |
121 | list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do |
122 | if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi |
123 | done` ;; |
124 | *) |
125 | list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do |
126 | if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi |
127 | done` ;; |
128 | esac |
129 | |
130 | prepare_boot_cache= |
131 | prepare_root_cache= |
132 | |
133 | while [ "x$list" != "x" ] ; do |
134 | linux=`version_find_latest $list` |
135 | echo "Found linux image: $linux" >&2 |
136 | basename=`basename $linux` |
137 | dirname=`dirname $linux` |
138 | rel_dirname=`make_system_path_relative_to_its_root $dirname` |
139 | version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` |
140 | alt_version=`echo $version | sed -e "s,\.old$,,g"` |
141 | linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" |
142 | |
143 | initrd= |
144 | for i in "initrd-${version}.img" \ |
145 | "initramfs-${version}.img" \ |
146 | "initrd-${alt_version}.img" \ |
147 | "initramfs-${alt_version}.img"; do |
148 | if test -e "${dirname}/${i}" ; then |
149 | initrd="$i" |
150 | break |
151 | fi |
152 | done |
153 | |
154 | config= |
155 | for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do |
156 | if test -e "${i}" ; then |
157 | config="${i}" |
158 | break |
159 | fi |
160 | done |
161 | |
162 | initramfs= |
163 | if test -n "${config}" ; then |
164 | initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"` |
165 | fi |
166 | |
167 | if test -n "${initrd}" ; then |
168 | echo "Found initrd image: ${dirname}/${initrd}" >&2 |
169 | elif test -z "${initramfs}" ; then |
170 | # "UUID=" magic is parsed by initrd or initramfs. Since there's |
171 | # no initrd or builtin initramfs, it can't work here. |
172 | linux_root_device_thisversion=${GRUB_DEVICE} |
173 | fi |
174 | |
175 | linux_entry "${OS}" "${version}" false \ |
176 | "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" |
177 | |
178 | list=`echo $list | tr ' ' '\n' | grepvx $linux | tr '\n' ' '` |
179 | done |