]> git.pond.sub.org Git - empserver/blobdiff - src/scripts/nightly/nightlybuild.sh
Switch nightlybuilds to git
[empserver] / src / scripts / nightly / nightlybuild.sh
index cd06fd903a8cf630647f491d00c3f83a76b1796b..67c6bf69ee9a8a08d1bcf8fd4e476df37c42bbcb 100755 (executable)
@@ -2,28 +2,24 @@
 #
 # Blame it on marcolz
 #
-
-# For some reason, solaris sh exits as soon as both stderr and stdout
-# are redirected to file at the exec, so if we run on solaris, use ksh
-# for this script.
+# Skip certain parts of this script by exporting the variable
+# "NIGHTLY_SKIP_STEP" containing the following possible substrings,
+# preventing the named behaviour:
+#
+# REDIRECT     -       Redirect all output to a logfile
+# CHECKOUT     -       Fill the sandbox with a fresh cvs checkout
+# PATCH                -       Apply the patches for this system (global + specific)
+# BUILD                -       Build everything
+# GENERATE     -       Generate a new world
+# SERVERSTART  -       Start the server
+# TESTSCRIPT   -       Run the testscript
+# SERVERSTOP   -       Stop the server if it was started by this script
+# CLEANUP      -       Remove the contents of the sandbox
 #
-INTERPRETER="$_"
-
-case "$INTERPRETER"
-in
-       */ksh|ksh)
-               ;;
-       *)
-               if  [ "`uname`" = "SunOS" ]
-               then
-                       exec ksh "$0" "$@"
-               fi
-       ;;
-esac
 
 PROGNAME="$0"
-CVS_RSH=ssh
-export CVS_RSH
+TERM="${TERM:-vt100}"
+export TERM
 
 usage() {
        echo "Usage: ${PROGNAME} <configfile>" >&2;
@@ -50,14 +46,28 @@ esac
 
 
 STAMP="`date +%Y%m%d%H%M%S`"
-WORKDIR="${EMPTARGET}.${ARCH}"
+WORKDIR="${INSTANCE}"
 [ -n "${EXTRASUFFIX}" ] && WORKDIR="${WORKDIR}.${EXTRASUFFIX}"
 LOGFILE="${LOGDIR}/${WORKDIR}.${STAMP}"
 
+#
+# START REDIRECT
+#
+case "${NIGHTLY_SKIP_STEP}"
+in
+       *REDIRECT*) ;;
+       *)
+
 # Log everything
 exec > "${LOGFILE}"
 exec 2>&1
 
