-
Notifications
You must be signed in to change notification settings - Fork 633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add validate_openexr_libs.sh to validate .so symlinks #1058
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# Validate the libary symlinks: | ||
# * The actual elf binary is, e.g. libIlmThread-3_1.so.29.0.0 | ||
# * The symlinks are: | ||
# libIlmThread.so -> libIlmThread-3_1.so | ||
# libIlmThread-3_1.so -> libIlmThread-3_1.so.29 | ||
# libIlmThread-3_1.so.29 -> libIlmThread-3_1.so.29.0.0 | ||
# | ||
# Extract the version by compiling a program that prints the | ||
# OPENEXR_VERSION_STRING. This also validates that the program | ||
# compiles and executes with the info from pkg-config. | ||
# | ||
|
||
if [[ $# == "0" ]]; then | ||
echo "usage: $0 BUILD_ROOT [SRC_ROOT]" | ||
exit -1 | ||
fi | ||
|
||
BUILD_ROOT=$1 | ||
SRC_ROOT=$2 | ||
|
||
# Locate OpenEXR.pc and set PKG_CONFIG_PATH accordingly | ||
|
||
pkgconfig=$(find $BUILD_ROOT -name OpenEXR.pc) | ||
if [[ "$pkgconfig" == "" ]]; then | ||
echo "Can't find OpenEXR.pc" | ||
exit -1 | ||
fi | ||
export PKG_CONFIG_PATH=$(dirname $pkgconfig) | ||
|
||
# Build the validation program | ||
|
||
CXX_FLAGS=$(pkg-config OpenEXR --cflags) | ||
LD_FLAGS=$(pkg-config OpenEXR --libs --static) | ||
|
||
VALIDATE_CPP=$(mktemp --tmpdir "validate_XXX.cpp") | ||
VALIDATE_BIN=$(mktemp --tmpdir "validate_XXX") | ||
trap "rm -rf $VALIDATE_CPP $VALIDATE_BIN" exit | ||
|
||
echo -e '#include <ImfHeader.h>\n#include <OpenEXRConfig.h>\n#include <stdio.h>\nint main() { puts(OPENEXR_PACKAGE_STRING); Imf::Header h; return 0; }' > $VALIDATE_CPP | ||
|
||
g++ $CXX_FLAGS $VALIDATE_CPP -o $VALIDATE_BIN $LD_FLAGS | ||
|
||
# Execute the program | ||
|
||
LIB_DIR=$(pkg-config OpenEXR --variable=libdir) | ||
export LD_LIBRARY_PATH=$LIB_DIR | ||
|
||
validate=`$VALIDATE_BIN` | ||
status=$? | ||
|
||
echo $validate | ||
|
||
if [[ "$status" != "0" ]]; then | ||
echo "validate failed: $validate" | ||
exit -1 | ||
fi | ||
|
||
# Get the suffix, e.g. -2_5_d, and determine if there's also a _d | ||
libsuffix=$(pkg-config OpenEXR --variable=libsuffix) | ||
if [[ $libsuffix != $(basename ./$libsuffix _d) ]]; then | ||
_d="_d" | ||
else | ||
_d="" | ||
fi | ||
|
||
# Validate each of the libs | ||
libs=$(pkg-config OpenEXR --libs-only-l | sed -e s/-l//g) | ||
for lib in $libs; do | ||
|
||
base=$(echo $lib | cut -d- -f1) | ||
suffix=$(echo $lib | cut -d- -f2) | ||
|
||
if [[ -f $LIB_DIR/lib$base$_d.so ]]; then | ||
libbase=$(readlink $LIB_DIR/lib$base$_d.so) | ||
libcurrent=$(readlink $LIB_DIR/$libbase) | ||
libversion=$(readlink $LIB_DIR/$libcurrent) | ||
file $LIB_DIR/$libversion | grep -q "ELF" | ||
|
||
if [[ "$?" != 0 ]]; then | ||
echo "Broken libs: lib$base.so -> $libbase -> $libcurrent -> $libversion" | ||
exit -1 | ||
fi | ||
|
||
echo "lib$base.so -> $libbase -> $libcurrent -> $libversion" | ||
|
||
elif [[ ! -f $LIB_DIR/lib$lib.a ]]; then | ||
echo "No static lib: $LIB_DIR/lib$lib.a" | ||
else | ||
echo "Static lib lib$lib.a" | ||
fi | ||
|
||
done | ||
|
||
# Confirm no broken .so symlinks | ||
file $LIB_DIR/lib* | grep -q broken | ||
if [[ "$?" == "0" ]]; then | ||
echo "Broken symbolic link." | ||
exit -1 | ||
fi | ||
|
||
if [[ "$SRC_ROOT" != "" ]]; then | ||
version=$(pkg-config OpenEXR --modversion) | ||
notes=$(grep "\* \[Version $version\]" $SRC_ROOT/CHANGES.md | head -1) | ||
if [[ "$notes" == "" ]]; then | ||
echo "No release notes." | ||
else | ||
echo "Release notes: $notes" | ||
fi | ||
fi | ||
|
||
echo "ok." |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this work on the build matrix variants where we are using clang? (not sure if docker will put a gcc in there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably does make sense to use the same compiler as the build matrix, I'll look into a way to pass that in, although it works for now.
We recently had problems with installing broken symlinks and pkg-configs, so this is just a check in the ci to ensure that bug doesn't creep back in, not intended as a general utility or part of the test suite.