#!/bin/bash
#
# boot-sparc v 1.12 (c) Steve Dunham <dunham@cse.msu.edu>, Eric
# Delaunay <delaunay@lix.polytechnique.fr>, Steve McIntyre
# <stevem@chiark.greenend.org.uk>
# Released under GPL 12 Mar 1999
# See the file COPYING for license details
# Released as part of the slink_cd package, not much use standalone
#
# Do install stuff for sparc, including making bootable CDs
#
# $1 is Debian-mirror location
# $2 is start directory location (where the scripts live)
# $3 is tmpdir location
# $4 is the binary arch
# $5 is debug level
# $6 is $BOOTDIR

MIRROR=$1
BASEDIR=$2
TDIR=$3
ARCH=$4
VERBOSE=$5
BOOTDIR=$6

. $BASEDIR/vecho # Include local definitions for vecho, vvecho, vvvecho

rm -fr boot1

# temporary mount point (eg. for silo to create the bootable CD image)
# only needed for Sparc so far...
if [ "$ARCH"x = "sparc"x ] ; then
	vecho Checking for temporary mount point for SILO
	mountpoint=/var/tmp/slink_cd.mnt
	if [ -d $mountpoint ]; then
		umount $mountpoint || true
	else
		mkdir -p $mountpoint
	fi
fi

# put the relevant parts of SILO boot loader
mkdir -p boot1/boot
cp -p $BOOTDIR/cd.b $BOOTDIR/second.b boot1/boot
cat - > boot1/boot/silo.conf << __EOF__
message=!cd1
timeout=300
root=/dev/ram
image[sun4c,sun4d,sun4m]=!cd2
   label=linux
   initrd=!cd5
image[sun4u]=!cd4
   label=linux
   initrd=!cd5
image[sun4c,sun4d,sun4m]=!cd3
   label=linux-2.2
   initrd=!cd5
image[sun4u]=!cd4
   label=linux-2.2
   initrd=!cd5
__EOF__

# linux kernel & co are fetched directly from the install dir
# ... put the message banner in boot/debian.txt

(cd slink1/dists/slink/main/disks-$ARCH/current/ ; \
	cp -p linux-a.out linux-2.2.1-sun4u-a.out \
	linux-2.2.1-a.out root.bin sparc_release_note.txt \
	$TDIR/slink1/install )

echo mount -o loop \
	$MIRROR/dists/slink/main/disks-$ARCH/current/resc1440.bin \
	$mountpoint
mount -o loop \
	$MIRROR/dists/slink/main/disks-$ARCH/current/resc1440.bin \
	$mountpoint
cp -p $mountpoint/debian.txt boot1/boot/debian.txt
umount $mountpoint