-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathewos.sh
executable file
·75 lines (70 loc) · 2.45 KB
/
ewos.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
#!/bin/bash
Message(){
if [ "$1" == "t" ]; then
echo -e "\e[1m\e[34m$2\e[0m"
fi
if [ "$1" == "s" ]; then
echo -e "\e[1m\e[32m$2\e[0m"
fi
if [ "$1" == "i" ]; then
echo -e "\e[1m\e[34m$2\e[0m"
fi
}
CommandVerbose()
{
echo -e "| \e[2;3m$1\e[0m"
}
if [ "$1" == "build" ]; then
Message t "Building bootloader"
CommandVerbose "nasm src/bootloader/Main.asm -f bin -o build/bootloader.bin"
nasm src/bootloader/Main.asm -f bin -o build/bootloader.bin
Message t "Building kernel"
CommandVerbose "nasm src/kernel/Main.asm -f bin -o build/kernel.bin"
nasm src/kernel/Main.asm -f bin -o build/kernel.bin
CommandVerbose "if=/dev/zero of=build/Main.floppy.img bs=512 count=2880"
dd if=/dev/zero of=build/Main.floppy.img bs=512 count=2880
CommandVerbose "dd if=build/bootloader.bin of=build/Main.floppy.img bs=512 count=1 conv=notrunc"
dd if=build/bootloader.bin of=build/Main.floppy.img bs=512 count=1 conv=notrunc
CommandVerbose "dd if=kernel.bin of=build/Main.floppy.img bs=512 seek=1 conv=notrunc"
dd if=build/kernel.bin of=build/Main.floppy.img bs=512 seek=1 conv=notrunc
Message s "Building complete"
fi
if [ "$1" == "buildtools" ]; then
if [ "$2" == "fat" ]; then
Message t "Building FAT12 Tools"
CommandVerbose "mkdir -p build/tools"
mkdir -p build/tools
CommandVerbose "gcc src/tools/fat/fat.c -o build/tools/fat"
gcc src/tools/fat/fat.c -o build/tools/fat
Message s "FAT12 Tools built"
fi
fi
if [ "$1" == "img" ]; then
if [ "$2" == "add" ]; then
message t "Adding files to the image"
CommandVerbose 'mcopy -i build/Main.floppy.img "$3"" "::$4"'
mcopy -i build/Main.floppy.img "$3" "::$4"
message s "Files added to the image"
fi
fi
if [ "$1" == "run" ]; then
Message t "Running the OS"
CommandVerbose "qemu-system-i386 -drive file=build/Main.floppy.img,format=raw"
qemu-system-i386 -drive file=build/Main.floppy.img,format=raw
fi
if [ "$1" == "test" ]; then
message t "Testing the OS"
CommandVerbose "./ewos.sh build"
./ewos.sh build
CommandVerbose "./ewos.sh run"
./ewos.sh run
fi
if [ "$1" == "clean" ]; then
Message t "Cleaning up the build directory"
CommandVerbose "rm -rf build/*"
rm -rf build/*
Message s "Build directory cleaned up"
fi
if [ "$1" == "" ]; then
Message t "Usage: ./ewos.sh [build|run|test|clean|img <action>|buildtools <tool>]"
fi