summaryrefslogtreecommitdiff
path: root/ikiwiki-makerepo
blob: 6ae3e28a3a7ee8a9cdc8bd769439c7e8433406cb (plain)
  1. #!/bin/sh
  2. set -e
  3. rcs="$1"
  4. srcdir="$2"
  5. repository="$3"
  6. usage () {
  7. echo "usage: ikiwiki-makerepo svn|git srcdir repository" >&2
  8. echo " ikiwiki-makerepo bzr|mercurial srcdir" >&2
  9. exit 1
  10. }
  11. if [ -z "$rcs" ] || [ -z "$srcdir" ]; then
  12. usage
  13. fi
  14. if [ ! -d "$srcdir" ]; then
  15. echo "srcdir $srcdir not found" >&2
  16. exit 1
  17. fi
  18. if [ "$rcs" != mercurial ] && [ "$rcs" != bzr ]; then
  19. if [ -e "$repository" ]; then
  20. echo "repository $repository already exists, aborting" >&2
  21. exit 1
  22. fi
  23. repository="$(perl -e 'use Cwd q{abs_path}; $r=shift; $r=~s/\/*$//; print abs_path($r)' $repository)"
  24. if [ -z "$repository" ]; then
  25. echo "internal error finding repository abs_path" >&2
  26. exit 1
  27. fi
  28. fi
  29. echo "Importing $srcdir into $rcs"
  30. case "$rcs" in
  31. svn)
  32. if [ -e "$srcdir/.svn" ]; then
  33. echo "$srcdir already seems to be a svn working copy" >&2
  34. exit 1
  35. fi
  36. svnadmin create "$repository"
  37. svn mkdir "file://$repository/trunk" -m "create trunk directory"
  38. cd "$srcdir"
  39. svn co "file://$repository/trunk" .
  40. svn propset svn:ignore ".ikiwiki" .
  41. svn add *
  42. svn commit -m "initial import"
  43. echo "Directory $srcdir is now a checkout of $rcs repository $repository"
  44. ;;
  45. git)
  46. # There are better ways to do this, but this works with older
  47. # versions of git.)
  48. mkdir -p "$repository"
  49. (cd "$repository" && git --bare init --shared)
  50. cd "$srcdir"
  51. git init
  52. echo /.ikiwiki > .gitignore
  53. git add .
  54. git commit -m "initial commit"
  55. git remote add origin "$repository"
  56. git config branch.master.merge refs/heads/master
  57. git config branch.master.remote origin
  58. git push --all
  59. echo "Directory $srcdir is now a clone of $rcs repository $repository"
  60. ;;
  61. mercurial)
  62. hg init "$srcdir"
  63. cd "$srcdir"
  64. echo .ikiwiki > .hgignore
  65. hg add * .hgignore
  66. hg commit -m "initial import"
  67. echo "Directory $srcdir is now set up as a mercurial repository"
  68. ;;
  69. bzr)
  70. bzr init "$srcdir"
  71. cd "$srcdir"
  72. echo .ikiwiki > .bzrignore
  73. bzr add * .bzrignore
  74. bzr commit -m "initial import"
  75. echo "Directory $srcdir is now set up as a bzr repository"
  76. ;;
  77. *)
  78. echo "Unsupported revision control system $rcs" >&2
  79. usage
  80. ;;
  81. esac