This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompile.sh
executable file
·96 lines (67 loc) · 2.4 KB
/
compile.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
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "You don't have the necessary permissions to work with files in the /mnt directory, which is necessary for mounting the loopback device. Please run as root, you can try append sudo to your command."
exit
fi
make # compile the kernel
# clone limine repo and build it
git clone https://github.com/limine-bootloader/limine.git --branch=v7.x-binary --depth=1
make -C limine
# do partition/loopback-y stuff (copied from old 32 bit version of SpecOS)
if test -f "disk.img"; then
rm disk.img
fi
if test -f "/mnt/specos"; then
rm -rf /mnt/specos
fi
mkdir /mnt/specos
# Make an empty img file with a bunch of zeros (512 byte sectors), about 70 Megabytes large (should be enough for now)
echo "Creating empty disk image file..."
dd if=/dev/zero of=disk.img bs=512 count=131072
# Add a partition that spans the whole disk
echo "Adding a partition..."
fdisk disk.img << EOF
n
p
a
w
EOF
# Make a couple loopback devices for installing GRUB and all that stuff
echo "Creating loopback device (GRUB)..."
sudo losetup /dev/loop0 disk.img # GRUB
echo "Creating loopback device (FAT32 FS)..."
sudo losetup /dev/loop1 disk.img -o 1048576 # File system
# Make a FAT32 file system
echo "Making the file system (FAT32)..."
sudo mkdosfs -F32 -f 2 /dev/loop1
# Mount it
echo "Mounting onto /mnt/specos..."
sudo mount /dev/loop1 /mnt/specos
# Install limine (idk if i did this one right)
echo "Installing Limine bootloader..."
./limine/limine bios-install disk.img
mkdir /mnt/specos/boot
# Add the kernel (this assumes that the kernel bin image and the grub config file are in the cd & ../bin)
echo "Copying kernel files..."
cp bin/SpecOS /mnt/specos/boot
cp limine.cfg /mnt/specos/boot
echo "Copying boot files..."
mkdir /mnt/specos/EFI
mkdir /mnt/specos/EFI/BOOT
cp limine/limine-bios.sys /mnt/specos/boot
cp limine/BOOTX64.EFI /mnt/specos/EFI/BOOT
mkdir /mnt/specos/stuff
echo "Hey there! This is a test file on a FAT32 file system on SpecOS. Long live the kernel!" >> /mnt/specos/stuff/testfile.txt
cp fscopy/font.bin /mnt/specos
# unmount it
echo "Unmounting..."
umount /mnt/specos
# Delete loopback device
losetup -d /dev/loop0
losetup -d /dev/loop1
echo "Complete! disk.img should now be in the current directory and bootable with Qemu."
# There should now be a disk image in the current directory (:
echo "Size of kernel: "
du -h bin/SpecOS
# delete old stuff
rm -rf obj limine /mnt/specos