Skip to content

Commit

Permalink
add config switch to build latest kernel or longterm.
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume committed Nov 30, 2024
1 parent 0033335 commit 98693b3
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 22 deletions.
3 changes: 3 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
ARG BASE_IMAGE="${BASE_IMAGE}"
ARG FEDORA_VERSION="${FEDORA_VERSION}"
ARG NVIDIA_VERSION="${NVIDIA_VERSION}"
ARG USE_LTS_KERNEL="${USE_LTS_KERNEL}"

# Build NVIDIA drivers and other source packages

FROM ${BASE_IMAGE}:${FEDORA_VERSION} as builder
ARG NVIDIA_VERSION="${NVIDIA_VERSION}"
ARG USE_LTS_KERNEL="${USE_LTS_KERNEL}"
ARG BUILDROOT=/build
COPY build_files/ "${BUILDROOT}"
RUN rpm-ostree cliwrap install-to-root / \
Expand All @@ -15,6 +17,7 @@ RUN rpm-ostree cliwrap install-to-root / \

FROM ${BASE_IMAGE}:${FEDORA_VERSION}
ARG NVIDIA_VERSION="${NVIDIA_VERSION}"
ARG USE_LTS_KERNEL="${USE_LTS_KERNEL}"
ARG BUILDROOT=/build

# Copy build scripts
Expand Down
30 changes: 24 additions & 6 deletions build_files/playbooks/install-packages.ansible.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- name: Install packages
hosts: localhost
vars:
kernel_longterm: 1 # Install the longterm kernel from copr
with_nvidia: 1 # Install the nvidia drivers and kernel modules
# kernel_longterm: false # Install the longterm kernel from copr
with_nvidia: true # Install the nvidia drivers and kernel modules
tasks:

- name: Install longterm kernel
Expand All @@ -12,7 +12,7 @@
args:
executable: /bin/bash
changed_when: false
when: kernel_longterm is defined and kernel_longterm == 1
when: kernel_longterm|bool

- name: Get kernel version
ansible.builtin.shell: |
Expand All @@ -36,15 +36,15 @@
- nvidia-peermem.ko
- nvidia-uvm.ko
- nvidia.ko
when: with_nvidia and with_nvidia == 1
when: with_nvidia

- name: Kernel depmod
ansible.builtin.shell: |
depmod {{ kernel_version }}
register: result
failed_when: result.rc != 0
changed_when: false
when: with_nvidia and with_nvidia == 1
when: with_nvidia

- name: Install ansible dnf
ansible.builtin.shell: |
Expand Down Expand Up @@ -106,7 +106,25 @@
register: result
failed_when: result.rc != 0
changed_when: false
when: with_nvidia and with_nvidia == 1
when: with_nvidia

- name: Install hyprland copr repo
ansible.builtin.shell: |
set -oeux pipefail
dnf5 copr enable solopasha/hyprland -y
changed_when: false

- name: Install hyprland packages
ansible.builtin.dnf:
name:
- hyprland
- hyprland-plugins
- hyprlock
- hyprpaper
- hyprsunset
- eww-git
- waybar-git
state: present

- name: Cleanup container
ansible.builtin.shell: |
Expand Down
22 changes: 11 additions & 11 deletions build_files/scripts/build-nvidia-modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ disable-repo /etc/yum.repos.d/fedora-updates-testing.repo
mkdir -p /tmp/nvidia
cd /tmp/nvidia

