From 891085e151966f1b21363e80139501137622eb88 Mon Sep 17 00:00:00 2001 From: Nigel Date: Thu, 2 Feb 2023 14:59:42 +0100 Subject: [PATCH] Successfully able to create a disk-image file - Created a scripts folder - Written instructions on how to create the disk image - Working on a python build script that executes all other scripts The scripts folder should contain scripts to build a full installation of our operating system. Scripts like creating a filesystem should be found here --- Makefile | 3 ++ scripts/build.py | 25 ++++++++++++++ scripts/create-filesystem.sh | 64 ++++++++++++++++++++++++++++++++++++ scripts/test.sh | 5 +++ 4 files changed, 97 insertions(+) create mode 100755 scripts/build.py create mode 100644 scripts/create-filesystem.sh create mode 100755 scripts/test.sh diff --git a/Makefile b/Makefile index 31eb6d9..fbdbff8 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,9 @@ test: test_iso: $(EMULATOR) -boot d -cdrom $(BUILD_DIR)/barinkOS.iso -serial stdio -vga std -display gtk -m 2G -cpu core2duo +test_disk: + $(EMULATOR) -boot d -drive format=raw,file=disk.img -serial stdio -vga std -display gtk -m 2G -cpu core2duo + build_kernel: $(OBJ_LINK_LIST) $(CC) -T $(SRC_DIR)/kernel/linker.ld -o $(BUILD_DIR)/myos.bin \ diff --git a/scripts/build.py b/scripts/build.py new file mode 100755 index 0000000..cd06dc4 --- /dev/null +++ b/scripts/build.py @@ -0,0 +1,25 @@ +#!/usr/bin/python3 +import os +import subprocess + + +print("Building BarinkOS") + + +# list and run build scripts +print("Running build-scripts") +os.chdir("scripts") + +scripts=os.listdir() +currentScript=os.path.basename(__file__) + +if currentScript in scripts: + scripts.remove(currentScript) + + +for script in scripts: + print(os.getcwd()) + print("Running:" + script) + subprocess.call(script, cwd=os.getcwd()) + +os.chdir("..") \ No newline at end of file diff --git a/scripts/create-filesystem.sh b/scripts/create-filesystem.sh new file mode 100644 index 0000000..45dc117 --- /dev/null +++ b/scripts/create-filesystem.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# +# How to build a boot image +# NOTE: This script cant run properly yet +# Things described here should be done manually for now +# +# COPYRIGHT © Nigel Barink 2023 +# + +echo "Building a FAT16 filesystem" + + +su + +# dd if=/dev/zero of=diks.img bs=512 count=131072 +# fdisk disk.img +# Use the following options in fdisk (Format Disk Tool) +# We want to create a MBR (NOT GPT) Partition table containing 1 logical disk +# with a primary FAT16 partition marked bootable + +#OPTIONs + +# Create new DOS disklabel +# o +# Create new partition +# n +# Choose Primary as partition type +# p +# hit enter to choose default for the other options + +# Mark partition 1 as bootable +# a + +# Change partition type to FAT16 +# t +# Choose Partition 1 +# 1 +# Choose HEX 6 for FAT16 +# 6 + +# Sync and write changes to disk +# w + +# Create a "block" device from the disk.img +# losetup /dev/loop9 disk.img + +# Format the partition on the disk as FAT16 +# mkdosfs -F16 /dev/loop9 + +# Mount the disk to a folder on our dev machine +# mount /dev/loop9 /mnt + +# Install the grub bootloader onto the disk +# grub-install --no-floppy --modules="normal multiboot" /dev/loop9 --target=i386-pc --boot-directory=/mnt/boot --force + +# copy the necessary OS files +# cp root/boot/myos.bin /mnt/boot/myos.bin +# cp root/boot/grub/grub.cfg /mnt/boot/grub/grub.cfg + +# Unmount the device +# umount /mnt + +# Destroy the loop device +# losetup -d /dev/loop9 diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 0000000..cb84bbe --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,5 @@ +#!/bin/bash +start=`date +%s` +end=`date +%s` +echo That took $((end-start)) seconds +date +"%c" -d195440409