source: grub-pc/trunk/fuentes/.pc/gfxpayload_keep_default.patch/util/grub.d/10_linux.in @ 22

Last change on this file since 22 was 22, checked in by mabarracus, 4 years ago

updated version and apply net.ifnames=0 into debian/rules

File size: 9.0 KB
Line 
1#! /bin/sh
2set -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
20prefix="@prefix@"
21exec_prefix="@exec_prefix@"
22datarootdir="@datarootdir@"
23
24. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
25
26export TEXTDOMAIN=@PACKAGE@
27export TEXTDOMAINDIR="@localedir@"
28
29CLASS="--class gnu-linux --class gnu --class os"
30
31if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
32  OS=GNU/Linux
33else
34  OS="${GRUB_DISTRIBUTOR} GNU/Linux"
35  CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
36fi
37
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.
40case ${GRUB_DEVICE} in
41  /dev/loop/*|/dev/loop[0-9])
42    GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
43  ;;
44esac
45
46if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
47    || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
48    || uses_abstraction "${GRUB_DEVICE}" lvm; then
49  LINUX_ROOT_DEVICE=${GRUB_DEVICE}
50else
51  LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
52fi
53
54case x"$GRUB_FS" in
55    xbtrfs)
56        rootsubvol="`make_system_path_relative_to_its_root /`"
57        rootsubvol="${rootsubvol#/}"
58        if [ "x${rootsubvol}" != x ]; then
59            GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
60        fi;;
61    xzfs)
62        rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
63        bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
64        LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
65        ;;
66esac
67
68title_correction_code=
69
70linux_entry ()
71{
72  os="$1"
73  version="$2"
74  type="$3"
75  args="$4"
76
77  if [ -z "$boot_device_id" ]; then
78      boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
79  fi
80  if [ x$type != xsimple ] ; then
81      case $type in
82          recovery)
83              title="$(gettext_printf "%s, with Linux %s (recovery mode)" "${os}" "${version}")" ;;
84          *)
85              title="$(gettext_printf "%s, with Linux %s" "${os}" "${version}")" ;;
86      esac
87      if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
88          replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
89          quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
90          title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
91          grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
92      fi
93      echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
94  else
95      echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
96  fi     
97  if [ x$type != xrecovery ] ; then
98      save_default_entry | grub_add_tab
99  fi
100
101  # Use ELILO's generic "efifb" when it's known to be available.
102  # FIXME: We need an interface to select vesafb in case efifb can't be used.
103  if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
104      echo "    load_video" | sed "s/^/$submenu_indentation/"
105      if grep -qx "CONFIG_FB_EFI=y" "${config}" 2> /dev/null \
106          && grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" "${config}" 2> /dev/null; then
107          echo "        set gfxpayload=keep" | sed "s/^/$submenu_indentation/"
108      fi
109  else
110      if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then
111          echo "        load_video" | sed "s/^/$submenu_indentation/"
112      fi
113      echo "    set gfxpayload=$GRUB_GFXPAYLOAD_LINUX" | sed "s/^/$submenu_indentation/"
114  fi
115
116  echo "        insmod gzio" | sed "s/^/$submenu_indentation/"
117
118  if [ x$dirname = x/ ]; then
119    if [ -z "${prepare_root_cache}" ]; then
120      prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)"
121    fi
122    printf '%s\n' "${prepare_root_cache}" | sed "s/^/$submenu_indentation/"
123  else
124    if [ -z "${prepare_boot_cache}" ]; then
125      prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)"
126    fi
127    printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
128  fi
129  message="$(gettext_printf "Loading Linux %s ..." ${version})"
130  sed "s/^/$submenu_indentation/" << EOF
131        echo    '$(echo "$message" | grub_quote)'
132        linux   ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
133EOF
134  if test -n "${initrd}" ; then
135    # TRANSLATORS: ramdisk isn't identifier. Should be translated.
136    message="$(gettext_printf "Loading initial ramdisk ...")"
137    sed "s/^/$submenu_indentation/" << EOF
138        echo    '$(echo "$message" | grub_quote)'
139        initrd  ${rel_dirname}/${initrd}
140EOF
141  fi
142  sed "s/^/$submenu_indentation/" << EOF
143}
144EOF
145}
146
147machine=`uname -m`
148case "x$machine" in
149    xi?86 | xx86_64)
150        list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
151                  if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
152              done` ;;
153    *)
154        list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
155                  if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
156             done` ;;
157esac
158
159case "$machine" in
160    i?86) GENKERNEL_ARCH="x86" ;;
161    mips|mips64) GENKERNEL_ARCH="mips" ;;
162    mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;;
163    arm*) GENKERNEL_ARCH="arm" ;;
164    *) GENKERNEL_ARCH="$machine" ;;
165esac
166
167prepare_boot_cache=
168prepare_root_cache=
169boot_device_id=
170title_correction_code=
171
172# Extra indentation to add to menu entries in a submenu. We're not in a submenu
173# yet, so it's empty. In a submenu it will be equal to '\t' (one tab).
174submenu_indentation=""
175
176is_top_level=true
177while [ "x$list" != "x" ] ; do
178  linux=`version_find_latest $list`
179  gettext_printf "Found linux image: %s\n" "$linux" >&2
180  basename=`basename $linux`
181  dirname=`dirname $linux`
182  rel_dirname=`make_system_path_relative_to_its_root $dirname`
183  version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
184  alt_version=`echo $version | sed -e "s,\.old$,,g"`
185  linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
186
187  initrd=
188  for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
189           "initrd-${version}" "initramfs-${version}.img" \
190           "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
191           "initrd-${alt_version}" "initramfs-${alt_version}.img" \
192           "initramfs-genkernel-${version}" \
193           "initramfs-genkernel-${alt_version}" \
194           "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
195           "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do
196    if test -e "${dirname}/${i}" ; then
197      initrd="$i"
198      break
199    fi
200  done
201
202  config=
203  for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
204    if test -e "${i}" ; then
205      config="${i}"
206      break
207    fi
208  done
209
210  initramfs=
211  if test -n "${config}" ; then
212      initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"`
213  fi
214
215  if test -n "${initrd}" ; then
216    gettext_printf "Found initrd image: %s\n" "${dirname}/${initrd}" >&2
217  elif test -z "${initramfs}" ; then
218    # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs.  Since there's
219    # no initrd or builtin initramfs, it can't work here.
220    linux_root_device_thisversion=${GRUB_DEVICE}
221  fi
222
223  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
224    linux_entry "${OS}" "${version}" simple \
225    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
226
227    submenu_indentation="$grub_tab"
228   
229    if [ -z "$boot_device_id" ]; then
230        boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
231    fi
232    # TRANSLATORS: %s is replaced with an OS name
233    echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
234    is_top_level=false
235  fi
236
237  linux_entry "${OS}" "${version}" advanced \
238              "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
239  if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
240    linux_entry "${OS}" "${version}" recovery \
241                "single ${GRUB_CMDLINE_LINUX}"
242  fi
243
244  list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
245done
246
247# If at least one kernel was found, then we need to
248# add a closing '}' for the submenu command.
249if [ x"$is_top_level" != xtrue ]; then
250  echo '}'
251fi
252
253echo "$title_correction_code"
Note: See TracBrowser for help on using the repository browser.