From e07c4a68a9a0dca15c6b3ee201a5eacd58f6b6bb Mon Sep 17 00:00:00 2001 From: Nasir Hossain Date: Fri, 16 Feb 2024 14:08:11 +0600 Subject: [PATCH 01/10] fix: format release number value --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c818fc..6947d98 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: v${{ github.run_number }} - release_name: Build Number\:\ ${{ github.run_number }} + release_name: "Build Number: ${{ github.run_number }}" draft: false prerelease: false - name: Upload release asset From b5ec106b1616901d49832f42d41982391d926a46 Mon Sep 17 00:00:00 2001 From: Nasir Hossain Date: Fri, 16 Feb 2024 15:01:41 +0600 Subject: [PATCH 02/10] feat: add the initramfs and install grub --- .github/workflows/build.yml | 2 +- build.bash | 36 +++++++++++++++++++++--------------- config/grub.cfg | 17 +++++++++++++++++ 3 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 config/grub.cfg diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6947d98..43c51a0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,6 +37,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./dist/boot/boot.img + asset_path: ./egos.iso asset_name: egos-v${{ github.run_number }}.img asset_content_type: application/octet-stream diff --git a/build.bash b/build.bash index fac1866..953155c 100755 --- a/build.bash +++ b/build.bash @@ -22,19 +22,22 @@ sudo apt-get install -y\ libtool\ libpng-dev\ libfreetype-dev\ - git + git\ + grub-common -# Create the dist directory -mkdir -p dist/boot +# Create the directory structure +mkdir -p iso/boot/grub +mkdir -p initramfs/{bin,sbin,etc,proc,sys,usr/{bin,sbin}} # Download the kernel source wget https://www.kernel.org/pub/linux/kernel/v${LINUX_MAJOR}.x/linux-${LINUX_MAJOR}.${LINUX_MINOR}.${LINUX_PATCH}.tar.xz tar -xf linux-${LINUX_MAJOR}.${LINUX_MINOR}.${LINUX_PATCH}.tar.xz cd linux-${LINUX_MAJOR}.${LINUX_MINOR}.${LINUX_PATCH} + make -j$(nproc) x86_64_defconfig cp ../config/linux.config .config - make -j$(nproc) + make -j$(nproc) bzImage echo $PWD - cp arch/x86/boot/bzImage ../dist/boot/. + cp arch/x86/boot/bzImage ../iso/boot/. cd .. # Download the busybox source @@ -43,19 +46,22 @@ tar -xf busybox-${BUSYBOX_MAJOR}.${BUSYBOX_MINOR}.${BUSYBOX_PATCH}.tar.bz2 cd busybox-${BUSYBOX_MAJOR}.${BUSYBOX_MINOR}.${BUSYBOX_PATCH} cp ../config/busybox.config .config make -j$(nproc) - make CONFIG_PREFIX=../dist install + make CONFIG_PREFIX=../initramfs install cd .. +# Create the initramfs +sudo mount -t proc /proc initramfs/proc +sudo mount -t sysfs /sys initramfs/sys +sudo mount -o bind /dev initramfs/dev +sudo mount -o bind /dev/pts initramfs/dev/pts +cd initramfs + find . | cpio -H newc -o > ../iso/boot/initramfs.cpio + +# Install GRUB +cp config/grub.cfg iso/boot/grub/grub.cfg + # Create the bootable image -dd if=/dev/zero of=dist/boot/boot.img bs=1M count=256 -mkfs.ext4 dist/boot/boot.img -mkdir -p dist/mnt -sudo mount dist/boot/boot.img dist/mnt - set +e - sudo cp -r dist/* dist/mnt/. - set -e - sudo umount dist/mnt -sudo rmdir dist/mnt +grub-mkrescue -o egos.iso iso # The image is ready to be used echo " ___ ___ ___ "; diff --git a/config/grub.cfg b/config/grub.cfg new file mode 100644 index 0000000..afc6938 --- /dev/null +++ b/config/grub.cfg @@ -0,0 +1,17 @@ +set default=0 +set timeout=10 +insmod efi_gop +insmod font +if loadfont /boot/grub/fonts/unicode.pf2 +then + insmod gfxterm + set gfxmode-auto + set gfxpayload=keep + terminal_output gfxterm +fi +menuentry 'EgOS LINUX' --class os { + insmod gzio + insmod part_msdos + linux /boot/bzImage + initrd /boot/initramfs.cpio +} \ No newline at end of file From 4e9cc08e39e6d3f1cc8e816204374077de025bc8 Mon Sep 17 00:00:00 2001 From: Nasir Hossain Nishad Date: Fri, 16 Feb 2024 17:17:26 +0600 Subject: [PATCH 03/10] refector: move config.bash out of config dir --- build.bash | 14 +++++++------- config.bash | 12 ++++++++++++ config/config.bash | 9 --------- 3 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 config.bash delete mode 100755 config/config.bash diff --git a/build.bash b/build.bash index 953155c..6061b75 100755 --- a/build.bash +++ b/build.bash @@ -1,6 +1,6 @@ #!/bin/bash -. config/config.bash +. config.bash set -e @@ -30,9 +30,9 @@ mkdir -p iso/boot/grub mkdir -p initramfs/{bin,sbin,etc,proc,sys,usr/{bin,sbin}} # Download the kernel source -wget https://www.kernel.org/pub/linux/kernel/v${LINUX_MAJOR}.x/linux-${LINUX_MAJOR}.${LINUX_MINOR}.${LINUX_PATCH}.tar.xz -tar -xf linux-${LINUX_MAJOR}.${LINUX_MINOR}.${LINUX_PATCH}.tar.xz -cd linux-${LINUX_MAJOR}.${LINUX_MINOR}.${LINUX_PATCH} +wget https://www.kernel.org/pub/linux/kernel/v${LINUX_MAJOR}.x/linux-${LINUX_VERSION}.tar.xz +tar -xf linux-${LINUX_VERSION}.tar.xz +cd linux-${LINUX_VERSION} make -j$(nproc) x86_64_defconfig cp ../config/linux.config .config make -j$(nproc) bzImage @@ -41,9 +41,9 @@ cd linux-${LINUX_MAJOR}.${LINUX_MINOR}.${LINUX_PATCH} cd .. # Download the busybox source -wget https://busybox.net/downloads/busybox-${BUSYBOX_MAJOR}.${BUSYBOX_MINOR}.${BUSYBOX_PATCH}.tar.bz2 -tar -xf busybox-${BUSYBOX_MAJOR}.${BUSYBOX_MINOR}.${BUSYBOX_PATCH}.tar.bz2 -cd busybox-${BUSYBOX_MAJOR}.${BUSYBOX_MINOR}.${BUSYBOX_PATCH} +wget https://busybox.net/downloads/busybox-${BUSYBOX_VERSION}.tar.bz2 +tar -xf busybox-${BUSYBOX_VERSION}.tar.bz2 +cd busybox-${BUSYBOX_VERSION} cp ../config/busybox.config .config make -j$(nproc) make CONFIG_PREFIX=../initramfs install diff --git a/config.bash b/config.bash new file mode 100644 index 0000000..d2eca06 --- /dev/null +++ b/config.bash @@ -0,0 +1,12 @@ +#!/bin/bash + +LINUX_MAJOR=6 +LINUX_MINOR=7 +LINUX_PATCH=4 + +BUSYBOX_MAJOR=1 +BUSYBOX_MINOR=36 +BUSYBOX_PATCH=1 + +LINUX_VERSION=${LINUX_MAJOR}.${LINUX_MINOR}.${LINUX_PATCH} +BUSYBOX_VERSION=${BUSYBOX_MAJOR}.${BUSYBOX_MINOR}.${BUSYBOX_PATCH} \ No newline at end of file diff --git a/config/config.bash b/config/config.bash deleted file mode 100755 index 2006492..0000000 --- a/config/config.bash +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -LINUX_MAJOR=6 -LINUX_MINOR=7 -LINUX_PATCH=4 - -BUSYBOX_MAJOR=1 -BUSYBOX_MINOR=36 -BUSYBOX_PATCH=1 From 9fdf6d6a1f1a2f4ef2195b92c384f52e808745eb Mon Sep 17 00:00:00 2001 From: Nasir Hossain Nishad Date: Fri, 16 Feb 2024 17:18:15 +0600 Subject: [PATCH 04/10] feat: introduce init script for initramfs --- build.bash | 7 +++---- scripts/init.sh | 9 +++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 scripts/init.sh diff --git a/build.bash b/build.bash index 6061b75..65fcb78 100755 --- a/build.bash +++ b/build.bash @@ -50,12 +50,11 @@ cd busybox-${BUSYBOX_VERSION} cd .. # Create the initramfs -sudo mount -t proc /proc initramfs/proc -sudo mount -t sysfs /sys initramfs/sys -sudo mount -o bind /dev initramfs/dev -sudo mount -o bind /dev/pts initramfs/dev/pts cd initramfs + rm linuxrc # We'll be using a init sciprt instead + cp config/initramfs.sh init find . | cpio -H newc -o > ../iso/boot/initramfs.cpio +cd .. # Install GRUB cp config/grub.cfg iso/boot/grub/grub.cfg diff --git a/scripts/init.sh b/scripts/init.sh new file mode 100644 index 0000000..ca2c41d --- /dev/null +++ b/scripts/init.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Disable Kernel Messages +dmesg -n 1 + +# Mount the file system +mount -t devtmpfs none /dev +mount -t proc none /dev +mount -t sysfs none /sys \ No newline at end of file From ad5cce2fb87e313972a5d5cffbb50f062da1db0d Mon Sep 17 00:00:00 2001 From: Nasir Hossain Nishad Date: Fri, 16 Feb 2024 17:19:52 +0600 Subject: [PATCH 05/10] fix: add dev dir to mount devtmpfs later --- build.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.bash b/build.bash index 65fcb78..cd9692e 100755 --- a/build.bash +++ b/build.bash @@ -27,7 +27,7 @@ sudo apt-get install -y\ # Create the directory structure mkdir -p iso/boot/grub -mkdir -p initramfs/{bin,sbin,etc,proc,sys,usr/{bin,sbin}} +mkdir -p initramfs/{bin,sbin,etc,dev,proc,sys,usr/{bin,sbin}} # Download the kernel source wget https://www.kernel.org/pub/linux/kernel/v${LINUX_MAJOR}.x/linux-${LINUX_VERSION}.tar.xz From d127438dd5efc68c9a9a25d5ad3a6aa5ae466ba5 Mon Sep 17 00:00:00 2001 From: Nasir Hossain Nishad Date: Fri, 16 Feb 2024 17:40:53 +0600 Subject: [PATCH 06/10] fix: start shell in init and shutdown on exit --- scripts/init.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/init.sh b/scripts/init.sh index ca2c41d..6fbe832 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -6,4 +6,10 @@ dmesg -n 1 # Mount the file system mount -t devtmpfs none /dev mount -t proc none /dev -mount -t sysfs none /sys \ No newline at end of file +mount -t sysfs none /sys + +# Start shell +/bin/sh + +# Shutdown the machine when shell is exited +poweroff -f \ No newline at end of file From 46d74ac103c63ead75163c0796ab7b9b2e0c920e Mon Sep 17 00:00:00 2001 From: Nasir Hossain Nishad Date: Fri, 16 Feb 2024 17:51:49 +0600 Subject: [PATCH 07/10] feat: add test github action --- .github/workflows/test.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d21d793 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: Test + +on: + push: + branches: + - feature + pull_request: + types: + - opened + - reopened + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Run build + run: ./build.bash \ No newline at end of file From 5b3a04122578f975145fb1646f8c4bcb9982b8df Mon Sep 17 00:00:00 2001 From: Nasir Hossain Nishad Date: Fri, 16 Feb 2024 18:04:14 +0600 Subject: [PATCH 08/10] fix: incorrect path to init.sh --- build.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.bash b/build.bash index cd9692e..5be3dc6 100755 --- a/build.bash +++ b/build.bash @@ -52,7 +52,7 @@ cd .. # Create the initramfs cd initramfs rm linuxrc # We'll be using a init sciprt instead - cp config/initramfs.sh init + cp scripts/init.sh init find . | cpio -H newc -o > ../iso/boot/initramfs.cpio cd .. From 6f9853a9c8b4b4c3754f54fc5ac0493630731f67 Mon Sep 17 00:00:00 2001 From: Nasir Hossain Nishad <157484627+nishad-prime@users.noreply.github.com> Date: Fri, 16 Feb 2024 18:17:41 +0600 Subject: [PATCH 09/10] fix: incorrect path to init.sh --- build.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.bash b/build.bash index 5be3dc6..7ba68c9 100755 --- a/build.bash +++ b/build.bash @@ -52,7 +52,7 @@ cd .. # Create the initramfs cd initramfs rm linuxrc # We'll be using a init sciprt instead - cp scripts/init.sh init + cp ../scripts/init.sh init find . | cpio -H newc -o > ../iso/boot/initramfs.cpio cd .. @@ -68,4 +68,4 @@ echo " | __|__ _ / _ \/ __|"; echo " | _|/ _\` | (_) \__ \\"; echo " |___\__, |\___/|___/"; echo " |___/ "; -echo "Is Built Successfully!"; \ No newline at end of file +echo "Is Built Successfully!"; From 35fe8a30bff1efeeb05678ebc8e13faeccf46742 Mon Sep 17 00:00:00 2001 From: Nasir Hossain Nishad Date: Fri, 16 Feb 2024 20:54:23 +0600 Subject: [PATCH 10/10] fix: add required dependency mtools --- build.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.bash b/build.bash index 7ba68c9..d019b39 100755 --- a/build.bash +++ b/build.bash @@ -23,7 +23,8 @@ sudo apt-get install -y\ libpng-dev\ libfreetype-dev\ git\ - grub-common + grub-common\ + mtools # Create the directory structure mkdir -p iso/boot/grub