-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from ublue-os/akmods-impl
feat: initial shared akmods implementation
- Loading branch information
Showing
13 changed files
with
363 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 @@ | ||
* @castrojo |
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,5 @@ | ||
blank_issues_enabled: true | ||
contact_links: | ||
- name: Questions | ||
url: https://github.com/orgs/ublue-os/discussions/ | ||
about: Ask a question, share tips, and help others |
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,35 @@ | ||
name: Request a Package | ||
description: Request an RPM package to be included in an image | ||
labels: [package-request] | ||
|
||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Thank you for taking the time to fill out this request! | ||
- type: textarea | ||
id: describe-bug | ||
attributes: | ||
label: Describe the package | ||
description: Include why you feel this should be on the image | ||
placeholder: Tell us what you need | ||
value: "I'd like to request the package `vim` because ..." | ||
validations: | ||
required: true | ||
- type: dropdown | ||
id: image | ||
attributes: | ||
label: Image | ||
description: Which specific image do you want? | ||
options: | ||
- All Images | ||
- Bazzite | ||
- Kinoite | ||
- LXQt | ||
- Mate | ||
- Silverblue | ||
- Ubuntu | ||
- Vauxite | ||
validations: | ||
required: true | ||
|
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 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
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,164 @@ | ||
name: build-ublue | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '**.md' | ||
- '**.txt' | ||
schedule: | ||
- cron: '0 6 * * *' # 6am everyday (1h after 'config') | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '**.md' | ||
- '**.txt' | ||
env: | ||
IMAGE_NAME: akmods | ||
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} | ||
SOURCE_IMAGE: base | ||
|
||
jobs: | ||
push-ghcr: | ||
name: Build and push akmods image | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: read | ||
packages: write | ||
id-token: write | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
major_version: [37, 38] | ||
steps: | ||
# Checkout push-to-registry action GitHub repository | ||
- name: Checkout Push to Registry action | ||
uses: actions/checkout@v3 | ||
|
||
- name: Generate tags | ||
id: generate-tags | ||
shell: bash | ||
run: | | ||
# Generate a timestamp for creating an image version history | ||
TIMESTAMP="$(date +%Y%m%d)" | ||
VARIANT="${{ matrix.major_version }}" | ||
COMMIT_TAGS=() | ||
BUILD_TAGS=() | ||
# Have tags for tracking builds during pull request | ||
SHA_SHORT="${GITHUB_SHA::7}" | ||
COMMIT_TAGS+=("pr-${{ github.event.number }}-${VARIANT}") | ||
COMMIT_TAGS+=("${SHA_SHORT}-${VARIANT}") | ||
BUILD_TAGS=("${VARIANT}" "${VARIANT}-${TIMESTAMP}") | ||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
echo "Generated the following commit tags: " | ||
for TAG in "${COMMIT_TAGS[@]}"; do | ||
echo "${TAG}" | ||
done | ||
alias_tags=("${COMMIT_TAGS[@]}") | ||
else | ||
alias_tags=("${BUILD_TAGS[@]}") | ||
fi | ||
echo "Generated the following build tags: " | ||
for TAG in "${BUILD_TAGS[@]}"; do | ||
echo "${TAG}" | ||
done | ||
echo "alias_tags=${alias_tags[*]}" >> $GITHUB_OUTPUT | ||
- name: Retrieve akmods signing key | ||
run: | | ||
mkdir -p certs | ||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
echo "Using test signing key" | ||
else | ||
echo "${{ secrets.AKMOD_PRIVKEY_20230517 }}" > certs/private_key.priv | ||
fi | ||
# DEBUG: get character count of key | ||
wc -c certs/private_key.priv | ||
# Build metadata | ||
- name: Image Metadata | ||
uses: docker/metadata-action@v4 | ||
id: meta | ||
with: | ||
images: | | ||
${{ env.IMAGE_NAME }} | ||
labels: | | ||
org.opencontainers.image.title=${{ env.IMAGE_NAME }} | ||
org.opencontainers.image.description=An OCI image layer with pre-built driver (akmod) RPMs | ||
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/main/README.md | ||
io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/1728152?s=200&v=4 | ||
# Build image using Buildah action | ||
- name: Build Image | ||
id: build_image | ||
uses: redhat-actions/buildah-build@v2 | ||
with: | ||
containerfiles: | | ||
./Containerfile | ||
image: ${{ env.IMAGE_NAME }} | ||
tags: | | ||
${{ steps.generate-tags.outputs.alias_tags }} | ||
build-args: | | ||
SOURCE_IMAGE=${{ env.SOURCE_IMAGE }} | ||
FEDORA_MAJOR_VERSION=${{ matrix.major_version }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
oci: false | ||
|
||
# Workaround bug where capital letters in your GitHub username make it impossible to push to GHCR. | ||
# https://github.com/macbre/push-to-ghcr/issues/12 | ||
- name: Lowercase Registry | ||
id: registry_case | ||
uses: ASzc/change-string-case-action@v5 | ||
with: | ||
string: ${{ env.IMAGE_REGISTRY }} | ||
|
||
# Push the image to GHCR (Image Registry) | ||
- name: Push To GHCR | ||
uses: redhat-actions/push-to-registry@v2 | ||
id: push | ||
if: github.event_name != 'pull_request' | ||
env: | ||
REGISTRY_USER: ${{ github.actor }} | ||
REGISTRY_PASSWORD: ${{ github.token }} | ||
with: | ||
image: ${{ steps.build_image.outputs.image }} | ||
tags: ${{ steps.build_image.outputs.tags }} | ||
registry: ${{ steps.registry_case.outputs.lowercase }} | ||
username: ${{ env.REGISTRY_USER }} | ||
password: ${{ env.REGISTRY_PASSWORD }} | ||
extra-args: | | ||
--disable-content-trust | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
if: github.event_name != 'pull_request' | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Sign container | ||
- uses: sigstore/cosign-installer@v3.0.5 | ||
if: github.event_name != 'pull_request' | ||
|
||
- name: Sign container image | ||
if: github.event_name != 'pull_request' | ||
run: | | ||
cosign sign -y --key env://COSIGN_PRIVATE_KEY ${{ steps.registry_case.outputs.lowercase }}/${{ env.IMAGE_NAME }}@${TAGS} | ||
env: | ||
TAGS: ${{ steps.push.outputs.digest }} | ||
COSIGN_EXPERIMENTAL: false | ||
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }} | ||
|
||
- name: Echo outputs | ||
if: github.event_name != 'pull_request' | ||
run: | | ||
echo "${{ toJSON(steps.push.outputs) }}" |
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,13 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
name: release-please | ||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
with: | ||
release-type: node | ||
package-name: release-please-action |
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,27 @@ | ||
#Build from base, simpley because it's the smallest image | ||
ARG SOURCE_IMAGE="${SOURCE_IMAGE:-base}" | ||
ARG BASE_IMAGE="quay.io/fedora-ostree-desktops/${SOURCE_IMAGE}" | ||
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-37}" | ||
|
||
FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS builder | ||
|
||
COPY build*.sh /tmp | ||
COPY certs /tmp/certs | ||
COPY ublue-os-akmods-key.spec /tmp/ublue-os-akmods-key/ublue-os-akmods-key.spec | ||
|
||
RUN /tmp/build-prep.sh | ||
|
||
RUN /tmp/build-ublue-os-akmods-key.sh | ||
|
||
RUN /tmp/build-kmod-v4l2loopback.sh | ||
|
||
RUN mkdir /var/cache/rpms && \ | ||
for RPM in $(find /var/cache/akmods/ -type f -name \*.rpm); do \ | ||
echo ${RPM}; \ | ||
cp "${RPM}" /var/cache/rpms/; \ | ||
done && \ | ||
cp /tmp/ublue-os-akmods-key/rpmbuild/RPMS/noarch/ublue-os-akmods-key*.rpm /var/cache/rpms/ | ||
|
||
FROM scratch | ||
|
||
COPY --from=builder /var/cache/rpms /rpms |
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,19 @@ | ||
#!/bin/sh | ||
|
||
set -oeux pipefail | ||
|
||
|
||
### PREPARE REPOS | ||
ARCH="$(rpm -E '%_arch')" | ||
KERNEL="$(rpm -q kernel --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}')" | ||
RELEASE="$(rpm -E '%fedora')" | ||
|
||
|
||
### BUILD v4l2loopbak (succeed or fail-fast with debug output) | ||
rpm-ostree install \ | ||
akmod-v4l2loopback-*.fc${RELEASE}.${ARCH} | ||
V4L2LOOP_AKMOD_VERSION="$(basename "$(rpm -q "akmod-v4l2loopback" --queryformat '%{VERSION}-%{RELEASE}.${ARCH}')" ".fc${RELEASE%%.*}")" | ||
akmods --force --kernels "${KERNEL}" --kmod "v4l2loopback" | ||
modinfo /usr/lib/modules/${KERNEL}/extra/v4l2loopback/v4l2loopback.ko.xz > /dev/null \ | ||
|| (cat /var/cache/akmods/v4l2loopback/${V4L2LOOP_AKMOD_VERSION}-for-${KERNEL}.failed.log && exit 1) | ||
|
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,39 @@ | ||
#!/bin/sh | ||
|
||
set -oeux pipefail | ||
|
||
|
||
### PREPARE REPOS | ||
ARCH="$(rpm -E '%_arch')" | ||
RELEASE="$(rpm -E '%fedora')" | ||
|
||
sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/fedora-{cisco-openh264,modular,updates-modular}.repo | ||
|
||
wget -P /tmp/rpms \ | ||
https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-${RELEASE}.noarch.rpm \ | ||
https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-${RELEASE}.noarch.rpm | ||
|
||
# enable RPMs with alternatives to create them in this image build | ||
mkdir -p /var/lib/alternatives | ||
|
||
rpm-ostree install \ | ||
/tmp/rpms/*.rpm \ | ||
fedora-repos-archive | ||
|
||
|
||
### PREPARE BUILD ENV | ||
rpm-ostree install \ | ||
akmods \ | ||
mock | ||
|
||
if [[ ! -s "/tmp/certs/private_key.priv" ]]; then | ||
echo "WARNING: Using test signing key. Run './generate-akmods-key' for production builds." | ||
cp /tmp/certs/private_key.priv{.test,} | ||
cp /tmp/certs/public_key.der{.test,} | ||
fi | ||
|
||
install -Dm644 /tmp/certs/public_key.der /etc/pki/akmods/certs/public_key.der | ||
install -Dm644 /tmp/certs/private_key.priv /etc/pki/akmods/private/private_key.priv | ||
|
||
# protect against incorrect permissions in tmp dirs which can break akmods builds | ||
chmod 1777 /tmp /var/tmp |
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/sh | ||
|
||
set -oeux pipefail | ||
|
||
|
||
### BUILD UBLUE AKMODS-KEY RPM | ||
install -D /etc/pki/akmods/certs/public_key.der /tmp/ublue-os-akmods-key/rpmbuild/SOURCES/public_key.der | ||
rpmbuild -ba \ | ||
--define '_topdir /tmp/ublue-os-akmods-key/rpmbuild' \ | ||
--define '%_tmppath %{_topdir}/tmp' \ | ||
/tmp/ublue-os-akmods-key/ublue-os-akmods-key.spec | ||
|
Binary file not shown.
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,4 @@ | ||
-----BEGIN PUBLIC KEY----- | ||
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE7lh7fJMV4dBT2jT1XafixUJa7OVA | ||
cT+QFVD8IfIJIS/KBAc8hx1aslzkH3tfeM0cwyCLB7kOStZ4sh6RyFQD9w== | ||
-----END PUBLIC KEY----- |
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,33 @@ | ||
Name: ublue-os-akmods-key | ||
Version: 0.1 | ||
Release: 1%{?dist} | ||
Summary: Signing key for ublue os akmods | ||
|
||
License: MIT | ||
URL: https://github.com/ublue-os/akmods | ||
|
||
BuildArch: noarch | ||
Supplements: mokutil policycoreutils | ||
|
||
Source0: public_key.der | ||
|
||
%description | ||
Add the signing key for importing with mokutil to enable secure boot for kernel modules | ||
|
||
%prep | ||
%setup -q -c -T | ||
|
||
|
||
%build | ||
# Have different name for *.der in case kmodgenca is needed for creating more keys | ||
install -Dm0644 %{SOURCE0} %{buildroot}%{_datadir}/ublue-os/%{_sysconfdir}/pki/akmods/certs/akmods-ublue.der | ||
|
||
install -Dm0644 %{buildroot}%{_datadir}/ublue-os/%{_sysconfdir}/pki/akmods/certs/akmods-ublue.der %{buildroot}%{_sysconfdir}/pki/akmods/certs/akmods-ublue.der | ||
|
||
%files | ||
%attr(0644,root,root) %{_datadir}/ublue-os/%{_sysconfdir}/pki/akmods/certs/akmods-ublue.der | ||
%attr(0644,root,root) %{_sysconfdir}/pki/akmods/certs/akmods-ublue.der | ||
|
||
%changelog | ||
* Fri Mar 17 2034 David Hoell - 0.1 | ||
- Add key for inrolling ublue kernel modules with new build infrastucture |