Skip to content

Commit cd3cdf5

Browse files
committed
Add rootfs workflow
1 parent 04d2502 commit cd3cdf5

File tree

4 files changed

+185
-26
lines changed

4 files changed

+185
-26
lines changed

.github/workflows/build2.yml

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ on:
2323
version:
2424
required: true
2525
type: string
26+
cache:
27+
required: false
28+
type: boolean
29+
default: false
2630
workflow_call:
2731
inputs:
2832
host-os:
@@ -38,6 +42,10 @@ on:
3842
version:
3943
required: true
4044
type: string
45+
cache:
46+
required: false
47+
type: boolean
48+
default: false
4149
outputs:
4250
artifact-dir:
4351
value: ${{ jobs.build.outputs.artifact-dir }}
@@ -125,6 +133,7 @@ jobs:
125133
126134
echo "ARTIFACT_DIR=kernel-artifacts-${SUFFIX}" >> $GITHUB_OUTPUT
127135
136+
# TODO: Control caching with an input argument
128137
- name: Cache kernel image
129138
id: cache-kernel
130139
uses: actions/cache@v4

.github/workflows/release.yml

+10
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,18 @@ jobs:
1616
arch: ${{ matrix.arch }}
1717
version: ${{ matrix.kernel.version }}
1818

19+
rootfs:
20+
uses: ./.github/workflows/rootfs.yml
21+
strategy:
22+
matrix:
23+
arch: [arm64, x86_64]
24+
with:
25+
host-os: ubuntu-22.04
26+
arch: ${{ matrix.arch }}
27+
1928
build-and-test:
2029
uses: ./.github/workflows/build-and-test.yml
30+
needs: rootfs
2131
strategy:
2232
matrix:
2333
kernel: [{ack: 0, version: 5.10.y}, {ack: 0, version: 5.15.y}, {ack: 0, version: 6.1.y}, {ack: 0, version: 6.6.y}, {ack: 1, version: android13-5.10-lts}, {ack: 1, version: android14-5.15-lts}]

