-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbootstrap.sh
executable file
·74 lines (61 loc) · 1.94 KB
/
bootstrap.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
#!/bin/sh
# Submodules
# These are not actual git submodules, at least for now. They are still just
# separate, independent repositories that are cloned here.
LIBFLUID_BASE_SUBMODULE="libfluid_base"
LIBFLUID_BASE_RELEASE="v0.1"
LIBFLUID_MSG_SUBMODULE="libfluid_msg"
LIBFLUID_MSG_RELEASE="v0.1"
GIT_REPO="https://github.com/OpenNetworkingFoundation"
GIT_REPO_DEV="[email protected]:OpenNetworkingFoundation"
# Utility functions
check() {
if test $? -ne 0; then
echo $1
exit
fi
}
init_lib() {
SUBMODULE="$1"
RELEASE="$2"
FLAG="$3"
echo "Initializing '$SUBMODULE'..."
# Check if submodule already exists
if test -e "$SUBMODULE"; then
read -r -p "File or directory '$SUBMODULE' exists. Overwrite [Y/n]? " \
OVERWRITE;
if [ "$OVERWRITE" = "Y" ]; then
rm -rf $SUBMODULE
else
echo "Keeping '$SUBMODULE' intact and not cloning repository."
return 0
fi
fi
# Clone
CLONE_PREFIX="$GIT_REPO"
if [ "$FLAG" = "dev" ]; then
CLONE_PREFIX="$GIT_REPO_DEV"
fi
git clone $CLONE_PREFIX/$SUBMODULE.git
check "Error cloning '$SUBMODULE' repository."
cd $SUBMODULE
# If using the development flag, keep the repository in the master branch.
if [ "$FLAG" = "dev" ]; then
cd ..
return 0
fi
# Figure out the most recent patch version for the chosen minor release
TAG=`git describe --match "$RELEASE*" --tags --abbrev=0`
check "Tag not found for '$SUBMODULE' $RELEASE."
echo "Checking out '$SUBMODULE' $RELEASE..."
git checkout tags/$TAG
check "Error checking out '$SUBMODULE' $TAG."
# Run autogen.sh (build autoconf tools)
./autogen.sh
check "Error running autogen.sh for '$SUBMODULE'."
cd ..
}
# Main
init_lib $LIBFLUID_BASE_SUBMODULE $LIBFLUID_BASE_RELEASE $1
init_lib $LIBFLUID_MSG_SUBMODULE $LIBFLUID_MSG_RELEASE $1
echo "Bootstrapping done."