earthenterprise icon indicating copy to clipboard operation
earthenterprise copied to clipboard

Release executables and libraries depend on gtest

Open tst-lsavoie opened this issue 7 years ago • 1 comments

On some platforms, some of the executables produced and installed in the RPM depend on gtest. The affected executables/libraries are libgeprotobuf, gerasterimport, fusion, libsharedportablelib.so, and geraster2gigapxl. Since gtest is only used for testing this should not be a requirement for run time libraries.

Steps to reproduce the error with libgeprotobuf:

  1. Build RPMs on CentOS 7
  2. Install the RPMs on another machine on which gtest and gtest-devel are not installed
  3. Symptom 1: run sudo /opt/google/bin/geserveradmin. You will get an error message indicating that there was a problem loading libgtest.
  4. Symptom 2: run /etc/init.d/geserver restart. You will get an error because a file named "stream_space" does not exist and the server will fail to start.

Reproducing the error with the other executables involves installing and running them on a system without gtest installed. Reproducing the error with the other libraries is similar except that you first have to find an executable that uses the affected library and run that.

As part of this ticket, we should make sure that RPMs do not include gtest as a dependency (currently gtest is automatically included as a dependency because the listed executables require it).

The following script can be used to find executables and libraries that depend on gtest. It should be run after running the build and stage_install steps in scons.

#! /bin/bash

: ${SEARCH_PATH:=/tmp/fusion_os_install}

find "$SEARCH_PATH" |
    while read f; do
        reqs=$(echo "$f" | /usr/lib/rpm/find-requires)
        if [ -n "$reqs" ]; then
            echo "-----------------------------"
            echo "File: $f"
            echo "---------"
            echo "$reqs"
            echo "-----------------------------"
            echo
        fi
    done

This problem was solved in the (rejected) PR #652 for libgeprotobuf. This PR was rejected because it doesn't solve the problem for the other executables. In this case, however, libgeprotobuf doesn't actually depend on gtest, but gtest is linked in anyway. The fix is to remove gtest from the linking step. It's possible that the other executables and libraries can be fixed similarly. The exact reason that scons decides to link gtest into these executables is unknown.

tst-lsavoie avatar Jan 05 '18 15:01 tst-lsavoie

The following executables link against libgtest.so.0 on CentOS 7:

/opt/google/lib/libgeprotobuf.so
/opt/google/lib/libsharedportablelib.so
/opt/google/bin/gerasterimport
/opt/google/bin/fusion

The script I used was the following. I used it as a find action.

#! /bin/bash

RPM_FIND_REQUIRES=/usr/lib/rpm/find-requires

while [ "$#" -gt 0 ]; do
    case "$1" in
        -e)
            shift
            CAPABILITY_PATTERN=$1
            ;;
        -E|--extended-regexp|-F|--fixed-strings|-G|--basic-regexp|-P|--perl-regexp)
            GREP_FORMAT_OPTION="$1"
            ;;
        --)
            break
            ;;
        *)
            CAPABILITY_PATTERN="$1"
            break
            ;;
    esac
    shift
done


function test_requires()
{
    local INPUT_PATH="$1"
    local CAPABILITY

    echo "$1" | "$RPM_FIND_REQUIRES" | \
        grep -q $GREP_FORMAT_OPTION -e "$CAPABILITY_PATTERN"
}

while [ "$#" -gt 0 ]; do
    if test_requires "$1"; then
        echo "$1"
    fi
    shift
done

tst-ppenev avatar Apr 17 '18 03:04 tst-ppenev