source: flair-dev/trunk/scripts/distribution_specific_hack.sh@ 88

Last change on this file since 88 was 70, checked in by Bayard Gildas, 7 years ago

shift from ubuntu_cgroup_hack to distribution_specific_hack script

File size: 1.7 KB
Line 
1if [ -f /etc/lsb-release ]; then
2 . /etc/lsb-release
3fi
4
5if [ _$DISTRIB_ID = _Ubuntu ]; then
6 #tested on Ubuntu 17.10
7 #we must run as root
8 if [ $EUID -ne 0 ]; then
9 exec sudo -E $0 $*
10 fi
11
12 #we must run in root cgroup to escape possible restrictions on scheduling
13 if [ -d /sys/fs/cgroup/cpu ]; then
14 echo $$ > /sys/fs/cgroup/cpu/tasks
15 fi
16
17 #special actions if we use 3D
18 ldd $EXEC | grep "libGL.so" > /dev/null
19 if [ $? -eq 0 ]; then
20 #allow root access to the X server
21 xhost si:localuser:root
22
23 #Mesa DRI driver may need a libstdc++ more recent than robomap3's
24 ldconfig -p | grep mesa > /dev/null
25 if [ $? -eq 0 ]; then
26 read DRI_CARD_MAJOR DRI_CARD_MINOR < <(stat -c '%t %T' /dev/dri/card0)
27 DRIVER=$(cat /sys/dev/char/$((16#$DRI_CARD_MAJOR)):$((16#$DRI_CARD_MINOR))/device/uevent | grep DRIVER | cut -d= -f2)
28 echo "Mesa DRI driver is $DRIVER"
29 DRIVER_LIB=$(LIBGL_DEBUG=verbose glxinfo 2>&1 | grep OpenDriver | tail -n 1 | sed -e "s/.* \(.*\)/\1/")
30 #get the highest required version of CXXABI
31 CXXABI_REQUIRED=$(objdump -T $DRIVER_LIB | grep CXXABI | sed -e 's/.*CXXABI_\(.*\) .*/\1/' | sort -uV | tail -1)
32 #get currently used libstdc++
33 LIBSTDCXX_PROVIDED=$(ldd $EXEC | grep libstdc++ | sed -e 's/.*=> \(.*\) (.*/\1/')
34 #get the highest version of CXXABI supported by the libstdc++
35 CXXABI_PROVIDED=$(objdump -T $LIBSTDCXX_PROVIDED | grep ".*CXXABI_[0-9.]*$" | sed -e 's/.*CXXABI_\(.*\)/\1/' | sort -V | tail -1)
36 if [ $(echo -e "$CXXABI_PROVIDED\n$CXXABI_REQUIRED" | sort -V | tail -n1) != $CXXABI_PROVIDED ]; then
37 echo "We must use the local system libstdc++"
38 export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
39 fi
40 fi
41 fi
42fi
43
Note: See TracBrowser for help on using the repository browser.