-
Notifications
You must be signed in to change notification settings - Fork 24
/
initialize
117 lines (104 loc) · 3.15 KB
/
initialize
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
shopt -s extglob # Extended globs must always be on for BDSM.
saved_bdsm_path="${bdsm_path:-/usr/local/bdsm}"
# Load System BDSM Configuration, if it exists.
for file in /etc/bdsmrc "$HOME/.bdsmrc"
do
if [[ -s "${file}" ]]
then
. "${file}"
fi
done
bdsm_path="${saved_bdsm_path}"
if (( UID == 0 ))
then # FHS
true \
"${var_path:="/var"}" \
"${etc_path:="/etc"}" \
"${profile_path:="/etc/profile"}" \
"${profile_d_path:="/etc/profile.d"}"
else
true \
"${var_path:="${bdsm_path}/var"}" \
"${etc_path:="$HOME/.etc"}" \
"${profile_path:="$HOME/.profile"}" \
"${profile_d_path:="$HOME/.profile.d"}"
fi
true \
"${modules_path:="${bdsm_path}/extensions/builtin/core/modules"}" \
"${templates_path:="${bdsm_path}/templates"}" \
"${src_path:="${bdsm_path}/src"}" \
"${md5_path:="${bdsm_path}/md5"}" \
"${archives_path:="${bdsm_path}/archives"}" \
"${scm_path:="${bdsm_path}/scm"}" \
"${tmp_path:="${bdsm_path}/tmp"}" \
"${bin_path:="${bdsm_path}/bin"}" \
"${repos_path:="${bdsm_path}/repos"}" \
"${archives_path:="${bdsm_path}/archives"}" \
"${extensions_src_path:="${src_path}/extensions"}" \
"${remote:="origin"}" \
"${branch:="master"}" \
"${language:="shell"}" \
"${user:=$USER}" \
"${keep_releases:=4}" \
"${hooks_flag:=1}" \
"${PAGER:="less"}" \
"${config_path:="${bdsm_path}/extensions/builtin/core/config"}" \
"${packages_path:="${bdsm_path}/pkg"}" \
"${active_path:="${packages_path}/active"}" \
"${extension_args:=""}"
# Make sure preload_modules is an array
export preload_modules=( ${preload_modules[@]} )
if [[ -d "${active_path}/bin" ]]
then
export PATH="${active_path}/bin:${active_path}/sbin:${PATH}"
fi
export bdsm_path modules_path initial_pwd extension_action_calls=0
# Load module() function and then load core modules.
source "${modules_path}/shell/core/dsl"
source "${modules_path}/shell/string/dsl"
source "${modules_path}/shell/logging/dsl"
source "${modules_path}/shell/logging/initialize"
source "${modules_path}/shell/modules/dsl"
source "${modules_path}/shell/modules/initialize"
if [[ "$MACHTYPE" = *solaris* ]]
then # custom compilations + g*
export PATH="/usr/local/bin:/opt/local/bin:/usr/sfw/bin:/usr/sbin:/usr/bin"
fi
# Ensure variables desired to be exported to extensions actually are.
bdsm_exports
if [[ -n $bdsm_script ]]
then
# load script
. $bdsm_script
elif [[ -n "${call_action}" ]]
then
if ! declare -F "${call_action}" >/dev/null
then
error "${call_action} is not a valid function name"
else
trace_filter action
"${call_action}" "${extension_args[@]}"
trace_filter
fi
elif set | grep '^extension_args=(' >/dev/null
then
case "${extension_args[0]}" in
*/*|*,*)
modules bdsm/array bdsm/system
array_shift extension_args extensions
sequential=(${extensions//,/ })
for sequence in "${sequential[@]}"
do
parallel=("${sequence//\// }")
PATH="${bdsm_path}/bin:${PATH}"
bdsm-ll --noswap -j $(os_cpu_count) bdsm {} ${extension_args[*]} ::: ${parallel[@]}
done
;;
*)
modules bdsm/extensions
extension_action
detect_action_type
extension_run
esac
fi