3 # A script to do automatic builds with several different configurations
5 # (C) 2008 Nelson Ferreira
8 # This program is free software; you can redistribute it and/or modify it
9 # under a BSD-like licence.
11 # Redistribution and use in source and binary forms, with or without
12 # modification, are permitted provided that the following conditions are met:
13 # Redistributions of source code must retain the above copyright notice, this
14 # list of conditions and the following disclaimer.
15 # Redistributions in binary form must reproduce the above copyright notice,
16 # this list of conditions and the following disclaimer in the documentation
17 # and/or other materials provided with the distribution.
18 # Neither the name of the Technical University of Berlin nor the names of its
19 # contributors may be used to endorse or promote products derived from this
20 # software without specific prior written permission.
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
35 if [ -n "$LOG_FILE" ]; then
36 echo "$0 $(date): $@" >> $LOG_FILE
40 if [ ! -f ./,,conf ]; then
42 # --*-shell-script-*--
44 # The path to the SXEmacs source
45 SOURCE=/path/to/sxemacs
47 # Hammer value when doing autogen.sh [Check it for more details
50 # Autogen command [leave empty in order to skip it]
51 AUTOGEN="./autogen.sh"
53 # The command line arguments to pass to the make command
54 MAKE_ARGS="time-build-report"
56 # File to log progress to
57 LOG_FILE=",,build.log"
59 # Make a ++TAGS directory
62 # Remove the build directory when build is successful
63 # (and after reporting...) ?
67 # Report the build status with an email?
69 # Failures or F (Failures only)
70 # Success or S (Successes only)
71 # Anything else - No reports at all
74 # Send success email to this address instead of sxemacs-devel@sxemacs.org
77 # Send failure email to this address instead of sxemacs-devel@sxemacs.org
80 # The email should come from this email address
81 # [ $USER@$(hostname -f 2> /dev/null || (hostname ; domainname)) will be used otherwise
84 echo "Please review the generated ,,conf file and rerun."
88 if [ -z "${SOURCE}" -o ! -d "${SOURCE}" -o ! -f ${SOURCE}/sxemacs.pc.in ]; then
89 echo "No SXEmacs source found at ${SOURCE}"
92 if [ -z "${MAIL_FROM}" ]; then
93 MAIL_FROM="${USER}@$(hostname -f 2> /dev/null || (hostname ; domainname))"
94 echo "WARNING: No mail from defined. Will use ${MAIL_FROM} instead."
97 if [ -n "${AUTOGEN}" ]; then
101 if [ -n "${HAMMER}" ]; then
102 echo HAMMER: ${HAMMER}
104 (export HAMMER ; ${AUTOGEN} ) || STATUS=FAIL_AUTOGEN
107 if [ -n "${STATUS}" ]; then
108 do_log "Failure: ${STATUS}"
111 if [ -n "${BUILD_TAGS}" ]; then
112 # Let's build ourselfs the tags for this source tree,
116 eval "${PREFIX}/configure" || STATUS="FAIL_CONFIGURE_$?"
117 if [ -z "${STATUS}" ]; then
118 make tags || STATUS="FAIL_TAGS_$?"
122 if [ -n "${STATUS}" ]; then
123 do_log "Failure: ${STATUS}"
127 if [ "$f" = "*.conf" ]; then
128 echo "Nothing to do - create some .conf files! "
132 CONF_OPTS="$(cat $f)"
133 build_name="$(echo ${f} |sed 's/\.conf$//')"
134 do_log "Started building ${build_name}"
135 if [ -d "./${build_name}" ]; then
136 /bin/rm -rf "./${build_name}"
138 mkdir -p "./${build_name}"
141 eval "${PREFIX}/configure ${CONF_OPTS}" || STATUS="FAIL_CONFIGURE_$?"
142 if [ "${STATUS}" = "FAIL_CONFIGURE_127" -a -f "./Installation" -a -f "./config.log" ]; then
143 if [ $(tail -1 ./config.log) = "configure: exit 0" ]; then
144 STATUS="FAIL_CONFIGURE_0"
147 if [ -z "${STATUS}" -o "${STATUS}" = "FAIL_CONFIGURE_0" ]; then
149 make ${MAKE_ARGS} || STATUS="FAIL_MAKE_$?"
150 if [ "${STATUS}" = "FAIL_MAKE_0" ]; then
153 if egrep '^make.*:.*Error' ,,beta.out; then
154 STATUS="${STATUS}_ERROR_IN_BUILD"
156 if [ -f ,,make-check.out ]; then
157 if [ ! "${STATUS}" = "Success" ]; then
159 elif [ -n "$(grep 'tests successful' ,,make-check.out | grep -v 100%)" ]; then
160 STATUS="Sucess(Some tests fail)"
167 if [ "${REPORT_STATUS}" = "Yes" -o "${REPORT_STATUS}" = "Y" ]; then
169 elif [ "${STATUS}" = "Success" -o "${STATUS}" = "Sucess(Some tests fail)" ]; then
170 if [ "${REPORT_STATUS}" = "Success" -o "${REPORT_STATUS}" = "S" ]; then
173 elif [ "${REPORT_STATUS}" = "Failures" -o "${REPORT_STATUS}" = "F" ]; then
176 if [ "${REPORT_THIS}" = "Yes" ]; then
177 if [ "${STATUS}" = "Success" -o "${STATUS}" = "Tests fail" -o "${STATUS}" = "Sucess(Some tests fail)" ]; then
178 # First test if can actually send email from SXEmacs, otherwise just give up :-)
179 CLI=" -eval \"(unless (fboundp 'mail-send-and-exit) (kill-emacs 2))\""
180 if [ -n "${MAIL_FROM}" ]; then
181 CLI="${CLI} -eval '(setq user-mail-address \"$MAIL_FROM\")'"
183 if [ -n "$MAIL_SUCCESS_TO" ]; then
184 CLI="${CLI} -eval '(setq build-rpt-email \"${MAIL_SUCCESS_TO}\")'"
186 CLI="${CLI} -eval '(if (send-build-rpt \"${STATUS}\") (kill-emacs 0) (kill-emacs 1))'"
187 eval "src/sxemacs -batch ${CLI}" || DO_REPORT_FAILURE="YES" STATUS="${STATUS}-Build-Rpt-Failed-$?"
189 DO_REPORT_FAILURE="YES"
191 if [ "${DO_REPORT_FAILURE}" = "YES" ]; then
192 ${PREFIX}/contrib/report-build-failure.sh "${MAIL_FROM}" "${MAIL_FAILURE_TO}" "${STATUS}"
196 if [ "${STATUS}" = "Success" ]; then
197 if [ "${REMOVE_ON_SUCCESS}" = "Yes" -o "${REMOVE_ON_SUCCESS}" = "Y" ]; then
198 /bin/rm -rf "./${build_name}"
201 do_log "Finished building ${build_name}: ${STATUS}"