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