Skip to content

Commit

Permalink
fix rpaths in all files in bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Apr 20, 2020
1 parent a9256f1 commit acc6778
Show file tree
Hide file tree
Showing 19 changed files with 527 additions and 171 deletions.
39 changes: 39 additions & 0 deletions qgis_build/config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Internals
CRED="\x1b[31;01m"
CBLUE="\x1b[34;01m"
CGRAY="\x1b[30;01m"
CRESET="\x1b[39;49;00m"

function try () {
"$@" || exit -1
}

function info() {
echo -e "$CBLUE"$@"$CRESET";
}

function error() {
MSG="$CRED"$@"$CRESET"
echo -e $MSG;
exit -1
}

function debug() {
echo -e "$CGRAY"$@"$CRESET";
}

source `dirname $0`/../qgis_deps/config.conf
if [ -d $ROOT_OUT_PATH/stage ]; then
info "Using qgis_deps: $ROOT_OUT_PATH/stage"
else
error "Missing qgis_deps directory '$ROOT_OUT_PATH/stage' not found."
fi

source $ROOT_OUT_PATH/stage/qgis-deps.config

CORES=$(sysctl -n hw.ncpu)

export QGIS_SOURCE_DIR=~/Projects/mesh/QGIS
export QGIS_VERSION=3.13
export QGIS_BUILD_DIR=$ROOT_OUT_PATH/../qgis-${QGIS_VERSION}-deps-${RELEASE_VERSION}/build
export QGIS_INSTALL_DIR=$ROOT_OUT_PATH/../qgis-${QGIS_VERSION}-deps-${RELEASE_VERSION}/install
43 changes: 1 addition & 42 deletions qgis_build/qgis_build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,7 @@ else
exit 1;
fi

# Internals
CRED="\x1b[31;01m"
CBLUE="\x1b[34;01m"
CGRAY="\x1b[30;01m"
CRESET="\x1b[39;49;00m"

function try () {
"$@" || exit -1
}

function info() {
echo -e "$CBLUE"$@"$CRESET";
}

function error() {
MSG="$CRED"$@"$CRESET"
echo -e $MSG;
exit -1
}

function debug() {
echo -e "$CGRAY"$@"$CRESET";
}

source `dirname $0`/../qgis_deps/config.conf
if [ -d $ROOT_OUT_PATH/stage ]; then
info "Using qgis_deps: $ROOT_OUT_PATH/stage"
else
error "Missing qgis_deps directory '$ROOT_OUT_PATH/stage' not found."
fi

source $ROOT_OUT_PATH/stage/qgis-deps.config

CORES=$(sysctl -n hw.ncpu)


# TODO replace with something configurable
# TODO use MACOSX_DEPLOYMENT_TARGET
export QGIS_VERSION=3.13
export QGIS_SOURCE_DIR=~/Projects/mesh/QGIS
export QGIS_BUILD_DIR=$ROOT_OUT_PATH/../qgis-${QGIS_VERSION}-deps-${RELEASE_VERSION}/build
export QGIS_INSTALL_DIR=$ROOT_OUT_PATH/../qgis-${QGIS_VERSION}-deps-${RELEASE_VERSION}/install
source `dirname $0`/config.conf

OLD_PATH=$PATH

Expand Down
8 changes: 1 addition & 7 deletions qgis_bundle/config.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,14 @@ if [ ! -d $DEPS_PYTHON_SITE_PACKAGES_DIR ]; then
error "Missing DEPS_PYTHON_SITE_PACKAGES_DIR directory '$DEPS_PYTHON_SITE_PACKAGES_DIR'"
fi

export QGIS_DEPS_LIB
# From step qgis_build
export QGIS_VERSION=3.13
export QGIS_BUILD_DIR=$ROOT_OPT_PATH/qgis-${QGIS_VERSION}-deps-${RELEASE_VERSION}/build
export QGIS_INSTALL_DIR=$ROOT_OPT_PATH/qgis-${QGIS_VERSION}-deps-${RELEASE_VERSION}/install

