Skip to content

Add patch to export kvm_ioctl_rq_line function in Hedge #78

Add patch to export kvm_ioctl_rq_line function in Hedge

Add patch to export kvm_ioctl_rq_line function in Hedge #78

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will rrun.
on:
# Triggers the workflow on push or pull requeest events but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains two jobs. The first one will create a dynamic matrix to use as strategy for the second job
generate-matrix:
name: Generate matrix for build
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check changed files
id: folders
run: |
export folders=$( ls -1d */ )
echo "$folders"
# Escape newlines (replace \n with %0A)
echo "::set-output name=folders::$( echo "$folders" | sed ':a;N;$!ba;s/\n/%0A/g' )"
- name: Set matrix for build
id: set-matrix
run: |
folders="${{ steps.folders.outputs.folders }}"
JSON="{\"versions\":["
# Loop by lines
while read path; do
# Add item to the matrix only if it is not already included and remove /
path=${path%?}
JSONline="\"$path\","
if [[ "$JSON" != *"$JSONline"* ]]; then
JSON="$JSON$JSONline"
fi
done <<< "$folders"
# Remove last "," and add closing brackets
if [[ $JSON == *, ]]; then
JSON="${JSON%?}"
fi
JSON="$JSON], \"architecture\":[\"x86_64\", \"arm64\"]}"
echo $JSON
# Set output
echo "::set-output name=matrix::$( echo "$JSON" )"
Patch-Linux:
#tries to apply the patch to each version
needs: [generate-matrix]
runs-on: ["${{ matrix.architecture }}", "gcc"]
#strategy matrix to run jobs in parallel for each version
strategy:
matrix:
${{fromJson(needs.generate-matrix.outputs.matrix)}}
fail-fast: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINUX_VERSION: ${{ matrix.versions }}
ARCHITECTURE: ${{ matrix.architecture }}
steps:
- name: Cleanup previous runs
run: |
sudo rm -rf ${{ github.workspace }}/*
sudo rm -rf ${{ github.workspace }}/.??*
- uses: actions/checkout@v2
- name: install necessary packages
run: |
sudo apt-get -y update
sudo apt-get -y install build-essential libncurses-dev bc bison flex libssl-dev libelf-dev
sudo apt-get -y install fakeroot rsync git kmod cpio liblz4-tool
- name: Clone linux
run: |
cd $LINUX_VERSION
git clone https://github.com/torvalds/linux -b $LINUX_VERSION --depth 1 linux-$LINUX_VERSION
cd linux-$LINUX_VERSION
- name: Apply patches
id: apply-patch
#working-directory: linux-$LINUX_VERSION
run: |
echo ::set-output name=patch_exit_code::1
echo "MYMSG=Patching failed for version $LINUX_VERSION, architecture $ARCHITECTURE" >> $GITHUB_ENV
cd $LINUX_VERSION/linux-$LINUX_VERSION
for i in ../*.patch
do
git config user.name "CI Bot"
git config user.email "ci-bot@nubificus.co.uk"
git am $i
done
echo ::set-output name=patch_exit_code::0
#build the linux kernel for this version. will run only if patching has succeeded
- name: Build Kernel
id: build-kernel
if: steps.apply-patch.outputs.patch_exit_code == 0
#working-directory: linux-$LINUX_VERSION
run: |
echo ::set-output name=build_exit_code::1
deliverypath=$PWD
echo "MYMSG=Building failed for version $LINUX_VERSION, architecture $ARCHITECTURE" >> $GITHUB_ENV
cd $LINUX_VERSION/linux-$LINUX_VERSION
sudo mkdir -p artifacts/$ARCHITECTURE/$LINUX_VERSION
if [[ $ARCHITECTURE == "arm64" ]]
then
wget https://gist.githubusercontent.com/ananos/dc2e2323f1b9bcb93c24f307e367ae80/raw/a001e5dd3b02fb79001296b1f9ae39270288f8d9/aarch64_config -O arch/arm64/configs/hedge.config
else
#wget https://gist.githubusercontent.com/ananos/4749c77111a560503bd9725409d82800/raw/3e65dec157a7a19d965675054ef85ce8bc06c74b/basic%2520kernel%2520config -O arch/x86/configs/hedge.config
#wget https://gist.githubusercontent.com/ananos/1031c91aa16b2be8098d5d386b625c7e/raw/dd0d170ebd3480b420e715ce85da8d3c4b096fce/hedge-x86.config -O arch/x86/configs/hedge.config
wget https://gist.githubusercontent.com/ananos/1031c91aa16b2be8098d5d386b625c7e/raw/9df4f61e0bb60fecad2308def2835a9ed5cbfcda/hedge-x86.config -O arch/x86/configs/hedge.config
fi
touch .config
make hedge.config
make deb-pkg -j $(nproc)
echo ::set-output name=build_exit_code::$?
sudo mv ../*linux-headers*.deb artifacts/$ARCHITECTURE/$LINUX_VERSION/linux-headers-$LINUX_VERSION-latest.deb
if [[ $ARCHITECTURE == "arm64" ]]
then
sudo mv ../*linux-image*-dbg*.deb artifacts/$ARCHITECTURE/$LINUX_VERSION/linux-image-$LINUX_VERSION-dbg-latest.deb
fi
sudo mv ../*linux-image*.deb artifacts/$ARCHITECTURE/$LINUX_VERSION/linux-image-$LINUX_VERSION-latest.deb
sudo mv ../*linux-libc-dev*.deb artifacts/$ARCHITECTURE/$LINUX_VERSION/linux-libc-dev_$LINUX_VERSION-latest.deb
#If build was successful, upload the kernel deb artifacts for the hedge module builder to have available
- name: Upload Kernel artifact
id: upload-artifact
if: steps.build-kernel.outputs.build_exit_code == 0
uses: cloudkernels/minio-upload@master
with:
url: https://s3.nubificus.co.uk
access-key: ${{ secrets.AWS_ACCESS_KEY }}
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
local-path: ${{ matrix.versions }}/linux-${{ matrix.versions }}/artifacts/${{ matrix.architecture }}/${{ matrix.versions }}
remote-path: nbfc-assets/github/linux_kernel_debs/${{ matrix.architecture }}/
#some (safe) shenanigans to access this specific job's logs.
- name: Set logs link
if: ${{ failure() }}
run: |
curl -i -u ${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs > json.txt
idparser=$(awk '/${{ matrix.versions }}, ${{ matrix.architecture }}/{ print NR; exit }' json.txt)
idparser=$((idparser-11))
idparser=$(sed "$idparser q;d" json.txt)
idparser=$(echo $idparser | cut -c 7-)
echo "LOGLINK=https://github.com/${{ github.repository }}/runs/$idparser?check_suite_focus=true" >> $GITHUB_ENV
env:
REPO: ${{ github.repository }}
JID: ${{ github.run_id }}
- name: Create Issue
if: ${{ failure() && (steps.apply-patch.outputs.patch_exit_code != 0 || steps.build-kernel.outputs.build_exit_code != 0) }}
uses: JasonEtco/create-an-issue@v2