4
# grub-mkconfig helper script.
5
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
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.
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.
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/>.
21
exec_prefix=@exec_prefix@
24
. ${libdir}/grub/grub-mkconfig_lib
26
export TEXTDOMAIN=@PACKAGE@
27
export TEXTDOMAINDIR=@localedir@
29
CLASS="--class gnu-linux --class gnu --class os --class xen"
31
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
34
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
35
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
38
# loop-AES arranges things so that /dev/loop/X can be our root device, but
39
# the initrds that Linux uses don't like that.
40
case ${GRUB_DEVICE} in
41
/dev/loop/*|/dev/loop[0-9])
42
GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
46
if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
47
|| ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then
48
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
50
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
62
title="$(gettext_quoted "%s, with Linux %s and XEN %s (recovery mode)")"
64
title="$(gettext_quoted "%s, with Linux %s and XEN %s")"
66
printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}" "${xen_version}"
67
save_default_entry | sed -e "s/^/\t/"
69
if [ -z "${prepare_boot_cache}" ]; then
70
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
72
printf '%s\n' "${prepare_boot_cache}"
74
echo '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})'
75
multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args}
76
module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
78
if test -n "${initrd}" ; then
80
echo '$(gettext_quoted "Loading initial ramdisk ...")'
81
module ${rel_dirname}/${initrd}
89
linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
90
basename=$(basename $i)
91
version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
92
if grub_file_is_not_garbage "$i" && grep -qx "CONFIG_XEN_DOM0=y" /boot/config-${version} 2> /dev/null ; then echo -n "$i " ; fi
94
xen_list=`for i in /boot/xen*; do
95
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
99
while [ "x${xen_list}" != "x" ] ; do
101
current_xen=`version_find_latest $xen_list`
102
xen_basename=`basename ${current_xen}`
103
xen_dirname=`dirname ${current_xen}`
104
rel_xen_dirname=`make_system_path_relative_to_its_root $xen_dirname`
105
xen_version=`echo $xen_basename | sed -e "s,.gz$,,g;s,^xen-,,g"`
106
while [ "x$list" != "x" ] ; do
107
linux=`version_find_latest $list`
108
echo "Found linux image: $linux" >&2
109
basename=`basename $linux`
110
dirname=`dirname $linux`
111
rel_dirname=`make_system_path_relative_to_its_root $dirname`
112
version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
113
alt_version=`echo $version | sed -e "s,\.old$,,g"`
114
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
117
for i in "initrd.img-${version}" "initrd-${version}.img" \
118
"initrd-${version}" "initrd.img-${alt_version}" \
119
"initrd-${alt_version}.img" "initrd-${alt_version}"; do
120
if test -e "${dirname}/${i}" ; then
125
if test -n "${initrd}" ; then
126
echo "Found initrd image: ${dirname}/${initrd}" >&2
128
# "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here.
129
linux_root_device_thisversion=${GRUB_DEVICE}
132
linux_entry "${OS}" "${version}" "${xen_version}" false \
133
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
134
if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
135
linux_entry "${OS}" "${version}" "${xen_version}" true \
136
"single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
139
list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
141
xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $current_xen | tr '\n' ' '`