#! /bin/bash # file: prep G. Moody 21 December 2013 # Last revised: 3 March 2017 # Challenge 2017 evaluation, stage 1: prepare an entry for evaluation set -e # Check the environment variables. if [ ! -d "$CHALLENGE" ]; then echo "CHALLENGE not set" exit 1 fi if [ ! -f "$CHALLENGE_ROOT_IMG" ]; then echo "CHALLENGE_ROOT_IMG not set" exit 1 fi if [ ! -f "$CHALLENGE_HOME_IMG" ]; then echo "CHALLENGE_HOME_IMG not set" exit 1 fi if [ ! -f "$CHALLENGE_ENTRY" ]; then echo "CHALLENGE_ENTRY not set" exit 1 fi DATA=$CHALLENGE/data DB=validation SE=`basename "$CHALLENGE_ENTRY"` cat >unpack.sh <>/tmp/prep/answers; then echo "Error: Result for record '\$rec' is missing or invalid" fi done | sed '11{s/.*/ .../;q}' | grep . && EX=1 fi if [ -z "$CHALLENGE_IGNORE_MISSING" ] && [ \$EX -ne 0 ]; then echo "Required component(s) missing -- not scored" exit 1 fi sed 's/\\r\$//' -i setup.sh next.sh answers.txt dependencies.txt chmod 755 setup.sh next.sh if ! timeout -k 10 120 /challenge/prep-pkgdeps --list dependencies.txt \\ >/tmp/prep/pkgdeps 2>/tmp/prep/pkglist.log; then echo "Error: unable to install dependencies" exit 1 fi if [ -e DRYRUN ]; then touch /tmp/prep/00_dry_run fi touch /tmp/prep/00_unpacked EOF cat >pkgdeps.sh <&/tmp/prep/pkginst.log; then echo "Error: unable to install dependencies" exit 1 fi touch /tmp/prep/00_pkgdeps EOF cat >compile.sh </tmp/prep/setup.log 2>&1 x=\$? if [ \$x != 0 ]; then case \$x in 124) echo "Error: setup.sh timed out after 5 minutes" ;; *) echo "Error: setup.sh failed (status \$x)" ;; esac exit 1 # quit if error or timeout in setup.sh fi touch /tmp/prep/00_success EOF cat >licensecheck.sh <> /tmp/prep/00_warnings touch /tmp/prep/00_licensechecked EOF chmod +x unpack.sh compile.sh pkgdeps.sh licensecheck.sh # Run the above scripts in the VM. echo 'licensecheck' cvmrun -T 240 -c './licensecheck.sh' licensecheck.sh \ $CHALLENGE_ENTRY `which find-copyrights` \ -i /tmp/prep -o results/prep -t 00_licensechecked echo 'unpack' cvmrun --rw -T 360 -c './unpack.sh >&/tmp/prep/00_log' unpack.sh \ $CHALLENGE_ENTRY $DATA/$DB/RECORDS `which prep-pkgdeps` \ -i /tmp/prep -o results/prep -t 00_unpacked if [ -s results/prep/pkgdeps ]; then echo 'pkgdeps' challenge-get-pkgdeps < results/prep/pkgdeps \ 2> results/prep/00_log cvmrun --rw --overlay -T 660 --user root \ -c './pkgdeps.sh >&/tmp/prep/00_log' pkgdeps.sh \ `which prep-pkgdeps` deb \ -i /tmp/prep -o results/prep -t 00_pkgdeps fi opt= if [ -f results/prep/00_matlab ]; then opt="--net --opt $CHALLENGE/matlab.img $CHALLENGE/mlconf.sh" fi echo 'compile' cvmrun $opt --rw --overlay -T 1260 -J 2 \ -c './compile.sh >&/tmp/prep/00_log' \ compile.sh \ -i /tmp/prep -o results/prep -t 00_success