#!/bin/sh -x

# $1 = tape device
# $2 = list of machine architectures
# $3 = machine specific bootable file, usually "sadie" or "install" 
# $4 = Image file, usually DIAG_IMAGE or miniroot
# $5 = physical position of image file on tape, should be equal to
#      the define in sadie.h "MINIFILENO" + 1
	mt -f $1 reset
	mt -f $1 rew
	echo "" > /tmp/dummy$$
	file=0
	for mch in $2; do
	    if [ -f $mch/$3 ] ; then
		echo $file : $mch/$3
		dd if=$mch/$3 of=$1 bs=8k conv=sync
	    else
		echo $mch/$3 not found
		dd if=/tmp/dummy$$ of=$1 bs=512 conv=sync count=1
	    fi
	    file=`expr $file + 1`
	done
	
	while [ $file -lt $5 ] ; do
		echo $file : DUMMY
		dd if=/tmp/dummy$$ of=$1 bs=512 conv=sync count=1
		file=`expr $file + 1`	
	done
	rm -f /tmp/dummy$$

	echo $file : $4
	dd if=$4 of=$1 bs=8k conv=sync
#	mt -f $1 rew
