#!/bin/bash
#
# boot-mips
#
# $1 is the CD number
# $2 is the temporary CD build dir

# genisovh is used to make ISOs bootable on mips.

. $BASEDIR/tools/boot/$DI_CODENAME/common.sh

set -e

N=$1
CDROOT=$2
if [ "$DI_WWW_HOME" = "default" ];then
   DI_WWW_HOME="http://d-i.debian.org/daily-images/mips/daily/"
   if [ -n "$DI_DIR" ];then
       DI_DIR="$DI_DIR/${DI_WWW_HOME#*http://}"
       DI_WWW_HOME=""                     
   fi
fi
if [ ! "$DI_DIST" ]; then
   DI_DIST="$DI_CODENAME"
fi

add_mkisofs_opt $CDROOT/../$N.mkisofs_opts "-J -joliet-long"

# Only disk 1* bootable
if [ $N != 1 -a $N != 1_NONUS ]; then
	exit 0
fi

if [ ! "$DI_WWW_HOME" ];then
        if [ ! "$DI_DIR" ];then
           DI_DIR="$MIRROR/dists/$DI_DIST/main/installer-$ARCH/current/images"
        fi
else
	DI_DIR="di_stuff"
	wget -P "$DI_DIR/r4k-ip22" "$DI_WWW_HOME/r4k-ip22/cdrom-boot.img"
#   r5k-ip32 has no cdrom boot image yet
#	wget -P "$DI_DIR/r5k-ip32" "$DI_WWW_HOME/r5k-ip32/cdrom-boot.img"
fi
install -m 644 -D "$DI_DIR"/r4k-ip22/cdrom-boot.img "$CDROOT"/install/r4k-ip22-boot.img
#r5k-ip32 has no cdrom boot image yet
#install -m 644 -D "$DI_DIR"/r5k-ip32/cdrom-boot.img "$CDROOT"/install/r5k-ip32-boot.img

install_languages $CDROOT

add_mkisofs_opt $CDROOT/../$N.mkisofs_opts "-mips-boot install/r4k-ip22-boot.img"
#r5k-ip32 has no cdrom boot image yet
#add_mkisofs_opt $CDROOT/../$N.mkisofs_opts "-mips-boot install/r5k-ip32-boot.img"

exit 0
