-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall
executable file
·95 lines (79 loc) · 2.93 KB
/
install
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
#!/bin/bash
# current dir
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# 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 UPIPE_ROOT). Otherwise, if not supplied installs under UPIPE_DEV_ROOT (default)
--update-alpha update alpha release symlink to point to the version provided by info.json
--update-beta update beta release symlink to point to the version provided by info.json
--update-stable update stable release symlink to point to the version provided by info.json
--update-all update all release symlinks (alpha, beta and stable) to point to the version provided by info.json"
exit 0
fi
updateReleaseSymlinks() {
installRoot="$1"
declare info=($(cat "$dir/info.json" | jq -r ".name, .version, .type"))
local name=${info[0]}
local version=${info[1]}
local type=${info[2]}
for releaseType in stable beta alpha; do
# removing current soft-link
local targetReleaseLocation="$installRoot/$type/$name/$releaseType"
if [[ $* == *--update-$releaseType* || $* == *--update-all* ]]; then
if [[ -L "$targetReleaseLocation" ]]; then
rm $targetReleaseLocation
fi
fi
# creating soft-link
if ! [[ -L "$targetReleaseLocation" ]]; then
echo "- Updating $releaseType release to point to $version ($targetReleaseLocation -> $(dirname $targetReleaseLocation)/$version)"
ln -s $version $targetReleaseLocation
fi
done
unset info
}
# making sure jq is installed
if ! [ -x "$(command -v jq)" ]; then
echo 'ERROR "jq" IS NOT INSTALLED (https://stedolan.github.io/jq/download/).' >&2
exit
fi
# production release
if [[ $* == *--production* ]]; then
# removing any previous build folder
if [ -d "build_release" ]; then
rm -r "build_release"
fi
# making sure UPIPE_ROOT is defined
if [ -z $UPIPE_ROOT ]; then
echo "UPIPE_ROOT is not defined"
exit 1
fi
# showing a prompt confirmation, in case of a mistake
read -r -p "Are you sure you want to run the production release? [y/N] " response
if [[ "$response" =~ ^(yes|y)$ ]]; then
# running installation
qbs build_release project.releaseType:production qbs.installRoot:$UPIPE_ROOT
# updating release
updateReleaseSymlinks $UPIPE_ROOT $@
fi
# development release
else
# making sure UPIPE_DEV_ROOT is defined
if [ -z $UPIPE_DEV_ROOT ]; then
echo "UPIPE_DEV_ROOT is not defined"
exit 1
fi
# TODO: workaround to avoid the installation not detecting
# modifications in files and installing a wrong version from the cache
# (rather than invalidating the cache).
# This issue has been noticed in qbs 1.8.1
if [ -d "default" ]; then
rm -r "default"
fi
# running installation
qbs project.releaseType:dev qbs.installRoot:$UPIPE_DEV_ROOT
# updating release
updateReleaseSymlinks $UPIPE_DEV_ROOT $@
fi