Skip to content

Commit

Permalink
nvidia: split binaries and firmware packages
Browse files Browse the repository at this point in the history
  • Loading branch information
xtexChooser committed Dec 14, 2024
1 parent 453f5a9 commit 539d9df
Show file tree
Hide file tree
Showing 27 changed files with 213 additions and 109 deletions.
3 changes: 3 additions & 0 deletions runtime-display/nvidia-open/autobuild/build
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ make -C src install \
make -C doc install \
DESTDIR="$PKGDIR" \
PREFIX=/usr

abinfo "Installing XNVCtrl headers ..."
install -Dvm644 "src/libXNVCtrl/*.h" -t "$PKGDIR"/usr/include/NVCtrl
popd

pushd "$SRCDIR"/nvidia-xconfig
Expand Down
4 changes: 2 additions & 2 deletions runtime-display/nvidia-open/autobuild/defines
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ PKGNAME=nvidia-open
PKGSEC=x11
PKGDEP="libcl zlib opencl-registry-api xorg-server dkms \
libglvnd egl-wayland gtk-3 jansson libvdpau \
libxnvctrl vulkan"
PKGDES="The open-source control panel for NVIDIA cards drivers"
libxnvctrl vulkan nvidia-firmware nvidia-utils"
PKGDES="The open-source drivers suite for NVIDIA cards"
BUILDDEP="inetutils"

