cvs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. # Call it as:
  7. # .../cvs [-q] OUT_FILE CVS_URL REV PKG_NAME BASENAME
  8. #
  9. # Environment:
  10. # CVS : the cvs command to call
  11. verbose=
  12. while getopts :q OPT; do
  13. case "${OPT}" in
  14. q) verbose=-Q;;
  15. \?) printf "unknown option '%s'\n" "${OPTARG}" >&2; exit 1;;
  16. esac
  17. done
  18. shift $((OPTIND-1))
  19. output="${1}"
  20. repo="${2}"
  21. rev="${3}"
  22. rawname="${4}"
  23. basename="${5}"
  24. # Caller needs to single-quote its arguments to prevent them from
  25. # being expanded a second time (in case there are spaces in them)
  26. _cvs() {
  27. eval ${CVS} "${@}"
  28. }
  29. if [[ ${rev} =~ ^[0-9] ]]; then
  30. # Date, because a tag or a branch cannot begin with a number
  31. select="-D"
  32. else
  33. # Tag or branch
  34. select="-r"
  35. fi
  36. # The absence of an initial : on ${repo} means access method undefined
  37. if [[ ! "${repo}" =~ ^: ]]; then
  38. # defaults to anonymous pserver
  39. repo=":pserver:anonymous@${repo}"
  40. fi
  41. export TZ=UTC
  42. _cvs ${verbose} -z3 -d"'${repo}'" \
  43. co -d "'${basename}'" ${select} "'${rev}'" -P "'${rawname}'"
  44. tar czf "${output}" "${basename}"