Home | History | Annotate | Line # | Download | only in tos
      1  1.1    leo #!/bin/sh
      2  1.2  perry # $NetBSD: build_image.sh,v 1.2 2009/04/03 22:36:34 perry Exp $
      3  1.1    leo # This script is a quick hack to generate the various floppies in the
      4  1.1    leo # 'installation/floppies' directory. This script cannot be run in the
      5  1.1    leo # build environment, it is provided as a howto.
      6  1.1    leo # When msdos support is added to makefs, it makes sense to provide a
      7  1.1    leo # decent script that can be integrated into the build environment.
      8  1.1    leo #
      9  1.1    leo # Leo 10 Sept. 2002.
     10  1.1    leo 
     11  1.1    leo DESTDIR=/tmp/flop_images
     12  1.1    leo TOOLDIR=/tmp/flop_tools
     13  1.1    leo KERNEL_DIR=/tmp/kernels
     14  1.1    leo MNT_DIR=/mnt2
     15  1.1    leo VND_DEV=vnd0
     16  1.1    leo SUDO=sudo
     17  1.1    leo 
     18  1.1    leo IMAGE720="boot BOOT"
     19  1.1    leo IMAGE144="hades_boot HADES milan_isa_boot MILAN-ISAIDE"
     20  1.1    leo IMAGE144="$IMAGE144  milan_pci_boot MILAN-PCIIDE"
     21  1.1    leo TOOLS="chg_pid.ttp file2swp.ttp loadbsd.ttp rawwrite.ttp aptck.ttp"
     22  1.1    leo 
     23  1.1    leo unpack_tools() {
     24  1.1    leo 	if [ ! -d $TOOLDIR ]; then
     25  1.1    leo 		mkdir $TOOLDIR;
     26  1.1    leo 	fi
     27  1.1    leo 	for i in $TOOLS
     28  1.1    leo 	do
     29  1.1    leo 		cat ${i}.gz.uu | (cd $TOOLDIR; uudecode)
     30  1.1    leo 		gunzip -f $TOOLDIR/${i}.gz
     31  1.1    leo 	done
     32  1.1    leo }
     33  1.1    leo 
     34  1.1    leo do_images() {
     35  1.1    leo 	base_img=$1; geom=$2; shift 2
     36  1.1    leo 
     37  1.1    leo 	while : ; do
     38  1.1    leo 		if [ -z "$1" ]; then
     39  1.1    leo 			break;
     40  1.1    leo 		fi
     41  1.1    leo 		cat ${base_img}.fs.gz.uu | (cd /tmp; uudecode)
     42  1.1    leo 		gunzip /tmp/${base_img}.fs.gz
     43  1.1    leo 		$SUDO vnconfig $VND_DEV /tmp/${base_img}.fs $geom
     44  1.1    leo 		$SUDO mount -t msdos /dev/${VND_DEV}c ${MNT_DIR}
     45  1.1    leo 
     46  1.1    leo 		# Copy the kernel first...
     47  1.1    leo 		cp ${KERNEL_DIR}/netbsd-${2}.gz ${MNT_DIR}/netbsd
     48  1.1    leo 
     49  1.1    leo 		# Thereafter the tools, some may not fit :-(
     50  1.1    leo 		for i in $TOOLS; do
     51  1.1    leo 			cp $TOOLDIR/$i ${MNT_DIR} 2> /dev/null
     52  1.1    leo 			if [ $? -ne 0 ]; then
     53  1.1    leo 				echo "$i does not fit on ${1}.fs"
     54  1.1    leo 				rm -f ${MNT_DIR}/$i
     55  1.1    leo 			fi
     56  1.1    leo 		done
     57  1.1    leo 		echo "Contents of ${1}.fs:\n"; ls -l ${MNT_DIR}
     58  1.1    leo 
     59  1.1    leo 		$SUDO umount ${MNT_DIR}
     60  1.1    leo 		$SUDO vnconfig -u ${VND_DEV}
     61  1.1    leo 		mv /tmp/${base_img}.fs /tmp/$1.fs
     62  1.2  perry 		gzip -9n /tmp/$1.fs
     63  1.1    leo 		mv /tmp/$1.fs.gz $DESTDIR
     64  1.1    leo 		shift 2
     65  1.1    leo 	done
     66  1.1    leo }
     67  1.1    leo 
     68  1.1    leo 
     69  1.1    leo if [ ! -d $DESTDIR ]; then
     70  1.1    leo 	mkdir $DESTDIR
     71  1.1    leo fi
     72  1.1    leo 
     73  1.1    leo if [ ! -d $KERNEL_DIR ]; then
     74  1.1    leo 	echo "Please put the kernel images in $KERNEL_DIR!!"
     75  1.1    leo 	exit 1
     76  1.1    leo fi
     77  1.1    leo rm -f $TOOLDIR/* $DESTDIR/*
     78  1.1    leo 
     79  1.1    leo unpack_tools
     80  1.1    leo do_images boot720 "512/18/1/80" ${IMAGE720}
     81  1.1    leo do_images boot144 "512/18/2/80" ${IMAGE144}
     82  1.1    leo 
     83  1.1    leo echo "The images can be found in: $DESTDIR"
     84