svn 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. # We want to catch any command failure, and exit immediately
  3. set -e
  4. # Download helper for svn
  5. # Call it with:
  6. # $1: svn repo
  7. # $2: svn revision
  8. # $3: package's basename (eg. foobar-1.2.3)
  9. # $4: output file
  10. # And this environment:
  11. # SVN : the svn command to call
  12. # BUILD_DIR: path to Buildroot's build dir
  13. repo="${1}"
  14. rev="${2}"
  15. basename="${3}"
  16. output="${4}"
  17. repodir="${basename}.tmp-svn-checkout"
  18. tmp_output="$( mktemp "${output}.XXXXXX" )"
  19. cd "${BUILD_DIR}"
  20. # Remove leftovers from a previous failed run
  21. rm -rf "${repodir}"
  22. # Play tic-tac-toe with temp files
  23. # - first, we download to a trashable location (the build-dir)
  24. # - then we create a temporary tarball in the final location, so it is
  25. # on the same filesystem as the final file
  26. # - finally, we atomically rename to the final file
  27. ret=1
  28. if ${SVN} export "${repo}@${rev}" "${repodir}"; then
  29. if tar czf "${tmp_output}" "${repodir}"; then
  30. mv "${tmp_output}" "${output}"
  31. ret=0
  32. fi
  33. fi
  34. # Cleanup
  35. rm -rf "${repodir}" "${tmp_output}"
  36. exit ${ret}