~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, Robert Millan, Updated translations
  • Date: 2010-11-22 12:24:56 UTC
  • mfrom: (1.26.4 upstream) (17.3.36 sid)
  • mto: (17.3.43 sid)
  • mto: This revision was merged to the branch mainline in revision 89.
  • Revision ID: james.westby@ubuntu.com-20101122122456-y82z3sfb7k4zfdcc
Tags: 1.99~20101122-1
[ Colin Watson ]
* New Bazaar snapshot.  Too many changes to list in full, but some of the
  more user-visible ones are as follows:
  - GRUB script:
    + Function parameters, "break", "continue", "shift", "setparams",
      "return", and "!".
    + "export" command supports multiple variable names.
    + Multi-line quoted strings support.
    + Wildcard expansion.
  - sendkey support.
  - USB hotunplugging and USB serial support.
  - Rename CD-ROM to cd on BIOS.
  - Add new --boot-directory option to grub-install, grub-reboot, and
    grub-set-default; the old --root-directory option is still accepted
    but was often confusing.
  - Basic btrfs detection/UUID support (but no file reading yet).
  - bash-completion for utilities.
  - If a device is listed in device.map, always assume that it is
    BIOS-visible rather than using extra layers such as LVM or RAID.
  - Add grub-mknetdir script (closes: #550658).
  - Remove deprecated "root" command.
  - Handle RAID devices containing virtio components.
  - GRUB Legacy configuration file support (via grub-menulst2cfg).
  - Keyboard layout support (via grub-mklayout and grub-kbdcomp).
  - Check generated grub.cfg for syntax errors before saving.
  - Pause execution for at most ten seconds if any errors are displayed,
    so that the user has a chance to see them.
  - Support submenus.
  - Write embedding zone using Reed-Solomon, so that it's robust against
    being partially overwritten (closes: #550702, #591416, #593347).
  - GRUB_DISABLE_LINUX_RECOVERY and GRUB_DISABLE_NETBSD_RECOVERY merged
    into a single GRUB_DISABLE_RECOVERY variable.
  - Fix loader memory allocation failure (closes: #551627).
  - Don't call savedefault on recovery entries (closes: #589325).
  - Support triple-indirect blocks on ext2 (closes: #543924).
  - Recognise DDF1 fake RAID (closes: #603354).

[ Robert Millan ]
* Use dpkg architecture wildcards.

[ Updated translations ]
* Slovenian (Vanja Cvelbar).  Closes: #604003
* Dzongkha (dawa pemo via Tenzin Dendup).  Closes: #604102

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