# if [ ${USE_LTS_KERNEL} = true ]; then
source "$(dirname "$0")"/kernel-installer.sh --devel
KERNEL_VERSION=$(rpm -q --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}' kernel-longterm-devel)
# else
# # Install build requirements
# # Getting kernel source from Koji in order to avoid build failure when silverblue image kernel is outdated
# dnf install koji g++ kmod patch -y
# koji download-build --arch="${ARCH}" kernel-"${KERNEL_VERSION}"
# dnf install -y kernel-devel-*.rpm
# rm -rf /tmp/nvidia/*.rpm
# fi
if [ ${USE_LTS_KERNEL} = true ]; then
source "$(dirname "$0")"/kernel-installer.sh --devel
KERNEL_VERSION=$(rpm -q --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}' kernel-longterm-devel)
else
# Install build requirements
# Getting kernel source from Koji in order to avoid build failure when silverblue image kernel is outdated
dnf install koji g++ kmod patch -y
koji download-build --arch="${ARCH}" kernel-"${KERNEL_VERSION}"
dnf install -y kernel-devel-*.rpm
rm -rf /tmp/nvidia/*.rpm
fi

# Clone open NVIDIA kernel modules from Github
git clone --depth 1 --branch "${NVIDIA_VERSION}" https://github.com/NVIDIA/open-gpu-kernel-modules /tmp/nvidia/src
Expand Down
1 change: 1 addition & 0 deletions build_files/scripts/config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
TARGET_IMAGE_NAME=perpixel-silverblue
BASE_IMAGE=quay.io/fedora-ostree-desktops/silverblue
FEDORA_VERSION=41
USE_LTS_KERNEL=true
NVIDIA_VERSION=565.57.01 # beta
# NVIDIA_VERSION=560.35.03 # new feature branch
# NVIDIA_VERSION=550.135 # stable
3 changes: 2 additions & 1 deletion build_files/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ rpm-ostree cliwrap install-to-root /
dnf install -y ansible

# run installation
ansible-playbook ${BUILDROOT}/playbooks/install-packages.ansible.yaml -e buildroot=${BUILDROOT} -e fedora_version=41
ansible-playbook ${BUILDROOT}/playbooks/install-packages.ansible.yaml \
--extra-vars "kernel_longterm=${USE_LTS_KERNEL} buildroot=${BUILDROOT} fedora_version=${FEDORA_VERSION}"
1 change: 1 addition & 0 deletions local_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ buildah bud --pull=true \
--build-arg BASE_IMAGE=${BASE_IMAGE} \
--build-arg FEDORA_VERSION=${FEDORA_VERSION} \
--build-arg NVIDIA_VERSION=${NVIDIA_VERSION} \
--build-arg USE_LTS_KERNEL=${USE_LTS_KERNEL} \
--no-cache \
--pull=always \
--volume $(pwd):/workspace:z \
Expand Down
6 changes: 6 additions & 0 deletions nvidia-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ echo Services:
for service in "${services[@]}"; do
echo " $service: $(systemctl is-enabled ${service})"
done
echo

echo "### Nvidia services status"
if command -v rpm &> /dev/null; then
echo "$(rpm -qa | grep -E 'gnome-session|xorg')"
fi
6 changes: 2 additions & 4 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/bash

NVIDIA_VERSION="565.57.01"
FEDORA_VERSION=41
IMAGE=quay.io/fedora-ostree-desktops/silverblue:${FEDORA_VERSION}
source ./build_files/scripts/config.sh

while [[ $# -gt 0 ]]; do
case $1 in
Expand All @@ -28,7 +26,7 @@ done
podman pull ${IMAGE}

if [ "${TEST_NVIDIA}" == true ] || [ "${TEST_ALL}" == true ]; then
podman run -it --rm -e NVIDIA_VERSION="${NVIDIA_VERSION}" -e BUILDROOT="/build" -v ./build_files/:/build ${IMAGE} /build/scripts/build-nvidia-modules.sh
podman run -it --rm -e NVIDIA_VERSION="${NVIDIA_VERSION}" -e USE_LTS_KERNEL="${USE_LTS_KERNEL}" -e BUILDROOT="/build" -v ./build_files/:/build ${BASE_IMAGE}:${FEDORA_VERSION} /build/scripts/build-nvidia-modules.sh
fi

if [ "${TEST_PACKAGES}" == true ] || [ "${TEST_ALL}" == true ]; then
Expand Down

0 comments on commit 98693b3

Please sign in to comment.