source `dirname $0`/../qgis_build/config.conf
if [ ! -d $QGIS_INSTALL_DIR ]; then
error "Missing QGIS directory 'QGIS_INSTALL_DIR: $QGIS_INSTALL_DIR'"
fi

# From step qgis_bundle

export APPLICATION_PATH=/Applications/QGIS-${QGIS_VERSION}

export BUNDLE_DIR=$ROOT_OPT_PATH/qgis-${QGIS_VERSION}-deps-${RELEASE_VERSION}/bundle
export BUNDLE_CONTENTS_DIR=$BUNDLE_DIR/QGIS.app/Contents
export BUNDLE_FRAMEWORKS_DIR=$BUNDLE_CONTENTS_DIR/Frameworks
Expand Down
48 changes: 0 additions & 48 deletions qgis_bundle/find_that_link.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,6 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $DIR/config.conf

function check_binary_linker_links() {
OTOOL_L=$(otool -L ${BUNDLE_DIR}/$1)
OTOOL_RPATH=$(otool -l ${BUNDLE_DIR}/$1)

if echo "${OTOOL_L}" | grep -q /usr/local/
then
echo "${OTOOL_L}"
error "$1 contains /usr/local/ string <-- Picked some homebrew libraries!"
fi

if echo "${OTOOL_L}" | grep -q $QGIS_INSTALL_DIR
then
echo "${OTOOL_L}"
error "$1 contains $QGIS_INSTALL_DIR string <-- forgot to change install_name for the linked library?"
fi

if echo "${OTOOL_L}" | grep -q $STAGE_PATH
then
echo "${OTOOL_L}"
error "$1 contains $STAGE_PATH string <-- forgot to change install_name for the linked library?"
fi

if echo ${OTOOL_L} | grep -q $BUNDLE_DIR
then
echo "${OTOOL_L}"
error "$1 contains $BUNDLE_DIR string <-- forgot to change install_name for the linked library?"
fi

targets=(
libz
libssl
libcrypto
libpq
lib
libxml2
libsqlite3
)

for i in ${targets[*]}
do
if echo "${OTOOL_L}" | grep -q /usr/lib/$i.dylib
then
echo "${OTOOL_L}"
info "$1 contains /usr/lib/$i.dylib string -- we should be using our $i, not system!"
fi
done
}

run() {
BINARY_FILENAME=$(basename -- "$BINARY")
RESULT_BIN=
Expand Down
49 changes: 49 additions & 0 deletions qgis_bundle/list_rpaths.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

# Script to list all rpaths in all binaries

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $DIR/config.conf

run() {
RPATH_DIR_FILENAME=$(basename -- "$RPATH_DIR")
RESULT_BIN=
COMMANDS_BIN=

cd $FOLDER
LIBS1=`find . -type f -name "*.so"`
LIBS2=`find . -type f -name "*.dylib"`
BINS=`find . -type f ! -name "*.*"`
LIBS="$BINS $LIBS1 $LIBS2"
for lib in $LIBS; do
RP=$(otool -l $FOLDER/$lib | grep RPATH -A2)
LIB="\$BUNDLE_CONTENTS_DIR/${lib:2:${#lib}}"

if [ "X$RPATH_DIR" == "X" ]; then
RP=$(otool -l $FOLDER/$lib | grep RPATH -A2)
if [ ! "X$RP" == "X" ]; then
echo $FOLDER/$lib
echo $RP
fi
else
if echo ${RP} | grep -q $RPATH_DIR
then
RESULT_BIN="$RESULT_BIN\n$LIB"
COMMANDS_BIN="$COMMANDS_BIN\n install_name_delete_rpath $RPATH_DIR $LIB"
fi
fi
done

printf "$RESULT_BIN\n"
echo "-----------"
printf "$COMMANDS_BIN\n"
}

if (( $# < 1 )); then
echo "listing all RPATHs"
fi

FOLDER=$BUNDLE_CONTENTS_DIR
RPATH_DIR=$1
echo "Checking which binaries in $FOLDER have rpath $RPATH_DIR"
run
Loading

0 comments on commit acc6778

Please sign in to comment.