cvs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. shift 5 # Get rid of our options
  25. # Caller needs to single-quote its arguments to prevent them from
  26. # being expanded a second time (in case there are spaces in them)
  27. _cvs() {
  28. eval ${CVS} "${@}"
  29. }
  30. if [[ ${rev} =~ ^[0-9] ]]; then
  31. # Date, because a tag or a branch cannot begin with a number
  32. select="-D"
  33. else
  34. # Tag or branch
  35. select="-r"
  36. fi
  37. # The absence of an initial : on ${repo} means access method undefined
  38. if [[ ! "${repo}" =~ ^: ]]; then
  39. # defaults to anonymous pserver
  40. repo=":pserver:anonymous@${repo}"
  41. fi
  42. export TZ=UTC
  43. _cvs ${verbose} -z3 -d"'${repo}'" \
  44. co "${@}" -d "'${basename}'" ${select} "'${rev}'" -P "'${rawname}'"
  45. tar czf "${output}" "${basename}"