blob: e91938c3c1331d2475e08bb781432040f40422a3 (
plain) (
blame)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
#!/bin/bash
fetch_source() {
local version url
mkdir -p src
cde src
for version in $NVIDIA_VERSIONS; do
for url in $REQUIRED_URL; do
url="${url//%VERSION%/$version}"
pinfo "Downloading '$url'"
wget -O "${version}.run" "$url" && continue 2
done
perror "Could not download installer for $version"
done
}
build() {
local bundle destdir builddir version
pdebug "--- chroot ---------------------------------------------------------------------"
pdebug "- -"
pdebug "- Notice: This may take a while! -"
pdebug "- -"
pdebug "- Please keep note the Nvidia installer _will_ complain about -"
pdebug "- several warnings and errors. It will do this in any case. -"
pdebug "- -"
pdebug "- This does _not_ mean the library module compilation was unsuccessful! -"
pdebug "- -"
pdebug "--------------------------------------------------------------------------------"
declare -A pciids
local file RESULT NVIDIA_MODULES drmfile filenum
filenum=10
for version in $NVIDIA_VERSIONS; do
bundle="${MODULE_WORK_DIR}/src/${version}.run"
builddir="${MODULE_BUILD_DIR}/${version}"
destdir="${builddir}/NVIDIA"
pdebug "Unpacking NVidia-Installer ..."
[ -d "$destdir" ] && rm -rf "$destdir"
sh "$bundle" --extract-only --target "$destdir" || perror "Could not extract $bundle to $destdir."
if ! [ -s "$builddir/supportedchips.html" ]; then
download "${REQUIRED_HTML//%VERSION%/$version}" "$builddir/supportedchips.html"
fi
local KMOD_ERROR="(ERROR: The nvidia kernel module was not created.|.ko failed to build)"
local KMOD_LOG="/var/log/nvidia-installer.kmod.log"
pinfo "Ready to chroot - may take some time."
chroot_run "${builddir}" <<-EOF
echo "Removing nvidia from /proc/modules so we can build on hosts with nvidia (....)"
ln -nfs /usr/bin/true /usr/sbin/lsmod
grep -v nvidia /proc/modules > /tmp/modules
mount --bind /tmp/modules /proc/modules
/NVIDIA/nvidia-installer --no-nouveau-check --no-backup --no-rpms \
--no-distro-scripts --no-cc-version-check --no-x-check --no-precompiled-interface --silent \
--skip-module-unload --no-kernel-module-source \
--no-nvidia-modprobe \
--log-file-name="$KMOD_LOG" --kernel-source-path "/$KERNEL_HEADERS_DIR"
grep -qE "$KMOD_ERROR" "$KMOD_LOG" \
|| /NVIDIA/nvidia-installer --no-nouveau-check --no-backup --no-rpms \
--no-distro-scripts --no-cc-version-check --no-x-check --no-precompiled-interface --silent \
--skip-module-unload --no-kernel-module-source \
--no-nvidia-modprobe \
--no-kernel-module
exit 0 # Fake it since it will try to load the module and probably fail
EOF
rm -f -- "${builddir}/usr/sbin/lsmod" # Don't want this outside the container
if grep -qE "$KMOD_ERROR" "${builddir}${KMOD_LOG}"; then
pwarning "Could not compile all kernel modules: $( grep -E "$KMOD_ERROR" "${builddir}${KMOD_LOG}" )"
perror "Bailing out..."
fi
pinfo "chroot terminated, cleaning up"
# move whiteout list to its /opt/openslx/etc/nvidia.whiteout (inside $builddir, for lib target)
if [ -e "${builddir}/overlay.whiteout.list" ]; then
mkdir -p "${builddir}/opt/openslx/etc"
mv "${builddir}/overlay.whiteout.list" "${builddir}/opt/openslx/etc/nvidia.whiteout"
fi
ldconfig -v -n -r "${builddir}" /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/vdpau/ /usr/lib/xorg/modules/extensions/
# These sometimes maybe don't get created
[ -f "${builddir}/usr/lib/x86_64-linux-gnu/vdpau/libvdpau_nvidia.so.${version}" ] \
&& ln -nfs "vdpau/libvdpau_nvidia.so.${version}" "${builddir}/usr/lib/x86_64-linux-gnu/libvdpau_nvidia.so"
if [ -f "${builddir}/usr/lib/x86_64-linux-gnu/libGLX_nvidia.so.${version}" ]; then
ln -nfs "libGLX_nvidia.so.${version}" "${builddir}/usr/lib/x86_64-linux-gnu/libGLX_nvidia.so.0"
ln -nfs "libGLX_nvidia.so.${version}" "${builddir}/usr/lib/x86_64-linux-gnu/libGLX_indirect.so.0"
fi
[ -f "${builddir}/usr/lib/xorg/modules/extensions/libglxserver_nvidia.so.${version}" ] \
&& ln -nfs "libglxserver_nvidia.so.${version}" "${builddir}/usr/lib/xorg/modules/extensions/libglxserver_nvidia.so"
# Kernel related - outside of version subdir ($builddir)
NVIDIA_MODULES="${MODULE_BUILD_DIR}/lib/modules/nvidia/${version}"
mkdir -p "$NVIDIA_MODULES"
pinfo "Copying kernel modules..."
for file in nvidia.ko nvidia-uvm.ko nvidia-modeset.ko nvidia-drm.ko; do
RESULT=$(find "$builddir/NVIDIA/kernel" -name "$file" | head -n 1)
[ -z "$RESULT" ] && perror "Could not find built module $file in ./NVIDIA/kernel"
pinfo "Fetching ${file}..."
strip -g "$RESULT" || pwarning "Could not strip $file"
cp "$RESULT" "$NVIDIA_MODULES" || perror "Could not copy $file"
done
mkdir -p "${MODULE_BUILD_DIR}/drm.cfg.d"
drmfile="${MODULE_BUILD_DIR}/drm.cfg.d/$(( filenum++ ))-nvidia-$version"
cat > "$drmfile" <<-BLOFF
@nvidia-${version} acpi_ipmi nvidia/$version/nvidia.ko nvidia/$version/nvidia-uvm.ko nvidia/$version/nvidia-modeset.ko nvidia/$version/nvidia-drm.ko
@nvidia-${version}_fallback nouveau
BLOFF
if ! [ -s "${builddir}/supportedchips.html" ]; then
pwarning "No supportedchips.html -- THE GOGGLES, THEY DO NOTHING!"
else
local mode line dev version
pinfo "Creating drm.cfg"
local regex='^<td[^>]*>([0-9A-F]{4})(\s+[0-9A-F]{4}\s+[0-9A-F]{4})?<'
mode=0
while read -r line; do
if [[ "$line" =~ '<a name="legacy_' ]]; then
break # For now, we stop here; older versions will be fetched from their own html file
elif [[ "$mode" = 0 ]] && [[ "$line" =~ ^'<tr' ]]; then
mode=1
elif [[ "$mode" = 1 ]] && [[ "$line" =~ ^'<td' ]]; then
mode=2
elif [[ "$mode" = 2 ]] && [[ "$line" =~ $regex ]]; then
mode=0
dev="${BASH_REMATCH[1]}"
dev="${dev~~}"
if [ -n "${pciids[$dev]}" ]; then
pdebug "$dev already handled"
else
echo "10de:$dev @nvidia-$version"
pciids[$dev]=1
fi
else
mode=0
dev=
fi
done < "${builddir}/supportedchips.html" >> "$drmfile"
fi
rm -rf -- "$destdir"
done
}
post_copy() {
:
}
|