forked from rock-simulation/mars_install_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mars.sh
executable file
·103 lines (89 loc) · 2.32 KB
/
mars.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
#! /bin/bash
PUSH=false
for i in $*; do
if [ "$i" = "+w" ]; then
PUSH=true
fi
LAST=$i
done
PACKAGE_FILE="packageList.txt"
pushd . > /dev/null 2>&1
function setScriptDir {
if [[ x"${MARS_SCRIPT_DIR}" == "x" ]]; then
MARS_SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
fi
export MARS_SCRIPT_DIR=${MARS_SCRIPT_DIR}
}
setScriptDir
source ${MARS_SCRIPT_DIR}/func_collection.sh
if [[ $# == 0 ]]; then
printErr "Please specify an action. Your options are:
bootstrap, fetch, update, install, rebuild, clean, diff, envsh, or uninstall"
popd > /dev/null 2>&1
exit 1
fi
setupConfig || exit 1
SOURCES_FILE="sources.txt"
while read source_file; do
source_file=${source_file/\#*/}
if [[ x${source_file} = x ]]; then
continue
fi
eval $(parse_yaml "${MARS_SCRIPT_DIR}/${source_file}" "")
done < ${MARS_SCRIPT_DIR}/${SOURCES_FILE}
if [[ -f ${MARS_SCRIPT_DIR}/${LAST} ]]; then
PACKAGE_FILE=$LAST
else
last_clean=${LAST//-/_}
p="${last_clean}_path"
if [[ x${!p} != x ]]; then
PACKAGE_FILE=$LAST
fi
fi
for arg in $*; do
case ${arg} in
bootstrap)
forAllPackagesDo fetch || exit 1
forAllPackagesDo patch || exit 1
setup_env || exit 1
forAllPackagesDo install || exit 1
;;
fetch)
forAllPackagesDo fetch || exit 1
forAllPackagesDo patch || exit 1
;;
update)
forAllPackagesDo update || exit 1
;;
install)
setup_env || exit 1
forAllPackagesDo patch || exit 1
forAllPackagesDo install || exit 1
;;
clean)
forAllPackagesDo clean || exit 1
;;
rebuild)
forAllPackagesDo clean || exit 1
setup_env || exit 1
forAllPackagesDo install || exit 1
;;
diff)
forAllPackagesDo diff || exit 1
;;
envsh)
setup_env || exit 1
;;
uninstall)
forAllPackagesDo uninstall || exit 1
;;
+w)
;;
*)
if ! [ "${arg}" = "${PACKAGE_FILE}" ]; then
printErr "unsupported argument \"${arg}\"."
fi
;;
esac
done
popd > /dev/null 2>&1