~hamo/ubuntu/precise/grub2/grub2.hi_res

« back to all changes in this revision

Viewing changes to util/grub-mknetdir.in

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, Colin Watson, Evan Broder, Mario Limonciello
  • Date: 2010-11-24 13:59:55 UTC
  • mfrom: (1.17.6 upstream) (17.6.15 experimental)
  • Revision ID: james.westby@ubuntu.com-20101124135955-r6ii5sepayr7jt53
Tags: 1.99~20101124-1ubuntu1
[ Colin Watson ]
* Resynchronise with Debian experimental.  Remaining changes:
  - Adjust for default Ubuntu boot options ("quiet splash").
  - Default to hiding the menu; holding down Shift at boot will show it.
  - Set a monochromatic theme for Ubuntu.
  - Apply Ubuntu GRUB Legacy changes to legacy update-grub script: title,
    recovery mode, quiet option, tweak how memtest86+ is displayed, and
    use UUIDs where appropriate.
  - Fix backslash-escaping in merge_debconf_into_conf.
  - Remove "GNU/Linux" from default distributor string.
  - Add crashkernel= options if kdump and makedumpfile are available.
  - If other operating systems are installed, then automatically unhide
    the menu.  Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus
    if available to check whether Shift is pressed.  If it is, show the
    menu, otherwise boot immediately.  If keystatus is not available, then
    fall back to a short delay interruptible with Escape.
  - Allow Shift to interrupt 'sleep --interruptible'.
  - Don't display introductory message about line editing unless we're
    actually offering a shell prompt.  Don't clear the screen just before
    booting if we never drew the menu in the first place.
  - Remove some verbose messages printed before reading the configuration
    file.
  - Suppress progress messages as the kernel and initrd load for
    non-recovery kernel menu entries.
  - Change prepare_grub_to_access_device to handle filesystems
    loop-mounted on file images.
  - Ignore devices loop-mounted from files in 10_linux.
  - Show the boot menu if the previous boot failed, that is if it failed
    to get to the end of one of the normal runlevels.
  - Don't generate /boot/grub/device.map during grub-install or
    grub-mkconfig by default.
  - Adjust upgrade version checks for Ubuntu.
  - Don't display "GRUB loading" unless Shift is held down.
  - Adjust versions of grub-doc and grub-legacy-doc conflicts to tolerate
    our backport of the grub-doc split.
  - Fix LVM/RAID probing in the absence of /boot/grub/device.map.
  - Look for .mo files in /usr/share/locale-langpack as well, in
    preference.
  - Make sure GRUB_TIMEOUT isn't quoted unnecessarily.
  - Probe all devices in 'grub-probe --target=drive' if
    /boot/grub/device.map is missing.
  - Build-depend on qemu-kvm rather than qemu-system for grub-pc tests.
  - Use qemu rather than qemu-system-i386.
  - Program vesafb on BIOS systems rather than efifb.
  - Add a grub-rescue-efi-amd64 package containing a rescue CD-ROM image
    for EFI-AMD64.
  - On Wubi, don't ask for an install device, but just update wubildr
    using the diverted grub-install.
  - When embedding the core image in a post-MBR gap, check for and avoid
    sectors matching any of a list of known signatures.
  - Disable video_bochs and video_cirrus on PC BIOS systems, as probing
    PCI space seems to break on some systems.
* Downgrade "ACPI shutdown failed" error to a debug message, since it can
  cause spurious test failures.

[ Evan Broder ]
* Enable lua from grub-extras.
* Incorporate the bitop library into lua.
* Add enum_pci function to grub module in lua.
* Switch back to gfxpayload=keep by default, unless the video hardware
  is known to not support it.

