createdrives: add a script to automatically generate z80pack drives.
authorSergio L. Pascual <slp@sinrega.org>
Fri, 2 Jan 2015 01:02:19 +0000 (02:02 +0100)
committerSergio L. Pascual <slp@sinrega.org>
Fri, 2 Jan 2015 01:02:19 +0000 (02:02 +0100)
Kernel/platform-z80pack/createdrives [new file with mode: 0755]

diff --git a/Kernel/platform-z80pack/createdrives b/Kernel/platform-z80pack/createdrives
new file mode 100755 (executable)
index 0000000..7fc2b66
--- /dev/null
@@ -0,0 +1,126 @@
+#!/bin/sh
+
+BASEDIR=`dirname $0`
+UTILDIR="${BASEDIR}/../../Applications/util"
+UCP="${BASEDIR}/../../Standalone/ucp"
+MKFS="${BASEDIR}/../../Standalone/mkfs"
+DISK1BINS="cat cp df fdisk fsck kill ln ls mkdir mknod mount prtroot ps ssh rm rmdir"
+DISK2BINS="bd cut chgrp chmod chown date dd du echo ed false grep id mkfs more mv printenv prtroot pwd sleep su sync touch tr true wc which"
+DISK1DIRS="dev bin etc lib root home usr tmp"
+DISK2DIRS="bin cpm"
+DEVS="fd0 60644 0
+fd1 60644 1
+hda 60644 256
+tty1 20666 513
+null 20622 1024
+kmem 20622 1025
+zero 20622 1026
+proc 20622 1027
+"
+
+BOOTBLOCK="${BASEDIR}/bootblock.bin"
+KERNEL="${BASEDIR}/../fuzix.bin"
+DISK1="drivea.cpm"
+DISK2="drivei.cpm"
+
+if [ ! -e $BOOTBLOCK ]; then
+       echo "$0: Can't find bootblock.bin, build kernel first."
+       exit 1
+fi
+
+if [ ! -e $KERNEL ]; then
+       echo "$0: Can't find fuzix.bin, build kernel first."
+       exit 1
+fi
+
+if [ ! -e ${UTILDIR}/init ]; then
+       echo "$0: Can't find init, build userspace applications first."
+       exit 1
+fi
+
+$MKFS $DISK1 8 390
+if [ $? != 0 ]; then
+       echo "$0: Error creating first disk"
+       exit 1
+fi
+
+$MKFS $DISK2 64 8192
+if [ $? != 0 ]; then
+       echo "$0: Error creating second disk"
+       exit 1
+fi
+
+for DIR in $DISK1DIRS; do
+       $UCP $DISK1 "mkdir $DIR" &> /dev/null
+       if [ $? != 0 ]; then
+               echo "$0: Error creating directory \"$DIR\""
+               exit 1
+       fi
+done
+
+for DIR in $DISK2DIRS; do
+       $UCP $DISK2 "mkdir $DIR" &> /dev/null
+       if [ $? != 0 ]; then
+               echo "$0: Error creating directory \"$DIR\""
+               exit 1
+       fi
+done
+
+IFS="
+"
+
+for DEV in $DEVS; do
+       $UCP $DISK1 "cd /dev ; mknod $DEV" &> /dev/null
+       if [ $? != 0 ]; then
+               echo "$0: Error creating device \"$DEV\""
+               exit 1
+       fi
+done
+
+IFS=" "
+
+$UCP $DISK1 "bget $UTILDIR/init" &> /dev/null
+$UCP $DISK1 "chmod 755 init" &> /dev/null
+
+for FILE in $DISK1BINS; do
+       $UCP $DISK1 "cd /bin ; bget $UTILDIR/$FILE" &> /dev/null
+       $UCP $DISK1 "cd /bin ; chmod 755 $FILE" &> /dev/null
+       if [ $? != 0 ]; then
+               echo "$0: Error copying file \"$FILE\""
+               exit 1
+       fi
+done
+
+for FILE in $DISK2BINS; do
+       $UCP $DISK2 "cd /bin ; bget $UTILDIR/$FILE" &> /dev/null
+       $UCP $DISK2 "cd /bin ; chmod 755 $FILE" &> /dev/null
+       if [ $? != 0 ]; then
+               echo "$0: Error copying file \"$FILE\""
+               exit 1
+       fi
+done
+
+mkdir /tmp/ucp
+echo "root::0:0:superuser:/root:/bin/ssh" > /tmp/ucp/passwd
+echo "root::0:root" > /tmp/ucp/group
+echo "rootfs / rootfs rw 0 0" > /tmp/ucp/mtab
+
+$UCP $DISK1 "cd /etc ; bget /tmp/ucp/passwd" &> /dev/null
+$UCP $DISK1 "cd /etc ; bget /tmp/ucp/group" &> /dev/null
+$UCP $DISK1 "cd /etc ; bget /tmp/ucp/mtab" &> /dev/null
+
+rm /tmp/ucp/passwd
+rm /tmp/ucp/group
+rm /tmp/ucp/mtab
+rmdir /tmp/ucp
+
+mv $DISK1 ${DISK1}.tmp
+dd if=$KERNEL of=$DISK1 bs=1 seek=199680 conv=notrunc
+dd if=${DISK1}.tmp of=$DISK1 conv=notrunc
+dd if=$BOOTBLOCK of=$DISK1 conv=notrunc
+rm ${DISK1}.tmp
+
+echo "z80pack drives \"drivea.cpm\" and \"drivei.cpm\" successfully generated"
+
+exit 0
+