X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=qchess%2Fupdate.sh;fp=qchess%2Fupdate.sh;h=0000000000000000000000000000000000000000;hb=444244d5c7698bb7861cdb7c0ec6bfb0e8cebfb7;hp=bec40eacca5f653b0ac81b954050cb62ecffe0a5;hpb=707e794d26062516eb4188d1cd2902929613c46b;p=progcomp2013.git diff --git a/qchess/update.sh b/qchess/update.sh deleted file mode 100644 index bec40ea..0000000 --- a/qchess/update.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash - -# I still can't believe I am doing this - -# This updates the component files from the target, as well as the target from the components -# You can't do that with gnu make, because of the circular dependency -# But this should probably not be used by any sane person - -exit 1 - -target=qchess.py -components="piece.py board.py player.py network.py thread_util.py game.py graphics.py main.py" -# The below seems nicer, but doesn't work because things need to be imported in the right order :( -#components=$(ls *.py | tr '\t' '\n' | grep -v $target) - -header="#!/usr/bin/python -u" -footer="# EOF - created from update.sh on $(date)" - - - -# If the target was modified more recently than any of the components, update the component file -target_mod=$(stat -c %Y $target 2>/dev/null) - -if [ $? -ne 0 ]; then - merge_required=true -else - merge_required=true - - - for f in $components; do - - component_mod=$(stat -c %Y $f 2>/dev/null) - if [ $? -ne 0 ]; then - update_required=true - elif [ $component_mod -lt $target_mod ]; then - update_required=true - else - update_required=false - fi - - if $update_required; then - echo "$0 - update $f from $target" - sanity=$(egrep "(+++ $f +++)|(--- $f ---)" $target | wc -l) - if [ $sanity -ne 2 ]; then - $(echo "$0 - $target does not have markers for $f in it!") 1>&2 - exit 1 - fi - cp $f $f~ - new_contents=$(nawk "/+++ $f +++/, /--- $f ---/" $target | grep -v "+++ $f +++" | grep -v "\--- $f ---") - - echo "$new_contents" > $f - else - echo "$0 - $f is newer than $target" - merge_required=true - fi - done - - -fi - -# If any components were modified more recently than the target, merge the components into the target -if $merge_required; then - echo $header > $target - for f in $components; do - echo "$0 - merge $f into $target" - echo "# +++ $f +++ #" >> $target - cat $f >> $target - echo "# --- $f --- #" >> $target - done - - echo $footer >> $target - chmod u+x $target -fi