[ Mario Limonciello ]
* Built part_msdos and vfat into bootx64.efi (LP: #677758)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
 
 
3
# Install GRUB on your drive.
 
4
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
 
5
#
 
6
# GRUB is free software: you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation, either version 3 of the License, or
 
9
# (at your option) any later version.
 
10
#
 
11
# GRUB is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
18
 
 
19
# Initialize some variables.
 
20
transform="@program_transform_name@"
 
21
 
 
22
prefix=@prefix@
 
23
exec_prefix=@exec_prefix@
 
24
sbindir=@sbindir@
 
25
bindir=@bindir@
 
26
libdir=@libdir@
 
27
PACKAGE_NAME=@PACKAGE_NAME@
 
28
PACKAGE_TARNAME=@PACKAGE_TARNAME@
 
29
PACKAGE_VERSION=@PACKAGE_VERSION@
 
30
target_cpu=@target_cpu@
 
31
platform=@platform@
 
32
host_os=@host_os@
 
33
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
 
34
localedir=@datadir@/locale
 
35
native_platform=@platform@
 
36
pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst"
 
37
 
 
38
self=`basename $0`
 
39
 
 
40
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
 
41
rootdir=/srv/tftp
 
42
grub_prefix=`echo /boot/grub | sed ${transform}`
 
43
modules=
 
44
 
 
45
install_device=
 
46
no_floppy=
 
47
recheck=no
 
48
debug=no
 
49
debug_image=
 
50
subdir=`echo /boot/grub | sed ${transform}`
 
51
pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-pc
 
52
 
 
53
# Usage: usage
 
54
# Print the usage.
 
55
usage () {
 
56
    cat <<EOF
 
57
Usage: $self [OPTION] install_device
 
58
Install GRUB on your drive.
 
59
 
 
60
  -h, --help              print this message and exit
 
61
  -v, --version           print the version information and exit
 
62
  --modules=MODULES       pre-load specified modules MODULES
 
63
  --net-directory=DIR     root directory of TFTP server
 
64
  --subdir=DIR            relative subdirectory on network server
 
65
  --grub-mkimage=FILE     use FILE as grub-mkimage
 
66
 
 
67
$self copies GRUB images into net_directory/subdir/${target_cpu}-${platform}
 
68
 
 
69
Report bugs to <bug-grub@gnu.org>.
 
70
EOF
 
71
}
 
72
 
 
73
argument () {
 
74
  opt=$1
 
75
  shift
 
76
 
 
77
  if test $# -eq 0; then
 
78
      echo "$0: option requires an argument -- '$opt'" 1>&2
 
79
      exit 1
 
80
  fi
 
81
  echo $1
 
82
}
 
83
 
 
84
# Check the arguments.
 
85
while test $# -gt 0
 
86
do
 
87
    option=$1
 
88
    shift
 
89
 
 
90
    case "$option" in
 
91
    -h | --help)
 
92
        usage
 
93
        exit 0 ;;
 
94
    -v | --version)
 
95
        echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
 
96
        exit 0 ;;
 
97
 
 
98
    --modules)
 
99
        modules=`argument $option "$@"`; shift;;
 
100
    --modules=*)
 
101
        modules=`echo "$option" | sed 's/--modules=//'` ;;
 
102
 
 
103
    --net-directory)
 
104
        rootdir=`argument $option "$@"`; shift;;
 
105
    --net-directory=*)
 
106
        rootdir=`echo "$option" | sed 's/--net-directory=//'` ;;
 
107
 
 
108
    --subdir)
 
109
        subdir=`argument $option "$@"`; shift;;
 
110
    --subdir=*)
 
111
        subdir=`echo "$option" | sed 's/--subdir=//'` ;;
 
112
 
 
113
    --grub-mkimage)
 
114
        grub_mkimage=`argument $option "$@"`; shift;;
 
115
    --grub-mkimage=*)
 
116
        grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
 
117
 
 
118
    # This is an undocumented feature...
 
119
    --debug)
 
120
        debug=yes ;;
 
121
    --debug-image)
 
122
        debug_image=`argument $option "$@"`; shift;;
 
123
    --debug-image=*)
 
124
        debug_image=`echo "$option" | sed 's/--debug-image=//'` ;;
 
125
 
 
126
    # Intentionally undocumented
 
127
    --override-directory)
 
128
        override_dir=`argument $option "$@"`
 
129
        shift
 
