reGen2 Linux Release Metatool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.6 KiB

9 years ago
9 years ago
  1. #!/bin/bash
  2. # Copyright 2010-2012, Asio Software Technologies
  3. # Distributed under the terms of the GNU General Public License v3
  4. #-------------------------------------------------------------------------------
  5. # Downloads or updates specified GIT repository
  6. # Parameters: %dest_directory% %address% [%branch%]
  7. #-------------------------------------------------------------------------------
  8. function checkoutGit() {
  9. local DIRECTORY="${1}"
  10. local ADDRESS="${2}"
  11. local BRANCH="${3:-master}"
  12. if [ -d ${DIRECTORY} ]; then
  13. cd ${DIRECTORY}
  14. run "git reset --hard origin/${BRANCH}" || return 1
  15. run "git clean --force" || return 1
  16. run "git pull --no-stat" || return 1
  17. else
  18. run "git clone ${ADDRESS} ${DIRECTORY}" || return 1
  19. if [ ${BRANCH} != "master" ]; then
  20. cd ${DIRECTORY}
  21. run "git checkout ${BRANCH}" || return 1
  22. fi
  23. fi
  24. return 0
  25. }
  26. #-------------------------------------------------------------------------------
  27. # Downloads or updates specified RSYNC repository
  28. # Parameters: %dest_directory% %address%
  29. #-------------------------------------------------------------------------------
  30. function checkoutRsync() {
  31. DIRECTORY="${1}"
  32. ADDRESS="${2}"
  33. run "rsync --compress --delete --delete-after --devices --force --links \
  34. --partial --perms --recursive --safe-links --stats --times \
  35. --timeout=${FETCHTIMEOUT} --whole-file --exclude=/.git --exclude=CVS \
  36. --exclude=/distfiles --exclude=/local --exclude=/metadata/cache \
  37. --exclude=/packages ${ADDRESS} ${DIRECTORY}" || return 1
  38. return 0
  39. }
  40. #-------------------------------------------------------------------------------
  41. # Downloads or updates specified SVN repository
  42. # Parameters: %dest_directory% %address%
  43. #-------------------------------------------------------------------------------
  44. function checkoutSubversion() {
  45. local DIRECTORY="${1}"
  46. local ADDRESS="${2}"
  47. if [ -d ${DIRECTORY} ]; then
  48. cd ${DIRECTORY}
  49. run "svn cleanup" || return 1
  50. run "svn update" || return 1
  51. else
  52. run "svn checkout ${ADDRESS} ${DIRECTORY}" || return 1
  53. fi
  54. return 0
  55. }
  56. #-------------------------------------------------------------------------------
  57. # Creates SSH Wrapper for use with unknown hosts (requires key authentication)
  58. #-------------------------------------------------------------------------------
  59. function makeSshWrapper() {
  60. echo "#!/bin/bash" > ${BINDIR}/ssh_wrapper.sh
  61. echo "exec ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
  62. \"\$@\"" >> ${BINDIR}/ssh_wrapper.sh
  63. chmod +x ${BINDIR}/ssh_wrapper.sh || return 1
  64. export GIT_SSH="${BINDIR}/ssh_wrapper.sh"
  65. export SVN_SSH="${BINDIR}/ssh_wrapper.sh"
  66. return 0
  67. }