FAIL_ARCH="!(amd64|arm64)"
Expand Down
13 changes: 8 additions & 5 deletions runtime-display/nvidia-open/spec
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
VER=565.77
SRCS="git::rename=nvidia-driver;commit=tags/${VER}::https://github.com/NVIDIA/open-gpu-kernel-modules
git::rename=nvidia-settings;commit=tags/${VER}::https://github.com/NVIDIA/nvidia-settings
git::rename=nvidia-xconfig;commit=tags/${VER}::https://github.com/NVIDIA/nvidia-xconfig
git::rename=nvidia-persistenced;commit=tags/${VER}::https://github.com/NVIDIA/nvidia-persistenced"
_DRIVER_VER=565.77
# Note: sometimes utilities are not updated timely
_UTILS_VERS=565.57.01
VER=${_DRIVER_VER}+utils${_UTILS_VERS}
SRCS="git::rename=nvidia-driver;commit=tags/${_DRIVER_VER}::https://github.com/NVIDIA/open-gpu-kernel-modules
git::rename=nvidia-settings;commit=tags/${_UTILS_VERS}::https://github.com/NVIDIA/nvidia-settings
git::rename=nvidia-xconfig;commit=tags/${_UTILS_VERS}::https://github.com/NVIDIA/nvidia-xconfig
git::rename=nvidia-persistenced;commit=tags/${_UTILS_VERS}::https://github.com/NVIDIA/nvidia-persistenced"
CHKSUMS="SKIP
SKIP
SKIP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ sanity_check() {
# The regex glob matching so that should not be installed, due to
# - Incompatibility with with GLVND, or
# - A separate package containing this so.
BLACKLIST="(EGL|GL|GLESv1_CM|GLESv2|GLX|OpenGL|OpenCL|GLdispatch|nvidia-egl-wayland).so."
BLACKLIST="(EGL|GL|GLESv1_CM|GLESv2|GLX|OpenGL|OpenCL|GLdispatch|nvidia-egl-wayland|libnvidia-gtk3|libnvidia-wayland-client).so."
# Assuming pwd is in NVIDIA-Linux-${NV_ARCH}
abinfo "Checking whether all the .so provided has been installed"
_PROVIDED=$(find -maxdepth 1 -name "*.so.*" -exec basename {} \; | sort | sed -E "/${BLACKLIST}/d")
Expand All @@ -71,48 +71,7 @@ case "$ABHOST" in
abdie "Unsupported architecture"
esac


cd "$SRCDIR"/NVIDIA-Linux-${NV_ARCH}-${PKGVER}

if [[ -d "${SRCDIR}/autobuild/patches" ]]; then
abinfo "Patching kernel driver"
for i in $(find "${SRCDIR}/autobuild/patches/" -type f -name "*.patch" | sort); do
abinfo "Applying $(basename $i)"
(
cd kernel
patch -Np1 -i "$i"
)
done
else
abinfo "No kernel patches needed"
fi

cd kernel

abinfo "Processing DKMS configuration file..."
sed -i "s/__VERSION_STRING/$PKGVER/" dkms.conf
sed -i 's/__JOBS/`nproc`/' dkms.conf
sed -i 's/__DKMS_MODULES//' dkms.conf
sed -i '$iBUILT_MODULE_NAME[0]="nvidia"\
DEST_MODULE_LOCATION[0]="/kernel/drivers/video"\
BUILT_MODULE_NAME[1]="nvidia-uvm"\
DEST_MODULE_LOCATION[1]="/kernel/drivers/video"\
BUILT_MODULE_NAME[2]="nvidia-modeset"\
DEST_MODULE_LOCATION[2]="/kernel/drivers/video"\
BUILT_MODULE_NAME[3]="nvidia-drm"\
DEST_MODULE_LOCATION[3]="/kernel/drivers/video"\
BUILT_MODULE_NAME[4]="nvidia-peermem"\
DEST_MODULE_LOCATION[4]="/kernel/drivers/video"' dkms.conf

cd ..

abinfo "NVIDIA blacklist for Nouveau..."
install -dm 755 "$PKGDIR"/usr/{lib/modprobe.d,src}
cp -dr --no-preserve='ownership' kernel "$PKGDIR"/usr/src/nvidia-$PKGVER
echo 'blacklist nouveau' > "$PKGDIR"/usr/lib/modprobe.d/nvidia.conf

abinfo "NVIDIA Persistenced..."
tar xf nvidia-persistenced-init.tar.bz2
pushd "$SRCDIR"/NVIDIA-Linux-${NV_ARCH}-${PKGVER}

abinfo "Processing and installing OpenCL runtime..."
install_for_all 644 nvidia.icd "$PKGDIR"/etc/OpenCL/vendors
Expand Down Expand Up @@ -182,7 +141,8 @@ install_for_all 755 "libnvidia-api.so.1" "$PKGDIR"/usr/lib

abinfo "Wayland support libraries and platform files..."
install_for_all 755 "libnvidia-egl-gbm.so.1.1.2" "$PKGDIR"/usr/lib
install_if_amd64 755 "libnvidia-wayland-client.so.$PKGVER" "$PKGDIR"/usr/lib
# libnvidia-wayland-client.so is open-source

install -Dvm644 "15_nvidia_gbm.json" \
"$PKGDIR"/usr/share/egl/egl_external_platform.d/15_nvidia_gbm.json
mkdir -vp "$PKGDIR/usr/lib/gbm"
Expand Down Expand Up @@ -240,12 +200,6 @@ abinfo "Debug and core dump utility..."
install -Dvm755 nvidia-debugdump \
"$PKGDIR"/usr/bin/nvidia-debugdump

abinfo "NVIDIA X configurator..."
install -Dvm755 nvidia-xconfig \
"$PKGDIR"/usr/bin/nvidia-xconfig
install -Dvm644 nvidia-xconfig.1.gz \
"$PKGDIR"/usr/share/man/man1/nvidia-xconfig.1.gz

abinfo "NVIDIA Bug Reporter..."
install -Dvm755 nvidia-bug-report.sh \
"$PKGDIR"/usr/bin/nvidia-bug-report
Expand All @@ -270,29 +224,14 @@ install -Dvm4755 nvidia-modprobe \
install -Dvm644 nvidia-modprobe.1.gz \
"$PKGDIR"/usr/share/man/man1/nvidia-modprobe.1.gz

abinfo "NVIDIA Persistence Daemon..."
install -Dvm755 nvidia-persistenced \
"$PKGDIR"/usr/bin/nvidia-persistenced
install -Dvm644 nvidia-persistenced.1.gz \
"$PKGDIR"/usr/share/man/man1/nvidia-persistenced.1.gz
install -Dvm644 \
nvidia-persistenced-init/systemd/nvidia-persistenced.service.template \
"$PKGDIR"/usr/lib/systemd/system/nvidia-persistenced.service
sed -e 's/__USER__/nvidia-persistenced/' \
-i "$PKGDIR"/usr/lib/systemd/system/nvidia-persistenced.service

abinfo "Application profiles..."
install -Dvm644 nvidia-application-profiles-$PKGVER-rc \
"$PKGDIR"/usr/share/nvidia/nvidia-application-profiles-$PKGVER-rc
install -Dvm644 nvidia-application-profiles-$PKGVER-key-documentation \
"$PKGDIR"/usr/share/nvidia/nvidia-application-profiles-$PKGVER-key-documentation

abinfo "NVIDIA Control Panel..."
install_for_all 755 nvidia-settings "$PKGDIR"/usr/bin
install_for_all 644 nvidia-settings.1.gz "$PKGDIR"/usr/share/man/man1
install_for_all 644 nvidia-settings.png "$PKGDIR"/usr/share/pixmaps
install_for_all 755 libnvidia-gtk2.so.$PKGVER "$PKGDIR"/usr/lib
install_for_all 755 libnvidia-gtk3.so.$PKGVER "$PKGDIR"/usr/lib

abinfo "Power management services"
for i in suspend hibernate resume; do
Expand All @@ -305,10 +244,6 @@ install_for_all 755 nvidia-powerd "${PKGDIR}/usr/bin"
install_for_all 644 nvidia-dbus.conf "${PKGDIR}/usr/share/dbus-1/system.d"
install_for_all 644 systemd/system/nvidia-powerd.service "$PKGDIR"/usr/lib/systemd/system

abinfo "Card Firmware"
install_for_all 644 firmware/gsp_ga10x.bin "${PKGDIR}"/usr/lib/firmware/nvidia/${PKGVER}
install_for_all 644 firmware/gsp_tu10x.bin "${PKGDIR}"/usr/lib/firmware/nvidia/${PKGVER}

if ((NEED_FIX)); then
aberr "Additional files should be installed. See errors above."
abdir
Expand All @@ -327,14 +262,10 @@ ln -sv "libglxserver_nvidia.so.$PKGVER" \

abinfo "License and help texts"
for i in README.txt LICENSE NVIDIA_Changelog; do
install -Dvm644 $i "$PKGDIR"/usr/share/doc/nvidia/$i
install -Dvm644 $i "$PKGDIR"/usr/share/doc/nvidia-utils/$i
done

cd "$SRCDIR"

abinfo "Installing XNVCtrl headers ..."
install -Dvm644 "$SRCDIR"/nvidia-settings-*/src/libXNVCtrl/*.h \
-t "$PKGDIR"/usr/include/NVCtrl
popd

if [[ $NV_ARCH == "x86_64" ]]; then
abinfo "Installing optenv32 libraries"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,3 @@ install -Dvm755 "libnvidia-glvkspirv.so.$PKGVER" \
sanity_check "${PKGDIR}/opt/32"

create_links

cd ..

abinfo "Installing XNVCtrl headers ..."
install -Dvm644 "$SRCDIR"/nvidia-settings-*/src/libXNVCtrl/*.h \
-t "$PKGDIR"/opt/32/include/NVCtrl
14 changes: 14 additions & 0 deletions runtime-display/nvidia/01-utils/defines
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
PKGNAME=nvidia-utils
PKGSEC=x11
# Note: this package includes all proprietary binaries from NVIDIA driver that
# are not open-source.
# If a binary is both source-available and available in the proprietary
# .run driver package, please put its pre-built binary in nvidia
# and open source version in nvidia-open respectively.
PKGDES="The proprietary utilities for NVIDIA cards"

PKGCONFL="nvidia<=565.77"
PKGBREAK="nvidia<=565.77"
ABSTRIP=0

FAIL_ARCH="!(amd64|arm64)"
2 changes: 2 additions & 0 deletions runtime-display/nvidia/01-utils/prepare
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
abinfo "Extracting archive"
sh NVIDIA-Linux-$PKGVER.run --extract-only
22 changes: 22 additions & 0 deletions runtime-display/nvidia/02-firmware/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
NV_ARCH="undefined"

case "$ABHOST" in
amd64)
NV_ARCH="x86_64"
;;
arm64)
NV_ARCH="aarch64"
;;
*)
abdie "Unsupported architecture"
esac

pushd "$SRCDIR"/NVIDIA-Linux-${NV_ARCH}-${PKGVER}

abinfo "Installing GSP binaries ..."
install -Dvm644 firmware/gsp_ga10x.bin \
"${PKGDIR}"/usr/lib/firmware/nvidia/"${PKGVER}"/gsp_ga10x.bin
install -Dvm644 firmware/gsp_tu10x.bin \
"${PKGDIR}"/usr/lib/firmware/nvidia/"${PKGVER}"/gsp_tu10x.bin

popd
9 changes: 9 additions & 0 deletions runtime-display/nvidia/02-firmware/defines
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PKGNAME=nvidia-firmware
PKGSEC=x11
PKGDES="The proprietary GPS firmwares for NVIDIA cards"

PKGCONFL="nvidia<=565.77"
PKGBREAK="nvidia<=565.77"
ABSTRIP=0

FAIL_ARCH="!(amd64|arm64)"
135 changes: 135 additions & 0 deletions runtime-display/nvidia/03-kernel/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# vim: set expandtab sts=4 ts=4 sw=4:

create_links() {
# FIXME: libglxserver_nvidia.so has no soname so this function won't create a symlink for it
find "$PKGDIR" -type f -name '*.so*' ! -path '*xorg/*' -print0 | while read -d $'\0' _lib; do
_soname=$(dirname "${_lib}")/$(readelf -d "${_lib}" | grep -Po 'SONAME.*: \[\K[^]]*' || true)
_base=$(echo ${_soname} | sed -r 's/(.*).so.*/\1.so/')
if [[ -e "${_soname}" ]]; then
abwarn "${_lib} does not have soname! Not creating symlink for it"
else
ln -sv $(basename "${_lib}") "${_soname}"
fi
[[ -e "${_base}" ]] || ln -sv $(basename "${_soname}") "${_base}"
done
}