130
        PATH=${override_dir}:$PATH
 
131
        export PATH
 
132
        ;;
 
133
    --override-directory=*)
 
134
        override_dir=`echo "${option}/" | sed 's/--override-directory=//'`
 
135
        PATH=${override_dir}:$PATH
 
136
        export PATH
 
137
        ;;
 
138
 
 
139
    -*)
 
140
        echo "Unrecognized option \`$option'" 1>&2
 
141
        usage
 
142
        exit 1
 
143
        ;;
 
144
    *)
 
145
        if test "x$install_device" != x; then
 
146
            echo "More than one install_devices?" 1>&2
 
147
            usage
 
148
            exit 1
 
149
        fi
 
150
        install_device="${option}" ;;
 
151
    esac
 
152
done
 
153
 
 
154
set $grub_mkimage dummy
 
155
if test -f "$1"; then
 
156
    :
 
157
else
 
158
    echo "$1: Not found." 1>&2
 
159
    exit 1
 
160
fi
 
161
 
 
162
# Create the GRUB directory if it is not present.
 
163
mkdir -p "${rootdir}/${subdir}" || exit 1
 
164
 
 
165
process_input_dir ()
 
166
 
167
    input_dir="$1"
 
168
    platform="$2"
 
169
    grubdir="${rootdir}/${subdir}/${platform}"
 
170
    config_opt=
 
171
    mkdir -p "$grubdir" || exit 1
 
172
 
 
173
    for file in ${grubdir}/*.mod ${grubdir}/*.lst ${grubdir}/*.img ${grubdir}/efiemu??.o; do
 
174
        if test -f $file && [ "`basename $file`" != menu.lst ]; then
 
175
            rm -f $file || exit 1
 
176
        fi
 
177
    done
 
178
    for file in ${input_dir}/*.mod; do
 
179
        if test -f "$file"; then
 
180
            cp -f "$file" "$grubdir/"
 
181
        fi
 
182
    done
 
183
    for file in ${pkglib_DATA}; do
 
184
        if test -f "${input_dir}/${file}"; then
 
185
            cp -f "${input_dir}/${file}" "$grubdir/"
 
186
        fi
 
187
    done
 
188
 
 
189
    mkdir -p "$grubdir/locale"
 
190
    for file in ${input_dir}/po/*.mo; do
 
191
        if test -f "$file"; then
 
192
            cp -f "$file" "$grubdir/locale/"
 
193
        fi
 
194
    done
 
195
 
 
196
    rm -f ${grubdir}/load.cfg
 
197
 
 
198
    if [ "x${debug_image}" != x ]; then
 
199
       echo "set debug='${debug_image}'" >> ${grubdir}/load.cfg
 
200
       config_opt="-c ${grubdir}/load.cfg "
 
201
    fi
 
202
 
 
203
    case "${platform}" in
 
204
         i386-pc) mkimage_target=i386-pc-pxe;
 
205
                  netmodules="pxe";
 
206
                  prefix="(pxe)/${subdir}/${platform}";
 
207
                  ext=0 ;;
 
208
         *) echo Unsupported platform ${platform};
 
209
            exit 1;;
 
210
    esac
 
211
 
 
212
    cat << EOF > ${grubdir}/grub.cfg
 
213
source ${subdir}/grub.cfg
 
214
EOF
 
215
 
 
216
    $grub_mkimage ${config_opt} -d "${input_dir}" -O ${mkimage_target} --output=${grubdir}/core.$ext --prefix=$prefix $modules $netmodules || exit 1
 
217
    echo "Netboot directory for ${platform} created. Configure your DHCP server to point to ${subdir}/${platform}/core.$ext"
 
218
}
 
219
 
 
220
if [ "${override_dir}" = "" ] ; then
 
221
    if test -e "${pc_dir}" ; then
 
222
        process_input_dir ${pc_dir} i386-pc
 
223
    fi
 
224
else
 
225
    process_input_dir ${override_dir} ${target_cpu}-${native_platform}
 
226
fi
 
227
 
 
228
 
 
229
# Bye.
 
230
exit 0