2
1

go-post-process 779 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env bash
  2. set -e
  3. . "${0%/*}/helpers"
  4. # Parse our options
  5. while getopts "n:o:s:" OPT; do
  6. case "${OPT}" in
  7. o) output="${OPTARG}";;
  8. n) base_name="${OPTARG}";;
  9. s) subdir="${OPTARG}";;
  10. :) error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
  11. \?) error "unknown option '%s'\n" "${OPTARG}";;
  12. esac
  13. done
  14. # Already vendored tarball, nothing to do
  15. if tar tf "${output}" | grep -q "^[^/]*/vendor" ; then
  16. exit 0
  17. fi
  18. post_process_unpack "${base_name}" "${output}"
  19. # Do the Go vendoring
  20. pushd "${base_name}/${subdir}" > /dev/null
  21. if [ ! -f go.mod ]; then
  22. echo "ERROR: no vendor/ folder and no go.mod, aborting"
  23. exit 1
  24. fi
  25. go mod vendor -v -modcacherw
  26. popd > /dev/null
  27. post_process_repack $(pwd) "${base_name}" "${output}"