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