12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- uid=`id -u`
- if [ ! $uid == "0" ];then
- echo "请以sudo权限运行"
- exit
- fi
- if [ ! "$1" == "--nobuild" ]; then
- echo "开始构建..."
- make all
- make clean
- fi
- if [ ! -x "bin/bootloader/boot.bin" ]; then
- echo "bin/bootloader/boot.bin 不存在!"
- exit
- fi
- if [ ! -x "bin/bootloader/loader.bin" ]; then
- echo "bin/bootloader/loader.bin 不存在!"
- exit
- fi
- if [ ! -x "bin/boot.img" ]; then
- echo "bin/boot.img 不存在!"
- exit
- fi
- dd if=bin/bootloader/boot.bin of=bin/boot.img bs=512 count=1 conv=notrunc
- if [ ! -d "tmp/" ]; then
- mkdir tmp/
- echo "创建了tmp文件夹"
- fi
- mkdir tmp/boot
- mount bin/boot.img tmp/boot -t vfat -o loop
-
- if mountpoint -q tmp/boot
- then
- echo "成功挂载 boot.img 到 tmp/boot"
-
- cp bin/bootloader/loader.bin tmp/boot
-
- cp bin/kernel/kernel.bin tmp/boot
- sync
-
- umount tmp/boot
- else
- echo "挂载 boot.img 失败!"
- fi
- rm -rf tmp
- flag_can_run=0
- if [ -d "tmp/" ]; then
- flag_can_run=0
- echo "tmp文件夹未删除!"
- else
- flag_can_run=1
- fi
- if [ $flag_can_run -eq 1 ]; then
- bochs -f ./bochsrc -q
- else
- echo "不满足运行条件"
- fi
|