2
1

cvs 1.1 KB

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