From 0ed6da2895fea690a6f04e68e1f9004dcc648304 Mon Sep 17 00:00:00 2001 From: Cappy Ishihara Date: Sun, 5 Jan 2025 02:57:32 +0700 Subject: [PATCH] add back the accursed tarball script, we can port the thing later --- anda/system/nvidia/nvidia-driver/.gitignore | 4 + anda/system/nvidia/nvidia-driver/anda.hcl | 5 +- .../nvidia/nvidia-driver/nvidia-driver.spec | 52 +++----- .../nvidia-driver/nvidia-generate-tarballs.sh | 111 ++++++++++++++++++ 4 files changed, 133 insertions(+), 39 deletions(-) create mode 100644 anda/system/nvidia/nvidia-driver/.gitignore create mode 100755 anda/system/nvidia/nvidia-driver/nvidia-generate-tarballs.sh diff --git a/anda/system/nvidia/nvidia-driver/.gitignore b/anda/system/nvidia/nvidia-driver/.gitignore new file mode 100644 index 0000000000..cfb0b7a5cd --- /dev/null +++ b/anda/system/nvidia/nvidia-driver/.gitignore @@ -0,0 +1,4 @@ +nvidia*/ +NVIDIA*/ +*.tar.* +*.run \ No newline at end of file diff --git a/anda/system/nvidia/nvidia-driver/anda.hcl b/anda/system/nvidia/nvidia-driver/anda.hcl index 9a6fa84649..bf45a257bf 100644 --- a/anda/system/nvidia/nvidia-driver/anda.hcl +++ b/anda/system/nvidia/nvidia-driver/anda.hcl @@ -1,6 +1,9 @@ project "pkg" { rpm { spec = "nvidia-driver.spec" + # We run the negativo17 generator script here because I genuinely tried fixing the spec file with our fancy patch and it didn't work + # TODO: Port it inside the specfile scripts + pre_script = "nvidia-generate-tarballs.sh" } - arches = ["x86_64", "aarch64"] + arches = ["x86_64", "aarch64", "i386"] } \ No newline at end of file diff --git a/anda/system/nvidia/nvidia-driver/nvidia-driver.spec b/anda/system/nvidia/nvidia-driver/nvidia-driver.spec index 08556a25ce..96e237c79d 100644 --- a/anda/system/nvidia/nvidia-driver/nvidia-driver.spec +++ b/anda/system/nvidia/nvidia-driver/nvidia-driver.spec @@ -3,15 +3,6 @@ %global __brp_ldconfig %{nil} %define _build_id_links none -# We're gonna assume for now that we only build for -# x86_64 + x86 and aarch64 - -%ifarch x86_64 aarch64 -%global _target_cpu %{_arch} -%else -%global _target_cpu x86 -%endif - # systemd 248+ %if 0%{?rhel} == 8 %global _systemd_util_dir %{_prefix}/lib/systemd @@ -26,7 +17,9 @@ License: NVIDIA License URL: http://www.nvidia.com/object/unix.html ExclusiveArch: %{ix86} x86_64 aarch64 -Source0: http://download.nvidia.com/XFree86/Linux-%{_target_cpu}/%{version}/NVIDIA-Linux-%{_target_cpu}-%{version}.run +Source0: %{name}-%{version}-i386.tar.xz +Source1: %{name}-%{version}-x86_64.tar.xz +Source2: %{name}-%{version}-aarch64.tar.xz Source8: 70-nvidia-driver.preset Source9: 70-nvidia-driver-cuda.preset Source10: 10-nvidia.conf @@ -36,6 +29,7 @@ Source40: com.nvidia.driver.metainfo.xml Source41: parse-supported-gpus.py Source42: com.nvidia.driver.png +Source99: nvidia-generate-tarballs.sh %ifarch x86_64 aarch64 BuildRequires: libappstream-glib @@ -166,35 +160,17 @@ The NVIDIA X.org X11 driver and associated components. %endif %prep -sh %{SOURCE0} -x --target nvidia-driver-%{version}-%{_target_cpu} -%setup -T -D -n nvidia-driver-%{version}-%{_target_cpu} - -# Stuff not needed for packages: -# - Compiled from source -# - Interactive installer files -# - GLVND GL libraries -# - Internal development only libraries -rm -fr \ - nvidia-xconfig* \ - nvidia-persistenced* \ - nvidia-modprobe* \ - libnvidia-gtk* libnvidia-wayland-client* nvidia-settings* \ - libGLESv1_CM.so.* libGLESv2.so.* libGLdispatch.so.* libOpenGL.so.* libGLX.so.* libGL.so.1* libEGL.so.1* \ - libnvidia-egl-wayland.so.* libnvidia-egl-gbm.so.* libnvidia-egl-xcb.so.* libnvidia-egl-xlib.so.* \ - libOpenCL.so.1* \ - libEGL.so.${VERSION} \ - nvidia-installer* .manifest make* mk* tls_test* libglvnd_install_checker - -if [ "%{_arch}" == x86_64 ]; then - rm -fr \ - 32/libGLESv1_CM.so.* 32/libGLESv2.so.* 32/libGLdispatch.so.* 32/libOpenGL.so.* 32/libGLX.so.* 32/libGL.so.1* 32/libEGL.so.1* \ - 32/libOpenCL.so.1* \ - 32/libGL.so.${VERSION} 32/libEGL.so.${VERSION} \ - 32/libnvidia-egl-wayland.so.* 32/libnvidia-egl-gbm.so.* 32/libnvidia-egl-xcb.so.* 32/libnvidia-egl-xlib.so.* - - cp -f *.json* 32/ -fi +%ifarch %{ix86} +%setup -q -n %{name}-%{version}-i386 +%endif +%ifarch x86_64 +%setup -q -T -b 1 -n %{name}-%{version}-x86_64 +%endif + +%ifarch aarch64 +%setup -q -T -b 2 -n %{name}-%{version}-aarch64 +%endif %ifarch x86_64 %if 0%{?rhel} == 8 diff --git a/anda/system/nvidia/nvidia-driver/nvidia-generate-tarballs.sh b/anda/system/nvidia/nvidia-driver/nvidia-generate-tarballs.sh new file mode 100755 index 0000000000..45c36ab41a --- /dev/null +++ b/anda/system/nvidia/nvidia-driver/nvidia-generate-tarballs.sh @@ -0,0 +1,111 @@ +#!/bin/sh +CONTEXT=$(realpath $(dirname $0)) +set -e + +set_vars() { + export VERSION=${VERSION:-565.77} + export DL_SITE=${DL_SITE:-http://download.nvidia.com/XFree86} + export TEMP_UNPACK=${ARCH} + export PLATFORM=Linux-${ARCH} + export RUN_FILE=NVIDIA-${PLATFORM}-${VERSION}.run +} + +run_file_get() { + printf "Downloading installer ${RUN_FILE}... " + [[ -f $RUN_FILE ]] || wget -c -q ${DL_SITE}/${PLATFORM}/${VERSION}/$RUN_FILE + printf "OK\n" +} + +run_file_extract() { + rm -fr ${TEMP_UNPACK} + sh ${RUN_FILE} --extract-only --target ${TEMP_UNPACK} +} + +cleanup_folder() { + + printf "Cleaning up binaries... " + + cd ${TEMP_UNPACK} + + # Stuff not needed for packages: + # - Compiled from source + # - Interactive installer files + # - GLVND GL libraries + # - Internal development only libraries + rm -fr \ + nvidia-xconfig* \ + nvidia-persistenced* \ + nvidia-modprobe* \ + libnvidia-gtk* libnvidia-wayland-client* nvidia-settings* \ + libGLESv1_CM.so.* libGLESv2.so.* libGLdispatch.so.* libOpenGL.so.* libGLX.so.* libGL.so.1* libEGL.so.1* \ + libnvidia-egl-wayland.so.* libnvidia-egl-gbm.so.* libnvidia-egl-xcb.so.* libnvidia-egl-xlib.so.* \ + libOpenCL.so.1* \ + libEGL.so.${VERSION} \ + nvidia-installer* .manifest make* mk* tls_test* libglvnd_install_checker + + if [ "${ARCH}" == x86_64 ]; then + rm -fr \ + 32/libGLESv1_CM.so.* 32/libGLESv2.so.* 32/libGLdispatch.so.* 32/libOpenGL.so.* 32/libGLX.so.* 32/libGL.so.1* 32/libEGL.so.1* \ + 32/libOpenCL.so.1* \ + 32/libGL.so.${VERSION} 32/libEGL.so.${VERSION} \ + 32/libnvidia-egl-wayland.so.* 32/libnvidia-egl-gbm.so.* 32/libnvidia-egl-xcb.so.* 32/libnvidia-egl-xlib.so.* + + cp -f *.json* 32/ + fi + + cd .. + + printf "OK\n" +} + +create_tarball() { + + KMOD=nvidia-kmod-${VERSION}-${ARCH} + KMOD_COMMON=nvidia-kmod-common-${VERSION} + USR_64=nvidia-driver-${VERSION}-${ARCH} + + mkdir ${KMOD} ${KMOD_COMMON} ${USR_64} + mv ${TEMP_UNPACK}/kernel* ${KMOD}/ + mv ${TEMP_UNPACK}/firmware ${KMOD_COMMON}/ + + if [ "$ARCH" == x86_64 ]; then + + USR_32=nvidia-driver-${VERSION}-i386 + + mkdir ${USR_32} + mv ${TEMP_UNPACK}/32/* ${USR_32}/ + rm -fr ${TEMP_UNPACK}/32 + + fi + + mv ${TEMP_UNPACK}/* ${USR_64}/ + + rm -fr ${TEMP_UNPACK} + + for tarball in ${KMOD} ${KMOD_COMMON} ${USR_64} ${USR_32}; do + + printf "Creating tarball $tarball... " + + XZ_OPT='-T0' tar --remove-files -cJf $tarball.tar.xz $tarball + + printf "OK\n" + + done +} +pushd $CONTEXT + +ARCH=aarch64 +set_vars +run_file_get +run_file_extract +cleanup_folder +create_tarball + +ARCH=x86_64 +set_vars +run_file_get +run_file_extract +cleanup_folder +create_tarball + +popd \ No newline at end of file