From 3304e2f048e23626d15287621727fb7acade116f Mon Sep 17 00:00:00 2001 From: Natalie Somersall Date: Mon, 11 Oct 2021 22:07:23 -0600 Subject: [PATCH] add action to build latest kernel --- .github/workflows/build-acs-kernel.yml | 18 ++++++++++++++++++ Dockerfile | 23 +++++++++++++++++++++++ action.yml | 7 +++++++ entrypoint.sh | 21 +++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 .github/workflows/build-acs-kernel.yml create mode 100644 Dockerfile create mode 100644 action.yml create mode 100644 entrypoint.sh diff --git a/.github/workflows/build-acs-kernel.yml b/.github/workflows/build-acs-kernel.yml new file mode 100644 index 0000000..d24c2e6 --- /dev/null +++ b/.github/workflows/build-acs-kernel.yml @@ -0,0 +1,18 @@ +on: workflow_dispatch + +jobs: + build: + runs-on: ubuntu-latest + name: Build the Fedora kernel with the ACS override patch in this repo + steps: + - name: Checkout this repo + uses: actions/checkout@v2 + + - name: Build the RPMs + uses: ./ + + - name: Upload the RPMs as artifacts + uses: actions/upload-artifact@v2 + with: + name: acs-override-rpms + path: ~/rpmbuild/RPMS/x86_64/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..42bc558 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM fedora:34 + +# Add RPM Fusion +RUN dnf install -y \ + https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \ + https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm + +# Update +RUN dnf update -y + +# Install build dependencies +RUN dnf install -y fedpkg fedora-packager rpmdevtools ncurses-devel pesign \ + bpftool bc bison dwarves elfutils-devel flex gcc gcc-c++ gcc-plugin-devel \ + hostname m4 make net-tools openssl openssl-devel perl-devel \ + perl-generators python3-devel + +# Setup build directory +RUN rpmdev-setuptree + +# Set up the entrypoint script +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..bf41c53 --- /dev/null +++ b/action.yml @@ -0,0 +1,7 @@ +name: 'Build ACS kernel' + +description: 'Build and upload the latest Fedora kernel RPMs with the ACS override patch' + +runs: + using: 'docker' + image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..3e33f24 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Download the latest kernel source RPM +koji download-build --arch=src kernel-"$(dnf list kernel | grep -Eo '[0-9]\.[0-9]+\.[0-9]+-[0-9]+')".fc34.src.rpm + +# Install the latest kernel source RPM +rpm -Uvh kernel-"$(dnf list kernel | grep -Eo '[0-9]\.[0-9]+\.[0-9]+-[0-9]+')".fc34.src.rpm + +# Install the build dependencies +cd ~/rpmbuild/SPECS/ && dnf builddep kernel.spec + +# Download the ACS override patch +curl -o ~/rpmbuild/SOURCES/add-acs-override.patch https://raw.githubusercontent.com/some-natalie/fedora-acs-override/main/acs/add-acs-override.patch + +# Edit the spec file with some sed magics +sed -i 's/# define buildid .local/%define buildid .acs/g' ~/rpmbuild/SPECS/kernel.spec +sed -i '/^Patch1:*/a Patch1000: add-acs-override.patch' ~/rpmbuild/SPECS/kernel.spec +sed -i '/^ApplyOptionalPatch patch-*/a ApplyOptionalPatch add-acs-override.patch' ~/rpmbuild/SPECS/kernel.spec + +# Build the things! +cd ~/rpmbuild/SPECS && rpmbuild -bb kernel.spec