-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.sh
executable file
·104 lines (95 loc) · 2.25 KB
/
checkout.sh
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
#!/bin/bash
set -eu
PROGNAME="$0"
my_dir="$(dirname $(readlink -f $0))"
if echo "$my_dir" | grep -E '/holoocean_tools(/.*)?' >/dev/null 2>&1
then
HOLOOCEAN_DIR="$(echo "$my_dir" | sed -E 's#/holoocean_tools(/.*)?$##')"
else
echo "Unable to detect HoloOcean base folder: $my_dir"
exit 1
fi
SKIP_TOOLS=false
GET_UNREAL=false
GET_HOLOOCEAN=false
SWITCH_BRANCH=false
RESET_BRANCH=false
BASE_URL="https://github.com/migeran"
function help() {
echo "Usage: $PROGNAME [--switch-branch] [--reset] [--skip-tools] [--base-url <url>] [--dev-build]"
}
# checkout <url> <local_path> <branch>
function checkout() {
url="$1"
local_path="$2"
branch="$3"
checkout_path="$HOLOOCEAN_DIR/$local_path"
if [ ! -d "$checkout_path" ]
then
mkdir -p "$checkout_path"
fi
cd "$checkout_path"
if [ ! -d .git ]
then
echo "Cloning $url:$branch -> $checkout_path"
git clone "$url" -b "$branch" .
else
echo "Updating $checkout_path"
git fetch
if [ "$RESET_BRANCH" = "true" ]
then
echo " Resetting current branch"
git reset --hard
fi
if [ "$SWITCH_BRANCH" = "true" ]
then
echo " Switching to branch $branch"
git checkout $branch
fi
git pull
fi
if [ -f .gitmodules ]
then
echo "Updating submodules at $checkout_path"
git submodule update --init --recursive
fi
}
while [ "${1:-}" != "" ]
do
case "$1" in
--base-url)
shift
BASE_URL="$1"
;;
--skip-tools)
SKIP_TOOLS=true
;;
--switch-branch)
SWITCH_BRANCH=true
;;
--reset)
RESET_BRANCH=true
;;
--dev-build)
GET_UNREAL=true
GET_HOLOOCEAN=true
;;
*)
help
exit 1
esac
shift
done
if ! $SKIP_TOOLS
then
checkout $BASE_URL/holoocean_tools.git holoocean_tools main
fi
checkout $BASE_URL/holoocean_ros.git holoocean_ros main
if $GET_UNREAL
then
checkout git@github.com:EpicGames/UnrealEngine.git UnrealEngine 4.27
fi
if $GET_HOLOOCEAN
then
checkout https://bitbucket.org/frostlab/holoocean.git holoocean develop
fi