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