summaryrefslogtreecommitdiff
path: root/localvcsactions
blob: a3fd5d16c435345892b10fb44e77c1e71aa317f9 (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 [ -d "$project/$target/.bzr" ]; then
  56. versys="Bazaar"
  57. versysfile="bzr"
  58. repository="$(cd $project/$target && bzr nick)"
  59. branch=""
  60. fi
  61. if [ -d "$project/$target/_darcs" ]; then
  62. versys="Darcs"
  63. versysfile="darcs"
  64. repository=""
  65. branch=""
  66. fi
  67. if [ -z "$versys" ] || [ -z "$versysfile" ]; then
  68. echo "ERROR: Unknown version control system used for \"$project/$target\"."
  69. exit 1
  70. fi
  71. case $action in
  72. update)
  73. echo " ** Updating $versys project \"$project\" target \"$target\"${repository:+ (repository \"$repository\"${branch:+ branch \"$branch\"})}"
  74. case $versys in
  75. CVS)
  76. ( cd $project/$target && cvs -z3 update -dP 2>&1 || exit 1 ) \
  77. | egrep -v '^cvs(pserver)? (server|update): Updating' || [ $? -lt 2 ] # catch grep failures
  78. ;;
  79. SVN)
  80. ( cd $project/$target && svn update )
  81. ;;
  82. ARCH)
  83. ( cd $project/$target && tla update )
  84. ;;
  85. Mercurial)
  86. ( cd $project/$target && hg pull -u )
  87. ;;
  88. GIT)
  89. ( cd $project/$target && git pull )
  90. ;;
  91. Bazaar)
  92. ( cd $project/$target && bzr pull )
  93. ;;
  94. Darcs)
  95. ( cd $project/$target && darcs pull )
  96. ;;
  97. *)
  98. echo "ERROR: Action \"$action\" not supported for \"$project/$target\"."
  99. exit 1
  100. ;;
  101. esac
  102. ;;
  103. archive)
  104. echo " ** Creating snapshot of $versys project \"$project\" target \"$target\"${repository:+ (repository \"$repository\"${branch:+ branch \"$branch\"})}"
  105. case $versys in
  106. CVS|SVN|ARCH|Mercurial)
  107. ( cd $project && tar chf - --exclude CVS $tar_excludes $target ) \
  108. | gzip -f9 > $project/$target-$versysfile$(date '+%Y%m%d').tar.gz
  109. ;;
  110. GIT)
  111. # FIXME: use tar_exclude to suppress other dirt than git itself
  112. ( cd $project/$target && git archive --format=tar --prefix="$target/" HEAD^{tree} ) \
  113. | gzip -f9 > $project/$target-$versysfile$(date '+%Y%m%d').tar.gz
  114. ;;
  115. Bazaar)
  116. # FIXME: use tar_exclude to suppress other dirt than bzr itself
  117. ( cd $project/$target && bzr export ../$target-$versysfile$(date '+%Y%m%d').tar.gz )
  118. ;;
  119. Darcs)
  120. # FIXME: use tar_exclude to suppress other dirt than bzr itself
  121. ( cd $project/$target && darcs dist && mv $target.tar.gz ../$target-$versysfile$(date '+%Y%m%d').tar.gz )
  122. ;;
  123. *)
  124. echo "ERROR: Action \"$action\" not supported for \"$project/$target\"."
  125. exit 1
  126. ;;
  127. esac
  128. ;;
  129. mkchanges)
  130. echo " ** Building changelog of $versys project \"$project\" target \"$target\"${repository:+ (repository \"$repository\"${branch:+ branch \"$branch\"})}"
  131. case $versys in
  132. CVS)
  133. ( cd $project/$target && cvs2cl --gmt -S --no-wrap -F ${branch:-TRUNK} -f ../$target.ChangeLog 2>&1 || exit 1 ) \
  134. | egrep -v '^cvs(pserver)? (server|log): Logging' || [ $? -lt 2 ] # catch grep failures
  135. ;;
  136. SVN)
  137. ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak )
  138. ( cd $project/$target && svn log -v | localsvnlog2cl > ../$target.ChangeLog )
  139. ;;
  140. ARCH)
  141. ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak )
  142. ( cd $project/$target && tla changelog > ../$target.ChangeLog )
  143. ;;
  144. Mercurial)
  145. ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak )
  146. ( cd $project/$target && hg log -v > ../$target.ChangeLog )
  147. ;;
  148. GIT)
  149. ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak )
  150. ( cd $project/$target && git log > ../$target.ChangeLog )
  151. ;;
  152. Bazaar)
  153. ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak )
  154. ( cd $project/$target && bzr log --short > ../$target.ChangeLog )
  155. ;;
  156. Darcs)
  157. ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak )
  158. ( cd $project/$target && darcs changes > ../$target.ChangeLog )
  159. ;;
  160. *)
  161. echo "ERROR: Action \"$action\" not supported for \"$project/$target\"."
  162. exit 1
  163. ;;
  164. esac
  165. ;;
  166. *)
  167. echo "ERROR: Unknown action \"$action\" for \"$project/$target\"."
  168. exit 1
  169. ;;
  170. esac
  171. done
  172. fi
  173. done