0bf1b2f7
Peter M. Groen
Fixed script.
|
1
|
#!/bin/bash
|
bbca8c1a
Peter M. Groen
Added comments to...
|
2
3
4
5
|
# ===============================================
# == Setting some environment variables
# ===============================================
|
59367614
Peter M. Groen
Install script..
|
6
|
GIT_URL_SUBS="http://gitlab.osdev.nl/open_source"
|
bbca8c1a
Peter M. Groen
Added comments to...
|
7
|
FUNC_RESULT="-1"
|
b5d9e433
Peter M. Groen
Fixed License Hea...
|
8
|
|
bbca8c1a
Peter M. Groen
Added comments to...
|
9
10
11
12
13
|
# Name : print_usage_exit()
# Description : Print the way this script is intended to be used and exit.
# Parameters : None.
# Returns : err_code 1 to the Operating System
# --------------------------------------------------------------------------------------
|
e0b1fe64
Peter M. Groen
Fixed script.
|
14
15
|
function print_usage_exit()
{
|
b5d9e433
Peter M. Groen
Fixed License Hea...
|
16
17
18
19
20
21
22
|
echo "Usage $0 -i|--install|-u|--update"
echo " -i or --install Install the submodules mentioned in the submodules.list"
echo " -u or --update Update the submodules mentioned in the submodules.list"
echo " "
exit 1
}
|
bbca8c1a
Peter M. Groen
Added comments to...
|
23
24
25
26
27
28
29
30
31
|
# Name : check_top_or_sub
# Description : Determine if we're running in a "single" lib-build or part of a
# "meta"-repository ( submodule ).
# Parameters : None
# Returns : Updates the value FUNC_RESULT.
# -1 - We're neither a git-repo or submodule.
# 0 - We're a submodule
# 1 - We're a top-repo ( Single library )
# --------------------------------------------------------------------------------------
|
e0b1fe64
Peter M. Groen
Fixed script.
|
32
33
|
function check_top_or_sub()
{
|
59367614
Peter M. Groen
Install script..
|
34
35
36
|
# This function checks if we're the top-repository.
# In that case we need the submodules.. If we're already a submodule,
# we simply exit this script with a message
|
e0b1fe64
Peter M. Groen
Fixed script.
|
37
38
39
40
41
|
if [ -e ./.git ]; then
FUNC_RESULT="1"
return
elif [ -e ../.git ]; then
if [ -e ../.submodules ]; then
|
59367614
Peter M. Groen
Install script..
|
42
|
echo "Seems like we're already a submodule. Nothing to do here."
|
e0b1fe64
Peter M. Groen
Fixed script.
|
43
44
|
FUNC_RESULT="0"
return
|
59367614
Peter M. Groen
Install script..
|
45
46
|
fi
fi
|
bbca8c1a
Peter M. Groen
Added comments to...
|
47
|
FUNC_RESULT="-1"
|
e0b1fe64
Peter M. Groen
Fixed script.
|
48
|
return
|
59367614
Peter M. Groen
Install script..
|
49
50
|
}
|
bbca8c1a
Peter M. Groen
Added comments to...
|
51
52
53
54
55
56
57
58
|
# Name : check_working_dir
# Description : If we're in the top of our repo, we can run this script further.
# Parameters : None.
# Returns : Updates the value FUNC_RESULT.
# -1 - Not used.
# 0 - We're not on the top-level
# 1 - We're at the top-level. Good to go.
# --------------------------------------------------------------------------------------
|
e0b1fe64
Peter M. Groen
Fixed script.
|
59
60
|
function check_working_dir()
{
|
bbca8c1a
Peter M. Groen
Added comments to...
|
61
|
FUNC_RESULT="-1"
|
59367614
Peter M. Groen
Install script..
|
62
63
64
|
# Check if we're in the top-level directory of our repository.
if [ -f ./scripts/submodules.list ]; then
# We're good to go
|
e0b1fe64
Peter M. Groen
Fixed script.
|
65
66
|
FUNC_RESULT="1"
return
|
59367614
Peter M. Groen
Install script..
|
67
|
fi
|
e0b1fe64
Peter M. Groen
Fixed script.
|
68
69
|
FUNC_RESULT="0"
return
|
59367614
Peter M. Groen
Install script..
|
70
71
|
}
|
bbca8c1a
Peter M. Groen
Added comments to...
|
72
73
74
75
76
77
78
|
# Name : read_submodules
# Description : Read the list of submodules needed for this project
# Parameters : None
# Returns : Updates the value FUNC_RESULT
# 0 - Module list was not found
# 1 - Module list was found and read.
# --------------------------------------------------------------------------------------
|
e0b1fe64
Peter M. Groen
Fixed script.
|
79
80
|
function read_submodules()
{
|
bbca8c1a
Peter M. Groen
Added comments to...
|
81
|
FUNC_RESULT="-1"
|
59367614
Peter M. Groen
Install script..
|
82
83
|
if [ -e ./scripts/submodules.list ]; then
source ./scripts/submodules.list
|
bbca8c1a
Peter M. Groen
Added comments to...
|
84
85
|
FUNC_RESULT="1"
return
|
b5d9e433
Peter M. Groen
Fixed License Hea...
|
86
|
fi
|
bbca8c1a
Peter M. Groen
Added comments to...
|
87
88
89
90
|
echo "Submodules list not found...."
FUNC_RESULT="0"
return
|
b5d9e433
Peter M. Groen
Fixed License Hea...
|
91
92
|
}
|
bbca8c1a
Peter M. Groen
Added comments to...
|
93
94
95
96
97
|
# Name : add_submodules
# Description : Configure the repo to add the submodules.
# Parameters : None.
# Returns : None.
# --------------------------------------------------------------------------------------
|
e0b1fe64
Peter M. Groen
Fixed script.
|
98
99
|
function add_submodules()
{
|
bbca8c1a
Peter M. Groen
Added comments to...
|
100
|
echo -e "Adding SubModule(s)."
|
b5d9e433
Peter M. Groen
Fixed License Hea...
|
101
102
|
for SUB_MODULE in ${SUB_MODULES}
do
|
bbca8c1a
Peter M. Groen
Added comments to...
|
103
|
echo -e "< ${SUB_MODULE} >"
|
e0b1fe64
Peter M. Groen
Fixed script.
|
104
105
|
git submodule add -f ${GIT_URL_SUBS}/${SUB_MODULE}.git ${SUB_MODULE}
git config submodule.${SUB_MODULE}.url ${GIT_URL_SUBS}/${SUB_MODULE}.git
|
b5d9e433
Peter M. Groen
Fixed License Hea...
|
106
107
108
|
done
}
|
bbca8c1a
Peter M. Groen
Added comments to...
|
109
110
111
112
113
|
# Name : get_submodules
# Description : Actually get the submodules from gitlab and add them.
# Parameters : None
# Returns : None
# --------------------------------------------------------------------------------------
|
e0b1fe64
Peter M. Groen
Fixed script.
|
114
115
|
function get_submodules()
{
|
b5d9e433
Peter M. Groen
Fixed License Hea...
|
116
117
118
|
git submodule update --init --recursive
}
|
bbca8c1a
Peter M. Groen
Added comments to...
|
119
120
121
122
123
|
# Name : update_submodules
# Description : Update the submodules already added.
# Parameters : None
# Returns : None
# --------------------------------------------------------------------------------------
|
0bf1b2f7
Peter M. Groen
Fixed script.
|
124
125
|
function update_submodules()
{
|
b5d9e433
Peter M. Groen
Fixed License Hea...
|
126
127
128
129
130
131
|
git submodule update --recursive
}
# =============================================================================
# == T H E M A I N E N T R Y O F T H I S S C R I P T ==
# =============================================================================
|
e0b1fe64
Peter M. Groen
Fixed script.
|
132
133
|
check_top_or_sub
if [ "${FUNC_RESULT}" == "0" ]; then
|
59367614
Peter M. Groen
Install script..
|
134
135
136
137
|
echo "Seems like we're a submodule already or not part of a repository."
exit 0
fi
|
e0b1fe64
Peter M. Groen
Fixed script.
|
138
139
|
check_working_dir
if [ "${FUNC_RESULT}" == "0" ]; then
|
59367614
Peter M. Groen
Install script..
|
140
141
142
143
|
echo "Go to the top of this repository and type : scripts/setup_submodules [-i|--install]"
exit 0
fi
|
b5d9e433
Peter M. Groen
Fixed License Hea...
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
read_submodules
case "$1" in
-i*|--install*)
echo "Installing submodules for this repository ( ${PWD} )"
add_submodules
get_submodules
;;
-u*|--update*)
echo "Update submodules : ${SUB_MODULES}"
update_submodules
;;
*)
echo "No parameters found..."
print_usage_exit
;;
esac
|