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
|
#!/bin/bash
#
#
# general: linking libGL.so and stuff to writable locations
#
#
PLUGIN_PATH="/opt/openslx/plugin-repo/xserver/"
# this has to be writable in stage3
LINK_PATH="/var/X11R6/lib/"
# these are to link libs to
ATIROOT="${PLUGIN_PATH}ati"
NVROOT="${PLUGIN_PATH}nvidia"
# this is the diversion path of libraries
if [ ! -d "${LINK_PATH}" ]; then
mkdir -p "${LINK_PATH}"
fi
VAL=0 # this is the return value of following helper functions
stripstr() {
VAL=$(echo ${1} | sed -e "s,^${2},,g")
}
stripbase() {
VAL=$(echo ${1} | sed -e "s,$(basename ${1}),,g")
}
## additional helper functions without return value
# moves mesa lib to backup
mvmesa() {
MESALIB="$(echo ${1} | sed -e 's,\.so,_MESA.so,g')"
mv ${1} ${MESALIB}
}
# makes dir, if not exists
testmkdir() {
if [ ! -d ${1} ]; then
mkdir -p ${1}
fi
}
#######################################
#
# Link all files FROM $1 to /usr/lib/
#
# Conflicting files are linked to
# /var/X11R6/lib
#
# mesa files are renamed to *_MESA.so*
#
#######################################
divert() {
ROOT="${1}"
RR="/usr/lib"
LPATH="/var/X11R6/lib"
# link all shared objects in ${1}
for lib in $(find ${ROOT} -wholename \
"*/xorg/modules" -prune -a '!' -type d -o -name '*so*'); do
# strip leading ROOT - to get e.g.: "/usr/lib/libGL.so.1.2"
stripstr ${lib} ${ROOT}
rlib=${VAL}
# strip leading /usr/lib/ - name for /var/X11R6/lib
stripstr ${rlib} ${RR}
divname=${VAL}
rootname=${RR}
if [ "${VAL}" = "${rlib}" ]; then
# Nothing has been stripped - sounds like /usr/X11R6 etc.
stripstr ${rlib} "/usr/X11R6/lib"
divname=${VAL}
rootname="/usr/X11R6/lib"
fi
#echo "${lib} ${rlib} ${divname} after stripping"
# divert, if exists
if [ -e ${rlib} ]; then
# back up mesa file
mvmesa ${rlib}
# link to /var/X11R6/lib
ln -sf ${LPATH}${divname} ${rlib}
else
# it does not exist in /usr/lib/
# just create folder and link
stripbase ${divname}
testmkdir ${rootname}${VAL}
ln -sf ${lib} ${rlib}
fi
done
touch ${ROOT}/installed
}
###############################################
# remove all links from system fs
#
# just run this function to clean up system
###############################################
uninstDist() {
# put mesa implementation back into place
for file in $(find /usr/lib/ -name '*_MESA.so*' | xargs); do
mesafile="$(echo ${file}|sed -e 's/_MESA.so/.so/')"
mv ${file} ${mesafile}
done
# somehow we have to repair this - what else?
# There is also a generic way, but this is only one file
ln -sf /usr/lib/libGL.so.1.2 /usr/lib/libGL.so.1
ln -sf /usr/lib/libGL.so.1.2 /usr/lib/libGL.so
# delete all remaining links to /opt/openslx and /var/X11R6/lib
find /usr/lib /usr/X11R6/lib -lname "${PLUGIN_PATH}*" \
-o -lname "${LINK_PATH}*" |xargs rm -rf
# delete LINK_PATH
rm -rf ${LINK_PATH}
}
if [ "$1" = "clean" ]; then
uninstDist
exit
fi
if [ "$1" = "both" ]; then
divert $NVROOT
divert $ATIROOT
# /bin/bash
exit
fi
if [ "$1" = "nvidia" ]; then
divert ${NVROOT}
exit
fi
if [ "$1" = "ati" ]; then
divert ${ATIROOT}
exit
fi
|