-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetenv.rc
62 lines (50 loc) · 1.3 KB
/
setenv.rc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#
# Setup variables and pathes for mckit build environment
#
# This may be used to create .env file to be loaded into python environment
# with dotenv module.
#
export MCKIT_ROOT="$(pwd)"
export PATH="$MCKIT_ROOT/bin:$PATH"
mckit_load_environment() {
if [[ -z "$MCKIT_BUILD_CFG" ]]; then
if [[ -r ./.local.env ]]; then
local env="./.local.env"
else
local env="build_configs/$(hostname).rc"
fi
if [[ -r "$env" ]]; then
echo "Sourcing environment from $env"
source "$env"
export MCKIT_BUILD_CFG="$env"
return 0
else
echo "Cannot find environment file $env"
return 1
fi
else
echo "MCKIT build config is already loaded: $MCKIT_BUILD_CFG"
return 0
fi
}
mckit_checkenv() {
[ -n MCKIT_BUILD_CFG ]
}
mckit_printenv() {
(
build_printenv
echo "MCKIT_ROOT=$MCKIT_ROOT"
echo "MCKIT_BUILD_CFG=$MCKIT_BUILD_CFG"
) | sort
}
mckit_update_dot_env() {
if [[ "$1" == "reset" ]]; then
shift
unset MCKIT_BUILD_CFG
fi
mckit_load_environment && \
mckit_checkenv && \
mckit_printenv >| .env
}
[ -n "$BATS_PREFIX" ] || mckit_update_dot_env $*
# vim: set ts=4 sw=0 tw=79 ss=0 ft=sh et ai :