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.
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.
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.
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/>.
19
# Initialize some variables.
20
transform="@program_transform_name@"
23
exec_prefix=@exec_prefix@
27
PACKAGE_NAME=@PACKAGE_NAME@
28
PACKAGE_TARNAME=@PACKAGE_TARNAME@
29
PACKAGE_VERSION=@PACKAGE_VERSION@
30
target_cpu=@target_cpu@
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"
40
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
42
grub_prefix=`echo /boot/grub | sed ${transform}`
50
subdir=`echo /boot/grub | sed ${transform}`
51
pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-pc
57
Usage: $self [OPTION] install_device
58
Install GRUB on your drive.
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
67
$self copies GRUB images into net_directory/subdir/${target_cpu}-${platform}
69
Report bugs to <bug-grub@gnu.org>.
77
if test $# -eq 0; then
78
echo "$0: option requires an argument -- '$opt'" 1>&2
84
# Check the arguments.
95
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
99
modules=`argument $option "$@"`; shift;;
101
modules=`echo "$option" | sed 's/--modules=//'` ;;
104
rootdir=`argument $option "$@"`; shift;;
106
rootdir=`echo "$option" | sed 's/--net-directory=//'` ;;
109
subdir=`argument $option "$@"`; shift;;
111
subdir=`echo "$option" | sed 's/--subdir=//'` ;;
114
grub_mkimage=`argument $option "$@"`; shift;;
116
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
118
# This is an undocumented feature...
122
debug_image=`argument $option "$@"`; shift;;
124
debug_image=`echo "$option" | sed 's/--debug-image=//'` ;;
126
# Intentionally undocumented
127
--override-directory)
128
override_dir=`argument $option "$@"`
130
PATH=${override_dir}:$PATH
133
--override-directory=*)
134
override_dir=`echo "${option}/" | sed 's/--override-directory=//'`
135
PATH=${override_dir}:$PATH
140
echo "Unrecognized option \`$option'" 1>&2
145
if test "x$install_device" != x; then
146
echo "More than one install_devices?" 1>&2
150
install_device="${option}" ;;
154
set $grub_mkimage dummy
155
if test -f "$1"; then
158
echo "$1: Not found." 1>&2
162
# Create the GRUB directory if it is not present.
163
mkdir -p "${rootdir}/${subdir}" || exit 1
169
grubdir="${rootdir}/${subdir}/${platform}"
171
mkdir -p "$grubdir" || exit 1
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
178
for file in ${input_dir}/*.mod; do
179
if test -f "$file"; then
180
cp -f "$file" "$grubdir/"
183
for file in ${pkglib_DATA}; do
184
if test -f "${input_dir}/${file}"; then
185
cp -f "${input_dir}/${file}" "$grubdir/"
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/"
196
rm -f ${grubdir}/load.cfg
198
if [ "x${debug_image}" != x ]; then
199
echo "set debug='${debug_image}'" >> ${grubdir}/load.cfg
200
config_opt="-c ${grubdir}/load.cfg "
203
case "${platform}" in
204
i386-pc) mkimage_target=i386-pc-pxe;
206
prefix="(pxe)/${subdir}/${platform}";
208
*) echo Unsupported platform ${platform};
212
cat << EOF > ${grubdir}/grub.cfg
213
source ${subdir}/grub.cfg
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"
220
if [ "${override_dir}" = "" ] ; then
221
if test -e "${pc_dir}" ; then
222
process_input_dir ${pc_dir} i386-pc
225
process_input_dir ${override_dir} ${target_cpu}-${native_platform}