summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/xserver/files/linkage.sh
blob: edf8930557929d7a21ba06e6bbee34e74ee5e463 (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
#!/bin/sh

#
#
# general: linking libGL.so and stuff to writable locations
#
#

PLUGIN_FOLDER="/opt/openslx/plugin-repo/xserver/"
MESA_FOLDER="${PLUGIN_FOLDER}mesa/"
# this has to be writable in stage3 - any folder is possible
LINK_FOLDER="/var/lib/X11R6/xserver/"

# these are to link libs to
ATIROOT="${PLUGIN_FOLDER}ati/atiroot"
NVROOT="${PLUGIN_FOLDER}nvidia/nvroot"

# declare array of conflicting libs
# TODO: add conflicting libs for opengl here
declare -a CONFLIBS=("/usr/lib/libGL.so.1.2" "/usr/lib/libGL.so.1")


if [ ! -d "${MESA_FOLDER}usr/lib/" ]; then
  mkdir -p "${MESA_FOLDER}usr/lib/"
fi
if [ ! -d "${LINK_FOLDER}usr/lib/" ]; then
  mkdir -p "${LINK_FOLDER}usr/lib/"
fi










function linkMesa {
  file=$1
  if [ -f "/${file}" ]; then
    # move file to the mesa implementation folder
    mv "${file}" "${MESA_FOLDER}${file}"
    # create links from link-folder to mesa-folder
    ln -s "${MESA_FOLDER}${file}" "${LINK_FOLDER}${file}"
    # create links from sys-folder to link-folder
    ln -s "${LINK_FOLDER}${file}" "${file}"

  else
    # ${file} is a link here
    rm -rf "${file}"
    case ${file} in
      /usr/lib/libGL.so.1)
        ln -s "${LINK_FOLDER}${file}.2" "${LINK_FOLDER}${file}"
        ;;
      *)
        ;;
    esac
  fi
}










# we create links for all of the binary drivers here 
# - as long as it's possible
# - if not, add to array of link files

# ATI
declare -a ATILIBS=($(find ${ATIROOT} -name "*\\.so*" | xargs))
# with stripped ATIROOT path
declare -a UATILIBS=(${ATILIBS[@]#${ATIROOT}})
for lib in ${UATILIBS[@]}; do
  if [ -e $lib ]; then
    # this is a conflicting MESA-Library
    linkMesa $lib
  fi
done
# NVIDIA
for lib in $(find ${NVROOT} -name "*\\.so*" | xargs); do

done







# go through conflicting libs and link them accordingly
for file in ${CONFLIBS[@]}; do
  linkMesa $file
done