| 1 |
# This script gets sourced from boot-hurd-i386. |
| 2 |
# |
| 3 |
# Do install stuff for hurd, including making bootable CDs |
| 4 |
# Works with debian-installer |
| 5 |
# |
| 6 |
# $1 is the CD number |
| 7 |
# $2 is the temporary CD build dir |
| 8 |
|
| 9 |
. $BASEDIR/tools/boot/$DI_CODENAME/common.sh |
| 10 |
. $BASEDIR/tools/boot/$DI_CODENAME/x86-desktop.sh |
| 11 |
|
| 12 |
set -e |
| 13 |
#set -x |
| 14 |
|
| 15 |
# Have we been told to use just one boot method? If none listed, |
| 16 |
# assume all are desired. Order also matters. Possible values are |
| 17 |
# "BIOS", "EFI" and "BIOS EFI". We'll also accept "EFI BIOS" for |
| 18 |
# completeness, but we will switch the order. |
| 19 |
if [ "$BOOT_METHODS"x = ""x ] \ |
| 20 |
|| [ "$BOOT_METHODS"x = "BIOS EFI"x ] \ |
| 21 |
|| [ "$BOOT_METHODS"x = "EFI BIOS"x ] ; then |
| 22 |
BOOT_BIOS=1 |
| 23 |
BOOT_EFI=2 |
| 24 |
elif [ "$BOOT_METHODS"x = "BIOS"x ] ; then |
| 25 |
BOOT_BIOS=1 |
| 26 |
BOOT_EFI=0 |
| 27 |
elif [ "$BOOT_METHODS"x = "EFI"x ] ; then |
| 28 |
BOOT_EFI=1 |
| 29 |
BOOT_BIOS=0 |
| 30 |
else |
| 31 |
echo "ERROR: Unrecognized boot method choice $BOOT_METHODS" |
| 32 |
exit 1 |
| 33 |
fi |
| 34 |
|
| 35 |
N=$1 |
| 36 |
CDDIR=$2 |
| 37 |
INSTALLDIR="install" |
| 38 |
|
| 39 |
# Common options for all disks |
| 40 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-J -joliet-long" |
| 41 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-cache-inodes" |
| 42 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-l" |
| 43 |
|
| 44 |
# Exit if this is not CD#1/DVD#1 |
| 45 |
if [ $N != "1" ]; then |
| 46 |
exit 0 |
| 47 |
fi |
| 48 |
|
| 49 |
if [ "$DI_WWW_HOME" = "default" ]; then |
| 50 |
DI_WWW_HOME="https://d-i.debian.org/daily-images/hurd-i386/daily/" |
| 51 |
try_di_image_cache |
| 52 |
else |
| 53 |
DI_WWW_HOME=$(echo $DI_WWW_HOME | sed "s,%ARCH%,$ARCH,") |
| 54 |
fi |
| 55 |
|
| 56 |
case "$MKISOFS" in |
| 57 |
*xorriso*) |
| 58 |
XORRISO_VER=$(xorriso_version) |
| 59 |
;; |
| 60 |
*) |
| 61 |
echo "ERROR: debian-cd now depends on xorriso for making x86 bootable CDs." |
| 62 |
exit 1; |
| 63 |
;; |
| 64 |
esac |
| 65 |
|
| 66 |
cd $CDDIR/.. |
| 67 |
|
| 68 |
# Download boot images. |
| 69 |
BOOT_IMAGES="cdrom/debian-cd_info.tar.gz cdrom/gnumach.gz cdrom/initrd.gz cdrom/gtk/initrd.gz cdrom/ext2fs.static cdrom/exec.static" |
| 70 |
|
| 71 |
for image in $BOOT_IMAGES; do |
| 72 |
if [ ! -e "$image" ]; then |
| 73 |
dir=$(dirname $image) |
| 74 |
mkdir -p $dir |
| 75 |
if [ ! "$DI_WWW_HOME" ];then |
| 76 |
if [ ! "$DI_DIR" ];then |
| 77 |
DI_DIR="$MIRROR/dists/$DI_DIST/main/installer-$ARCH/current/images" |
| 78 |
fi |
| 79 |
cp "$DI_DIR/$image" $image |
| 80 |
else |
| 81 |
$WGET "$DI_WWW_HOME/$image" -O $image |
| 82 |
fi |
| 83 |
fi |
| 84 |
done |
| 85 |
|
| 86 |
# Install kernel and initrd |
| 87 |
mkdir -p $CDDIR/boot/kernel/ |
| 88 |
mkdir -p $CDDIR/boot/gtk/ |
| 89 |
cp "cdrom/gnumach.gz" "$CDDIR/boot/kernel/gnumach.gz" |
| 90 |
cp "cdrom/initrd.gz" "$CDDIR/boot/initrd.gz" |
| 91 |
cp "cdrom/gtk/initrd.gz" "$CDDIR/boot/gtk/initrd.gz" |
| 92 |
cp "cdrom/ext2fs.static" "$CDDIR/boot/kernel/ext2fs.static" |
| 93 |
cp "cdrom/exec.static" "$CDDIR/boot/kernel/exec.static" |
| 94 |
|
| 95 |
# Install bootloader |
| 96 |
mkdir -p boot$N |
| 97 |
tar -C boot$N -zxf cdrom/debian-cd_info.tar.gz |
| 98 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-J -joliet-long" |
| 99 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-b boot/grub/grub_eltorito" |
| 100 |
[ -f boot$N/boot/grub/grub_embed ] && add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "--embedded-boot boot$N/boot/grub/grub_embed" |
| 101 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-c boot/boot.cat" |
| 102 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-no-emul-boot" |
| 103 |
|
| 104 |
bls=4 # Specify 4 for BIOS boot, don't calculate it |
| 105 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-boot-load-size $bls" |
| 106 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-boot-info-table" |
| 107 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-cache-inodes" |
| 108 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_dirs "boot$N" |
| 109 |
|
| 110 |
# Add autorun |
| 111 |
if [ -f $CDDIR/README.html ]; then |
| 112 |
todos > $CDDIR/autorun.inf <<EOF |
| 113 |
[autorun] |
| 114 |
open=autorun.bat |
| 115 |
label=Install Debian GNU/Hurd |
| 116 |
EOF |
| 117 |
todos > $CDDIR/autorun.bat <<EOF |
| 118 |
@echo Starting "README.html"... |
| 119 |
@start README.html |
| 120 |
@exit |
| 121 |
EOF |
| 122 |
fi |
| 123 |
|
| 124 |
# Cleanup |
| 125 |
rm -rf cdrom |
| 126 |
|
| 127 |
if [ $BOOT_EFI -ne 0 ] ; then |
| 128 |
echo " Adding EFI boot code for $ARCH on CD$N" |
| 129 |
|
| 130 |
# Move GRUB files to the right place. |
| 131 |
mkdir -p $CDDIR/EFI/boot |
| 132 |
mcopy -n -s -i boot$N/grub/efi.img '::efi/*' $CDDIR/EFI |
| 133 |
mkdir -p $CDDIR/boot/grub |
| 134 |
mv boot$N/grub/* $CDDIR/boot/grub/ |
| 135 |
rmdir boot$N/grub |
| 136 |
|
| 137 |
change_grub_cfg_uuid $CDDIR |
| 138 |
|
| 139 |
# Stuff the EFI boot files into a FAT filesystem, making it as |
| 140 |
# small as possible. We end up re-packing like this in case we're |
| 141 |
# making a multi-arch image |
| 142 |
|
| 143 |
# First, work out how many blocks we need |
| 144 |
blocks=$(calculate_efi_image_size $CDDIR) |
| 145 |
|
| 146 |
# Now make a new image to contain the files |
| 147 |
rm -f $CDDIR/boot/grub/efi.img |
| 148 |
mkfs.msdos -v -C "$CDDIR/boot/grub/efi.img" $blocks >/dev/null |
| 149 |
|
| 150 |
# And copy them into place |
| 151 |
mmd -i "$CDDIR/boot/grub/efi.img" ::efi |
| 152 |
mcopy -o -s -i "$CDDIR/boot/grub/efi.img" $CDDIR/EFI/* \ |
| 153 |
"::efi" |
| 154 |
|
| 155 |
if [ $BOOT_EFI = 2 ] ; then |
| 156 |
# We're being added alongside (after) a BIOS boot record. Tell |
| 157 |
# xorriso to create a (secondary) ElTorito boot record for the |
| 158 |
# EFI bootloader. Otherwise, xorriso will create it as the |
| 159 |
# primary. |
| 160 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-eltorito-alt-boot" |
| 161 |
fi |
| 162 |
|
| 163 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-e boot/grub/efi.img -no-emul-boot" |
| 164 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-isohybrid-gpt-basdat -isohybrid-apm-hfsplus" |
| 165 |
else |
| 166 |
echo " No EFI boot code for $ARCH on CD$N" |
| 167 |
fi |
| 168 |
|
| 169 |
# done |