forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
179 lines (148 loc) · 5.01 KB
/
build-with-llvm.yml
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: LLVM FOS 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 genisoimage grub-pc-bin xorriso curl
- name: Build Kernel with LLVM
run: |
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
make defconfig
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: |
mkdir -p rootfs/{bin,sbin,etc,proc,sys,usr/{bin,sbin}}
sudo apt-get install -y busybox-static
cp /bin/busybox rootfs/bin/
# Install Neofetch dependencies
sudo apt-get install -y neofetch
# Copy Neofetch to rootfs
cp /usr/bin/neofetch rootfs/usr/bin/
# Modify the init script to run neofetch on boot
cat << 'EOF' > rootfs/init
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
echo "Welcome to FOS!"
neofetch
/bin/sh
EOF
chmod +x rootfs/init
# 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
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: Create Bootable ISO
run: |
mkdir -p iso/boot/grub
cp arch/x86/boot/bzImage iso/boot/
cp rootfs/initramfs.img iso/boot/
cat << EOF > iso/boot/grub/grub.cfg
set default=0
set timeout=5
menuentry "FOS OS" {
linux /boot/bzImage
initrd /boot/initramfs.img
}
EOF
genisoimage -U -r -J -V "FOS_OS" -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o fos_os.iso iso
- name: Archive the ISO Artifact
run: |
tar -czvf fos-os-build.tar.gz fos_os.iso
- 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
- name: Upload ISO Artifact
uses: actions/upload-artifact@v3
with:
name: iso-build
path: fos-os-build.tar.gz
release:
name: Release FOS Kernel, RootFS, and ISO
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: Download ISO Artifact
uses: actions/download-artifact@v3
with:
name: iso-build
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: fos${{ github.run_number }}
release_name: FOS 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
- name: Upload ISO 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: fos-os-build.tar.gz
asset_name: fos-os-build.tar.gz
asset_content_type: application/gzip