~jonathank89/burg/burg-percise

« back to all changes in this revision

Viewing changes to util/i386/pc/grub-mkfloppy.in

merge mainline into mips

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh -e
2
 
 
3
 
# Make GRUB rescue floppy
4
 
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008  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
 
bindir=@bindir@
25
 
libdir=@libdir@
26
 
PACKAGE_NAME=@PACKAGE_NAME@
27
 
PACKAGE_TARNAME=@PACKAGE_TARNAME@
28
 
PACKAGE_VERSION=@PACKAGE_VERSION@
29
 
target_cpu=@target_cpu@
30
 
platform=@platform@
31
 
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
32
 
 
33
 
# Usage: usage
34
 
# Print the usage.
35
 
usage () {
36
 
    cat <<EOF
37
 
Usage: $0 [OPTION] output_image
38
 
Make GRUB rescue floppy.
39
 
 
40
 
  -h, --help              print this message and exit
41
 
  -v, --version           print the version information and exit
42
 
  --modules=MODULES       pre-load specified modules MODULES
43
 
  --output=FILE           save output in FILE
44
 
 
45
 
$0 generates a bootable rescue floppy.
46
 
 
47
 
Report bugs to <bug-grub@gnu.org>.
48
 
EOF
49
 
}
50
 
 
51
 
input_dir=${pkglibdir}
52
 
 
53
 
# Check the arguments.
54
 
for option in "$@"; do
55
 
    case "$option" in
56
 
    -h | --help)
57
 
        usage
58
 
        exit 0 ;;
59
 
    -v | --version)
60
 
        echo "$0 (GNU GRUB ${PACKAGE_VERSION})"
61
 
        exit 0 ;;
62
 
    --modules=*)
63
 
        modules=`echo "$option" | sed 's/--modules=//'` ;;
64
 
    --output=*)
65
 
        output_image=`echo "$option" | sed 's/--output=//'` ;;
66
 
    -*)
67
 
        echo "Unrecognized option \`$option'" 1>&2
68
 
        usage
69
 
        exit 1
70
 
        ;;
71
 
    *)
72
 
        if test "x$output_image" != x; then
73
 
            echo "Unrecognized option \`$option'" 1>&2
74
 
            usage
75
 
            exit 1
76
 
        fi
77
 
        output_image="${option}" ;;
78
 
    esac
79
 
done
80
 
 
81
 
if test "x$output_image" = x; then
82
 
  usage
83
 
  exit 1
84
 
fi
85
 
 
86
 
aux_dir=`mktemp -d`
87
 
mkdir -p ${aux_dir}/boot/grub
88
 
 
89
 
for file in ${input_dir}/*.mod ${input_dir}/efiemu??.o \
90
 
  ${input_dir}/command.lst ${input_dir}/moddep.lst ${input_dir}/fs.lst \
91
 
  ${input_dir}/handler.lst ${input_dir}/parttool.lst; do
92
 
  if test -f "$file"; then
93
 
    cp -f "$file" ${aux_dir}/boot/grub/
94
 
  fi
95
 
done
96
 
 
97
 
modules="$(cat ${input_dir}/partmap.lst) ${modules}"
98
 
for i in ${modules} ; do
99
 
  echo "insmod $i"
100
 
done > ${aux_dir}/boot/grub/grub.cfg
101
 
 
102
 
# build memdisk
103
 
memdisk_img=`mktemp`
104
 
tar -C ${aux_dir} -cf ${memdisk_img} boot
105
 
rm -rf ${aux_dir}
106
 
 
107
 
# build core.img
108
 
core_img=`mktemp`
109
 
grub-mkimage -d ${input_dir}/ -m ${memdisk_img} -o ${core_img} memdisk tar biosdisk
110
 
rm -f ${memdisk_img}
111
 
 
112
 
# build floppy image
113
 
cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > ${output_image}
114
 
rm -f ${core_img}
115
 
 
116
 
exit 0