Changeset 105 in flair-dev


Ignore:
Timestamp:
Feb 18, 2019, 4:00:43 PM (19 months ago)
Author:
Sanahuja Guillaume
Message:

add graphic lib check (mainly for intel)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/distribution_specific_hack.sh

    r70 r105  
     1#check required version of a lib in host graphic lib (ie i965)
     2#return 1 if robomap3 version is not sufficient
     3function 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
    120if [ -f /etc/lsb-release ]; then
    221  . /etc/lsb-release
     
    1534  fi
    1635
    17   #special actions if we use 3D
    18   ldd $EXEC | grep "libGL.so" > /dev/null
    19   if [ $? -eq 0 ]; then
     36fi
     37
     38#special actions if we use 3D
     39ldd $EXEC | grep "libGL.so" > /dev/null
     40if [ $? -eq 0 ]; then
    2041    #allow root access to the X server
    2142    xhost si:localuser:root
    2243
    23     #Mesa DRI driver may need a libstdc++ more recent than robomap3's
     44    #Mesa DRI driver may need a lib more recent than robomap3's
    2445    ldconfig -p | grep mesa > /dev/null
    2546    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
     47        read DRI_CARD_MAJOR DRI_CARD_MINOR < <(stat -c '%t %T' /dev/dri/card0)
     48        DRIVER=$(cat /sys/dev/char/$((16#$DRI_CARD_MAJOR)):$((16#$DRI_CARD_MINOR))/device/uevent | grep DRIVER | cut -d= -f2)
     49        echo "Mesa DRI driver is $DRIVER"
     50        DRIVER_LIB=$(LIBGL_DEBUG=verbose glxinfo 2>&1 | grep OpenDriver | tail -n 1 | sed -e "s/.* \(.*\)/\1/")
     51
     52        #todo: make a list, find a complete one!
     53        check_required_lib_ver $DRIVER_LIB GLIBC libm.so.6
     54        if [ "$?" = "1" ]; then
     55                   ADDED_LIBS=$(ldconfig -p | grep libm.so.6 | cut -d'>' -f2)
     56            fi
     57
     58        check_required_lib_ver $DRIVER_LIB CXXABI libstdc++.so.6
     59        if [ "$?" = "1" ]; then
     60                   ADDED_LIBS="$ADDED_LIBS:$(ldconfig -p | grep libstdc++.so.6 | cut -d'>' -f2)"
     61            fi
     62        #remove whitespace
     63        #add libs to LD_PRELOAD if version robomap3 version is not sufficient
     64        export LD_PRELOAD="$(echo -e "${ADDED_LIBS}" | tr -d '[:space:]')"
    4065    fi
    41   fi
    4266fi
    4367
     68
     69
Note: See TracChangeset for help on using the changeset viewer.