forked from ublue-os/akmods
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-kmod-nvidia.sh
More file actions
executable file
·58 lines (44 loc) · 2.29 KB
/
build-kmod-nvidia.sh
File metadata and controls
executable file
·58 lines (44 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/bash
set "${CI:+-x}" -euo pipefail
ARCH="$(rpm -E '%_arch')"
KERNEL_MODULE_TYPE="${1:-kernel}"
DIST="$(rpm -E '%dist')"
DIST="${DIST#.}"
VARS_KERNEL_VERSION="$(rpm -q "${KERNEL_NAME}" --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}')"
if [[ "${KERNEL_FLAVOR}" =~ "centos" ]]; then
# enable negativo17
cp /tmp/ublue-os-nvidia-addons/rpmbuild/SOURCES/negativo17-epel-nvidia.repo /etc/yum.repos.d/
else
# disable rpmfusion and enable negativo17
sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/rpmfusion-*.repo
cp /tmp/ublue-os-nvidia-addons/rpmbuild/SOURCES/negativo17-fedora-nvidia.repo /etc/yum.repos.d/
fi
DEPRECATED_RELEASE="${DIST}.${ARCH}"
cd /tmp
### BUILD nvidia
# query latest available driver in repo
DRIVER_VERSION=$(dnf info nvidia-driver | grep -E '^Version|^Release' | awk '{print $3}' | xargs | sed 's/\ /-/')
# only install the version of akmod-nviida which matches available nvidia-driver
# this works around situations where a new version may be released but not for one arch
dnf install -y \
"akmod-nvidia-${DRIVER_VERSION}"
# Either successfully build and install the kernel modules, or fail early with debug output
rpm -qa |grep nvidia
KERNEL_VERSION="$(rpm -q "${KERNEL_NAME}" --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}')"
NVIDIA_AKMOD_VERSION="$(basename "$(rpm -q "akmod-nvidia" --queryformat '%{VERSION}-%{RELEASE}')" ".${DIST}")"
sed -i "s/^MODULE_VARIANT=.*/MODULE_VARIANT=$KERNEL_MODULE_TYPE/" /etc/nvidia/kernel.conf
akmods --force --kernels "${KERNEL_VERSION}" --kmod "nvidia"
modinfo /usr/lib/modules/"${KERNEL_VERSION}"/extra/nvidia/nvidia{,-drm,-modeset,-peermem,-uvm}.ko.xz > /dev/null || \
(cat /var/cache/akmods/nvidia/"${NVIDIA_AKMOD_VERSION}"-for-"${KERNEL_VERSION}".failed.log && exit 1)
# View license information
modinfo -l /usr/lib/modules/"${KERNEL_VERSION}"/extra/nvidia/nvidia{,-drm,-modeset,-peermem,-uvm}.ko.xz
# create a directory for later copying of resulting nvidia specific artifacts
mkdir -p /var/cache/rpms/kmods/nvidia
# TODO: remove deprecated RELEASE var which clobbers more typical meanings/usages of RELEASE
cat <<EOF > /var/cache/rpms/kmods/nvidia-vars
DIST_ARCH="${DIST}.${ARCH}"
KERNEL_VERSION=${VARS_KERNEL_VERSION}
KERNEL_MODULE_TYPE=${KERNEL_MODULE_TYPE}
RELEASE="${DEPRECATED_RELEASE}"
NVIDIA_AKMOD_VERSION=${NVIDIA_AKMOD_VERSION}
EOF