1 | #check required version of a lib in host graphic lib (ie i965)
|
---|
2 | #return 1 if robomap3 version is not sufficient
|
---|
3 | function check_required_lib_ver () {
|
---|
4 | DRIVER_LIB=$1
|
---|
5 | PATTERN=$2
|
---|
6 | LIB=$3
|
---|
7 |
|
---|
8 | #get the highest required version of $PATTERN
|
---|
9 | VER_REQUIRED=$(objdump -T $DRIVER_LIB | grep $PATTERN | sed -e 's/.*'$PATTERN'_\(.*\) .*/\1/' | sort -uV | tail -1)
|
---|
10 | #get currently used $LIB
|
---|
11 | LIB_PROVIDED=$(ldd $EXEC | grep $LIB | sed -e 's/.*=> \(.*\) (.*/\1/')
|
---|
12 | #get the highest version of $PATTERN supported by the $LIB
|
---|
13 | VER_PROVIDED=$(objdump -T $LIB_PROVIDED | grep ".*"$PATTERN"_[0-9.]*$" | sed -e 's/.*'$PATTERN'_\(.*\)/\1/' | sort -V | tail -1)
|
---|
14 | if [ $(echo -e "$VER_PROVIDED\n$VER_REQUIRED" | sort -V | tail -n1) != $VER_PROVIDED ]; then
|
---|
15 | echo "We must use the local system $LIB"
|
---|
16 | return 1
|
---|
17 | fi
|
---|
18 | }
|
---|
19 |
|
---|
20 | function green_echo () {
|
---|
21 | echo -e "\033[32m$1\033[0m"
|
---|
22 | }
|
---|
23 |
|
---|
24 | function red_echo () {
|
---|
25 | echo -e "\033[33m$1\033[0m"
|
---|
26 | }
|
---|
27 |
|
---|
28 | red_echo "Calling distribution_specific_hack_compat.sh should not be necessary; try without it or warn a Flair developer"
|
---|
29 | red_echo "This script will be removed in future releases\n"
|
---|
30 |
|
---|
31 | if [ -f /etc/lsb-release ]; then
|
---|
32 | . /etc/lsb-release
|
---|
33 | fi
|
---|
34 |
|
---|
35 | #also needed in mint, but for different reason?
|
---|
36 | #if not in sudo in mint, simlator does not work cause of:
|
---|
37 | #libGL: MESA-LOADER: failed to open /usr/lib/x86_64-linux-gnu/dri/iris_dri.so: /usr/lib/x86_64-linux-gnu/dri/iris_dri.so: failed to map segment from shared object
|
---|
38 |
|
---|
39 | #if [ _$DISTRIB_ID = _Ubuntu ]; then
|
---|
40 | #tested on Ubuntu 17.10
|
---|
41 | #we must run as root
|
---|
42 | if [ $EUID -ne 0 ]; then
|
---|
43 | exec sudo -E $0 $*
|
---|
44 | fi
|
---|
45 |
|
---|
46 | #we must run in root cgroup to escape possible restrictions on scheduling
|
---|
47 | if [ -d /sys/fs/cgroup/cpu ]; then
|
---|
48 | echo $$ > /sys/fs/cgroup/cpu/tasks
|
---|
49 | fi
|
---|
50 |
|
---|
51 | #fi
|
---|
52 |
|
---|
53 | #special actions if we use 3D
|
---|
54 | ldd $EXEC | grep "libGL.so" > /dev/null
|
---|
55 | if [ $? -eq 0 ]; then
|
---|
56 | green_echo "checking for incompatibility when using libGL and trying to solve it..."
|
---|
57 | #allow root access to the X server
|
---|
58 | xhost si:localuser:root
|
---|
59 |
|
---|
60 | #Mesa DRI driver may need a lib more recent than robomap3's
|
---|
61 | ldconfig -p | grep mesa > /dev/null
|
---|
62 | if [ $? -eq 0 ]; then
|
---|
63 | read DRI_CARD_MAJOR DRI_CARD_MINOR < <(stat -c '%t %T' /dev/dri/card0)
|
---|
64 | DRIVER=$(cat /sys/dev/char/$((16#$DRI_CARD_MAJOR)):$((16#$DRI_CARD_MINOR))/device/uevent | grep DRIVER | cut -d= -f2)
|
---|
65 | echo "Mesa DRI driver is $DRIVER"
|
---|
66 | DRIVER_LIB=$(LIBGL_DEBUG=verbose glxinfo 2>&1 | grep "\.so" | tail -n 1 | grep -o '/.*\.so')
|
---|
67 |
|
---|
68 | #todo: make a list, find a complete one!
|
---|
69 | check_required_lib_ver $DRIVER_LIB GLIBC libm.so.6
|
---|
70 | if [ "$?" = "1" ]; then
|
---|
71 | ADDED_LIBS=$(ldconfig -p | grep libm.so.6 | grep libc6,x86-64 | cut -d'>' -f2)
|
---|
72 | fi
|
---|
73 |
|
---|
74 | check_required_lib_ver $DRIVER_LIB CXXABI libstdc++.so.6
|
---|
75 | if [ "$?" = "1" ]; then
|
---|
76 | ADDED_LIBS="$ADDED_LIBS:$(ldconfig -p | grep libstdc++.so.6 | grep libc6,x86-64 | cut -d'>' -f2)"
|
---|
77 | fi
|
---|
78 |
|
---|
79 | #remove whitespace
|
---|
80 | #add libs to LD_PRELOAD if version robomap3 version is not sufficient
|
---|
81 | export LD_PRELOAD="$(echo -e "${ADDED_LIBS}" | tr -d '[:space:]')"
|
---|
82 | fi
|
---|
83 |
|
---|
84 | #check if using DRI3 and disable it
|
---|
85 | #otherwise you get /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0: undefined symbol: xcb_dri3_get_supported_modifiers
|
---|
86 | cat /var/log/Xorg.0.log | grep DRI3 > /dev/null
|
---|
87 | if [ $? -eq 0 ]; then
|
---|
88 | export LIBGL_DRI3_DISABLE=1
|
---|
89 | echo "we must disable DRI3"
|
---|
90 | fi
|
---|
91 | green_echo "...done\n"
|
---|
92 | fi
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|