install_for_all() {
MOD="$1"
SRC="$2"
DESTDIR="$3"
install -Dvm${MOD} "$SRC" "$DESTDIR/$(basename ${SRC})"
return $?
}

NEED_FIX=0

install_if_amd64() {
MOD="$1"
SRC="$2"
DESTDIR="$3"
if [[ $NV_ARCH = x86_64 ]]; then
install -Dvm${MOD} "$SRC" "$DESTDIR/$(basename ${SRC})"
return $?
elif [[ -f "${SRC}" ]]; then
# Make sure the file really doesn't exist
aberr "File $SRC exists for non-amd64. Fix build scripts!"
# Set fail flag. Catch all errors in one go
NEED_FIX=1
fi
return 0
}

NV_ARCH="undefined"

case "$ABHOST" in
amd64)
NV_ARCH="x86_64"
;;
arm64)
NV_ARCH="aarch64"
;;
*)
abdie "Unsupported architecture"
esac


cd "$SRCDIR"/NVIDIA-Linux-${NV_ARCH}-${PKGVER}

if [[ -d "${SRCDIR}/autobuild/patches" ]]; then
abinfo "Patching kernel driver"
for i in $(find "${SRCDIR}/autobuild/patches/" -type f -name "*.patch" | sort); do
abinfo "Applying $(basename $i)"
(
cd kernel
patch -Np1 -i "$i"
)
done
else
abinfo "No kernel patches needed"
fi

