LLVM Linux Kernel #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: LLVM Linux Kernel | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build Kernel | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y clang llvm lld build-essential libncurses-dev bison flex libssl-dev libelf-dev cpio | |
- name: Build Kernel with LLVM | |
run: | | |
# Set LLVM environment variables | |
export CC=clang | |
export LD=ld.lld | |
export AR=llvm-ar | |
export NM=llvm-nm | |
export OBJCOPY=llvm-objcopy | |
export OBJDUMP=llvm-objdump | |
export STRIP=llvm-strip | |
# Build with LLVM and ensure networking support is enabled | |
make defconfig | |
make menuconfig # Ensure networking is enabled, e.g., Ethernet, wireless, etc. | |
make -j$(nproc) CC=clang LD=ld.lld | |
- name: Archive the Kernel Artifact | |
run: | | |
tar -czvf kernel-build.tar.gz arch/x86/boot/bzImage | |
- name: Build Root Filesystem | |
run: | | |
# Prepare root filesystem structure | |
mkdir -p rootfs/{bin,sbin,etc,proc,sys,usr/{bin,sbin},home} | |
# Install busybox-static for a self-contained binary | |
sudo apt-get install -y busybox-static openssh-server neofetch | |
cp /bin/busybox rootfs/bin/ | |
# Create init file | |
cat << 'EOF' > rootfs/init | |
#!/bin/sh | |
mount -t proc none /proc | |
mount -t sysfs none /sys | |
mount -t devtmpfs none /dev | |
# Start networking (if DHCP is available) | |
ifconfig eth0 up | |
udhcpc -i eth0 | |
# Start SSH service | |
/usr/sbin/sshd | |
# Display OS info with Neofetch | |
/usr/bin/neofetch | |
echo "Welcome to FOS!" | |
/bin/sh | |
EOF | |
chmod +x rootfs/init | |
# Modify /etc/os-release to set OS name to "FOS" | |
mkdir -p rootfs/etc | |
cat << 'EOF' > rootfs/etc/os-release | |
NAME="FOS" | |
VERSION="1.0" | |
ID=fos | |
VERSION_ID="1.0" | |
PRETTY_NAME="FOS 1.0" | |
ANSI_COLOR="0;34" | |
EOF | |
# Create symlinks for busybox commands | |
for cmd in $(rootfs/bin/busybox --list); do | |
[ ! -e rootfs/bin/$cmd ] && ln -s /bin/busybox rootfs/bin/$cmd | |
done | |
# Create initramfs image | |
cd rootfs | |
find . | cpio -H newc -ov --owner root:root | gzip > ../initramfs.img | |
- name: Archive the RootFS Artifact | |
run: | | |
tar -czvf rootfs-build.tar.gz initramfs.img | |
- name: Upload Kernel Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: kernel-build | |
path: kernel-build.tar.gz | |
- name: Upload RootFS Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: rootfs-build | |
path: rootfs-build.tar.gz | |
release: | |
name: Release Kernel & RootFS | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Kernel Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: kernel-build | |
- name: Download RootFS Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: rootfs-build | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: llVm${{ github.run_number }} | |
release_name: LLVM Build v${{ github.run_number }} | |
draft: false | |
prerelease: false | |
- name: Upload Kernel to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: kernel-build.tar.gz | |
asset_name: kernel-build.tar.gz | |
asset_content_type: application/gzip | |
- name: Upload RootFS to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: rootfs-build.tar.gz | |
asset_name: rootfs-build.tar.gz | |
asset_content_type: application/gzip |