.github/workflows/rootfs.yml

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Build Rootfs
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
host-os:
6+
required: false
7+
type: string
8+
default: ubuntu-22.04
9+
arch:
10+
required: true
11+
type: choice
12+
options:
13+
- x86_64
14+
- arm64
15+
cache:
16+
required: false
17+
type: boolean
18+
default: false
19+
workflow_call:
20+
inputs:
21+
host-os:
22+
required: false
23+
type: string
24+
default: ubuntu-22.04
25+
arch:
26+
required: true
27+
type: string
28+
cache:
29+
required: false
30+
type: boolean
31+
default: true
32+
33+
jobs:
34+
check-cache:
35+
runs-on: ${{ inputs.host-os }}
36+
outputs:
37+
cache-hit: ${{ steps.cache-check.outputs.cache-hit }}
38+
steps:
39+
- name: Cache kernel image
40+
id: cache-check
41+
uses: actions/cache/restore@v4
42+
with:
43+
key: rootfs-${{ inputs.arch }}
44+
path: rootfs/*
45+
46+
- name: Upload rootfs artifact
47+
if: steps.cache-check.outputs.cache-hit == 'true'
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: rootfs-${{ inputs.arch }}
51+
# We haven't checked out the repo yet, so it's safe to use a glob here, no other files should be present
52+
path: |
53+
rootfs/*
54+
55+
rootfs:
56+
needs: check-cache
57+
if: needs.check-cache.outputs.cache-hit != 'true'
58+
runs-on: ${{ inputs.host-os }}
59+
# Put ACK and ARCH in the environment so it's picked up by the `make` commands
60+
env:
61+
ARCH: ${{ inputs.arch }}
62+
steps:
63+
64+
- uses: actions/checkout@v4
65+
66+
- name: Install common dependencies
67+
run: sudo apt update && sudo apt install -y debootstrap qemu-utils
68+
69+
- name: Install arm64 dependencies
70+
if: ${{ inputs.arch == 'arm64' }}
71+
run: sudo apt install -y qemu-user-static binfmt-support
72+
73+
- name: Initialize rootfs and initramfs
74+
shell: bash
75+
run: |
76+
set -x
77+
78+
make rootfs-init
79+
80+
ALPINE_ROOTFS=alpine-${{ inputs.arch }}.img
81+
ALPINE_CPIO=alpine-${{ inputs.arch }}.cpio.gz
82+
UBUNTU_ROOTFS=ubuntu-jammy-${{ inputs.arch }}.img
83+
UBUNTU_CPIO=ubuntu-jammy-${{ inputs.arch }}.cpio.gz
84+
85+
# Test generating rootfs in non-standard location
86+
ROOTFS=${ALPINE_ROOTFS} make rootfs-init
87+
88+
# TODO: Verify it matches the expected rootfs
89+
90+
# Generate ubuntu rootfs and cpio (with CPIO at a non-standard location)
91+
scripts/ubuntu_debootstrap.sh jammy ${{ inputs.arch }}
92+
SUDO=1 ROOTFS_DIR=./rootfs/ubuntu-jammy-${{ inputs.arch }} CPIO_FILE=${UBUNTU_CPIO} make rootfs-overlay
93+
94+
mv ./${UBUNTU_CPIO} rootfs/${UBUNTU_CPIO}
95+
96+
echo "ALPINE_ROOTFS=$ALPINE_ROOTFS" >> $GITHUB_ENV
97+
echo "ALPINE_CPIO=$ALPINE_CPIO" >> $GITHUB_ENV
98+
echo "UBUNTU_ROOTFS=$UBUNTU_ROOTFS" >> $GITHUB_ENV
99+
echo "UBUNTU_CPIO=$UBUNTU_CPIO" >> $GITHUB_ENV
100+
101+
- name: Cache rootfs artifacts
102+
uses: actions/cache/save@v4
103+
with:
104+
key: rootfs-${{ inputs.arch }}
105+
path: |
106+
rootfs/${{ env.ALPINE_ROOTFS }}
107+
rootfs/${{ env.UBUNTU_ROOTFS }}
108+
rootfs/${{ env.ALPINE_CPIO }}
109+
rootfs/${{ env.UBUNTU_CPIO }}
110+
111+
- name: Upload rootfs artifact
112+
uses: actions/upload-artifact@v4
113+
with:
114+
name: rootfs-${{ inputs.arch }}
115+
path: |
116+
rootfs/${{ env.ALPINE_ROOTFS }}
117+
rootfs/${{ env.UBUNTU_ROOTFS }}
118+
rootfs/${{ env.ALPINE_CPIO }}
119+
rootfs/${{ env.UBUNTU_CPIO }}

.github/workflows/test.yml

+47-26
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ on:
2525
required: true
2626
type: string
2727

28-
2928
jobs:
3029
test:
3130
runs-on: ubuntu-22.04
@@ -42,36 +41,42 @@ jobs:
4241
name: ${{ inputs.artifact-dir }}
4342
path: ${{ inputs.artifact-dir }}
4443

44+
- name: Download rootfs artifacts
45+
uses: actions/download-artifact@v4
46+
with:
47+
name: rootfs-${{ inputs.arch }}
48+
path: rootfs
49+
4550
- run: ls -lR
4651

47-
- name: Install common dependencies
48-
run: sudo apt update && sudo apt install -y debootstrap
52+
# - name: Install common dependencies
53+
# run: sudo apt update && sudo apt install -y debootstrap
4954

5055
- name: Install x86_64 dependencies
5156
if: ${{ inputs.arch == 'x86_64' }}
52-
run: sudo apt install -y qemu-system-x86
57+
run: sudo apt update && sudo apt install -y qemu-system-x86
5358

5459
- name: Install arm64 dependencies
5560
if: ${{ inputs.arch == 'arm64' }}
56-
run: sudo apt install -y qemu-system-arm qemu-user-static binfmt-support
61+
run: sudo apt update && sudo apt install -y qemu-system-arm # qemu-user-static binfmt-support
5762

58-
- name: Initialize rootfs and initramfs
59-
shell: bash
60-
run: |
61-
set -x
63+
# - name: Initialize rootfs and initramfs
64+
# shell: bash
65+
# run: |
66+
# set -x
6267

63-
make rootfs-init
68+
# make rootfs-init
6469

65-
ALPINE_ROOTFS=alpine-${{ inputs.arch }}.img
66-
UBUNTU_ROOTFS=ubuntu-jammy-${{ inputs.arch }}.img
70+
# ALPINE_ROOTFS=alpine-${{ inputs.arch }}.img
71+
# UBUNTU_ROOTFS=ubuntu-jammy-${{ inputs.arch }}.img
6772

68-
ROOTFS=${ALPINE_ROOTFS} make rootfs-init
73+
# ROOTFS=${ALPINE_ROOTFS} make rootfs-init
6974

70-
scripts/ubuntu_debootstrap.sh jammy ${{ inputs.arch }}
71-
SUDO=1 ROOTFS_DIR=./rootfs/ubuntu-jammy-${{ inputs.arch }} CPIO_FILE=ubuntu-jammy-${{ inputs.arch }}.cpio.gz make rootfs-overlay
75+
# scripts/ubuntu_debootstrap.sh jammy ${{ inputs.arch }}
76+
# SUDO=1 ROOTFS_DIR=./rootfs/ubuntu-jammy-${{ inputs.arch }} CPIO_FILE=ubuntu-jammy-${{ inputs.arch }}.cpio.gz make rootfs-overlay
7277

73-
echo "ALPINE_ROOTFS=$ALPINE_ROOTFS" >> $GITHUB_OUTPUT
74-
echo "UBUNTU_ROOTFS=$UBUNTU_ROOTFS" >> $GITHUB_OUTPUT
78+
# echo "ALPINE_ROOTFS=$ALPINE_ROOTFS" >> $GITHUB_OUTPUT
79+
# echo "UBUNTU_ROOTFS=$UBUNTU_ROOTFS" >> $GITHUB_OUTPUT
7580

7681
- name: Setup shared/init.sh
7782
run: |
@@ -81,16 +86,32 @@ jobs:
8186
8287
- name: Run kernel
8388
run: |
84-
export QEMU_KERNEL_IMAGE=${{ inputs.artifact-dir }}/${{ inputs.kernel-image-name }}
89+
export QEMU_KERNEL_IMAGE=${{ inputs.artifact-dir }}/${{ inputs.kernel-image-name }}-${{ inputs.suffix }}
90+
91+
ALPINE_ROOTFS=alpine-${{ inputs.arch }}.img
92+
UBUNTU_ROOTFS=ubuntu-jammy-${{ inputs.arch }}.img
93+
UBUNTU_CPIO=ubuntu-jammy-${{ inputs.arch }}.cpio.gz
94+
95+
cp ./rootfs/${ALPINE_ROOTFS} ./${ALPINE_ROOTFS}
96+
cp ./rootfs/${UBUNTU_CPIO} ./${UBUNTU_CPIO}
8597
98+
# Run with default alpine rootfs
8699
make run
87-
ROOTFS=./rootfs/${{ env.UBUNTU_ROOTFS }} make run
100+
101+
# Run with ubuntu rootfs
102+
ROOTFS=./rootfs/${UBUNTU_ROOTFS} make run
103+
104+
# Run with default alpine cpio
88105
INITRD=1 make run
89-
INITRD=./ubuntu-jammy-${{ inputs.arch }}.cpio.gz make run
90-
CPU=2 MEM=2048M QEMU_EXTRA_ARGS="" QEMU_EXTRA_KERNEL_CMDLINE="nokaslr" ROOTFS=./${{ env.ALPINE_ROOTFS }} make run
91106
92-
- name: Upload rootfs artifact
93-
uses: actions/upload-artifact@v4
94-
with:
95-
name: rootfs-${{ inputs.SUFFIX }}
96-
path: rootfs/${{ env.ALPINE_ROOTFS }}
107+
# Run with ubuntu cpio in non-standard location
108+
INITRD=./${UBUNTU_CPIO} make run
109+
110+
# Run with alpine rootfs in non-standard location, with additional options
111+
CPU=2 MEM=2048M QEMU_EXTRA_ARGS="" QEMU_EXTRA_KERNEL_CMDLINE="nokaslr" ROOTFS=./${ALPINE_ROOTFS} make run
112+
113+
# - name: Upload rootfs artifact
114+
# uses: actions/upload-artifact@v4
115+
# with:
116+
# name: rootfs-${{ inputs.SUFFIX }}
117+
# path: rootfs/${{ env.ALPINE_ROOTFS }}

0 commit comments

Comments
 (0)