cvs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env bash
  2. # We want to catch any unexpected failure, and exit immediately
  3. set -e
  4. # Download helper for cvs, to be called from the download wrapper script
  5. #
  6. # Options:
  7. # -q Be quiet
  8. # -o FILE Generate archive in FILE.
  9. # -u URI Checkout from repository at URI.
  10. # -c REV Use revision REV.
  11. # -N RAWNAME Use rawname (aka module name) RAWNAME.
  12. # -n NAME Use basename NAME.
  13. #
  14. # Environment:
  15. # CVS : the cvs command to call
  16. verbose=
  17. while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do
  18. case "${OPT}" in
  19. q) verbose=-Q;;
  20. o) output="${OPTARG}";;
  21. u) uri="${OPTARG}";;
  22. c) rev="${OPTARG}";;
  23. N) rawname="${OPTARG}";;
  24. n) basename="${OPTARG}";;
  25. :) printf "option '%s' expects a mandatory argument\n" "${OPTARG}"; exit 1;;
  26. \?) printf "unknown option '%s'\n" "${OPTARG}" >&2; exit 1;;
  27. esac
  28. done
  29. shift $((OPTIND-1)) # Get rid of our options
  30. # Caller needs to single-quote its arguments to prevent them from
  31. # being expanded a second time (in case there are spaces in them)
  32. _cvs() {
  33. eval ${CVS} "${@}"
  34. }
  35. if [[ ${rev} =~ ^[0-9] ]]; then
  36. # Date, because a tag or a branch cannot begin with a number
  37. select="-D"
  38. else
  39. # Tag or branch
  40. select="-r"
  41. fi
  42. # The absence of an initial : on ${uri} means access method undefined
  43. if [[ ! "${uri}" =~ ^: ]]; then
  44. # defaults to anonymous pserver
  45. uri=":pserver:anonymous@${uri}"
  46. fi
  47. export TZ=UTC
  48. _cvs ${verbose} -z3 -d"'${uri}'" \
  49. co "${@}" -d "'${basename}'" ${select} "'${rev}'" -P "'${rawname}'"
  50. tar czf "${output}" "${basename}"