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
20 # For some reason, solaris sh exits as soon as both stderr and stdout
21 # are redirected to file at the exec, so if we run on solaris, use ksh
31 if [ "`uname`" = "SunOS" ]
45 echo "Usage: ${PROGNAME} <configfile>" >&2;
64 [ -f "${SCRIPTDIR}/common.sh" ] || { echo "Broken config ?" >&2; exit 1; }
65 . "${SCRIPTDIR}"/common.sh
68 STAMP="`date +%Y%m%d%H%M%S`"
69 WORKDIR="${EMPTARGET}.${ARCH}"
70 [ -n "${EXTRASUFFIX}" ] && WORKDIR="${WORKDIR}.${EXTRASUFFIX}"
71 LOGFILE="${LOGDIR}/${WORKDIR}.${STAMP}"
76 case "${NIGHTLY_SKIP_STEP}"
96 BOXDIR="${SCRIPTDIR}/${BOXDIR}"
100 cd "${BOXDIR}" || err "Could not chdir to ${BOXDIR}"
102 echo "Nightly build starting at `date`"
108 case "${NIGHTLY_SKIP_STEP}"
114 mkdir "${WORKDIR}" || warn "Could not create ${BOXDIR}/${WORKDIR}"
115 cd "${WORKDIR}" || err "Could not cd to ${BOXDIR}/${WORKDIR}"
117 echo "Getting source from CVS:"
120 while ! cvs -z3 -d:ext:"${SFLOGIN}"@cvs.sourceforge.net:/cvsroot/empserver co empserver >/dev/null
122 sleep "`expr 5 + ${RETR}`"
123 RETR="`expr 1 + ${RETR}`"
124 [ "${RETR}" -gt 5 ] && err "CVS Timeout after ${RETR} retres."
138 case "${NIGHTLY_SKIP_STEP}"
143 echo "Applying global patches from patches/All:"
144 for i in "${SCRIPTDIR}/patches/All"/*.patch
146 [ -r "${i}" ] || continue
147 if patch -Np0 < "${i}" >/dev/null
151 echo "========== ${i}: NOT OK! ${?} =========="
154 echo "Done (patch All)."
157 # Run local patches ${LOCALPATCHDIR}/*.patch
158 case "${LOCALPATCHDIR}"
163 LOCALPATCHDIR="${SCRIPTDIR}/${LOCALPATCHDIR}"
167 if [ -n "${LOCALPATCHDIR}" -a -d "${LOCALPATCHDIR}/." ]
169 echo "Applying system specific patches from ${LOCALPATCHDIR}:"
170 for i in "${LOCALPATCHDIR}"/*.patch
172 [ -r "${i}" ] || continue
173 if patch -Np0 < "${i}" >/dev/null
177 echo "========== ${i}: NOT OK! ${?} =========="
180 echo "Done (patch specific)."
184 cd empserver || err "Could not cd to ${BOXDIR}/${WORKDIR}/empserver."
187 echo "Preparing build.conf"
188 sed -e "s,^USERNAME = .*$,USERNAME = ${EMPLOGIN}," \
189 -e "s,^HOSTNAME = .*$,HOSTNAME = localhost," \
190 -e "s,^IPADDR = .*$,IPADDR = 127.0.0.1," \
191 -e "s,^PORTNUM = .*$,PORTNUM = ${EMPPORT}," \
192 -e "s,^EMPDIR = .*$,EMPDIR = ${BOXDIR}/${WORKDIR}/emp4," \
193 < build.conf > build.conf.new && \
194 mv build.conf.new build.conf || \
195 err "Could not prep build.conf"
196 echo "Done (build.conf)."
208 case "${NIGHTLY_SKIP_STEP}"
213 # TODO: this should be fixed another way...
214 echo "Generating empty Makedepends."
215 touch src/client/Makedepend src/doconfig/Makedepend src/lib/as/Makedepend src/lib/commands/Makedepend src/lib/common/Makedepend src/lib/empthread/Makedepend src/lib/gen/Makedepend src/lib/global/Makedepend src/lib/lwp/Makedepend src/lib/player/Makedepend src/lib/subs/Makedepend src/lib/update/Makedepend src/server/Makedepend src/util/Makedepend || err "Could tot touch Makedepends"
220 echo "Building server"
221 if make "${EMPTARGET}" >/dev/null
223 warn "make did not return 0"
234 # Try to run startup utilities
240 case "${NIGHTLY_SKIP_STEP}"
245 if [ -d ../emp4 -a -d ../emp4/bin -a -d ../emp4/data ]
247 echo "Directory structure is ok"
249 warn "Directory structure is NOT ok"
253 cd ../emp4/bin || err "Could not cd to ../emp4/bin"
255 echo "Determining type of files in bindir"
257 echo "Done (file *)."
260 echo "Running files and fairland"
261 echo y | ./files || warn "Error running files"
262 ./fairland -R 0 10 30 >/dev/null || { warn "Error running fairland" ; break ; }
263 [ -s "newcap_script" ] || { warn "fairland did not produce newcap_script" ; break ; }
264 echo "Done (files & fairland)."
276 case "${NIGHTLY_SKIP_STEP}"
281 echo "Starting server with -d in the background"
285 kill -0 "${PID}" || { warn "emp_server not running ?" ; break ; }
286 echo "Done (emp_server)."
296 # START GENERATE (2nd part)
298 case "${NIGHTLY_SKIP_STEP}"
303 echo "Running newcap_script through emp_client"
304 runfeed POGO peter < newcap_script >/dev/null 2>&1 ||
306 warn "Could not run newcap_script"
307 echo "Stopping server"
311 echo "Done (newcap_script / emp_client)."
314 echo "TODO: Replace this with a real test script."
315 echo "Just do some rudimentary testing for now."
318 echo "Prevent updates from happening without our consent."
319 runfeed POGO peter << EOF
322 echo "Done (update stop)."
328 # END GENERATE (2nd part)
334 case "${NIGHTLY_SKIP_STEP}"
339 for PLAYER in 2 3 4 5 6 7 8 9 10
341 echo "explore for player ${PLAYER}"
342 runfeed $PLAYER << EOF >/dev/null 2>&1
350 echo "Done (explore)."
354 # Something more elaborate for player 1
355 echo "explore and more for player 1"
356 runfeed 1 << EOF >/dev/null 2>&1
404 runfeed POGO peter << EOF
416 echo "Check player 1"
426 echo "Check whether the update did anything"
427 runfeed POGO peter << EOF
434 echo "Done (check update)."
437 echo "Continue some updates for player 1"
440 echo "Turn 2 for player 1"
442 runfeed 1 << EOF >/dev/null 2>&1
462 runfeed POGO peter << EOF
474 echo "Turn 3 for player 1"
504 runfeed POGO peter << EOF
516 echo "Done (player 1)."
518 echo "TODO: turn 4/5 (tech/assault)..."
520 echo "Done (Rudimentary tests)."
532 case "${NIGHTLY_SKIP_STEP}"
536 case "${NIGHTLY_SKIP_STEP}"
541 echo "Stopping server"
557 case "${NIGHTLY_SKIP_STEP}"
562 echo "Cleaning sandbox"
563 cd "${BOXDIR}" || err "Could not cd back to sanbox root !"
564 rm -r "${WORKDIR}" || warn "Directory ${WORKDIR} could not be cleanly removed !"
565 rm -rf "${WORKDIR}" || warn "Directory ${WORKDIR} could not be forcibly removed !"
566 [ -d "${WORKDIR}/." ] && warn "Directory ${WORKDIR} still present"
567 echo "Done (cleaning)."
575 echo "Nightly build finished at `date`"