-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mostly a copy over from vmtest repo with a few pathing changes.
- Loading branch information
Showing
8 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# This job builds test kernels and uploads them to the `assets` dummy release. | ||
# | ||
# It works by looking at the KERNELS file in the repository and checks it | ||
# against all the already-uploaded kernels. | ||
|
||
name: Kernels | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
|
||
concurrency: | ||
# Ensure only a single instance of this job is run at any time | ||
group: ${{ github.ref }} | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build-upload: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Calculate needed kernels | ||
id: calculate | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
existing=$(gh release view test_assets --json assets --jq '.[][].name') | ||
# Begin multiline output parameter | ||
echo "NEEDED_KERNELS<<MULTILINE_EOF" >> "$GITHUB_OUTPUT" | ||
echo "$existing" | python3 -c ' | ||
import sys | ||
# Calculate kernels that have already been uploaded | ||
existing = {line.strip() for line in sys.stdin} | ||
with open("./KERNELS", "r") as f: | ||
lines = {line.strip() for line in f if line.strip()} | ||
# Print to stdout kernel we need to build and upload | ||
for line in lines: | ||
version = line.strip() | ||
name = f"bzImage-{version}" | ||
if name not in existing: | ||
print(line) | ||
' | tee -a "$GITHUB_OUTPUT" | ||
# End multiline output parameter | ||
echo "MULTILINE_EOF" >> "$GITHUB_OUTPUT" | ||
- name: Build needed kernels | ||
run: | | ||
while IFS= read -r version; do | ||
echo "Building: ${version}" | ||
./build.sh "$version" | ||
done <<< "${{ steps.calculate.outputs.NEEDED_KERNELS }}" | ||
- name: Upload freshly built kernels | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
for kernel in bzImage-*; do | ||
gh release upload test_assets "$kernel" | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v5.15 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
# | ||
# Build a vmtest ready kernel. | ||
# | ||
# Usage: | ||
# ./build.sh v6.2 | ||
|
||
set -eu | ||
|
||
# Formats a version string to a comparable number | ||
# eg. v1.2.3 => 1002003 | ||
function version { | ||
# Strip the leading 'v' | ||
local vstripped="${1:1}" | ||
echo "$vstripped" | awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }' | ||
} | ||
|
||
# Go to repo root | ||
cd "$(git rev-parse --show-toplevel)" | ||
|
||
if [[ $# -ne 1 ]]; then | ||
echo "Usage: $0 <kernel-tag>" | ||
exit 1 | ||
fi | ||
|
||
VERSION="$1" | ||
|
||
# Anything older than 5.15 we need to use alpine 3.16, which at the time of | ||
# writing is the oldest supported alpine version that contains all the build | ||
# deps (pahole in particular). We need old alpines to use an older GCC. Newer | ||
# GCCs have better warnings and they break old kernel builds. | ||
ALPINE_VERSION=3.18 | ||
if [[ $(version "$1") -le $(version "v5.15") ]]; then | ||
ALPINE_VERSION=3.16 | ||
fi | ||
|
||
# Build builder | ||
docker build \ | ||
--build-arg ALPINE_VERSION="$ALPINE_VERSION" \ | ||
--build-arg KERNEL_TAG="$1" \ | ||
-t vmtest-kernel-builder-"$VERSION" \ | ||
-f docker/Dockerfile.kernel \ | ||
. | ||
|
||
# Run builder | ||
docker run --rm -v "$(pwd):/output" vmtest-kernel-builder-"$VERSION" | ||
|
||
# Rename bzImage appropriately | ||
mv -f bzImage bzImage-"$VERSION" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
# | ||
# Build a vmtest ready kernel. | ||
# | ||
# Usage: | ||
# ./build.sh v6.2 | ||
|
||
set -eu | ||
|
||
# Formats a version string to a comparable number | ||
# eg. v1.2.3 => 1002003 | ||
function version { | ||
# Strip the leading 'v' | ||
local vstripped="${1:1}" | ||
echo "$vstripped" | awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }' | ||
} | ||
|
||
# Go to repo root | ||
cd "$(git rev-parse --show-toplevel)" | ||
|
||
if [[ $# -ne 1 ]]; then | ||
echo "Usage: $0 <kernel-tag>" | ||
exit 1 | ||
fi | ||
|
||
VERSION="$1" | ||
|
||
# Anything older than 5.15 we need to use alpine 3.16, which at the time of | ||
# writing is the oldest supported alpine version that contains all the build | ||
# deps (pahole in particular). We need old alpines to use an older GCC. Newer | ||
# GCCs have better warnings and they break old kernel builds. | ||
ALPINE_VERSION=3.18 | ||
if [[ $(version "$1") -le $(version "v5.15") ]]; then | ||
ALPINE_VERSION=3.16 | ||
fi | ||
|
||
# Build builder | ||
docker build \ | ||
--build-arg ALPINE_VERSION="$ALPINE_VERSION" \ | ||
--build-arg KERNEL_TAG="$1" \ | ||
-t vmtest-kernel-builder-"$VERSION" \ | ||
-f docker/Dockerfile.kernel \ | ||
. | ||
|
||
# Run builder | ||
docker run --rm -v "$(pwd):/output" vmtest-kernel-builder-"$VERSION" | ||
|
||
# Rename bzImage appropriately | ||
mv -f bzImage bzImage-"$VERSION" |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
ARG ALPINE_VERSION | ||
FROM alpine:${ALPINE_VERSION} | ||
|
||
RUN apk update && apk add \ | ||
bash \ | ||
bison \ | ||
build-base \ | ||
diffutils \ | ||
elfutils-dev \ | ||
findutils \ | ||
flex \ | ||
git \ | ||
gzip \ | ||
linux-headers \ | ||
pahole \ | ||
perl \ | ||
python3 \ | ||
openssl \ | ||
openssl-dev \ | ||
xz \ | ||
zstd | ||
|
||
WORKDIR / | ||
|
||
ARG KERNEL_REPO=https://github.com/torvalds/linux.git | ||
ARG KERNEL_TAG | ||
|
||
RUN git clone --depth 1 ${KERNEL_REPO} linux --branch ${KERNEL_TAG} | ||
WORKDIR linux | ||
|
||
COPY ./docker/config_kernel.sh config_kernel.sh | ||
COPY ./docker/build_kernel_container.sh build_kernel_container.sh | ||
COPY ./config config | ||
RUN ./config_kernel.sh | ||
|
||
ENTRYPOINT ["./build_kernel_container.sh"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# | ||
# Build kernel from inside container. | ||
# | ||
# Note this script expects the bind mounted output directly to be mounted | ||
# at /output. | ||
|
||
set -eux | ||
|
||
make -j "$(nproc)" bzImage | ||
bzimage=$(find . -type f -name bzImage) | ||
cp "$bzimage" /output |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
# | ||
# Configure a vmtest ready kernel. | ||
# | ||
# Run this inside kernel source tree root. | ||
|
||
set -eux | ||
|
||
# Set kconfig | ||
cat config/config config/config.x86_64 config/config.vm > .config | ||
make olddefconfig |