-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathget_dependencies.sh
100 lines (80 loc) · 2.29 KB
/
get_dependencies.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
#!/usr/bin/env bash
SWD=$(cd $(dirname $0);echo $PWD)
function get_build_dependency() {
echo "${CYAN}GET $1 build dependencies"
git clone -b $1 --single-branch --depth 1 https://gitlab.com/mathbou/docker-cgwire.git $SWD/$1 || :
if $FORCE && $UPDATE; then
git -C $SWD/$1 reset --hard || :
fi
if $UPDATE; then
git -C $SWD/$1 pull --rebase || :
fi
}
function get_develop_dependency(){
echo "${MAGENTA}GET $1 develop dependencies"
git clone -b master https://github.com/cgwire/$1.git $SWD/$1-dev || :
if $FORCE && $UPDATE; then
git -C $SWD/$1-dev reset --hard || :
fi
if $UPDATE; then
git -C $SWD/$1-dev pull --rebase || :
fi
}
# --------------------------------------------------------------
# ---------------------------- ARGS ----------------------------
# --------------------------------------------------------------
source $SWD/common.sh
DEVELOP=false
case $1 in
develop)
DEVELOP=true
shift
;;
esac
UPDATE=false
FORCE=false
for i in "$@"; do
case $i in
--update)
UPDATE=true
echo "${CYAN}UPDATE DEPENDENCIES"
shift
;;
--force)
FORCE=true
echo "${MAGENTA}/!\\ FORCE UPDATE /!\\ "
shift
;;
-h | --help)
echo "
Usage:
get_dependencies.sh [subcommand] [options]
Subcommand:
develop Get dependencies for development containers
Flags:
--update Pull dependencies if clone fails
--force Combine with `--update`. Hard reset instead of pull.
-h, --help Show this help
"
exit 0
;;
*)
echo "${ERROR}Invalid flag ${i} // Use -h or --help to print help"
exit 1
;;
esac
done
# --------------------------------------------------------------
# ---------------------------- MAIN ----------------------------
# --------------------------------------------------------------
if $FORCE && ! $UPDATE; then
echo "${ERROR}Force flag works with 'update' flag only"
exit 1
fi
if $DEVELOP; then
get_develop_dependency kitsu
get_develop_dependency zou
else
get_build_dependency kitsu
get_build_dependency zou
fi