Advertisement
alexforsale

sync-per-project

Mar 27th, 2014
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. FILE=".repo/manifest.xml"
  4.  
  5. if [ -e "./log.txt" ] ; then
  6. cat ./log.txt | grep Error >> newlog.txt
  7. while read line ; do
  8. check=`echo $line | grep "Error"`
  9. if [ ! -z "$check" ] ; then
  10. name=`echo $line | awk '{ print $2 }'`
  11. echo "Resyncing project=$name"
  12. repo sync $name > output.txt 2>&1
  13. check=`cat output.txt | grep "From ssh:"`
  14. if [ ! -z "$check" ] ; then
  15. end=`cat output.txt | grep "fatal"`
  16. if [ -z "$end" ] ; then
  17. echo "Project= $name Status=Done" >> log.txt
  18. else
  19. echo "Project= $name Status=Error" >> log.txt
  20. fi
  21. else
  22. echo "Project= $name Status=Already Synced" >> log.txt
  23. fi
  24.  
  25. fi
  26. done < ./newlog.txt
  27. rm -f ./log.txt ./newlog.txt
  28. fi
  29.  
  30. if [ -e "$FILE" ] ; then
  31. NPROJ=`cat $FILE | grep project | wc | awk '{ print $1}'`
  32. i=1
  33. while read line ; do
  34. PROJECT=`echo $line | grep "<project"`
  35.  
  36. if [ ! -z "$PROJECT" ] ; then
  37. name=$(grep -Po '(?<=name=")[^"]*' <<<$line )
  38. echo "Syncing project=$name ($i/$NPROJ $((100*i/$NPROJ))%)"
  39. repo sync $name > output.txt 2>&1
  40. check=`cat output.txt | grep "From ssh:"`
  41. if [ ! -z "$check" ] ; then
  42. end=`cat output.txt | grep "fatal"`
  43. if [ -z "$end" ] ; then
  44. echo "Project= $name Status=Done" >> log.txt
  45. else
  46. echo "Project= $name Status=Error" >> log.txt
  47. fi
  48. else
  49. echo "Project= $name Status=Already Synced" >> log.txt
  50. fi
  51. i=$((i+1))
  52. fi
  53. done < $FILE
  54. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement