2016-11-25 14:41:57 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-01-20 01:54:11 +01:00
|
|
|
# This file is part of Jehanne.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2016-2017 Giacomo Tesio <giacomo@tesio.it>
|
|
|
|
|
2016-11-25 14:41:57 +01:00
|
|
|
if [ "$JEHANNE" = "" ]; then
|
|
|
|
echo $0 requires the shell started by ./hacking/devshell.sh
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-02-15 00:48:49 +01:00
|
|
|
if [ "$SYSLINUXMBR" == "" ]; then
|
|
|
|
export SYSLINUXMBR=/usr/lib/syslinux/mbr/mbr.bin # GNU/Linux Debian way
|
|
|
|
fi
|
2016-11-25 14:41:57 +01:00
|
|
|
if [ "$SYSLINUXBIOS" == "" ]; then
|
|
|
|
export SYSLINUXBIOS=/usr/lib/syslinux/modules/bios/ # GNU/Linux Debian way
|
|
|
|
fi
|
|
|
|
if [ ! -d "$SYSLINUXBIOS" ]; then
|
|
|
|
echo 'Missing $SYSLINUXBIOS: install syslinux-utils or set it to the proper path.'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-02-15 01:13:10 +01:00
|
|
|
if [ "$TRAVIS_BUILD_DIR" != "" ]; then
|
|
|
|
echo "Syslinux's version, supported options and file list"
|
|
|
|
syslinux --version
|
|
|
|
syslinux --help
|
|
|
|
ls $SYSLINUXBIOS
|
|
|
|
ls $SYSLINUXMBR
|
2017-02-16 00:07:56 +01:00
|
|
|
echo "Fdisk's version, supported options, help"
|
|
|
|
/sbin/fdisk -v
|
|
|
|
/sbin/fdisk -h
|
2017-02-15 01:13:10 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2016-11-25 14:41:57 +01:00
|
|
|
if [ -d $JEHANNE/hacking/disk-setup/bios/ ]; then
|
|
|
|
rm $JEHANNE/hacking/disk-setup/bios/*
|
|
|
|
else
|
|
|
|
mkdir $JEHANNE/hacking/disk-setup/bios/
|
|
|
|
fi
|
2018-06-04 23:27:16 +02:00
|
|
|
if [ -d $SYSLINUXBIOS/com32/ ]; then
|
|
|
|
cp $SYSLINUXBIOS/com32/lib* $JEHANNE/hacking/disk-setup/bios/
|
|
|
|
else
|
|
|
|
cp $SYSLINUXBIOS/lib* $JEHANNE/hacking/disk-setup/bios/
|
|
|
|
fi
|
2016-11-25 14:41:57 +01:00
|
|
|
cp $SYSLINUXBIOS/elf.c32 $JEHANNE/hacking/disk-setup/bios/
|
|
|
|
cp $SYSLINUXBIOS/mboot.c32 $JEHANNE/hacking/disk-setup/bios/
|
|
|
|
cp $SYSLINUXBIOS/menu.c32 $JEHANNE/hacking/disk-setup/bios/
|
|
|
|
|
|
|
|
# Create the data disk
|
|
|
|
if [ "$DISK" == "" ]; then
|
|
|
|
export DISK=$JEHANNE/hacking/sample-disk.img
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -f $DISK ]; then
|
|
|
|
qemu-img create $DISK 4G
|
|
|
|
|
2017-02-25 11:07:45 +01:00
|
|
|
sed -e 's/^\s*\([\+0-9a-zA-Z]*\)[ ].*/\1/' << EOF | /sbin/fdisk $DISK
|
2016-11-25 14:41:57 +01:00
|
|
|
o #clear partition table
|
|
|
|
n #new partition
|
|
|
|
p #primary partition
|
|
|
|
1 #partition 1
|
|
|
|
#start at beginning of disk
|
|
|
|
+40M #reserve 40 megabytes
|
|
|
|
t #change type
|
|
|
|
c #W95 FAT32 (LBA)
|
|
|
|
n #new partition
|
|
|
|
p #primary partition
|
|
|
|
2 #partition 2
|
|
|
|
#start at first free sector
|
|
|
|
#end at the end of disk
|
|
|
|
t #change type
|
|
|
|
2 #partition 2
|
|
|
|
39 #Plan 9
|
2017-02-16 00:07:56 +01:00
|
|
|
a #set bootable partition
|
|
|
|
1 #partition 1
|
2016-11-25 14:41:57 +01:00
|
|
|
p #print partition table
|
|
|
|
w #write partition table
|
|
|
|
q #quit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
export KERNEL=$JEHANNE/hacking/bin/workhorse.32bit
|
|
|
|
export KERNDIR=$JEHANNE/hacking/bin/
|
|
|
|
|
2017-02-05 02:37:00 +01:00
|
|
|
if [ "$DISK_KERNEL" = "" ]; then
|
|
|
|
export DISK_KERNEL=/arch/$ARCH/kern/jehanne.32bit
|
|
|
|
fi
|
|
|
|
if [ "$DISK_INITRD" = "" ]; then
|
|
|
|
export DISK_INITRD=/arch/amd64/kern/initrd
|
|
|
|
fi
|
|
|
|
|
2016-11-25 14:41:57 +01:00
|
|
|
# install everything
|
|
|
|
cat << EOF | runqemu
|
|
|
|
disk/fdisk -p /dev/sdE0/data >> /dev/sdE0/ctl
|
|
|
|
disk/prep -w -a nvram -a fs /dev/sdE0/plan9
|
|
|
|
disk/prep -p /dev/sdE0/plan9 >> /dev/sdE0/ctl
|
|
|
|
cat /dev/sdE0/ctl
|
|
|
|
|
2017-02-05 02:37:00 +01:00
|
|
|
disk/format -d /dev/sdE0/dos /hacking/disk-setup/syslinux.cfg /hacking/disk-setup/bios/* $DISK_INITRD $DISK_KERNEL
|
2016-11-25 14:41:57 +01:00
|
|
|
|
|
|
|
dd -if /hacking/nvram -of /dev/sdE0/nvram
|
|
|
|
|
|
|
|
hjfs -n hjfs -Srf /dev/sdE0/fs
|
|
|
|
/hacking/disk-setup/configure-hjfs >>/srv/hjfs.cmd
|
|
|
|
hjfs -n hjfs -Sf /dev/sdE0/fs
|
|
|
|
mount -c /srv/hjfs /n/newfs
|
|
|
|
cd /n/newfs
|
|
|
|
cd cfg
|
|
|
|
dircp /root/cfg .
|
|
|
|
cd /n/newfs
|
|
|
|
mkdir arch
|
|
|
|
cd arch
|
|
|
|
dircp /root/arch .
|
|
|
|
cd /n/newfs
|
|
|
|
mkdir lib
|
|
|
|
cd lib
|
|
|
|
dircp /root/lib .
|
|
|
|
cd /n/newfs
|
|
|
|
mkdir mnt
|
|
|
|
cd mnt
|
|
|
|
mkdir temp
|
|
|
|
mkdir term
|
|
|
|
mkdir acme
|
|
|
|
mkdir wsys
|
|
|
|
cd /n/newfs
|
|
|
|
mkdir usr
|
|
|
|
cd usr
|
|
|
|
dircp /root/usr .
|
|
|
|
cd /n/newfs
|
|
|
|
mkdir sys
|
|
|
|
cd sys
|
|
|
|
mkdir include
|
|
|
|
mkdir src
|
|
|
|
dircp /root/sys/src src/
|
|
|
|
dircp /root/sys/include include/
|
|
|
|
mkdir log
|
|
|
|
cd /n/newfs
|
|
|
|
mkdir qa
|
|
|
|
cd qa
|
|
|
|
dircp /root/qa .
|
|
|
|
cd /n/newfs
|
|
|
|
lc
|
2017-02-05 02:37:00 +01:00
|
|
|
$AFTER_DISK_FILL
|
2016-11-25 14:41:57 +01:00
|
|
|
unmount /n/newfs
|
|
|
|
echo df >> /srv/hjfs.cmd
|
|
|
|
echo sync >> /srv/hjfs.cmd
|
|
|
|
sleep 60
|
|
|
|
echo halt >> /srv/hjfs.cmd
|
|
|
|
sleep 20
|
|
|
|
EOF
|
2017-02-16 00:07:56 +01:00
|
|
|
OFFSETSECTOR=`echo p |/sbin/fdisk $DISK|grep img1|awk '{print $3}'`
|
2017-02-15 01:13:10 +01:00
|
|
|
syslinux --offset $(($OFFSETSECTOR*512)) $DISK
|
2017-02-15 00:48:49 +01:00
|
|
|
dd bs=440 count=1 conv=notrunc if=$SYSLINUXMBR of=$DISK
|
2016-11-25 14:41:57 +01:00
|
|
|
else
|
|
|
|
echo Root disk already exists: $DISK
|
|
|
|
fi
|
|
|
|
|