-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·613 lines (518 loc) · 15.4 KB
/
install.sh
File metadata and controls
executable file
·613 lines (518 loc) · 15.4 KB
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
#!/bin/bash
#######################################################################
# This is the DRI installation script. It compiles the kernel modules
# and installs the kernel, DRI and libGL modules.
#
# Frank Worsley <franco@nettaxi.com>
# Alan Hourihane <alanh@fairlite.demon.co.uk>
#
#######################################################################
###########################################################
# VARIABLE DEFINITIONS
###########################################################
LOGFILE="dri.log"
LOGFILE_TMP="tmp.log"
# Defaults
XF86_DIR="/usr/X11R6"
KERNEL_VER=`uname -r`
KERNEL_LIB_DIR="/lib/modules/$KERNEL_VER"
OPTION=$1
###########################################################
# FUNCTION DECLARATIONS
###########################################################
print_logo() {
################################################################
# This function prints a DRI logo and a general text header.
################################################################
clear
echo ""
echo "DIRECT RENDERING OPEN SOURCE PROJECT - DRIVER INSTALLATION SCRIPT"
echo ""
echo "[ http://dri.sourceforge.net ]"
echo ""
echo "=========================================================================="
echo ""
}
set_values() {
#####################################################################
# Sets up default values.
#####################################################################
# Determine driver to be installed
DRV_NAME=`echo "1 p" | ed -s pkginfo`
DRV_DESC=`echo "2 p" | ed -s pkginfo`
DRV_ARCH=`echo "3 p" | ed -s pkginfo`
DRV_DATE=`echo "4 p" | ed -s pkginfo`
DRV_MODULE=`echo "5 p" | ed -s pkginfo`
DRV_VERSION=`echo "6 p" | ed -s pkginfo`
DRV_BUILD_DESC=`echo "7 p" | ed -s pkginfo`
# Determine directories from default or user values
XF86_DRI_DIR="$XF86_DIR/lib/modules/dri"
XF86_DRV_DIR="$XF86_DIR/lib/modules/drivers"
XF86_GL_DIR="$XF86_DIR/lib"
XF86_EXT_DIR="$XF86_DIR/lib/modules/extensions"
XF86_OS_DIR="$XF86_DIR/lib/modules/linux"
KERNEL_DRM_DIR="$KERNEL_LIB_DIR/kernel/drivers/char/drm"
USE_EXISTING_KERNEL_MODULE="0"
}
check_values() {
#####################################################################
# Checks if default/user given values are correct.
#####################################################################
# Check if installation directories exist
MSG=$'The following problems have occured:\n'
FATAL=0
ERR=0
if [ ! -d "$XF86_DIR" ]; then
MSG="$MSG"$'\n - XFree86 directory does not exist'
ERR="1"
FATAL="1";
fi
if [ ! -d "$KERNEL_LIB_DIR" ]; then
MSG="$MSG"$'\n - Kernel module directory does not exist'
ERR="1"
FATAL="1";
fi
if [ ! -d "$KERNEL_DRM_DIR" ]; then
MSG="$MSG"$'\n - Kernel DRM directory does not exist'
ERR="1";
fi
if [ ! -d "$XF86_GL_DIR" ]; then
MSG="$MSG"$'\n - XFree86 GL library directory does not exist'
ERR="1";
fi
if [ ! -d "$XF86_DRI_DIR" ]; then
MSG="$MSG"$'\n - XFree86 DRI directory does not exist'
ERR="1";
fi
if [ ! -d "$XF86_DRV_DIR" ]; then
MSG="$MSG"$'\n - XFree86 driver directory does not exist'
ERR="1";
fi
if [ ! -d "$XF86_EXT_DIR" ]; then
MSG="$MSG"$'\n - XFree86 extensions directory does not exist'
ERR="1";
fi
if [ ! -d "$XF86_OS_DIR" ]; then
MSG="$MSG"$'\n - XFree86 Linux OS directory does not exist'
ERR="1";
fi
# No error so return
if [ "$ERR" == "0" ]; then
return 0;
fi
# Get out if we have a fatal error that requires user to re-enter values
if [ "$FATAL" == "1" ]; then
MSG="$MSG"$'\n\nPlease make sure you have entered all information correctly.\n\nPress ENTER to review the information.'
print_logo
echo "$MSG"
read KEY
return -1;
fi
#Fix what we can
MSG="$MSG"$'\n\nThe script can create these directories for you.\n\nPress ENTER to continue or CTRL-C to abort.'
print_logo
echo "$MSG"
read KEY
# Now we just create all directories no matter what ...
mkdir -p $XF86_GL_DIR
mkdir -p $XF86_DRI_DIR
mkdir -p $XF86_DRV_DIR
mkdir -p $XF86_EXT_DIR
mkdir -p $XF86_OS_DIR
mkdir -p $KERNEL_DRM_DIR
return 0;
}
copy_files() {
#####################################################################
# This function copies files to their destination directories.
#####################################################################
echo "Installing files:"
echo -n " DRI XFree86 modules..."
cd $DRV_NAME
for FILE in *drv.o
do
mv -f $XF86_DRV_DIR/$FILE $XF86_DRV_DIR/dri-old.$FILE >& $LOGFILE_TMP;
done
for FILE in *dri.so
do
mv -f $XF86_DRI_DIR/$FILE $XF86_DRI_DIR/dri-old.$FILE >& $LOGFILE_TMP;
done
cd ..
cp -f $DRV_NAME/*drv.o $XF86_DRV_DIR
cp -f $DRV_NAME/*dri.so $XF86_DRI_DIR
echo "done"
echo -n " kernel modules..."
if [ "$USE_EXISTING_KERNEL_MODULE" == "1" ]; then
echo "using existing module"
else
cd drm
mkdir -p $KERNEL_DRM_DIR
for FILE in *o
do
mv -f $KERNEL_DRM_DIR/$FILE $KERNEL_DRM_DIR/dri-old.$FILE >& $LOGFILE_TMP;
done
cd ..
cp -f drm/$DRV_MODULE.o $KERNEL_DRM_DIR
echo "done"
fi
#echo -n " GL & GLU libraries..."
#cd GL
#for FILE in *
#do
# mv -f $XF86_GL_DIR/$FILE $XF86_GL_DIR/dri-old.$FILE >& $LOGFILE_TMP;
#done
#cd ..
#cp -f GL/* $XF86_GL_DIR
#echo "done"
#echo -n " core libraries..."
#mv -f $XF86_EXT_DIR/libdri.a $XF86_EXT_DIR/dri-old.libdri.a >& $LOGFILE_TMP;
#cp -f core/libdri.a $XF86_EXT_DIR
#mv -f $XF86_EXT_DIR/libglx.a $XF86_EXT_DIR/dri-old.libglx.a >& $LOGFILE_TMP;
#cp -f core/libglx.a $XF86_EXT_DIR
#mv -f $XF86_EXT_DIR/libGLcore.a $XF86_EXT_DIR/dri-old.libGLcore.a >& $LOGFILE_TMP;
#cp -f core/libGLcore.a $XF86_EXT_DIR
#mv -f $XF86_OS_DIR/libdrm.a $XF86_OS_DIR/dri-old.libdrm.a >& $LOGFILE_TMP;
#cp -f core/libdrm.a $XF86_OS_DIR
#echo "done"
if [ -e extras/extras.sh ]; then
echo -n " Executing extras script..."
extras/extras.sh $XF86_DIR
fi
}
restore_files () {
print_logo
echo "Restoring files..."
echo -n " XFree86 modules..."
cd $DRV_NAME
for FILE in *drv.o
do
mv -f $XF86_DRV_DIR/dri-old.$FILE $XF86_DRV_DIR/$FILE >& $LOGFILE_TMP;
done
for FILE in *dri.so
do
mv -f $XF86_DRI_DIR/dri-old.$FILE $XF86_DRI_DIR/$FILE >& $LOGFILE_TMP;
done
cd ..
echo "done"
echo -n " kernel modules..."
cd drm
for FILE in *o
do
mv -f $KERNEL_DRM_DIR/dri-old.$FILE $KERNEL_DRM_DIR/$FILE >& $LOGFILE_TMP;
done
cd ..
echo "done"
#echo -n " system libraries..."
#cd GL
#for FILE in *
#do
# mv -f $XF86_GL_DIR/dri-old.$FILE $XF86_GL_DIR/$FILE >& $LOGFILE_TMP;
#done
#cd ..
#echo "done"
#echo -n " core libraries..."
#mv -f $XF86_EXT_DIR/dri-old.libdri.a $XF86_EXT_DIR/libdri.a >& $LOGFILE_TMP;
#mv -f $XF86_EXT_DIR/dri-old.libglx.a $XF86_EXT_DIR/libglx.a >& $LOGFILE_TMP;
#mv -f $XF86_EXT_DIR/dri-old.libGLcore.a $XF86_EXT_DIR/libGLcore.a >& $LOGFILE_TMP;
#mv -f $XF86_OS_DIR/dri-old.libdrm.a $XF86_OS_DIR/libdrm.a >& $LOGFILE_TMP;
#echo "done"
echo ""
echo "Completed restoring files."
}
update_config() {
#####################################################################
# This function updates the system configuration.
#####################################################################
echo ""
echo "Updating configuration:"
#echo -n " Running ldconfig..."
#grep "$XF86_DIR" /etc/ld.so.conf >& $LOGFILE_TMP
#if [ $? != 0 ]; then
# echo "$XF86_DIR/lib" >> /etc/ld.so.conf
#fi
#/sbin/ldconfig >& $LOGFILE_TMP
#if [ $? != 0 ]; then
# echo "ERROR";
# ERR=1
#else
# echo "done";
#fi
#cat $LOGFILE_TMP >> $LOGFILE
if [ ! "$X_RUNNING" == "1" ]; then
# Only try and update kernel modules if X server is not running
for MOD in $DRV_MODULE
do
echo -n " Removing old kernel module \"$MOD\"..."
/sbin/modprobe -r $MOD >& $LOGFILE_TMP
if [ $? != 0 ]; then
echo "ERROR"
ERR=1;
else
echo "done";
fi
cat $LOGFILE_TMP >> $LOGFILE
echo -n " Inserting new kernel module \"$MOD\"..."
/sbin/modprobe agpgart >& $LOGFILE_TMP
/sbin/modprobe $MOD >& $LOGFILE_TMP
if [ $? != 0 ]; then
echo "ERROR"
ERR=1;
else
echo "done";
fi
cat $LOGFILE_TMP >> $LOGFILE;
done;
fi
if [ "$ERR" == "1" ]; then
echo ""
echo "There were errors updating the system configuration."
echo "See the $LOGFILE file for more information.";
fi
rm $LOGFILE_TMP
}
check_config() {
#####################################################################
# This function checks the system configuration.
#####################################################################
echo ""
echo -n "Checking configuration..."
# Fix potential libGL problems
#LIBGL1=`ldd $XF86_DIR/bin/glxinfo | grep libGL.so.1 | awk -F" " '{ printf "%s",$3 }'`
#LIBGL=`echo $LIBGL1 | sed -e 's/\.1//'`
#if [ "$LIBGL" != "$XF86_GL_DIR/libGL.so" ]; then
# echo ""
# echo -n " second copy of DRI libraries found in "
# echo `echo $LIBGL1 | sed -e 's/libGL.so.1//'`
#
# echo -n " libraries have been backed up to old.* in "
# echo `echo $LIBGL1 | sed -e 's/libGL.so.1//'`
# echo ""
#
# mv $LIBGL1 `echo $LIBGL1 | sed -e 's/libGL.so.1/old.libGL.so.1/'`
# mv $LIBGL `echo $LIBGL | sed -e 's/libGL.so/old.libGL.so/'`
# ln -s $XF86_GL_DIR/libGL.so.1 $LIBGL1;
# ln -s $XF86_GL_DIR/libGL.so $LIBGL;
#fi
# Make sure libGL and libGLU have correct links
#rm -f $XF86_GL_DIR/libGL.so
#rm -f $XF86_GL_DIR/libGL.so.1
#ln -s $XF86_GL_DIR/libGL.so.1.2 $XF86_GL_DIR/libGL.so
#ln -s $XF86_GL_DIR/libGL.so.1.2 $XF86_GL_DIR/libGL.so.1
#rm -f $XF86_GL_DIR/libGLU.so
#rm -f $XF86_GL_DIR/libGLU.so.1
#ln -s $XF86_GL_DIR/libGLU.so.1.3 $XF86_GL_DIR/libGLU.so;
#ln -s $XF86_GL_DIR/libGLU.so.1.3 $XF86_GL_DIR/libGLU.so.1;
echo "done"
}
###########################################################
# MAIN SCRIPT
###########################################################
# Check if pkginfo file exists
if [ ! -e "pkginfo" ]; then
echo "Could not locate 'pkginfo' file. Aborting."
exit 127;
fi
# Check if we are running as root
if [ `whoami` != "root" ] && [ `whoami` != "ROOT" ]; then
echo "You must be root to install the DRI drivers."
exit 127;
fi
# Check if ed is installed
which ed &> /dev/null
if [ "$?" != "0" ]; then
echo "Could not located 'ed' editor. Aborting."
exit 127;
fi
### FIXME: We should check for matching architectures here!!! ###
# Figure out if we should restore files
if [ "$OPTION" == "restore" ]; then
print_logo
echo "This will restore your previous files."
echo ""
echo "XFree86 Dir : $XF86_DIR"
echo "Kernel Module Dir : $KERNEL_LIB_DIR"
echo ""
echo "Press ENTER to restore files or C to change defaults."
read KEY
if [ "$KEY" == "C" ] || [ "$KEY" == "c" ]; then
print_logo
echo "Enter new values and then press ENTER."
echo ""
echo -n "XFree86 Dir : "
read XF86_DIR
echo -n "Kernel Module Dir : "
read KERNEL_LIB_DIR
echo ""
echo "Press ENTER to restore files."
read KEY;
fi
set_values
restore_files
echo "";
exit 0;
fi
# Print X is running message
ps -C X > /dev/null
if [ $? == 0 ]; then
X_RUNNING=1
print_logo
echo "WARNING: YOUR X SERVER SEEMS TO BE RUNNING!"
echo ""
echo "The script can not update your kernel modules while the X server is running."
echo ""
echo "You can do one of the following:"
echo ""
echo "1. Log out of your X session now and then run this script."
echo ""
echo "2. Run the script now and restart your computer after the installation."
echo " If you exit your X session now you will not have to restart."
echo ""
echo "Press ENTER to continue or CTRL-C to exit."
read KEY ;
else
X_RUNNING=0;
fi
# Do misc stuff
rm $LOGFILE
touch $LOGFILE
# Setup the defaults values
set_values
# Print a welcome message
print_logo
echo "Welcome to the DRI Driver Installation Script"
echo ""
echo "The package you downloaded is for the following driver: "
echo ""
echo "Driver Name : $DRV_NAME"
echo "Description : $DRV_DESC"
echo "Architecture : $DRV_ARCH"
echo "Build Date : $DRV_DATE"
echo "Kernel Module : $DRV_MODULE"
echo ""
echo "Optional Information"
echo ""
echo "Driver Version : $DRV_VERSION"
echo "Special Description : $DRV_BUILD_DESC"
echo ""
echo "Press ENTER to continue or CTRL-C to exit."
read KEY
# Determine XFree86 Directory and Kernel Module directory from user input
ERR=-1;
while [ "$ERR" == "-1" ]; do
# Determine XFree86 directory
print_logo
echo "The script will need to copy the DRI XFree86 driver modules to"
echo "your XFree86 directory."
echo ""
echo "The script will use the following XFree86 directory:"
echo ""
echo " $XF86_DIR"
echo ""
echo "If this is correct press ENTER, press C to change or CTRL-C to exit."
read KEY
if [ "$KEY" == "C" ] || [ "$KEY" == "c" ]; then
print_logo
echo "Please enter the XFree86 directory you would like to use."
echo ""
echo "Press ENTER when done or CTRL-C to abort."
echo ""
echo -n "Directory: "
read XF86_DIR ;
fi
# Determine Kernel module directory
print_logo
echo "The script also needs to copy the DRM kernel modules to your"
echo "kernel module directory."
echo ""
echo "Please note that only 2.4.x kernels are supported right now."
echo ""
echo "Kernel Version : $KERNEL_VER"
echo "Module Directory : $KERNEL_LIB_DIR"
echo ""
echo "If this is correct press ENTER, press C to change or CTRL-C to exit."
read KEY
if [ "$KEY" == "C" ] || [ "$KEY" == "c" ]; then
print_logo
echo "Please enter your kernel module directory."
echo ""
echo "Press ENTER when done or CTRL-C to abort."
echo ""
echo -n "Directory: "
read KERNEL_LIB_DIR ;
fi
# Determine paths from user input or defaults
set_values
# Check if values are good
check_values
ERR="$?";
done
# Compile the kernel modules
print_logo
echo "The script will now compile the DRM kernel modules for your machine."
echo ""
echo "Press ENTER to continue or CTRL-C to exit."
read KEY
echo ""
echo -n "Compiling..."
cd drm
make -f Makefile.linux $DRV_MODULE.o >& ../$LOGFILE_TMP
if [ $? != 0 ]; then
cat ../$LOGFILE_TMP >> ../$LOGFILE
echo ""
echo ""
echo "ERROR: Kernel modules did not compile"
# Check to see if any older DRM module already exists
if [ -e $KERNEL_DRM_DIR/$DRV_MODULE.o ]; then
echo ""
echo "WARNING: The existing DRM kernel module available on your system might"
echo "work; however, using an older module may severly limit functionality"
echo "or performance!!! It is recommended that you upgrade to the latest"
echo "DRM kernel module. For further details see:"
echo ""
echo " http://dri.sourceforge.net/doc/DRIcompile.html#s4"
echo ""
echo "Press ENTER to continue with the existing kernel module or CTRL-C to exit."
read KEY
USE_EXISTING_KERNEL_MODULE="1"
else
cd ..
echo ""
echo "The DRI drivers can not be installed without the latest kernel modules."
echo "Installation will be aborted. See the $LOGFILE file for information on"
echo "what went wrong."
echo ""
exit 127;
fi
else
echo "done";
fi
cat ../$LOGFILE_TMP >> ../$LOGFILE
cd ..
# Print a last message
print_logo
echo "The script is now ready to complete the installation."
echo ""
echo "Press ENTER to continue or CTRL-C to exit."
read KEY
# Copy files, update config, check config and fix problems
print_logo
copy_files
update_config
check_config
echo ""
echo "Press ENTER to continue."
read KEY
# Print last message
print_logo
echo "The DRI installation is complete."
echo ""
echo "Restart your X server to try the new DRI drivers."
echo ""
echo "If you have problems with the DRI after upgrading your drivers"
echo "please visit the DRI website and read the Help and FAQ section."
echo "The FAQ contains solutions to many common problems."
echo ""
echo "Report any bugs, problems and comments on the dri-devel mailing list."
echo ""
echo "Thank you for using the DRI."
echo ""