6 # Get the absolute path of a file.
7 # Args 1: Relative path to file
10 if [[ "$?" != "0" ]]; then
11 echo "Error: Could not get absolute path to \"$1\"." 1>&2
16 SCRIPT_NAME
=`basename "$0"`
17 SCRIPT_DIR
=`get_absolute_path "$PWD"`
18 SCRIPT_TMP_DIR
="$SCRIPT_DIR/tmp"
19 SCRIPT_PARENT_DIR
=`get_absolute_path "$SCRIPT_DIR/.."`
20 SCRIPT_PATH
="$SCRIPT_DIR/$SCRIPT_NAME"
21 BACKEND_DIR
=`get_absolute_path ../backend`
22 IRRECO_DIR
=`get_absolute_path ../irreco`
23 IRRECO_DATA
="$IRRECO_DIR/data"
24 IRRECO_SRC
="$IRRECO_DIR/src"
25 INSTALL_DIR
=`get_absolute_path ".."`"/install"
26 MAKE_LOG_FILE
="$SCRIPT_TMP_DIR/make_log"
27 RUN_LOG_FILE
="$SCRIPT_TMP_DIR/run_log"
28 DEB_LOG_FILE
="$SCRIPT_TMP_DIR/deb_log"
30 EXIT_CODE_FILE
="$SCRIPT_TMP_DIR/exit_code"
32 mkdir
-p "$SCRIPT_TMP_DIR"
36 #THEME_DIR='../../../../themes'
37 #if [ ! -d "$THEME_DIR" ]; then
38 # THEME_DIR='../../../themes'
39 # if [ ! -d "$THEME_DIR" ]; then
40 # THEME_DIR='../../themes'
41 # if [ ! -d "$THEME_DIR" ]; then
42 # echo "Cant find theme dir"
49 if [ ! -d "$THEME_DIR" ]; then
50 echo "Cant find theme dir"
54 THEME_DIR
=`get_absolute_path "$THEME_DIR"`
59 #IRTRANS_DIR='../../../../irtrans/'
60 #if [ ! -d "$IRTRANS_DIR" ]; then
61 # IRTRANS_DIR='../../../irtrans/'
62 # if [ ! -d "$IRTRANS_DIR" ]; then
63 # IRTRANS_DIR='../../irtrans/'
64 # if [ ! -d "$IRTRANS_DIR" ]; then
65 # echo "Cant find theme dir"
71 IRTRANS_DIR
='../irtrans/'
72 if [ ! -d "$IRTRANS_DIR" ]; then
73 echo "Cant find theme dir"
77 IRTRANS_DIR
=`get_absolute_path "$IRTRANS_DIR"`
78 IRTRANS_SHLIB_DIR
="$IRTRANS_DIR/shlib"
79 IRTRANS_IRSERVER_DIR
="$IRTRANS_DIR/irserver"
89 if [ ! -e "$INSTALL_DIR" ]; then
97 if [[ "$_SBOX_DIR" == "" ||
98 "$_SBOX_RESTART_FILE" == "" ||
99 "$_SBOX_SHELL_PID" == "" ||
100 "$_SBOX_USER_GROUPNAME" == "" ]]; then
101 echo "Error: Need scratchbox."
105 #which sb-conf &> /dev/null
106 #if [[ "$?" != "0" ]]; then
107 # echo "Error: Need scratchbox."
114 if [[ "$_SBOX_DIR" != "" ||
115 "$_SBOX_RESTART_FILE" != "" ||
116 "$_SBOX_SHELL_PID" != "" ||
117 "$_SBOX_USER_GROUPNAME" != "" ]]; then
118 echo "Error: Cant run this command inside scratchbox."
122 #which sb-conf &> /dev/null
123 #if [[ "$?" == "0" ]]; then
124 # echo "Error: Cant run this command inside scratchbox."
136 for ((LEN
+= 6; LEN
<= 80; LEN
++)); do
143 # Check log for error & warnings
148 REGEX
="(warning|error|cannot find"
149 REGEX
="$REGEX|^[0-9a-zA-Z\/._-]+\.[cho]:"
150 REGEX
="$REGEX|^[0-9a-zA-Z\/._-]+:[0-9]+"
151 REGEX
="$REGEX|^[0-9a-zA-Z\/._-]+:[0-9]+:[0-9]+"
152 REGEX
="$REGEX|^:[0-9a-zA-Z\/._-]+"
155 egrep -i -A $ERROR_CONTEXT -B $ERROR_CONTEXT --color=yes "$REGEX" "$1"
157 if [[ "$2" == "1" ]]; then
158 if [[ "$EXIT_CODE" != "0" ]]; then
169 echo "$?" > "$EXIT_CODE_FILE"
174 EXIT_CODE
=`cat "$EXIT_CODE_FILE"`
180 # Stop script if exit code is not 0
182 # Usage: check_exit_code "$?"
185 if [[ "$1" != "0" ]]; then
186 if [[ "$2" != "" ]]; then
187 echo "Error:" "$2" "$3" "$4" "$5"
200 for ((; LEN
> 0; LEN--
)); do
210 # Generic build functions
219 save_exit_code
make "${MAKE_ARGS[@]:1}" 2>&1 |
tee "$MAKE_LOG_FILE"
222 check_log
"$MAKE_LOG_FILE" "1"
233 if [ -e "Makefile" ]; then
239 if [ -e "autoclean.sh" ]; then
246 # Save current sb_target to file,
247 # and return 0 if it is the same as current target.
252 CURRENT_TARGET
=`sb-conf current`
254 if [ -f "$SB_TARGET_FILE" ]; then
255 PREVIOUS_TARGET
=`cat "$SB_TARGET_FILE"`
260 #echo "SB_TARGET_FILE = $SB_TARGET_FILE"
261 #echo "CURRENT_TARGET = $CURRENT_TARGET"
262 #echo "PREVIOUS_TARGET = $PREVIOUS_TARGET"
264 if [[ "$CURRENT_TARGET" != "$PREVIOUS_TARGET" ]]; then
265 echo "Saving \"$CURRENT_TARGET\" to \"$SB_TARGET_FILE\""
266 echo "$CURRENT_TARGET" > "$SB_TARGET_FILE"