+               ;;
+esac
+#
+# END REDIRECT
+#
+
 case "${BOXDIR}"
 in
        /*)
@@ -72,28 +82,67 @@ cd "${BOXDIR}" || err "Could not chdir to ${BOXDIR}"
 echo "Nightly build starting at `date`"
 
 
-# Make sandbox
+#
+# START CHECKOUT
+#
+case "${NIGHTLY_SKIP_STEP}"
+in
+       *CHECKOUT*) ;;
+       *)
 
-mkdir "${WORKDIR}" || warn "Could not create ${BOXDIR}/${WORKDIR}"
+# Make sandbox
+if [ -d "${WORKDIR}" ]
+then
+       ! [ -d "${WORKDIR}"/empserver/.git ]  || err "Invalid sandbox, missing .git directory"
+else
+       echo making directory
+       mkdir "${WORKDIR}" || warn "Could not create ${BOXDIR}/${WORKDIR}"
+fi
 cd "${WORKDIR}" || err "Could not cd to ${BOXDIR}/${WORKDIR}"
 
-echo "Getting source from CVS:"
+echo "Getting source from GIT:"
 # Extract source
+export GITROOT=${GITROOT:= git://git.pond.sub.org/~armbru/empserver}
 RETR=0
-while ! cvs -z3 -d:ext:"${SFLOGIN}"@cvs.sourceforge.net:/cvsroot/empserver co empserver >/dev/null
-do
-       sleep "`expr 5 + ${RETR}`"
-       RETR="`expr 1 + ${RETR}`"
-       [ "${RETR}" -gt 100 ] && err "CVS Timeout after ${RETR} retres."
+if ! [ -d empserver ]
+then
+       while ! git clone $GITROOT empserver >/dev/null
+       do
+               sleep "`expr 5 + ${RETR}`"
+               RETR="`expr 1 + ${RETR}`"
+               [ "${RETR}" -gt 5 ] && err "git-clone Timeout after ${RETR} retres."
+       done
+else
+       while ! git pull $GITROOT master >/dev/null
+       do
+               sleep "`expr 5 + ${RETR}`"
+               RETR="`expr 1 + ${RETR}`"
+               [ "${RETR}" -gt 5 ] && err "GIT pull Timeout after ${RETR} retres."
 done
-echo "Done (CVS)."
+
+fi
+
+echo "Done (GIT)."
 echo ""
+               ;;
+esac
+#
+# END CHECKOUT
+#
 
-echo "Applying global patches from patches/All:"
-for i in "${SCRIPTDIR}/patches/All"/*.patch
+#
+# START PATCH
+#
+case "${NIGHTLY_SKIP_STEP}"
+in
+       *PATCH*) ;;
+       *)
+
+echo "Applying global patches from ${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/All"
+for i in "${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/All"/*.patch
 do
        [ -r "${i}" ] || continue
-       if patch -Np0 < "${i}" >/dev/null
+       if ${PATCH:=patch} -Np0 < "${i}" >/dev/null
        then
                echo "${i}: OK"
        else
@@ -103,23 +152,14 @@ done
 echo "Done (patch All)."
 echo ""
 
-# Run local patches ${LOCALPATCHDIR}/*.patch
-case "${LOCALPATCHDIR}"
-in
-       /*)
-               ;;
-       *)
-               LOCALPATCHDIR="${SCRIPTDIR}/${LOCALPATCHDIR}"
-               ;;
-esac
-
-if [ -n "${LOCALPATCHDIR}" -a -d "${LOCALPATCHDIR}/." ]
+LOCALPATCHDIRECTORY="${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/${INSTANCE}"
+if [ -n "${LOCALPATCHDIRECTORY}" -a -d "${LOCALPATCHDIRECTORY}/." ]
 then
-       echo "Applying system specific patches from ${LOCALPATCHDIR}:"
-       for i in "${LOCALPATCHDIR}"/*.patch
+       echo "Applying system specific patches from ${LOCALPATCHDIRECTORY}:"
+       for i in "${LOCALPATCHDIRECTORY}"/*.patch
        do
                [ -r "${i}" ] || continue
-               if patch -Np0 < "${i}" >/dev/null
+               if ${PATCH:=patch} -Np0 < "${i}" >/dev/null
                then
                        echo "${i}: OK"
                else
@@ -132,38 +172,52 @@ fi
 
 cd empserver || err "Could not cd to ${BOXDIR}/${WORKDIR}/empserver."
 
-# Prep build.conf
-echo "Preparing build.conf"
-sed    -e "s,^USERNAME = .*$,USERNAME = ${EMPLOGIN}," \
-       -e "s,^HOSTNAME = .*$,HOSTNAME = localhost," \
-       -e "s,^IPADDR = .*$,IPADDR = 127.0.0.1," \
-       -e "s,^PORTNUM = .*$,PORTNUM = ${EMPPORT}," \
-       -e "s,^EMPDIR = .*$,EMPDIR = ${BOXDIR}/${WORKDIR}/emp4," \
-       < build.conf > build.conf.new && \
-       mv build.conf.new build.conf || \
-       err "Could not prep build.conf"
-echo "Done (build.conf)."
-echo ""
+git-pull
+sh ./bootstrap
+./configure --prefix ${BOXDIR}/${WORKDIR}/emp4
+
+               ;;
+esac
+#
+# END PATCH
+#
+
+#
+# START BUILD
+#
+case "${NIGHTLY_SKIP_STEP}"
+in
+       *BUILD*) ;;
+       *)
 
-# TODO: this should be fixed another way...
-echo "Generating empty Makedepends."
-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"
-echo "Done (touch)."
-echo ""
 
 # Start the build
 echo "Building server"
-if make "${EMPTARGET}" >/dev/null
+if make -k install >/dev/null
 then
        warn "make did not return 0"
 fi
 echo "Done (make)."
 echo ""
 
+               ;;
+esac
+#
+# END BUILD
+#
+
 # Try to run startup utilities
 for onetime in 1
 do
-       if [ -d ../emp4 -a -d ../emp4/bin -a -d ../emp4/data ]
+       #
+       # START GENERATE
+       #
+       case "${NIGHTLY_SKIP_STEP}"
+       in
+               *GENERATE*) ;;
+               *)
+
+       if [ -d ../emp4 -a -d ../emp4/bin -a -d ../emp4/sbin -a -d ../emp4/var/empire ]
        then
                echo "Directory structure is ok"
        else
@@ -173,27 +227,62 @@ do
 
        cd ../emp4/bin || err "Could not cd to ../emp4/bin"
 
-       echo "Determining type of files in bindir"
+       echo "Determining type of files in bin directory"
+       file *
+       echo "Done (file *)."
+       echo ""
+
+       cd ../../emp4/sbin || err "Could not cd to ../../emp4/sbin"
+
+       echo "Determining type of files in sbin directory"
        file *
        echo "Done (file *)."
        echo ""
 
        echo "Running files and fairland"
        echo y | ./files || warn "Error running files"
-       ./fairland -R 0 10 30 >/dev/null || { warn "Error running fairland" ; break ; }
+       ./fairland -R 1 10 30 >/dev/null || { warn "Error running fairland" ; break ; }
        [ -s "newcap_script" ] || { warn "fairland did not produce newcap_script" ; break ; }
        echo "Done (files & fairland)."
        echo ""
 
+                       ;;
+       esac
+       #
+       # END GENERATE
+       #
+
+       #
+       # START SERVERSTART
+       #
+       case "${NIGHTLY_SKIP_STEP}"
+       in
+               *SERVERSTART*) ;;
+               *)
+
        echo "Starting server with -d in the background"
-       ./emp_server -d &
+       ./emp_server -R 1 -d &
        PID="$!"
        sleep 1
        kill -0 "${PID}" || { warn "emp_server not running ?" ; break ; }
        echo "Done (emp_server)."
        echo ""
 
-       echo "Running newcap_script through emp_client"
+                       ;;
+       esac
+       #
+       # END SERVERSTART
+       #
+
+       #
+       # START GENERATE (2nd part)
+       #
+       case "${NIGHTLY_SKIP_STEP}"
+       in
+               *GENERATE*) ;;
+               *)
+
+       echo "Running newcap_script through empire"
        runfeed POGO peter < newcap_script >/dev/null 2>&1 ||
                {
                        warn "Could not run newcap_script"
@@ -201,43 +290,105 @@ do
                        trykill $PID
                        break
                }
-       echo "Done (newcap_script / emp_client)."
+       echo "Done (newcap_script / empire)."
        echo ""
        
-       # After a platform independent PRNG is used, we can really do some
-       # useful testing here...
-       echo "TODO: Replace this with a real test script as soon as"
-       echo "a platform independent PRNG is used in fairland."
-       echo ""
+       echo "TODO: Replace this with a real test script."
        echo "Just do some rudimentary testing for now."
        echo ""
 
-       echo "Preparing to ensure repeatable results"
+       echo "Prevent updates from happening without our consent."
        runfeed POGO peter << EOF
 disable
-give uw * ?uw>0 5
 EOF
-       echo "Done (preparing)."
+       echo "Done (update stop)."
        echo ""
-
-       for PLAYER in 1 2 3 4 5 6 7 8 9 10
+       
+                       ;;
+       esac
+       #
+       # END GENERATE (2nd part)
+       #
+
+       #
+       # START TESTSCRIPT
+       #
+       case "${NIGHTLY_SKIP_STEP}"
+       in
+               *TESTSCRIPT*) ;;
+               *)
+
+       for PLAYER in 2 3 4 5 6 7 8 9 10
        do
                echo "explore for player ${PLAYER}"
                runfeed $PLAYER << EOF >/dev/null 2>&1
 break
-expl c 0,0 10 uh
-mov f 0,0 5 uh
+expl c 0,0 1 uh
 desi 1,-1 +
+mov c 0,0 205 uh
+desi 1,-1 g
 cen *
 EOF
                echo "Done (explore)."
                echo ""
        done
 
+       # Something more elaborate for player 1
+       echo "explore and more for player 1"
+       runfeed 1 << EOF >/dev/null 2>&1
+break
+expl c 0,0 1 uh
+expl c 2,0 1 jh
+expl c 2,0 1 uh
+expl c 2,0 1 nh
+expl c 2,0 1 bh
+expl c 0,0 1 yh
+expl c 0,0 1 gh
+expl c 0,0 1 bh
+desi * ?ne=- +
+expl c 2,0 1 njh
+expl c 2,0 1 nnh
+expl c 2,0 1 bnh
+expl c 0,0 1 bbh
+expl c 0,0 1 yyh
+expl c 0,0 1 yuh
+expl c 0,0 1 bnh
+expl c 2,0 1 yuh
+expl c 2,0 1 uuh
+expl c 2,0 1 juh
+desi * ?ne=- +
+expl c 2,0 1 nnnh
+expl c 2,0 1 nnjh
+expl c 2,0 1 njjh
+expl c 2,0 1 uujh
+expl c 0,0 1 bbnh
+expl c 0,0 1 bnnh
+expl c 0,0 1 yygh
+expl c 0,0 1 yuuh
+desi * ?ne=- +
+expl c 2,0 1 nnjjh
+desi * ?ne=- +
+expl c 2,0 1 nnjjjh
+desi * ?ne=- +
+mov u 0,0 75 jh
+demob 0:2,0 55 y
+desi 2,0 m
+mov c 0,0 767 -1,-1
+desi -1,-1 g
+mov c 0,0 275 1,-1
+mov c 2,0 274 1,-1
+desi 1,-1 m
+deliver i 2,0 230 u
+deliver i 1,-1 0 j
+dist 4,0 2,0
+thres i 2,0 1
+EOF
+
        echo "Run an update"
        runfeed POGO peter << EOF
 power new
 cen * ?own#0
+reso * ?own#0
 enable
 force 1
 disable
@@ -248,36 +399,163 @@ EOF
        sleep 10
        echo "Check player 1"
        runfeed 1 << EOF
+real 0 -8:12,-4:4
 cen *
-read n
+map #
+read y
 EOF
        echo "Done (check)."
        echo ""
 
        echo "Check whether the update did anything"
        runfeed POGO peter << EOF
+power new
 cen * ?own#0
+reso * ?own#0
 read
-n
+y
 EOF
        echo "Done (check update)."
        echo ""
 
+       echo "Continue some updates for player 1"
+       echo ""
+
+       echo "Turn 2 for player 1"
+
+       runfeed 1 << EOF >/dev/null 2>&1
+desi -1,-1 b
+mov i 2,0 200 4,0
+mov i 1,-1 4 jh
+mov c -1,-1 435 4,0
+deli i 2,0 0 j
+deli i 1,-1 0 j
+mov c -1,-1 80 3,-1
+mov c 1,-1 256 4,0
+mov c 2,0 230 5,-1
+mov c 1,-1 409 3,-1
+desi 4,0 k
+desi 3,-1 j
+dist # 5,-1
+thre h 4,0 1
+thre l 3,-1 1
+desi 5,-1 h
+EOF
+
+       echo "Run an update"
+       runfeed POGO peter << EOF
+power new
+cen * ?own#0
+reso * ?own#0
+enable
+force 1
+disable
+EOF
+       echo "Done (force)."
+       echo ""
+       sleep 10
+
+       echo "Turn 3 for player 1"
+       runfeed 1 << EOF
+cen *
+map #
+read y
+build sh 5,-1 frg
+mov l 5,-1 134 6,-2
+mov c 4,0 377 6,-2
+desi 6,-2 l
+thre l 6,-2 150
+mov c -1,-1 600 1,1
+mov c 2,0 370 -2,2
+deliver i 2,0 0 j
+deliver i 1,-1 0 j
+thres d 1,1 1
+thres o -2,0 1
+thres i 2,0 0
+thres i 1,-1 0
+desi -2,2 o
+desi 1,1 g
+prod *
+EOF
+
+       echo "Run an update"
+       runfeed POGO peter << EOF
+power new
+cen * ?own#0
+reso * ?own#0
+enable
+force 1
+disable
+EOF
+       echo "Done (force)."
+       echo ""
+       sleep 10
+
+       echo "Done (player 1)."
+       echo ""
+       echo "TODO: turn 4/5 (tech/assault)..."
+
        echo "Done (Rudimentary tests)."
        echo ""
 
+                       ;;
+       esac
+       #
+       # END TESTSCRIPT
+       #
+
+       #
+       # START SERVERSTOP
+       #
+       case "${NIGHTLY_SKIP_STEP}"
+       in
+               *SERVERSTOP*) ;;
+               *)
+                       case "${NIGHTLY_SKIP_STEP}"
+                       in
+                               *SERVERSTART*) ;;
+                               *)
+
        echo "Stopping server"
        trykill "${PID}"
        echo "Done (kill)."
        echo ""
+                                       ;;
+                       esac
+                       ;;
+       esac
+       #
+       # END SERVERSTOP
+       #
 done
 
+#
+# START CLEANUP
+#
+case "${NIGHTLY_SKIP_STEP}"
+in
+       *CLEANUP*) ;;
+       *)
+
 echo "Cleaning sandbox"
-cd "${BOXDIR}" || err "Could not cd back to sanbox root !"
+cd "${BOXDIR}" || err "Could not cd back to sandbox root !"
+case "${NIGHTLY_SKIP_STEP}"
+in
+       *REMOVE_REPOSITORY*)
+rm -rf `find "${WORKDIR}" -maxdepth 1 ! -name .git` || warn "Directory ${WORKDIR} could not be forcibly removed !"
+               ;;
+       *)
 rm -r "${WORKDIR}" || warn "Directory ${WORKDIR} could not be cleanly removed !"
 rm -rf "${WORKDIR}" || warn "Directory ${WORKDIR} could not be forcibly removed !"
 [ -d "${WORKDIR}/." ] && warn "Directory ${WORKDIR} still present"
 echo "Done (cleaning)."
+               ;;
+esac
+               ;;
+esac
+#
+# END CLEANUP
+#
 
 echo "Nightly build finished at `date`"