cd kernel

abinfo "Processing DKMS configuration file..."
sed -i "s/__VERSION_STRING/$PKGVER/" dkms.conf
sed -i 's/__JOBS/`nproc`/' dkms.conf
sed -i 's/__DKMS_MODULES//' dkms.conf
sed -i '$iBUILT_MODULE_NAME[0]="nvidia"\
DEST_MODULE_LOCATION[0]="/kernel/drivers/video"\
BUILT_MODULE_NAME[1]="nvidia-uvm"\
DEST_MODULE_LOCATION[1]="/kernel/drivers/video"\
BUILT_MODULE_NAME[2]="nvidia-modeset"\
DEST_MODULE_LOCATION[2]="/kernel/drivers/video"\
BUILT_MODULE_NAME[3]="nvidia-drm"\
DEST_MODULE_LOCATION[3]="/kernel/drivers/video"\
BUILT_MODULE_NAME[4]="nvidia-peermem"\
DEST_MODULE_LOCATION[4]="/kernel/drivers/video"' dkms.conf

cd ..

abinfo "Installing kernel sources ..."
install -dm 755 "$PKGDIR"/usr/src
cp -dr --no-preserve='ownership' kernel "$PKGDIR"/usr/src/nvidia-$PKGVER

abinfo "Wayland support libraries and platform files ..."
install_if_amd64 755 "libnvidia-wayland-client.so.$PKGVER" "$PKGDIR"/usr/lib

