Skip to content
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

JCF: Issue #273: add a DUNEDAQ_DB_PATH environment variable to dbt-wo… #274

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions scripts/dbt-setup-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,55 @@ function load_yaml() {
python3 -c "import yaml;print(yaml.safe_load(open('$1'))$2)"
}
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------

# JCF, Apr-16-2024
# Based on the requirements in Issue #273, this function will take the
# name of an environment variable (DUNEDAQ_DB_PATH, e.g.) and proceed
# to prioritize directories as follows:

# 1) User directories that aren't a source code or local installation directory
# 2) Source code directories in the work area
# 3) Installation directories in the work area
# 4) Any other directories (/cvmfs, etc.)

function prioritize_directories() {

local dirlist_name="$1"

local install_patt="$DBT_INSTALL_DIR/*"
local sourcecode_patt="$DBT_AREA_ROOT/sourcecode/*"
local user_patt="$HOME/*"

local priority_level1=()
local priority_level2=()
local priority_level3=()
local priority_level4=()

local dirlist="${!dirlist_name}"
IFS=':' read -r -a dirs <<< "$dirlist"

for dir in "${dirs[@]}"; do

if [[ "$dir" == $user_patt && ! "$dir" == $sourcecode_patt && ! "$dir" == $install_patt ]]; then
priority_level1+=("$dir")
elif [[ "$dir" == $sourcecode_patt ]]; then
priority_level2+=("$dir")
elif [[ "$dir" == $install_patt ]]; then
priority_level3+=("$dir")
else
priority_level4+=("$dir")
fi
done

# First sed command is swapping whitespace for a ":", second is to remove leading and trailing ":"s

local reordered_dirs=$( echo "${priority_level1[*]}" "${priority_level2[*]}" "${priority_level3[*]}" "${priority_level4[*]}" | sed -r 's/\s+/:/g' | sed -r 's/^:*(.*[^:]).*$/\1/' )

eval "$dirlist_name=\"$reordered_dirs\""

}


#------------------------------------------------------------------------------
8 changes: 5 additions & 3 deletions scripts/dbt-workarea-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,17 @@ for p in ${DBT_PACKAGES}; do
# Share
pkg_share="${PNAME//-/_}_SHARE"
declare -xg "${pkg_share}"="${DBT_INSTALL_DIR}/${p}/share"

add_many_paths PATH "${PKG_INSTALL_PATH}/bin" "${PKG_INSTALL_PATH}/test/bin"
add_many_paths PYTHONPATH "${PKG_INSTALL_PATH}/lib64/python"
add_many_paths LD_LIBRARY_PATH "${PKG_INSTALL_PATH}/lib64" "${PKG_INSTALL_PATH}/test/lib64"
add_many_paths CET_PLUGIN_PATH "${PKG_INSTALL_PATH}/lib64" "${PKG_INSTALL_PATH}/test/lib64"
add_many_paths DUNEDAQ_SHARE_PATH "${PKG_INSTALL_PATH}/share"
add_many_paths DUNEDAQ_SHARE_PATH "${PKG_INSTALL_PATH}/share"
add_many_paths DUNEDAQ_DB_PATH "${SOURCE_DIR}/$p"
done

export PATH PYTHONPATH LD_LIBRARY_PATH CET_PLUGIN_PATH DUNEDAQ_SHARE_PATH
prioritize_directories DUNEDAQ_DB_PATH

export PATH PYTHONPATH LD_LIBRARY_PATH CET_PLUGIN_PATH DUNEDAQ_SHARE_PATH DUNEDAQ_DB_PATH
echo -e "${COL_GREEN}...done${COL_RESET}"
echo

Expand Down