-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbash
More file actions
133 lines (120 loc) · 4.15 KB
/
bash
File metadata and controls
133 lines (120 loc) · 4.15 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Rock-specific shell functions
#
function rock-find-root() {
local __resultvar=$1
# Allow to set the ROCK_ROOT_DIR externally
# to avoid complete dependence upon finding the env.sh
if [ "$ROCK_ROOT_DIR" = "" ]; then
local ROCK_ROOT_DIR=""
if [ -e "$PWD/env.sh" ]; then
ROCK_ROOT_DIR=$PWD
else
ROCK_ROOT_DIR=`echo $PWD`
while [ true ]; do
if [ "$ROCK_ROOT_DIR" = "" ]; then
break
fi
ROCK_ROOT_DIR=`echo $ROCK_ROOT_DIR | sed 's/\(.*\)\/[^\/]*/\1/g'`
if [ -e "$ROCK_ROOT_DIR/env.sh" ]; then
break
fi
done
fi
fi
eval $__resultvar="${ROCK_ROOT_DIR}"
}
function rock-source-env() {
rock-find-root DIR
if [ -d "${DIR}" ]; then
echo "Sourcing ${DIR}/env.sh"
source ${DIR}/env.sh
else
echo "Warning: no env.sh found"
fi
}
# The bundle support requires the base/scripts package to be installed
function rock-bundle-sel() {
if ! test -f $AUTOPROJ_CURRENT_ROOT/.bundle_env.sh; then
echo "something's wrong: the $AUTOPROJ_CURRENT_ROOT/.env_bundle.sh does not exist."
echo "have you successfully installed autoproj the base/scripts package ?"
return 1
fi
name=$1
bundle_path=$(rock-bundle-find $name)
if test "x$?" != "x0"; then
echo "cannot find bundle $name, run bundle-info to get the list of available bundles"
return 1
elif test -z "$name" || test -d "$name"; then
bundle_path=$(echo $bundle_path | tail -n1)
export ROCK_BUNDLE=$bundle_path
rock-bundle-info
return 0
else
export ROCK_BUNDLE=$name
rock-bundle-info
return 0
fi
}
function rock-bundle-default() {
if ! test -f $AUTOPROJ_CURRENT_ROOT/.bundle_env.sh; then
echo "something's wrong: the $AUTOPROJ_CURRENT_ROOT/.env_bundle.sh does not exist."
echo "have you successfully installed autoproj the base/scripts package ?"
return 1
fi
if test -z "$1"; then
echo "# File generated by the bundle-default command" > $AUTOPROJ_CURRENT_ROOT/.bundle_env.sh
echo "# Do not change ! Your changes would be overriden !" >> $AUTOPROJ_CURRENT_ROOT/.bundle_env.sh
echo "unset ROCK_BUNDLE" >> $AUTOPROJ_CURRENT_ROOT/.bundle_env.sh
elif rock-bundle-sel $1; then
echo "# File generated by the bundle-default command" > $AUTOPROJ_CURRENT_ROOT/.bundle_env.sh
echo "# Do not change ! Your changes would be overriden !" >> $AUTOPROJ_CURRENT_ROOT/.bundle_env.sh
echo "export ROCK_BUNDLE=$ROCK_BUNDLE" >> $AUTOPROJ_CURRENT_ROOT/.bundle_env.sh
return 0
fi
}
function rock-bundle-unsel() {
unset ROCK_BUNDLE
}
function rock-log-level() {
if test "x$#" != "x1" || test "$1" = "--help" || test "$1" = "-h"; then
echo "usage: $0 <log-level>"
echo "Allows setting of logging level for Orocos and Rock in parallel."
echo ""
echo "Available general logging levels:"
echo " DEBUG, INFO, WARN, ERROR, FATAL"
echo "Applied to Orocos only"
echo " REALTIME, CRITICAL"
echo ""
echo "Current setting of environmental variables:"
echo " BASE_LOG_LEVEL=$BASE_LOG_LEVEL"
echo " ORO_LOGLEVEL=$ORO_LOGLEVEL"
return
fi
if test "$1" = "REALTIME"; then
export ORO_LOGLEVEL=7
return
elif test "$1" = "CRITICAL"; then
export ORO_LOGLEVEL=2
return
fi
if test "$1" = "DEBUG"; then
export ORO_LOGLEVEL=6
elif test "$1" = "INFO"; then
export ORO_LOGLEVEL=5
elif test "$1" = "WARN" || test "$1" = "WARNING"; then
export ORO_LOGLEVEL=4
elif test "$1" = "ERROR"; then
export ORO_LOGLEVEL=3
elif test "$1" = "FATAL"; then
export ORO_LOGLEVEL=1
else
echo "Unknown logging level: $1"
return
fi
export BASE_LOG_LEVEL=$1
}
alias bundle-sel=rock-bundle-sel
alias bundle-unsel=rock-bundle-unsel
alias bundle-default=rock-bundle-default
alias bundle-find=rock-bundle-find
alias bundle-info=rock-bundle-info