abinfo "NVIDIA X configurator ..."
install -Dvm755 nvidia-xconfig \
"$PKGDIR"/usr/bin/nvidia-xconfig
install -Dvm644 nvidia-xconfig.1.gz \
"$PKGDIR"/usr/share/man/man1/nvidia-xconfig.1.gz

abinfo "NVIDIA Persistence Daemon..."
tar xf nvidia-persistenced-init.tar.bz2
install -Dvm755 nvidia-persistenced \
"$PKGDIR"/usr/bin/nvidia-persistenced
install -Dvm644 nvidia-persistenced.1.gz \
"$PKGDIR"/usr/share/man/man1/nvidia-persistenced.1.gz
install -Dvm644 \
nvidia-persistenced-init/systemd/nvidia-persistenced.service.template \
"$PKGDIR"/usr/lib/systemd/system/nvidia-persistenced.service
sed -e 's/__USER__/nvidia-persistenced/' \
-i "$PKGDIR"/usr/lib/systemd/system/nvidia-persistenced.service

abinfo "NVIDIA Control Panel..."
install_for_all 755 nvidia-settings "$PKGDIR"/usr/bin
install_for_all 644 nvidia-settings.1.gz "$PKGDIR"/usr/share/man/man1
install_for_all 644 nvidia-settings.png "$PKGDIR"/usr/share/pixmaps
install_for_all 755 libnvidia-gtk3.so.$PKGVER "$PKGDIR"/usr/lib

if ((NEED_FIX)); then
aberr "Additional files should be installed. See errors above."
abdir
fi

abinfo "Creating symbolic links for shared objects ..."
create_links

abinfo "License and help texts ..."
for i in README.txt LICENSE NVIDIA_Changelog; do
install -Dvm644 $i "$PKGDIR"/usr/share/doc/nvidia/$i
done

cd "$SRCDIR"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PKGNAME=nvidia
PKGSEC=x11
PKGDEP="libcl zlib opencl-registry-api xorg-server gtk-2 dkms \
libglvnd egl-wayland"
libglvnd egl-wayland nvidia-firmware nvidia-utils"
PKGDES="The proprietary drivers suite for NVIDIA cards"

PKGCONFL="mesa<=11.1.0 xorg-server<=1.18.0-2 nvidia+340 nvidia+390 nvidia-open"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blacklist nouveau
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
u nvidia-persistenced - "NVIDIA Persistence Daemon" / /bin/nologin
g nvidia-persistenced - -
m nvidia-persistenced nvidia-persistenced
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ if test -d /usr/lib/modules; then
done
fi

getent group nvidia-persistenced &>/dev/null || groupadd -g 143 nvidia-persistenced
getent passwd nvidia-persistenced &>/dev/null || useradd -c 'NVIDIA Persistence Daemon' -u 143 -g nvidia-persistenced -d '/' -s /sbin/nologin nvidia-persistenced

systemd-sysusers nvidia.conf
systemctl enable nvidia-persistenced
Loading

0 comments on commit 539d9df

Please sign in to comment.