-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbinstall
More file actions
executable file
·79 lines (67 loc) · 2.44 KB
/
binstall
File metadata and controls
executable file
·79 lines (67 loc) · 2.44 KB
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
#!/bin/bash
# auxiliary function to convert a path to the current os
__normalizeOsPath() {
if [[ "$BSYS_OS" == "windows" ]]; then
echo $(cygpath -w "$1" | tr '\\' '/')
# posix
else
echo "$1"
fi
}
# showing help
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo "$(basename "$0") [-h] -- Runs the installation:
-h/--help show this help text
--production installs as production release (under BACKBONE_ROOT). Otherwise, if not supplied installs under BACKBONE_DEV_ROOT (default)"
exit 0
fi
# reading info.json
name=$(grep -Po "\"name\": *\K\"[^\"]*\"" info.json | cut -d '"' -f 2)
type=$(grep -Po "\"type\": *\K\"[^\"]*\"" info.json | cut -d '"' -f 2)
version=$(grep -Po "\"version\": *\K\"[^\"]*\"" info.json | cut -d '"' -f 2)
if [[ -z "$type" || -z "$name" || -z "$version" ]]; then
echo "Error, missing type, name or version from info.json"
exit 1
fi
targetSuffixPath="$type/$name/$version"
# production release
if [[ $* == *--production* ]]; then
# making sure BACKBONE_ROOT is defined
if [[ -z $BACKBONE_ROOT ]]; then
echo "BACKBONE_ROOT is not defined!"
exit 1
fi
if [[ "$BBASE_DEPLOYMENT_IGNORE_PROMPT" == "1" ]]; then
response="yes"
# showing a prompt confirmation to avoid mistakes
else
read -r -p "Are you sure you want to run the production release? [y/N] " response
fi
if [[ "$response" =~ ^(yes|y)$ ]]; then
# running installation
target=$(__normalizeOsPath "$BACKBONE_ROOT/$targetSuffixPath")
if [[ -e "$target" ]]; then
echo "Cannot override an existent production release: $target"
exit 1
fi
# Since this config lives on the server, creating a build directory
# on tmp for this module to speed-up things.
buildDirectory=$(__normalizeOsPath "$(mktemp --tmpdir -d $name-build-production.XXXXXXXXX)")
cmake -DCMAKE_INSTALL_PREFIX="$target" -B$buildDirectory
cmake --install $buildDirectory --prefix="$target"
echo "Production deployment completed: $target"
fi
# development release
else
# making sure BACKBONE_DEV_ROOT is defined
if [[ -z $BACKBONE_DEV_ROOT ]]; then
echo "BACKBONE_DEV_ROOT is not defined"
exit 1
fi
# preparing build
buildDirectory=$(__normalizeOsPath "$(mktemp --tmpdir -d $name-build-dev.XXXXXXXXX)")
target=$(__normalizeOsPath "$BACKBONE_DEV_ROOT/$targetSuffixPath")
# running installation
cmake -DCMAKE_INSTALL_PREFIX="$target" -B$buildDirectory
cmake --install $buildDirectory --prefix="$target"
fi