#!/bin/sh
#
# Do install stuff for arm, including making bootable CDs
# Works with debian-installer
#
# $1 is the CD number
# $2 is the temporary CD build dir
#
# According to Vince Sanders, most subarchitectures (with the notable
# exception of real netwinders; note that 'netwinder' actually supports
# other machines too) have CD-ROM drives, and can boot from them given a
# kernel and an initrd. The bootloader is in NOR flash memory.

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

set -e

N=$1
CDDIR=$2
INSTALLDIR=$CDDIR/install
if [ "$DI_WWW_HOME" = "default" ];then
   DI_WWW_HOME="http://people.debian.org/~vince/d-i/images/daily"
fi
if [ ! "$DI_DIST" ]; then
   DI_DIST="$DI_CODENAME"
fi

cd $CDDIR/..

echo -J > $N.mkisofs_opts

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

cd $INSTALLDIR

for subarch in bast netwinder riscpc riscstation; do
	if [ ! "$DI_WWW_HOME" ];then
		DI_DIR="$MIRROR/dists/$DI_DIST/main/installer-$ARCH/current/images/$subarch/cdrom"
	else
		DI_DIR="di_stuff"
		wget -r -nd --no-parent --level=1 -P "$DI_DIR" "$DI_WWW_HOME/$subarch/cdrom/"
		rm -f "$DI_DIR"/index*
	fi
	cp -a "$DI_DIR" "$subarch"
	rm -rf di_stuff
done

exit 0