-
Notifications
You must be signed in to change notification settings - Fork 5
/
guest_common.bash
60 lines (49 loc) · 1.05 KB
/
guest_common.bash
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
set_user_env() {
: "${USER:="$(id -un)"}"
: "${LOGNAME:=${USER}}"
export USER LOGNAME
}
default_python_home() {
python <<-EOF
import sys
print(sys.prefix)
EOF
}
ext_path() {
# This is safe only when we're in a subshell
shopt -s nullglob
# quoting around the pattern is not only unnecessary, it's also wrong,
# because word splitting happens **before** pathname expansion
local ext_dirs=(/build/gpdb/gpAux/ext/*)
# guard against empty
[[ "${ext_dirs[*]+x}" == "x" ]]
# guard against multiple subdirs
[[ "${#ext_dirs[@]}" -eq "1" ]]
echo "${ext_dirs[0]}"
}
ncpu() {
# you'd think nproc is the way to go
# but getconf is more portable, given that we run in CentOS 5...
if getconf _NPROCESSORS_ONLN; then
true
else
echo 8
fi
}
clone_gpdb() {
local repo
repo=$1
if [[ ! -e /build/gpdb ]]; then
git clone --shared "/workspace/${repo}" /build/gpdb
fi
}
clone_gpdb_with_submodules() {
local repo
repo=$1
clone_gpdb "$1"
(
pushd /build/gpdb
rsync -r "/workspace/${repo}/.git/modules" .git
git submodule update --init --recursive
)
}