X-Git-Url: https://git.grml.org/?p=grml-live.git;a=blobdiff_plain;f=scripts%2Fcreate-grub-dir.sh;h=681b0c00c7b5167f697f0336c38e2de1844e53e3;hp=0f3691c8b2ea4d8dad54d2d08d4f28bd586b1382;hb=900b82d5c818409cb10d9b746454b54d828bc0d1;hpb=e8e351d4a28c0788518c94890b550d6c05062a4e diff --git a/scripts/create-grub-dir.sh b/scripts/create-grub-dir.sh index 0f3691c..681b0c0 100755 --- a/scripts/create-grub-dir.sh +++ b/scripts/create-grub-dir.sh @@ -6,12 +6,18 @@ # License: This file is licensed under the GPL v2 or any later version. # Latest change: Thu Mar 11 14:25:15 CET 2010 [mika] ################################################################################ +# This script is very hackish due to the way the grub directory has to be +# generated. :-/ The script is meant to be executed on a Debian system that +# matches the grub version, otherwise the execution of grub-mkimage *might* fail. +# So if you want to use a recent Grub version make sure you execute this script +# on an up2date Debian/unstable system. +################################################################################ set -e if [ -z "$1" ] ; then - echo "Usage: $0 ">&2 - echo "Usage example: $0 grub-pc_1.98-1_i386.deb">&2 + echo "Usage: $0 ">&2 + echo "Usage example: $0 1.98-1">&2 exit 1 fi @@ -23,25 +29,36 @@ fi GRUB="$1" oldpwd=$(pwd) -if ! [ -f "$GRUB" ] ; then - wget http://ftp.de.debian.org/debian/pool/main/g/grub2/"$GRUB" +ARCH=$(dpkg --print-architecture) + +if ! [ -f "grub-pc_${GRUB}_${ARCH}.deb" ] || ! [ -f "grub-common_${GRUB}_${ARCH}.deb" ] ; then + wget http://cdn.debian.net/debian/pool/main/g/grub2/grub-pc_"${GRUB}"_${ARCH}.deb + wget http://cdn.debian.net/debian/pool/main/g/grub2/grub-common_"${GRUB}"_${ARCH}.deb fi -if ! [ -f "$GRUB" ] ; then - echo "Error reading $GRUB - exiting.">&2 +if ! [ -f "grub-pc_${GRUB}_${ARCH}.deb" ] || ! [ -f "grub-common_${GRUB}_${ARCH}.deb" ] ; then + echo "Error reading grub files version $GRUB - exiting.">&2 exit 1 fi GRUBDIR=$(mktemp -d) +echo "Using temporary directory $GRUBDIR" cd "$GRUBDIR" mkdir -p grub -ar x "${oldpwd}"/"$GRUB" +ar x "${oldpwd}"/"grub-pc_${GRUB}_${ARCH}.deb" +tar xzf data.tar.gz +ar x "${oldpwd}"/"grub-common_${GRUB}_${ARCH}.deb" tar xzf data.tar.gz -./usr/bin/grub-mkimage -d usr/lib/grub/i386-pc -o core.img biosdisk iso9660 -for a in usr/lib/grub/i386-pc/{*.mod,efiemu??.o,command.lst,moddep.lst,fs.lst,handler.lst,parttool.lst}; do \ +if ./usr/bin/grub-mkimage --help | grep -q -- --format ; then + ./usr/bin/grub-mkimage -d usr/lib/grub/*-pc -o core.img biosdisk iso9660 --format=i386-pc +else + ./usr/bin/grub-mkimage -d usr/lib/grub/*-pc -o core.img biosdisk iso9660 +fi + +for a in usr/lib/grub/*-pc/{*.mod,efiemu??.o,command.lst,moddep.lst,fs.lst,handler.lst,parttool.lst}; do \ [[ -e $a ]] && cp $a grub/ done