From c69ac198ed948498c2528e6011f236eab0bcbddd Mon Sep 17 00:00:00 2001 From: Kieron Morris Date: Sat, 26 Jun 2021 02:28:07 +0100 Subject: [PATCH] Cleaned up Compile Scripts & Pipeline Commiting to test. --- .gitlab-ci.yml | 77 ++++++++++++-------- Dockerfile | 4 +- compile.sh | 82 ++++----------------- compile_and_run.sh | 7 -- compile_and_run_debug.sh | 7 -- checksum.sh => compile_checksum.sh | 0 compile_debug.sh | 2 - compile_finish.sh | 18 +++++ compile_isogen.sh | 8 ++ compile_link.sh | 17 +++++ compile_sources.sh | 7 ++ compile_stub.sh | 8 ++ compile_sumgen.sh | 8 ++ versioning.sh => compile_vergen.sh | 28 ++++--- install_dev_env.sh | 113 ----------------------------- mount.sh | 53 -------------- run.sh | 38 ---------- run_bochs.sh | 2 - unmount.sh | 11 --- updatevm.sh | 6 -- vb_compile_run.sh | 7 -- vbox.sh | 3 - 22 files changed, 145 insertions(+), 361 deletions(-) delete mode 100755 compile_and_run.sh delete mode 100644 compile_and_run_debug.sh rename checksum.sh => compile_checksum.sh (100%) mode change 100755 => 100644 delete mode 100644 compile_debug.sh create mode 100644 compile_finish.sh create mode 100644 compile_isogen.sh create mode 100644 compile_link.sh create mode 100644 compile_sources.sh create mode 100644 compile_stub.sh create mode 100644 compile_sumgen.sh rename versioning.sh => compile_vergen.sh (81%) mode change 100755 => 100644 delete mode 100755 install_dev_env.sh delete mode 100755 mount.sh delete mode 100755 run.sh delete mode 100755 run_bochs.sh delete mode 100755 unmount.sh delete mode 100755 updatevm.sh delete mode 100755 vb_compile_run.sh delete mode 100755 vbox.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f68577be..6ed2ef25 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,39 +1,52 @@ -# This file is a template, and might need editing before it works on your project. -# see https://docs.gitlab.com/ee/ci/yaml/README.html for all available options - -.before_script: - - echo "Before script section" - - echo "For example you might run an update here or install a build dependency" - - echo "Or perhaps you might print out some debugging details" - .after_script: - - echo "After script section" - - echo "For example you might do some cleanup here" - -build: - stage: build - tags: - - asuro - script: ./compile.sh + script: ./compile_finish.sh "$CI_JOB_STATUS" + rules: + - if: '$CI_JOB_STATUS == "failed"' + - when: never artifacts: paths: - - release/Asuro.iso - - iso/boot/asuro.bin - release/*.svg -.test1: - stage: test - script: - - echo "Do a test here" - - echo "For example run a test suite" +stages: + - compile_stub + - vergen + - compile_sources + - link + - isogen + - finish -.test2: - stage: test - script: - - echo "Do another parallel test here" - - echo "For example run a lint test" +compile_stub: + stage: compile_stub + script: ./compile_stub.sh + +vergen: + stage: vergen + script: ./compile_vergen.sh + artifacts: + paths: + - release/*.svg -.deploy1: - stage: deploy - script: - - echo "Do your deploy here" +compile_sources: + stage: compile_sources + script: ./compile_sources.sh + +link: + stage: link + script: ./compile_link.sh + artifacts: + paths: + - bin/kernel.bin + +isogen: + stage: isogen + script: ./compile_isogen.sh + artifacts: + paths: + - ./Asuro.iso + +finish: + stage: finish + script: ./compile_finish.sh "$CI_JOB_STATUS" + artifacts: + paths: + - release/*.svg \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index c9c8befb..6b345c26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,8 @@ FROM ubuntu:latest VOLUME ["/code"] -RUN dpkg --add-architecture i386 && \ - apt-get update +RUN dpkg --add-architecture i386 +RUN apt-get update RUN apt-get install nasm curl make:i386 binutils:i386 xorriso grub-pc-bin dos2unix -y RUN apt-get clean RUN curl https://sourceforge.net/projects/freepascal/files/Linux/2.6.4/fpc-2.6.4.i386-linux.tar/download --output fpc.tar -L && \ diff --git a/compile.sh b/compile.sh index 26bb5686..20a282a2 100755 --- a/compile.sh +++ b/compile.sh @@ -2,18 +2,12 @@ ERRCOUNT=0 echo " " echo "=======================" -echo "== ASURO COMPILATION ==" -echo "=======================" echo " " -echo "Checking out latest VM Source..." +echo "Asuro Compilation" echo " " -./updatevm.sh -echo " " -echo "Compiling ASM Stub..." -echo " " -rm lib/* -nasm -f elf src/stub/stub.asm -o lib/stub.o +#Compile Stub.asm +./compile_stub.sh if [ $? -ne 0 ] then echo "Failed to compile stub!" @@ -22,47 +16,23 @@ else echo "Success." fi -echo " " -echo "=======================" -echo " " - -./versioning.sh - -if [ "$1" = "-d" ] -then - echo "Compiling Debug FPC Sources..." - echo " " - fpc -Aelf -gw -n -va -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/* src/kernel.pas -else - echo "Compiling FPC Sources..." - echo " " - fpc -Aelf -gw -n -va -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/* -Fusrc/driver/net/* src/kernel.pas -fi +#Generate .pas with versioning headers. +./compile_vergen.sh +#Compile all .pas sources +./compile_sources.sh if [ $? -ne 0 ] then + echo " " echo "Failed to compile FPC Sources!" ERRCOUNT=$((ERRCOUNT+1)) else + echo " " echo "Success." fi -echo " " -echo "=======================" -echo " " -echo "Linking..." -echo " " -objstring=""; -for object in `find lib/ -name "*.o"`; do - if [ "$object" != "lib/stub.o" ] - then - objstring=$objstring$object" "; - fi -done; -objstring=lib/stub.o" "$objstring -echo "Object Files: "$objstring -echo " " -ld -m elf_i386 -s --gc-sections -Tlinker.script -o bin/kernel.bin $objstring +#Link into a binary. +./compile_link.sh if [ $? -ne 0 ] then echo "Failed linking!" @@ -71,13 +41,8 @@ else echo "Success." fi -echo " " -echo "=======================" -echo " " -echo "Creating ISO..." -echo " " -cp bin/kernel.bin iso/boot/asuro.bin -grub-mkrescue -o Asuro.iso iso +#Generate an ISO with GRUB as the Bootloader. +./compile_isogen.sh if [ $? -ne 0 ] then echo "Failed to create ISO!" @@ -86,27 +51,12 @@ else echo "Success." fi -echo " " -echo "=======================" -echo " " +#Call generate final artifacts based on failure or success of the above. if [ "$ERRCOUNT" -ne "0" ] then - echo "$ERRCOUNT Errors Occurred, please review." - wget -q https://img.shields.io/badge/build-failed-red.svg -O release/build.svg + ./compile_finish.sh "failed" else - echo "No errors." - wget -q https://img.shields.io/badge/build-succeeded-green.svg -O release/build.svg + ./compile_finish.sh "success" fi -echo " " -echo "=======================" -echo " " -#cp Asuro.iso ~/host/Asuro.iso -cp Asuro.iso release/Asuro.iso - -checksum=$(md5sum release/Asuro.iso | awk '{print $1}') -wget -q https://img.shields.io/badge/checksum-$checksum-important.svg -O release/checksum.svg -cd release -touch * -#svn commit -m "Versioning Auto-Commit" cd .. diff --git a/compile_and_run.sh b/compile_and_run.sh deleted file mode 100755 index 05bc209f..00000000 --- a/compile_and_run.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -ERRCOUNT=0 -echo "=======================" -echo "== ASURO ==" -echo "=======================" -./compile.sh -./run.sh diff --git a/compile_and_run_debug.sh b/compile_and_run_debug.sh deleted file mode 100644 index bd6484e9..00000000 --- a/compile_and_run_debug.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -ERRCOUNT=0 -echo "=======================" -echo "== ASURO ==" -echo "=======================" -./compile.sh -d -./run.sh -d diff --git a/checksum.sh b/compile_checksum.sh old mode 100755 new mode 100644 similarity index 100% rename from checksum.sh rename to compile_checksum.sh diff --git a/compile_debug.sh b/compile_debug.sh deleted file mode 100644 index 50efa9bc..00000000 --- a/compile_debug.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./compile.sh -d diff --git a/compile_finish.sh b/compile_finish.sh new file mode 100644 index 00000000..222a9027 --- /dev/null +++ b/compile_finish.sh @@ -0,0 +1,18 @@ +#/bin/sh +echo " " +echo "=======================" +echo " " +if [ "$1" != "success" ] +then + echo "Errors Occurred, please review." + wget -q https://img.shields.io/badge/build-failed-red.svg -O release/build.svg 2>/dev/null + echo " " + echo "=======================" + exit 1 +else + echo "No errors." + wget -q https://img.shields.io/badge/build-succeeded-green.svg -O release/build.svg 2>/dev/null + echo " " + echo "=======================" + exit 0 +fi \ No newline at end of file diff --git a/compile_isogen.sh b/compile_isogen.sh new file mode 100644 index 00000000..efec801d --- /dev/null +++ b/compile_isogen.sh @@ -0,0 +1,8 @@ +#!/bin/sh +echo " " +echo "=======================" +echo " " +echo "Creating ISO..." +echo " " +cp bin/kernel.bin iso/boot/asuro.bin +grub-mkrescue -o Asuro.iso iso \ No newline at end of file diff --git a/compile_link.sh b/compile_link.sh new file mode 100644 index 00000000..f8611920 --- /dev/null +++ b/compile_link.sh @@ -0,0 +1,17 @@ +#!/bin/sh +echo " " +echo "=======================" +echo " " +echo "Linking..." +echo " " +objstring=""; +for object in `find lib/ -name "*.o"`; do + if [ "$object" != "lib/stub.o" ] + then + objstring=$objstring$object" "; + fi +done; +objstring=lib/stub.o" "$objstring +echo "Object Files: "$objstring +echo " " +ld -m elf_i386 -s --gc-sections -Tlinker.script -o bin/kernel.bin $objstring \ No newline at end of file diff --git a/compile_sources.sh b/compile_sources.sh new file mode 100644 index 00000000..aedefff5 --- /dev/null +++ b/compile_sources.sh @@ -0,0 +1,7 @@ +#!/bin/sh +echo " " +echo "=======================" +echo " " +echo "Compiling FPC Sources..." +echo " " +fpc -Aelf -gw -n -va -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/* -Fusrc/driver/net/* src/kernel.pas \ No newline at end of file diff --git a/compile_stub.sh b/compile_stub.sh new file mode 100644 index 00000000..3f834379 --- /dev/null +++ b/compile_stub.sh @@ -0,0 +1,8 @@ +#!/bin/sh +echo " " +echo "=======================" +echo " " +echo "Compiling Stub..." +echo " " +rm lib/* +nasm -f elf src/stub/stub.asm -o lib/stub.o \ No newline at end of file diff --git a/compile_sumgen.sh b/compile_sumgen.sh new file mode 100644 index 00000000..f0f961d1 --- /dev/null +++ b/compile_sumgen.sh @@ -0,0 +1,8 @@ +#/bin/sh +echo " " +echo "=======================" +echo " " +echo "Generating Checksum Badge..." +echo " " +checksum=$(md5sum Asuro.iso | awk '{print $1}') +wget -q https://img.shields.io/badge/checksum-$checksum-important.svg -O release/checksum.svg 2>/dev/null \ No newline at end of file diff --git a/versioning.sh b/compile_vergen.sh old mode 100755 new mode 100644 similarity index 81% rename from versioning.sh rename to compile_vergen.sh index d1380369..a6505cad --- a/versioning.sh +++ b/compile_vergen.sh @@ -1,6 +1,10 @@ #!/bin/bash +echo " " +echo "=======================" +echo " " echo "Generating Versioning Info..." -./checksum.sh +echo " " +./compile_checksum.sh outfile="src/include/asuro.pas" file="version" while IFS=: read -r line;do @@ -44,15 +48,15 @@ echo "implementation" >> $outfile echo " " >> $outfile echo "end." >> $outfile echo "Generating release info..." -wget -q https://img.shields.io/badge/version-$major.$minor.$sub--$revision$release-blue.svg -O release/version.svg -wget -q https://img.shields.io/badge/revision-$revision-blue.svg -O release/revision.svg -wget -q https://img.shields.io/badge/release-$release-blue.svg -O release/release.svg -wget -q https://img.shields.io/badge/lines-$linecount-blueviolet.svg -O release/lines.svg -wget -q https://img.shields.io/badge/files-$sourcecount-blueviolet.svg -O release/files.svg -wget -q https://img.shields.io/badge/drivers-$drivercount-blueviolet.svg -O release/drivers.svg -wget -q https://img.shields.io/badge/FPC_version-$fpcversion-lightgrey.svg -O release/fpcversion.svg -wget -q https://img.shields.io/badge/NASM_version-$nasmversion-lightgrey.svg -O release/nasmversion.svg -wget -q https://img.shields.io/badge/MAKE_version-$makeversion-lightgrey.svg -O release/makeversion.svg -wget -q https://img.shields.io/badge/release_date-$compiledate-lightgrey.svg -O release/date.svg -wget -q https://img.shields.io/badge/fingerprint-$checksum-important.svg -O release/fingerprint.svg +wget -q https://img.shields.io/badge/version-$major.$minor.$sub--$revision$release-blue.svg -O release/version.svg 2>/dev/null +wget -q https://img.shields.io/badge/revision-$revision-blue.svg -O release/revision.svg 2>/dev/null +wget -q https://img.shields.io/badge/release-$release-blue.svg -O release/release.svg 2>/dev/null +wget -q https://img.shields.io/badge/lines-$linecount-blueviolet.svg -O release/lines.svg 2>/dev/null +wget -q https://img.shields.io/badge/files-$sourcecount-blueviolet.svg -O release/files.svg 2>/dev/null +wget -q https://img.shields.io/badge/drivers-$drivercount-blueviolet.svg -O release/drivers.svg 2>/dev/null +wget -q https://img.shields.io/badge/FPC_version-$fpcversion-lightgrey.svg -O release/fpcversion.svg 2>/dev/null +wget -q https://img.shields.io/badge/NASM_version-$nasmversion-lightgrey.svg -O release/nasmversion.svg 2>/dev/null +wget -q https://img.shields.io/badge/MAKE_version-$makeversion-lightgrey.svg -O release/makeversion.svg 2>/dev/null +wget -q https://img.shields.io/badge/release_date-$compiledate-lightgrey.svg -O release/date.svg 2>/dev/null +wget -q https://img.shields.io/badge/fingerprint-$checksum-important.svg -O release/fingerprint.svg 2>/dev/null echo "Done versioning." diff --git a/install_dev_env.sh b/install_dev_env.sh deleted file mode 100755 index 05b1de39..00000000 --- a/install_dev_env.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/sh -ERRCOUNT=0 -echo " " -echo "===================================" -echo "== ASURO DEV ENVIRONMENT INSTALL ==" -echo "===================================" - -echo " " -echo "Installing Build Essentials..." -sudo apt-get install build-essential:i386 -if [ $? -ne 0 ] -then - echo "Failed to install!" - ERRCOUNT=$((ERRCOUNT+1)) -else - echo "Success." -fi - -echo " " -echo "Installing NASM..." -sudo apt-get install nasm -if [ $? -ne 0 ] -then - echo "Failed to install!" - ERRCOUNT=$((ERRCOUNT+1)) -else - echo "Success." -fi - -echo " " -echo "Installing Bin-Utils..." -sudo apt-get install binutils:i386 -if [ $? -ne 0 ] -then - echo "Failed to install!" - ERRCOUNT=$((ERRCOUNT+1)) -else - echo "Success." -fi - -echo " " -echo "Installing FPC Sources..." -sudo apt-get install fpc-src:i386 -if [ $? -ne 0 ] -then - echo "Failed to install!" - ERRCOUNT=$((ERRCOUNT+1)) -else - echo "Success." -fi - -echo " " -echo "Installing FPC..." -sudo apt-get install fpc:i386 -if [ $? -ne 0 ] -then - echo "Failed to install!" - ERRCOUNT=$((ERRCOUNT+1)) -else - echo "Success." -fi - -echo " " -echo "Installing QEmu..." -sudo apt-get install qemu -if [ $? -ne 0 ] -then - echo "Failed to install!" - ERRCOUNT=$((ERRCOUNT+1)) -else - echo "Success." -fi - -echo " " -echo "Installing xorriso..." -sudo apt-get install xorriso -if [ $? -ne 0 ] -then - echo "Failed to install!" - ERRCOUNT=$((ERRCOUNT+1)) -else - echo "Success." -fi - -echo " " -echo "Installing GRUB PC Bin..." -sudo apt-get install grub-pc-bin -if [ $? -ne 0 ] -then - echo "Failed to install!" - ERRCOUNT=$((ERRCOUNT+1)) -else - echo "Success." -fi - -echo " " -echo "WARNING: We assume you already have Grub installed." -echo " Asuro depends on grub-mkrescue." - -echo " " -echo "=======================" -echo " " -if [ "$ERRCOUNT" -ne "0" ] -then - echo "$ERRCOUNT Errors Occurred, please review." -else - echo "No errors." -fi -echo " " -echo "=======================" -echo " " - - diff --git a/mount.sh b/mount.sh deleted file mode 100755 index 1f527841..00000000 --- a/mount.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -ERRCOUNT=0 -echo " " -echo "=======================" -echo "== ASURO MOUNT ==" -echo "=======================" -echo " " -echo "Mounting Asuro..." -sudo modprobe nbd -if [ $? -ne 0 ] -then - echo "Failed load nbd!" - ERRCOUNT=$((ERRCOUNT+1)) -fi - -sudo qemu-nbd --connect=/dev/nbd0 IMAGE.img -if [ $? -ne 0 ] -then - echo "Failed to mount Image!" - ERRCOUNT=$((ERRCOUNT+1)) -fi - -sudo partx -a /dev/nbd0 -if [ $? -ne 0 ] -then - echo "Failed to find Partitions!" - ERRCOUNT=$((ERRCOUNT+1)) -fi - -sudo mount /dev/nbd0p1 /mnt/asuro -if [ $? -ne 0 ] -then - echo "Failed to mount Asuro!" - ERRCOUNT=$((ERRCOUNT+1)) -fi - -echo " " -echo "=======================" -echo " " -if [ "$ERRCOUNT" -ne "0" ] -then - ./unmount.sh - echo " " - echo "=======================" - echo " " - echo "$ERRCOUNT Errors Occurred, please review." -else - echo "No errors." -fi - -echo " " -echo "=======================" -echo " " diff --git a/run.sh b/run.sh deleted file mode 100755 index 1ba1e657..00000000 --- a/run.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -ERRCOUNT=0 -echo " " -echo "=======================" -echo "== ASURO OPERATION ==" -echo "=======================" -echo " " -echo "Running Asaro..." -if [ "$1" = "-d" ] -then - qemu-system-i386 -hda IMAGE.img -serial pty -s -S -cdrom Asuro.iso& - sleep 1 - gdb -ex "target remote localhost:1234" -else - qemu-system-i386 -hda IMAGE.img -serial pty -monitor stdio -cdrom Asuro.iso -fi - -if [ $? -ne 0 ] -then - echo "Failed to run Asaro!" - ERRCOUNT=$((ERRCOUNT+1)) -else - echo "Finished Successfully." -fi - -echo " " -echo "=======================" -echo " " -if [ "$ERRCOUNT" -ne "0" ] -then - echo "$ERRCOUNT Errors Occurred, please review." -else - echo "No errors." -fi - -echo " " -echo "=======================" -echo " " diff --git a/run_bochs.sh b/run_bochs.sh deleted file mode 100755 index a16ed817..00000000 --- a/run_bochs.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -bochs diff --git a/unmount.sh b/unmount.sh deleted file mode 100755 index 7881a5f5..00000000 --- a/unmount.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -ERRCOUNT=0 -echo " " -echo "=========================" -echo "== ASURO UNMOUNT ==" -echo "=========================" -echo " " -echo "Unmounting Asuro..." -sudo umount /mnt/asuro -sudo qemu-nbd --disconnect /dev/nbd0 -sudo rmmod nbd diff --git a/updatevm.sh b/updatevm.sh deleted file mode 100755 index 7b3adeb1..00000000 --- a/updatevm.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -DIRECTORY="src/vm" -rm -rf /tmp/MINJ -git clone https://gitlab.spexeah.com/spexeah/MINJ.git /tmp/MINJ -rm -rf $DIRECTORY -cp -rf /tmp/MINJ/src/vm $DIRECTORY \ No newline at end of file diff --git a/vb_compile_run.sh b/vb_compile_run.sh deleted file mode 100755 index adcce76d..00000000 --- a/vb_compile_run.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -ERRCOUNT=0 -echo "=======================" -echo "== ASURO ==" -echo "=======================" -./compile.sh -./vbox.sh diff --git a/vbox.sh b/vbox.sh deleted file mode 100755 index 4a68bd56..00000000 --- a/vbox.sh +++ /dev/null @@ -1,3 +0,0 @@ -#name ur machine "asuro" - -VBoxManage startvm "asuro"