File: nvidia-alternative.postinst.in

package info (click to toggle)
nvidia-graphics-drivers 340.65-2
  • links: PTS, VCS
  • area: non-free
  • in suites: jessie-kfreebsd
  • size: 130,340 kB
  • sloc: sh: 515,262; ansic: 457; makefile: 386; perl: 31
file content (94 lines) | stat: -rw-r--r-- 3,687 bytes parent folder | download
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
#!/bin/sh
set -e


TRIPLETS="/ /i386-linux-gnu/ /x86_64-linux-gnu/ /arm-linux-gnueabihf/"

add_slave()
{
	local target_link name source_path prefix
	target_link="$1"
	name="$2"
	source_path="$3"
	prefix="nvidia--"

	if [ -f "${source_path}" ] && [ -d "$(dirname "${target_link}")" ]; then
		echo --slave "${target_link}" "${prefix}${name}" "${source_path}"
	fi
}

add_multiarch_slave()
{
	local target_dir target_sub_dir file source_dir source_sub_dir prefix suffix triplet
	target_dir="$1"
	target_sub_dir="$2"
	file="$3"
	source_dir="$4"
	source_sub_dir="$5"
	prefix="$6"

	for triplet in $TRIPLETS ; do
		# s|/$||; s|^/|-|;
		suffix="${triplet%/}"
		suffix="${suffix:+-${suffix#/}}"
		add_slave \
			"${target_dir}${triplet}${target_sub_dir}${file}" \
			"${prefix}${file}${suffix}" \
			"${source_dir}${triplet}${source_sub_dir}${file}"
	done
}

# A trigger that handles the alternatives for /usr/lib[/<triplet>]/nvidia/*.*
if [ "$1" = "triggered" ]; then

	slaves="
		$(add_multiarch_slave /usr/lib nvidia/ libGL.so.1 /usr/lib #PRIVATE#/)
		$(add_multiarch_slave /usr/lib nvidia/ libEGL.so.1 /usr/lib #PRIVATE#/)
		$(add_multiarch_slave /usr/lib nvidia/ libGLESv1_CM.so.1 /usr/lib #PRIVATE#/)
		$(add_multiarch_slave /usr/lib nvidia/ libGLESv2.so.2 /usr/lib #PRIVATE#/)
		$(add_multiarch_slave /usr/lib nvidia/ libnvidia-cfg.so.1 /usr/lib #PRIVATE#/)
		$(add_slave /usr/lib/nvidia/libglx.so libglx.so /usr/lib/#PRIVATE#/libglx.so)
		$(add_slave /usr/lib/nvidia/nvidia_drv.so nvidia_drv.so /usr/lib/#PRIVATE#/nvidia_drv.so)
		$(add_multiarch_slave /usr/lib vdpau/ libvdpau_nvidia.so.1 /usr/lib #PRIVATE#/)
		$(add_multiarch_slave /usr/lib "" libcuda.so.1 /usr/lib #PRIVATE#/)
		$(add_multiarch_slave /usr/lib "" libcuda.so /usr/lib #PRIVATE#/)
		$(add_multiarch_slave /usr/lib "" libnvidia-opencl.so.1 /usr/lib #PRIVATE#/)
		$(add_multiarch_slave /usr/lib "" libnvidia-ifr.so.1 /usr/lib #PRIVATE#/)
		$(add_multiarch_slave /usr/lib "" libnvidia-fbc.so.1 /usr/lib #PRIVATE#/)
		$(add_multiarch_slave /usr/lib "" libnvidia-encode.so.1 /usr/lib #PRIVATE#/)
		$(add_multiarch_slave /usr/lib "" libnvcuvid.so.1 /usr/lib #PRIVATE#/)
		$(add_multiarch_slave /usr/lib "" libnvidia-ml.so.1 /usr/lib #PRIVATE#/)
		$(add_slave /usr/bin/nvidia-smi nvidia-smi /usr/lib/#PRIVATE#/nvidia-smi)
		$(add_slave /usr/share/man/man1/nvidia-smi.1.gz nvidia-smi.1.gz /usr/lib/#PRIVATE#/nvidia-smi.1.gz)
		$(add_slave /usr/lib/nvidia/nvidia-bug-report.sh nvidia-bug-report.sh /usr/lib/#PRIVATE#/nvidia-bug-report.sh)
		$(add_slave /usr/bin/nvidia-debugdump nvidia-debugdump /usr/lib/#PRIVATE#/nvidia-debugdump)
		$(add_slave /usr/share/nvidia/monitoring.conf monitoring.conf /usr/lib/#PRIVATE#/monitoring.conf)
		$(add_slave /usr/bin/nvidia-settings nvidia-settings /usr/lib/#PRIVATE#/nvidia-settings)
		$(add_slave /usr/bin/nv-control-dpy nv-control-dpy /usr/lib/#PRIVATE#/nv-control-dpy)
		$(add_slave /usr/share/applications/nvidia-settings.desktop nvidia-settings.desktop /usr/lib/#PRIVATE#/nvidia-settings.desktop)
		$(add_slave /usr/share/man/man1/nvidia-settings.1.gz nvidia-settings.1.gz /usr/lib/#PRIVATE#/nvidia-settings.1.gz)
"
	minor_slaves="
		$(add_slave /etc/modprobe.d/nvidia.conf nvidia-modprobe.conf /etc/nvidia/#NVIDIA#-modprobe.conf)
"
	if echo "$slaves" | grep -q "slave" ; then
		update-alternatives --install /usr/lib/nvidia/nvidia nvidia /usr/lib/#PRIVATE# #MAJOR# $slaves $minor_slaves
	else
		update-alternatives --remove nvidia /usr/lib/#PRIVATE#
	fi

	# activate the trigger selecting NVIDIA as GLX provider
	dpkg-trigger register-glx-alternative-nvidia

fi


if [ "$1" = "configure" ]; then

	# activate our trigger
	dpkg-trigger register-#NVIDIA_ALTERNATIVE#

fi


#DEBHELPER#