summaryrefslogtreecommitdiff
path: root/localvcsactions
blob: 7352c3d67a7c16c98833e08cb7970ed1a6b8e887 (plain)
  1. #!/bin/sh
  2. set -e
  3. action=$(basename $0 .sh)
  4. tar_excludes="--exclude CVSROOT --exclude .cvsignore --exclude .svn --exclude .arch-ids --exclude {arch} --exclude .hg --exclude .hgignore --exclude .hgtags"
  5. projects=${1:-$(find -mindepth 1 -maxdepth 1 -type d -printf '%f\n')}
  6. for project in $projects; do
  7. if [ -x $project/$action.sh ]; then
  8. echo " ** Custom updating project $project... **"
  9. (cd $project && ./$action.sh)
  10. else
  11. targets=${2:-$(find $project -mindepth 1 -maxdepth 1 -type d -printf '%f\n')}
  12. for target in $targets; do
  13. repository=""
  14. branch=""
  15. if [ -d "$project/$target/.hg" ]; then
  16. versys="Mercurial"
  17. versysfile="hg"
  18. repository="$(cat $project/$target/.hg/hgrc | perl -n -e '/^default\s+=\s+(\S+)/ && print "$1\n"')"
  19. elif [ -d "$project/$target/{arch}" ]; then
  20. versys="ARCH"
  21. versysfile="arch"
  22. repository="$(cat $project/$target/{arch}/++default-version)"
  23. elif [ -d "$project/$target/.svn" ]; then
  24. versys="SVN"
  25. versysfile="svn"
  26. elif [ -d "$project/$target/CVS" ]; then
  27. versys="CVS"
  28. versysfile="cvs"
  29. repository="$(cat $project/$target/CVS/Repository)"
  30. # Get Tag if available
  31. if [ -f $project/$target/CVS/Tag ]; then
  32. branch="$(egrep '^N' $project/$target/CVS/Tag | sed 's/^N//')"
  33. fi
  34. else
  35. echo "ERROR: Unknown version control system used for \"$project/$target\"."
  36. exit 1
  37. fi
  38. case $action in
  39. update)
  40. echo " ** Updating $versys project \"$project\" target \"$target\"${repository:+ (repository \"$repository\"${branch:+ branch \"$branch\"})}"
  41. case $versys in
  42. CVS)
  43. ( cd $project/$target && cvs -z3 update -dP 2>&1 || exit 1 ) \
  44. | egrep -v '^cvs(pserver)? (server|update): Updating' || [ $? -lt 2 ] # catch grep failures
  45. ;;
  46. SVN)
  47. ( cd $project/$target && svn update )
  48. ;;
  49. ARCH)
  50. ( cd $project/$target && tla update )
  51. ;;
  52. Mercurial)
  53. ( cd $project/$target && hg pull -u )
  54. ;;
  55. *)
  56. echo "ERROR: Action \"$action\" not supported for \"$project/$target\"."
  57. exit 1
  58. ;;
  59. esac
  60. ;;
  61. archive)
  62. echo " ** Creating snapshot of $versys project \"$project\" target \"$target\"${repository:+ (repository \"$repository\"${branch:+ branch \"$branch\"})}"
  63. case $versys in
  64. CVS|SVN|ARCH|Mercurial)
  65. ( cd $project && tar chf - --exclude CVS $tar_excludes $target ) \
  66. | gzip -f9 > $project/$target-$versysfile$(date '+%Y%m%d').tar.gz
  67. ;;
  68. *)
  69. echo "ERROR: Action \"$action\" not supported for \"$project/$target\"."
  70. exit 1
  71. ;;
  72. esac
  73. ;;
  74. mkchanges)
  75. echo " ** Building changelog of $versys project \"$project\" target \"$target\"${repository:+ (repository \"$repository\"${branch:+ branch \"$branch\"})}"
  76. case $versys in
  77. CVS)
  78. # ( cd $project/$target && cvs2cl --gmt -S --no-wrap -f ../$target.ChangeLog 2>&1 || exit 1 ) \
  79. # ( cd $project/$target && cvs2cl --gmt -S --no-wrap ${branch:+-F $branch} -f ../$target.ChangeLog 2>&1 || exit 1 ) \
  80. ( cd $project/$target && cvs2cl --gmt -S --no-wrap -F ${branch:-TRUNK} -f ../$target.ChangeLog 2>&1 || exit 1 ) \
  81. | egrep -v '^cvs(pserver)? (server|log): Logging' || [ $? -lt 2 ] # catch grep failures
  82. ;;
  83. SVN)
  84. ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak )
  85. ( cd $project/$target && svn log -v | localsvnlog2cl > ../$target.ChangeLog )
  86. ;;
  87. ARCH)
  88. ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak )
  89. ( cd $project/$target && tla changelog > ../$target.ChangeLog )
  90. ;;
  91. Mercurial)
  92. ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak )
  93. ( cd $project/$target && hg log -v > ../$target.ChangeLog )
  94. ;;
  95. *)
  96. echo "ERROR: Action \"$action\" not supported for \"$project/$target\"."
  97. exit 1
  98. ;;
  99. esac
  100. ;;
  101. *)
  102. echo "ERROR: Unknown action \"$action\" for \"$project/$target\"."
  103. exit 1
  104. ;;
  105. esac
  106. done
  107. fi
  108. done