2 # Filename: create-grub-dir.sh
3 # Purpose: generate core.img and according files for templates/boot/grub/
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2 or any later version.
7 # Latest change: Thu Mar 11 14:25:15 CET 2010 [mika]
8 ################################################################################
9 # This script is very hackish due to the way the grub directory has to be
10 # generated. :-/ The script is meant to be executed on a Debian system that
11 # matches the grub version, otherwise the execution of grub-mkimage *might* fail.
12 # So if you want to use a recent Grub version make sure you execute this script
13 # on an up2date Debian/unstable system.
14 ################################################################################
19 echo "Usage: $0 <grub-version>">&2
20 echo "Usage example: $0 1.98-1">&2
25 echo "Directory 'grub' exists in current working directory already, will not continue.">&2
32 ARCH=$(dpkg --print-architecture)
34 if ! [ -f "grub-pc_${GRUB}_${ARCH}.deb" ] || ! [ -f "grub-pc-bin_${GRUB}_${ARCH}.deb" ] || ! [ -f "grub-common_${GRUB}_${ARCH}.deb" ] ; then
35 wget http://cdn.debian.net/debian/pool/main/g/grub2/grub-pc_"${GRUB}"_${ARCH}.deb
36 wget http://cdn.debian.net/debian/pool/main/g/grub2/grub-pc-bin_"${GRUB}"_${ARCH}.deb
37 wget http://cdn.debian.net/debian/pool/main/g/grub2/grub-common_"${GRUB}"_${ARCH}.deb
40 if ! [ -f "grub-pc_${GRUB}_${ARCH}.deb" ] || ! [ -f "grub-pc-bin_${GRUB}_${ARCH}.deb" ] || ! [ -f "grub-common_${GRUB}_${ARCH}.deb" ] ; then
41 echo "Error reading grub files version $GRUB - exiting.">&2
46 echo "Using temporary directory $GRUBDIR"
51 ar x "${oldpwd}"/"grub-pc_${GRUB}_${ARCH}.deb"
53 ar x "${oldpwd}"/"grub-pc-bin_${GRUB}_${ARCH}.deb"
55 ar x "${oldpwd}"/"grub-common_${GRUB}_${ARCH}.deb"
58 if ./usr/bin/grub-mkimage --help | grep -q -- --format ; then
59 ./usr/bin/grub-mkimage -d usr/lib/grub/*-pc -o core.img biosdisk iso9660 --format=i386-pc
61 ./usr/bin/grub-mkimage -d usr/lib/grub/*-pc -o core.img biosdisk iso9660
64 for a in usr/lib/grub/*-pc/{*.mod,efiemu??.o,command.lst,moddep.lst,fs.lst,handler.lst,parttool.lst}; do \
65 [[ -e $a ]] && cp $a grub/
71 mv "${GRUBDIR}"/grub .
74 echo "Generated new grub boot directory 'grub'."
76 ## END OF FILE #################################################################