Skip to content

Commit

Permalink
Simplify activate/deactivate scripts.
Browse files Browse the repository at this point in the history
Since plugins are now installed in ${PREFIX}/lib, modification of
LD_LIBRARY_PATH is no longer needed. ${PLUGIN_DIR} is removed.
  • Loading branch information
duboism committed Aug 22, 2019
1 parent d9708af commit 7624ae9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
5 changes: 2 additions & 3 deletions recipes/vmatch/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ set -euxo pipefail
# Those variables are also used in pre and post-link scripts
BIN_DIR="$PREFIX"/bin
SHARE_DIR="$PREFIX"/share/${PKG_NAME}-${PKG_VERSION}-${PKG_BUILDNUM}
PLUGIN_DIR="$SHARE_DIR"/plugin
DOC_DIR="$SHARE_DIR"/doc

# Create directories
mkdir -p ${BIN_DIR}
mkdir -p ${PLUGIN_DIR}
mkdir -p ${SHARE_DIR}
mkdir -p ${DOC_DIR}
mkdir -p ${PREFIX}/lib
Expand All @@ -27,9 +25,10 @@ fi
# Compile selection functions and install them.
# The SYSTEM variable is not really needed
# but we set it as should be done.
# The libs are installed in ${PREFIX}/lib so `vmatch`
# can find them without the full path.
pushd SELECT
SYSTEM=$(uname -s) make
cp -p *.so ${PLUGIN_DIR}
cp -p *.so ${PREFIX}/lib
popd

Expand Down
22 changes: 5 additions & 17 deletions recipes/vmatch/post-link.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
#!/bin/bash

SHARE_DIR="$PREFIX"/share/${PKG_NAME}-${PKG_VERSION}-${PKG_BUILDNUM}
PLUGIN_DIR="$SHARE_DIR"/plugin
MKVTREESMAPDIR="$SHARE_DIR"/TRANS/

# Create activate script
mkdir -p ${PREFIX}/etc/conda/activate.d
ACTIVATE_SCRIPT=${PREFIX}/etc/conda/activate.d/${PKG_NAME}-${PKG_VERSION}-${PKG_BUILDNUM}.sh
# This variable holds the name of a environement variable
# that contains the value of LD_LIBRARY_PATH before activating the environment.
# Its name doesn't include the version (should be enough since there is only one version per env)
SAVE_VARIABLE_NAME=LD_LIBRARY_PATH_BEFORE_${PKG_NAME}
echo "# Activate script for ${PKG_NAME}-${PKG_VERSION}-${PKG_BUILDNUM}
# Save LD_LIBRARY_PATH
export ${SAVE_VARIABLE_NAME}=\${LD_LIBRARY_PATH}
# Modify it
export LD_LIBRARY_PATH=${PLUGIN_DIR}:\${LD_LIBRARY_PATH}
# Export MKVTREESMAPDIR
export MKVTREESMAPDIR=${MKVTREESMAPDIR}
" > ${ACTIVATE_SCRIPT}
Expand All @@ -24,18 +14,16 @@ export MKVTREESMAPDIR=${MKVTREESMAPDIR}
mkdir -p ${PREFIX}/etc/conda/deactivate.d
DEACTIVATE_SCRIPT=${PREFIX}/etc/conda/deactivate.d/${PKG_NAME}-${PKG_VERSION}-${PKG_BUILDNUM}.sh
echo "# Deactivate script for ${PKG_NAME}-${PKG_VERSION}-${PKG_BUILDNUM}
# Restore LD_LIBRARY_PATH
export LD_LIBRARY_PATH=\${${SAVE_VARIABLE_NAME}}
# Remove MKVTREESMAPDIR
unset MKVTREESMAPDIR
# Remove ${SAVE_VARIABLE_NAME}
unset ${SAVE_VARIABLE_NAME}
" > ${DEACTIVATE_SCRIPT}

# Write a message for the user
echo "Selection functions are installed in ${PLUGIN_DIR}.
echo "
vmatch selection functions are installed in ${PREFIX}/lib.
You can use them without specifying their full path.
Symbol map files are installed in ${MKVTREESMAPDIR}.
Activation and deactivation scripts will set LD_LIBRARY_PATH and MKVTREESMAPDIR accordingly
so you can use selection functions and symbol map files without specifying their full path.
Activation and deactivation scripts will set MKVTREESMAPDIR accordingly
so you can use symbol map files without specifying their full path.
Those scripts are in ${ACTIVATE_SCRIPT} and ${DEACTIVATE_SCRIPT} respectively.
" > $PREFIX/.messages.txt

0 comments on commit 7624ae9

Please sign in to comment.