From f7f923668f6ca583612f080681d532ece3317e7b Mon Sep 17 00:00:00 2001 From: RJ Trujillo Date: Sat, 21 Oct 2023 22:19:21 -0600 Subject: [PATCH] feat(nvidia): Attempt to support NVIDIA open --- .github/workflows/build.yml | 16 +++++++++++++++- Containerfile.nvidia | 5 +++-- build-kmod-nvidia.sh | 15 ++++++++++++--- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f36079f8..b2129f50 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,13 +25,22 @@ jobs: cfile_suffix: [common, nvidia] major_version: [37, 38, 39] nvidia_version: [0, 470, 535] + nvidia_variant: [none, proprietary, open] exclude: + - cfile_suffix: common + nvidia_variant: proprietary + - cfile_suffix: common + nvidia_variant: open - cfile_suffix: common nvidia_version: 470 - cfile_suffix: common nvidia_version: 535 + - cfile_suffix: nvidia + nvidia_variant: none - cfile_suffix: nvidia nvidia_version: 0 + - nvidia_variant: open + nvidia_version: 470 - kernel_flavor: asus major_version: 37 - kernel_flavor: surface @@ -50,7 +59,11 @@ jobs: # Generate a timestamp for creating an image version history TIMESTAMP="$(date +%Y%m%d)" if [[ "${{ matrix.cfile_suffix }}" == "nvidia" ]]; then - VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.major_version }}-${{ matrix.nvidia_version }}" + if [[ "${{ matrix.nvidia_variant }}" == "proprietary" ]]; then + VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.major_version }}-${{ matrix.nvidia_version }}" + else + VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.major_version }}-${{ matrix.nvidia_variant }}" + fi else VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.major_version }}" fi @@ -133,6 +146,7 @@ jobs: KERNEL_FLAVOR=${{ matrix.kernel_flavor }} FEDORA_MAJOR_VERSION=${{ matrix.major_version }} NVIDIA_MAJOR_VERSION=${{ matrix.nvidia_version }} + NVIDIA_DRIVER_VARIANT=${{ matrix.nvidia_variant }} labels: ${{ steps.meta.outputs.labels }} oci: false diff --git a/Containerfile.nvidia b/Containerfile.nvidia index f6fd0343..c79859fa 100644 --- a/Containerfile.nvidia +++ b/Containerfile.nvidia @@ -5,11 +5,12 @@ #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:-38}" +ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-39}" FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS builder -ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-38}" +ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-39}" ARG NVIDIA_MAJOR_VERSION="${NVIDIA_MAJOR_VERSION:-535}" +ARG NVIDIA_DRIVER_VARIANT="${NVIDIA_DRIVER_VARIANT:-proprietary}" ARG KERNEL_FLAVOR="{KERNEL_FLAVOR:-main}" COPY build*.sh /tmp diff --git a/build-kmod-nvidia.sh b/build-kmod-nvidia.sh index 2948701e..b3a3a05f 100755 --- a/build-kmod-nvidia.sh +++ b/build-kmod-nvidia.sh @@ -22,14 +22,24 @@ rpm-ostree install \ akmod-${NVIDIA_PACKAGE_NAME}*:${NVIDIA_MAJOR_VERSION}.*.fc${RELEASE} \ xorg-x11-drv-${NVIDIA_PACKAGE_NAME}-{,cuda,devel,kmodsrc,power}*:${NVIDIA_MAJOR_VERSION}.*.fc${RELEASE} +if [[ "${NVIDIA_DRIVER_VARIANT}" != "proprietary" ]]; then + rpm-ostree install rpmfusion-nonfree-release-tainted + rpm-ostree override replace --experimental \ + akmod-${NVIDIA_PACKAGE_NAME}*:${NVIDIA_MAJOR_VERSION}.*.fc${RELEASE} \ + --install akmod-${NVIDIA_PACKAGE_NAME}-${NVIDIA_DRIVER_VARIANT}*:${NVIDIA_MAJOR_VERSION}.*.fc${RELEASE} +fi + # Either successfully build and install the kernel modules, or fail early with debug output KERNEL_VERSION="$(rpm -q "${KERNEL_NAME}" --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}')" NVIDIA_AKMOD_VERSION="$(basename "$(rpm -q "akmod-${NVIDIA_PACKAGE_NAME}" --queryformat '%{VERSION}-%{RELEASE}')" ".fc${RELEASE%%.*}")" NVIDIA_LIB_VERSION="$(basename "$(rpm -q "xorg-x11-drv-${NVIDIA_PACKAGE_NAME}" --queryformat '%{VERSION}-%{RELEASE}')" ".fc${RELEASE%%.*}")" NVIDIA_FULL_VERSION="$(rpm -q "xorg-x11-drv-${NVIDIA_PACKAGE_NAME}" --queryformat '%{EPOCH}:%{VERSION}-%{RELEASE}.%{ARCH}')" - -akmods --force --kernels "${KERNEL_VERSION}" --kmod "${NVIDIA_PACKAGE_NAME}" +if [[ "${NVIDIA_DRIVER_VARIANT}" =~ "proprietary" ]]; then + akmods --force --kernels "${KERNEL_VERSION}" --kmod "${NVIDIA_PACKAGE_NAME}" +else + akmods --force --kernels "${KERNEL_VERSION}" --kmod "${NVIDIA_PACKAGE_NAME}"-"${NVIDIA_DRIVER_VARIANT}" +fi modinfo /usr/lib/modules/${KERNEL_VERSION}/extra/${NVIDIA_PACKAGE_NAME}/nvidia{,-drm,-modeset,-peermem,-uvm}.ko.xz > /dev/null || \ (cat /var/cache/akmods/${NVIDIA_PACKAGE_NAME}/${NVIDIA_AKMOD_VERSION}-for-${KERNEL_VERSION}.failed.log && exit 1) @@ -43,4 +53,3 @@ NVIDIA_FULL_VERSION=${NVIDIA_FULL_VERSION} NVIDIA_AKMOD_VERSION=${NVIDIA_AKMOD_VERSION} NVIDIA_LIB_VERSION=${NVIDIA_LIB_VERSION} EOF -