update-full-onetree.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/sh
  2. cd `dirname $0`
  3. TREE="$1"
  4. CRON=""
  5. UNIT=""
  6. if [ -n "$2" ] && [ "$1" = "-cron" ]; then
  7. TREE="$2"
  8. CRON="$1"
  9. fi
  10. if [ -n "$3" ] && [ "$2" = "--by-unit" ]; then
  11. TREE="$3"
  12. UNIT="$2"
  13. fi
  14. DURATION=""
  15. if [ ${TREE} = "addons" ]; then
  16. DURATION="long"
  17. elif [ ${TREE} = "projects-central" ]; then
  18. DURATION="long"
  19. elif [ ${TREE} = "gaia" ]; then
  20. DURATION="medium"
  21. else
  22. DURATION="short"
  23. fi
  24. LOCKFILE=/var/lock/mxr/${DURATION}/${TREE}.lock
  25. if [ -f $LOCKFILE ]; then
  26. LOCKPID=`cat $LOCKFILE`
  27. ps $LOCKPID > /dev/null
  28. if [ $? -eq 0 ]
  29. then
  30. logger -p local7.err -t ${TREE} "ERR: Tried to start a new job while a previous one was still running. Aborting this one."
  31. exit 0
  32. else
  33. logger -p local7.warning -t ${TREE} "WARN: stale lockfile found, removing."
  34. rm $LOCKFILE
  35. fi
  36. fi
  37. echo $$ > $LOCKFILE
  38. logger -p local7.info -t ${TREE} "INFO: Starting."
  39. # Debug logging... currently just informational, but eventually could institute an abort or sleep on this
  40. NUMRUNNING=$(find /var/lock/mxr -type f | wc -l)
  41. logger -p local7.debug -t ${TREE} "DEBUG: ${NUMRUNNING} total running or stale MXR jobs."
  42. TREE_PATH=$(grep "^sourceroot: $TREE " /data/www/mxr.mozilla.org/lxr.conf | head -n 1 | awk '{print $3}')
  43. OUT1=`perl update-src.pl $CRON "$TREE" 2>&1`
  44. if [ -f "${TREE_PATH}/last-processed" ] && [ -z "$(find ${TREE_PATH} -type f -newer ${TREE_PATH}/last-processed ! -path "*/.hg/*" ! -path "*/CVS/*" ! -path "*/.git/*" ! -path "${TREE_PATH}/.mozconfig.out" -print -quit)" ]; then
  45. echo "$TREE: No files changed, skipping xref and indexing"
  46. logger -p local7.info -t ${TREE} "INFO: No files changed, skipping xref and indexing"
  47. OUT2=''
  48. OUT3=''
  49. else
  50. echo "$TREE: Has changes, running xref and search..."
  51. logger -p local7.info -t ${TREE} "INFO: Has changes, running xref and search"
  52. OUT2=`perl update-xref.pl $CRON $UNIT "$TREE" 2>&1`
  53. OUT3=`perl update-search.pl $CRON "$TREE" 2>&1`
  54. touch "${TREE_PATH}/last-processed"
  55. fi
  56. if [ -n "$OUT1" ] || [ -n "$OUT2" ] || [ -n "$OUT3" ]; then
  57. echo "Updating $TREE..."
  58. echo "$OUT1"
  59. echo "$OUT2"
  60. echo "$OUT3"
  61. fi
  62. logger -p local7.info -t ${TREE} "INFO: Done."
  63. rm $LOCKFILE