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 if [ -d "${WORKDIR}" ]
96 ! [ -d "${WORKDIR}"/empserver/.git ] || err "Invalid sandbox, missing .git directory"
99 mkdir "${WORKDIR}" || warn "Could not create ${BOXDIR}/${WORKDIR}"
101 cd "${WORKDIR}" || err "Could not cd to ${BOXDIR}/${WORKDIR}"
103 echo "Getting source from GIT:"
105 export GITROOT=${GITROOT:= git://git.pond.sub.org/~armbru/empserver}
107 if ! [ -d empserver ]
109 while ! git clone $GITROOT empserver >/dev/null
111 sleep "`expr 5 + ${RETR}`"
112 RETR="`expr 1 + ${RETR}`"
113 [ "${RETR}" -gt 5 ] && err "git-clone Timeout after ${RETR} retres."
116 while ! git pull $GITROOT master >/dev/null
118 sleep "`expr 5 + ${RETR}`"
119 RETR="`expr 1 + ${RETR}`"
120 [ "${RETR}" -gt 5 ] && err "GIT pull Timeout after ${RETR} retres."
136 case "${NIGHTLY_SKIP_STEP}"
141 echo "Applying global patches from ${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/All"
142 for i in "${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/All"/*.patch
144 [ -r "${i}" ] || continue
145 if ${PATCH:=patch} -Np0 < "${i}" >/dev/null
149 echo "========== ${i}: NOT OK! ${?} =========="
152 echo "Done (patch All)."
155 LOCALPATCHDIRECTORY="${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/${INSTANCE}"
156 if [ -n "${LOCALPATCHDIRECTORY}" -a -d "${LOCALPATCHDIRECTORY}/." ]
158 echo "Applying system specific patches from ${LOCALPATCHDIRECTORY}:"
159 for i in "${LOCALPATCHDIRECTORY}"/*.patch
161 [ -r "${i}" ] || continue
162 if ${PATCH:=patch} -Np0 < "${i}" >/dev/null
166 echo "========== ${i}: NOT OK! ${?} =========="
169 echo "Done (patch specific)."
173 cd empserver || err "Could not cd to ${BOXDIR}/${WORKDIR}/empserver."
177 ./configure --prefix ${BOXDIR}/${WORKDIR}/emp4
188 case "${NIGHTLY_SKIP_STEP}"
195 echo "Building server"
196 if make -k install >/dev/null
198 warn "make did not return 0"
209 # Try to run startup utilities
215 case "${NIGHTLY_SKIP_STEP}"
220 if [ -d ../emp4 -a -d ../emp4/bin -a -d ../emp4/sbin -a -d ../emp4/var/empire ]
222 echo "Directory structure is ok"
224 warn "Directory structure is NOT ok"
228 cd ../emp4/bin || err "Could not cd to ../emp4/bin"
230 echo "Determining type of files in bin directory"
232 echo "Done (file *)."
235 cd ../../emp4/sbin || err "Could not cd to ../../emp4/sbin"
237 echo "Determining type of files in sbin directory"
239 echo "Done (file *)."
242 echo "Running files and fairland"
243 echo y | ./files || warn "Error running files"
244 ./fairland -R 1 10 30 >/dev/null || { warn "Error running fairland" ; break ; }
245 [ -s "newcap_script" ] || { warn "fairland did not produce newcap_script" ; break ; }
246 echo "Done (files & fairland)."
258 case "${NIGHTLY_SKIP_STEP}"
263 echo "Starting server with -d in the background"
264 ./emp_server -R 1 -d &
267 kill -0 "${PID}" || { warn "emp_server not running ?" ; break ; }
268 echo "Done (emp_server)."
278 # START GENERATE (2nd part)
280 case "${NIGHTLY_SKIP_STEP}"
285 echo "Running newcap_script through empire"
286 runfeed POGO peter < newcap_script >/dev/null 2>&1 ||
288 warn "Could not run newcap_script"
289 echo "Stopping server"
293 echo "Done (newcap_script / empire)."
296 echo "TODO: Replace this with a real test script."
297 echo "Just do some rudimentary testing for now."
300 echo "Prevent updates from happening without our consent."
301 runfeed POGO peter << EOF
304 echo "Done (update stop)."
310 # END GENERATE (2nd part)
316 case "${NIGHTLY_SKIP_STEP}"
321 for PLAYER in 2 3 4 5 6 7 8 9 10
323 echo "explore for player ${PLAYER}"
324 runfeed $PLAYER << EOF >/dev/null 2>&1
332 echo "Done (explore)."
336 # Something more elaborate for player 1
337 echo "explore and more for player 1"
338 runfeed 1 << EOF >/dev/null 2>&1
388 runfeed POGO peter << EOF
400 echo "Check player 1"
410 echo "Check whether the update did anything"
411 runfeed POGO peter << EOF
418 echo "Done (check update)."
421 echo "Continue some updates for player 1"
424 echo "Turn 2 for player 1"
426 runfeed 1 << EOF >/dev/null 2>&1
446 runfeed POGO peter << EOF
458 echo "Turn 3 for player 1"
482 runfeed POGO peter << EOF
494 echo "Done (player 1)."
496 echo "TODO: turn 4/5 (tech/assault)..."
498 echo "Done (Rudimentary tests)."
510 case "${NIGHTLY_SKIP_STEP}"
514 case "${NIGHTLY_SKIP_STEP}"
519 echo "Stopping server"
535 case "${NIGHTLY_SKIP_STEP}"
540 echo "Cleaning sandbox"
541 cd "${BOXDIR}" || err "Could not cd back to sandbox root !"
542 case "${NIGHTLY_SKIP_STEP}"
545 rm -rf `find "${WORKDIR}" -maxdepth 1 ! -name .git` || warn "Directory ${WORKDIR} could not be forcibly removed !"
548 rm -r "${WORKDIR}" || warn "Directory ${WORKDIR} could not be cleanly removed !"
549 rm -rf "${WORKDIR}" || warn "Directory ${WORKDIR} could not be forcibly removed !"
550 [ -d "${WORKDIR}/." ] && warn "Directory ${WORKDIR} still present"
551 echo "Done (cleaning)."
560 echo "Nightly build finished at `date`"