syncGITScriptsToIAR.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/sh
  2. #
  3. # Edmund Edgar, 2010-11-01 as part of the Sloodle Project.
  4. # Licensed under the same license as Sloodle.
  5. # Script to copy over a single file in an opensim archive with the matching contents from Git.
  6. # For legacy reasons, this still says "Git".
  7. # Assumes that both the LSL script in the iar fila and its counterpart in GIT contain a line like the following:
  8. # // SLOODLE LSL Script Git Location: mod/awards-1.0/lsl/xytext_prims/xytext.lsl
  9. # It is intended that this script will be passed the results of a "find" command, allowing us to sync a whole .iar file in one go.
  10. # NB There may be some mistakes in the Git location lines in the iar file - these should turn up the first time we sync.
  11. #
  12. # Example of intended use:
  13. # cd working/sloodle_opensim_iar
  14. # git pull
  15. # find iar/ -name '*.lsl' -exec ../sloodle_development_tools/opensim_sync/syncGITScriptsToIAR.sh {} \;
  16. # git diff iar | more
  17. # # Scan through the changes to make sure they make sense
  18. # git add -a
  19. # git commit -a
  20. # git push
  21. # The name of your sloodle module checkout
  22. SLOODLE_ROOT=../moodle-mod_sloodle
  23. if [ $# -ne 1 ]
  24. then
  25. echo "Usage: $0 <filename.lslp>"
  26. exit 1
  27. fi
  28. FILE=$1
  29. if test ! -f "$FILE"
  30. then
  31. echo "Script $FILE not found in iar file"
  32. exit 2
  33. fi
  34. GIT_SCRIPT="`grep "SLOODLE LSL Script Git Location: " "$FILE" | awk -F': ' '{print $2}' | sed 's/\n//g' | sed 's/\s$//g'`"
  35. if test -z "$GIT_SCRIPT"
  36. then
  37. echo "No GIT location specified in file $FILE"
  38. exit 5
  39. fi
  40. GIT_SCRIPT="${SLOODLE_ROOT}/${GIT_SCRIPT}"
  41. echo $GIT_SCRIPT
  42. if test ! -f "$GIT_SCRIPT"
  43. then
  44. echo "Script $GIT_SCRIPT for file $FILE not found in sloodle repo"
  45. exit 4
  46. fi
  47. if [ `diff --brief -x --ignore-eol-style $GIT_SCRIPT $FILE | wc -l` -gt 0 ]
  48. then
  49. cp $GIT_SCRIPT $FILE
  50. fi