-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-video.func
253 lines (231 loc) · 6.21 KB
/
install-video.func
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#! /bin/bash
#=======================================
check_video_drivers(){
local INDEX CHIPSET_NAME DRIVERS DIR
DRIVERS=$1
VIDEO_CHIPSET=`echo $(lspci | grep -i --color vga) | tr a-z A-Z`
download_file_list "$DRIVERS";
if ! [ -f "${TMP_DIR}/install/$DRIVERS" ]; then
show_message FILE_NOT_FOUND "${TMP_DIR}/install/$DRIVERS"
exit 1
fi
INDEX=0
while read line ; do
CHIPSET_NAME[$INDEX]="$line"
INDEX=$(($INDEX+1))
done < ${TMP_DIR}/install/$DRIVERS
for i in "${CHIPSET_NAME[@]}"; do
if [ -z "$i" ]; then
continue
fi
echo "$VIDEO_CHIPSET" | grep "$i" > /dev/null
if [ "$?" = 0 ]; then
# yes
return 1
fi
done
# no
return 0
}
#=======================================
install_video_amd(){
local ARRAY AMSURE STR_READ OK
local VAL_ATI VAL_AMDGPU
show_message SPECIFY_VIDEO_DRIVER
show_message DO_NOT_INSTALL 0
ARRAY="0"
check_video_drivers "ati";
if [ $? = 1 ]; then
VAL_ATI="${#ARRAY}"
ARRAY="$ARRAY${VAL_ATI}"
show_message XF86_VIDEO_ATI ${VAL_ATI}
fi
check_video_drivers "amdgpu";
if [ $? = 1 ]; then
VAL_AMDGPU="${#ARRAY}"
ARRAY="$ARRAY${VAL_AMDGPU}"
show_message XF86_VIDEO_AMDGPU ${VAL_AMDGPU}
fi
STR_READ=`show_message CHOOSE_INSTALLATION_OPTION`
OK=0
while [ "${OK}" = 0 ] ; do
read -p "${STR_READ}" AMSURE
if [ "$ARRAY" = "${ARRAY#*$AMSURE}" ]; then
show_message NOT_RIGHT_VALUE
continue
else
OK=1
fi
done
if [ "${AMSURE}" = "0" ]; then
return 0
# no
elif [ "${AMSURE}" = "${VAL_ATI}" ]; then
install_pkg "xf86-video-ati" "y"
return 1
# yes
elif [ "${AMSURE}" = "${VAL_AMDGPU}" ]; then
install_pkg "xf86-video-amdgpu" "y"
sed -i $DIR_CHROOT/etc/mkinitcpio.conf -e 's|MODULES=()|MODULES=(amdgpu)|g'
chroot $DIR_CHROOT mkinitcpio -p linux$LINUX_VER
if ! [ -d $DIR_CHROOT/etc/X11/xorg.conf.d ]; then
mkdir $DIR_CHROOT/etc/X11/xorg.conf.d
fi
cp $DIR_CHROOT/usr/share/X11/xorg.conf.d/10-amdgpu.conf $DIR_CHROOT/etc/X11/xorg.conf.d/10-amdgpu.conf
return 1
# yes
fi
}
#=======================================
install_video_nvidia(){
local ARRAY AMSURE PREFIXDRIVER STR_READ OK
PREFIXDRIVER=""
ARRAY="012345"
show_message SPECIFY_VIDEO_DRIVER
show_message DO_NOT_INSTALL 0
show_message NVIDIA 1
show_message NVIDIA_390XX 2
show_message NVIDIA_340XX 3
show_message XF86_VIDEO_NOUVEAU 4
STR_READ=`show_message CHOOSE_INSTALLATION_OPTION`
OK=0
while [ "${OK}" = 0 ] ; do
read -p "${STR_READ}" AMSURE
if [ "$ARRAY" = "${ARRAY#*$AMSURE}" ]; then
show_message NOT_RIGHT_VALUE
continue
else
OK=1
fi
done
if [ "$AMSURE" = "0" ]; then
return 0
# no
elif [ "$AMSURE" = "2" ]; then
PREFIXDRIVER="-390xx";
elif [ "$AMSURE" = "3" ]; then
PREFIXDRIVER="-340xx";
elif [ "$AMSURE" = "4" ]; then
install_pkg "xf86-video-nouveau" "y"
return 1
# yes
fi
install_pkg "nvidia$PREFIXDRIVER$LINUX_VER" "y"
install_pkg "nvidia$PREFIXDRIVER-utils" "y"
install_pkg "opencl-nvidia$PREFIXDRIVER" "y"
install_pkg "libvdpau" "y"
install_pkg "nvidia$PREFIXDRIVER$LINUX_VER-dkms"
chroot $DIR_CHROOT nvidia-xconfig
return 1
# yes
}
#=======================================
install_video_vesa(){
local ARRAY AMSURE STR_READ OK
ARRAY="01"
show_message SPECIFY_VIDEO_DRIVER
show_message DO_NOT_INSTALL 0
show_message INSTALL_XF86_VIDEO_VESA 1
STR_READ=`show_message CHOOSE_INSTALLATION_OPTION`
OK=0
while [ "${OK}" = 0 ] ; do
read -p "${STR_READ}" AMSURE
if [ "$ARRAY" = "${ARRAY#*$AMSURE}" ]; then
show_message NOT_RIGHT_VALUE
continue
else
OK=1
fi
done
if [ "$AMSURE" = "0" ]; then
return 0
elif [ "$AMSURE" = "1" ]; then
install_pkg "xf86-video-vesa" "y"
return 1
fi
}
#=======================================
install_video_intel(){
local ARRAY AMSURE STR_READ OK
local VAL_INTEL VAL_NOMODESET
show_message SPECIFY_VIDEO_DRIVER
show_message DO_NOT_INSTALL 0
ARRAY="0"
check_video_drivers "intel";
if [ $? = 1 ]; then
VAL_INTEL="${#ARRAY}"
ARRAY="$ARRAY${VAL_INTEL}"
show_message INSTALL_XF86_VIDEO_INTEL ${VAL_INTEL}
fi
check_video_drivers "nomodeset";
if [ $? = 1 ]; then
VAL_NOMODESET="${#ARRAY}"
ARRAY="$ARRAY${VAL_NOMODESET}"
show_message INSTALL_NOMODESET ${VAL_NOMODESET}
fi
STR_READ=`show_message CHOOSE_INSTALLATION_OPTION`
OK=0
while [ "${OK}" = 0 ] ; do
read -p "${STR_READ}" AMSURE
if [ "$ARRAY" = "${ARRAY#*$AMSURE}" ]; then
show_message NOT_RIGHT_VALUE
continue
else
OK=1
fi
done
if [ "${AMSURE}" = "0" ]; then
return 0
# no
elif [ "${AMSURE}" = "${VAL_INTEL}" ]; then
install_pkg "xf86-video-intel" "y"
sed -i $DIR_CHROOT/etc/mkinitcpio.conf -e 's|MODULES=()|MODULES=(i915)|g'
chroot $DIR_CHROOT mkinitcpio -p linux$LINUX_VER
return 1
# yes
elif [ "${AMSURE}" = "${VAL_NOMODESET}" ]; then
install_pkg "libva-vdpau-driver lib32-libva-vdpau-driver libvdpau-va-gl vulkan-intel lib32-vulkan-intel lib32-mesa" "y"
return 1
# yes
fi
}
#=======================================
install_video_driver(){
local NVIDIA ATI INTEL VIDEO INSTALL_VIDEO
NOT_INSTALL_PKG=$(not_installed_pkg "xorg-server" "$DIR_CHROOT")
if [ -n "$NOT_INSTALL_PKG" ] ; then
installed_pkg "xorg-server" "$DIR_CHROOT"
if [ $? = 0 ]; then
return 1;
fi
fi
INSTALL_VIDEO="no"
VIDEO=`lspci | grep -i --color vga`
NVIDIA=`echo $VIDEO | grep "NVIDIA"`
if [ "${NVIDIA}" ]; then
install_video_nvidia
if [ $? = 1 ]; then
INSTALL_VIDEO="yes"
fi
fi
ATI=`echo ${VIDEO} | grep "RADEON\|ATI\|AMD"`
if [ "$ATI" ]; then
install_video_amd
if [ $? = 1 ]; then
INSTALL_VIDEO="yes"
fi
fi
INTEL=`echo ${VIDEO} | grep "Intel"`
if [ "${INTEL}" ]; then
install_video_intel
if [ $? = 1 ]; then
INSTALL_VIDEO="yes"
fi
fi
if [ "${INSTALL_VIDEO}" == "no" ]; then
install_video_vesa
if [ $? = 1 ]; then
INSTALL_VIDEO="yes"
fi
fi
}