-
Notifications
You must be signed in to change notification settings - Fork 11
/
mkfloppy.sh
executable file
·84 lines (73 loc) · 2.33 KB
/
mkfloppy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
if [[ $(which syslinux) == "" ]]; then
echo "You need to install syslinux"
exit 1
fi
SYSLINUX_FILES="/usr/lib/syslinux/bios"
if ! [[ -f "${SYSLINUX_FILES}/mboot.c32" ]]; then
echo "You need to edit the SYSLINUX_FILES variable of this script" \
"to point to where the syslinux boot files are located."
exit 1
fi
ARCH=i386
BUILD_TYPE=Debug
BUILD_TAG=CHK
if [[ ${1,,} == "release" || ${2,,} == "release" ]]; then
BUILD_TYPE=Release
BUILD_TAG=FRE
fi
if [[ $1 == "amd64" || $2 == "amd64" ]]; then
ARCH=amd64
fi
BUILDDIR="build-$ARCH-${BUILD_TYPE,,}"
IMAGEDIR="images-$ARCH-${BUILD_TYPE,,}"
if [[ ${BUILD_TYPE} == Release ]]; then
KERNEL=kernel
NTOS=ntos
else
KERNEL=kernel-stripped
NTOS=ntos-stripped
fi
cd "$(dirname "$0")"
cd $BUILDDIR
FLOPPYIMG=floppy.img
if [[ -e $FLOPPYIMG ]]; then
rm $FLOPPYIMG
fi
SYSLINUXCFGTMP=$(mktemp /tmp/syslinux.XXXXXXXX)
mkfs.msdos -C $FLOPPYIMG 1440 -n NT${ARCH^^}${BUILD_TAG}
syslinux --install $FLOPPYIMG
cat <<EOF > $SYSLINUXCFGTMP
DEFAULT neptune
SERIAL 0 115200
PROMPT 0
TIMEOUT 300
UI menu.c32
EOF
echo "MENU TITLE Neptune OS $ARCH ${BUILD_TYPE}" >> $SYSLINUXCFGTMP
cat <<EOF >> $SYSLINUXCFGTMP
MENU COLOR border 30;44 #40ffffff #a0000000 std
MENU COLOR title 1;36;44 #9033ccff #a0000000 std
MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all
MENU COLOR unsel 37;44 #50ffffff #a0000000 std
MENU COLOR help 37;40 #c0ffffff #a0000000 std
MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std
MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std
MENU COLOR msg07 37;40 #90ffffff #a0000000 std
MENU COLOR tabmsg 31;40 #30ffffff #00000000 std
LABEL neptune
EOF
echo " MENU LABEL Neptune OS $ARCH ${BUILD_TYPE}" >> $SYSLINUXCFGTMP
cat <<EOF >> $SYSLINUXCFGTMP
KERNEL mboot.c32
APPEND kernel --- ntos
EOF
KERNELTMP=$(mktemp /tmp/neptuneos-kernel.XXXXXXXX)
NTOSTMP=$(mktemp /tmp/neptuneos-ntos.XXXXXXXX)
gzip -c $IMAGEDIR/$KERNEL > $KERNELTMP
gzip -c $IMAGEDIR/$NTOS > $NTOSTMP
mcopy -i $FLOPPYIMG $KERNELTMP ::kernel
mcopy -i $FLOPPYIMG $NTOSTMP ::ntos
mcopy -i $FLOPPYIMG $SYSLINUXCFGTMP ::syslinux.cfg
mcopy -i $FLOPPYIMG $SYSLINUX_FILES/mboot.c32 $SYSLINUX_FILES/menu.c32 $SYSLINUX_FILES/libutil.c32 $SYSLINUX_FILES/libcom32.c32 ::
mcopy -i $FLOPPYIMG base/umtests/umtests.exe ::
rm $KERNELTMP $NTOSTMP $SYSLINUXCFGTMP