5 # Skip certain parts of this script by exporting the variable
6 # "NIGHTLY_SKIP_STEP" containing the following possible substrings,
7 # preventing the named behaviour:
9 # REDIRECT - Redirect all output to a logfile
10 # CHECKOUT - Fill the sandbox with a fresh cvs checkout
11 # PATCH - Apply the patches for this system (global + specific)
12 # BUILD - Build everything
13 # GENERATE - Generate a new world
14 # SERVERSTART - Start the server
15 # TESTSCRIPT - Run the testscript
16 # SERVERSTOP - Stop the server if it was started by this script
17 # CLEANUP - Remove the contents of the sandbox
25 echo "Usage: ${PROGNAME} <configfile>" >&2;
44 [ -f "${SCRIPTDIR}/common.sh" ] || { echo "Broken config ?" >&2; exit 1; }
45 . "${SCRIPTDIR}"/common.sh
48 STAMP="`date +%Y%m%d%H%M%S`"
50 [ -n "${EXTRASUFFIX}" ] && WORKDIR="${WORKDIR}.${EXTRASUFFIX}"
51 LOGFILE="${LOGDIR}/${WORKDIR}.${STAMP}"
56 case "${NIGHTLY_SKIP_STEP}"
76 BOXDIR="${SCRIPTDIR}/${BOXDIR}"
80 cd "${BOXDIR}" || err "Could not chdir to ${BOXDIR}"
82 echo "Nightly build starting at `date`"
88 case "${NIGHTLY_SKIP_STEP}"
94 mkdir "${WORKDIR}" || warn "Could not create ${BOXDIR}/${WORKDIR}"
95 cd "${WORKDIR}" || err "Could not cd to ${BOXDIR}/${WORKDIR}"
97 echo "Getting source from CVS:"
99 export CVS_RSH=${CVS_RSH:=ssh}
100 export CVSROOT=${CVSROOT:=:pserver:anonymous@empserver.cvs.sourceforge.net:/cvsroot/empserver}
102 while ! cvs -z3 co empserver >/dev/null
104 sleep "`expr 5 + ${RETR}`"
105 RETR="`expr 1 + ${RETR}`"
106 [ "${RETR}" -gt 5 ] && err "CVS Timeout after ${RETR} retres."
120 case "${NIGHTLY_SKIP_STEP}"
125 echo "Applying global patches from ${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/All"
126 for i in "${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/All"/*.patch
128 [ -r "${i}" ] || continue
129 if ${PATCH:=patch} -Np0 < "${i}" >/dev/null
133 echo "========== ${i}: NOT OK! ${?} =========="
136 echo "Done (patch All)."
139 LOCALPATCHDIRECTORY="${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/${INSTANCE}"
140 if [ -n "${LOCALPATCHDIRECTORY}" -a -d "${LOCALPATCHDIRECTORY}/." ]
142 echo "Applying system specific patches from ${LOCALPATCHDIRECTORY}:"
143 for i in "${LOCALPATCHDIRECTORY}"/*.patch
145 [ -r "${i}" ] || continue
146 if ${PATCH:=patch} -Np0 < "${i}" >/dev/null
150 echo "========== ${i}: NOT OK! ${?} =========="
153 echo "Done (patch specific)."
157 cd empserver || err "Could not cd to ${BOXDIR}/${WORKDIR}/empserver."
161 ./configure --prefix ${BOXDIR}/${WORKDIR}/emp4
172 case "${NIGHTLY_SKIP_STEP}"
179 echo "Building server"
180 if make -k install >/dev/null
182 warn "make did not return 0"
193 # Try to run startup utilities
199 case "${NIGHTLY_SKIP_STEP}"
204 if [ -d ../emp4 -a -d ../emp4/bin -a -d ../emp4/sbin -a -d ../emp4/var/empire ]
206 echo "Directory structure is ok"
208 warn "Directory structure is NOT ok"
212 cd ../emp4/bin || err "Could not cd to ../emp4/bin"
214 echo "Determining type of files in bin directory"
216 echo "Done (file *)."
219 cd ../../emp4/sbin || err "Could not cd to ../../emp4/sbin"
221 echo "Determining type of files in sbin directory"
223 echo "Done (file *)."
226 echo "Running files and fairland"
227 echo y | ./files || warn "Error running files"
228 ./fairland -R 1 10 30 >/dev/null || { warn "Error running fairland" ; break ; }
229 [ -s "newcap_script" ] || { warn "fairland did not produce newcap_script" ; break ; }
230 echo "Done (files & fairland)."
242 case "${NIGHTLY_SKIP_STEP}"
247 echo "Starting server with -d in the background"
248 ./emp_server -R 1 -d &
251 kill -0 "${PID}" || { warn "emp_server not running ?" ; break ; }
252 echo "Done (emp_server)."
262 # START GENERATE (2nd part)
264 case "${NIGHTLY_SKIP_STEP}"
269 ln -s ../bin/empire emp_client
270 echo "Running newcap_script through emp_client"
271 runfeed POGO peter < newcap_script >/dev/null 2>&1 ||
273 warn "Could not run newcap_script"
274 echo "Stopping server"
278 echo "Done (newcap_script / emp_client)."
281 echo "TODO: Replace this with a real test script."
282 echo "Just do some rudimentary testing for now."
285 echo "Prevent updates from happening without our consent."
286 runfeed POGO peter << EOF
289 echo "Done (update stop)."
295 # END GENERATE (2nd part)
301 case "${NIGHTLY_SKIP_STEP}"
306 for PLAYER in 2 3 4 5 6 7 8 9 10
308 echo "explore for player ${PLAYER}"
309 runfeed $PLAYER << EOF >/dev/null 2>&1
317 echo "Done (explore)."
321 # Something more elaborate for player 1
322 echo "explore and more for player 1"
323 runfeed 1 << EOF >/dev/null 2>&1
373 runfeed POGO peter << EOF
385 echo "Check player 1"
395 echo "Check whether the update did anything"
396 runfeed POGO peter << EOF
403 echo "Done (check update)."
406 echo "Continue some updates for player 1"
409 echo "Turn 2 for player 1"
411 runfeed 1 << EOF >/dev/null 2>&1
431 runfeed POGO peter << EOF
443 echo "Turn 3 for player 1"
467 runfeed POGO peter << EOF
479 echo "Done (player 1)."
481 echo "TODO: turn 4/5 (tech/assault)..."
483 echo "Done (Rudimentary tests)."
495 case "${NIGHTLY_SKIP_STEP}"
499 case "${NIGHTLY_SKIP_STEP}"
504 echo "Stopping server"
520 case "${NIGHTLY_SKIP_STEP}"
525 echo "Cleaning sandbox"
526 cd "${BOXDIR}" || err "Could not cd back to sandbox root !"
527 rm -r "${WORKDIR}" || warn "Directory ${WORKDIR} could not be cleanly removed !"
528 rm -rf "${WORKDIR}" || warn "Directory ${WORKDIR} could not be forcibly removed !"
529 [ -d "${WORKDIR}/." ] && warn "Directory ${WORKDIR} still present"
530 echo "Done (cleaning)."
538 echo "Nightly build finished at `date`"