Files
buildroot/support/download/go-post-process
Yann E. MORIN b974c91fe4 package/pkg-golang: support _SUBDIR
Some packages have their actual source tree in a sub-directory (even if
that is the only source in the repository); this is the case for example
with the Amazon ECR credential helper (to be packaged in a follow up
commit):
    https://github.com/awslabs/amazon-ecr-credential-helper

Do the build in _SUBDIR, and also do the vendoring in there.

We don't need the build to generate executables inside _SUBDIR, so we
just keep using $(@D)/bin as a place to generate them (and install them
from).

Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Cc: Christian Stewart <christian@aperture.us>
Reviewed-by: Christian Stewart <christian@aperture.us>
Signed-off-by: Julien Olivain <ju.o@free.fr>
2025-03-29 16:55:32 +01:00

37 lines
779 B
Bash
Executable File

#!/usr/bin/env bash
set -e
. "${0%/*}/helpers"
# Parse our options
while getopts "n:o:s:" OPT; do
case "${OPT}" in
o) output="${OPTARG}";;
n) base_name="${OPTARG}";;
s) subdir="${OPTARG}";;
:) error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
\?) error "unknown option '%s'\n" "${OPTARG}";;
esac
done
# Already vendored tarball, nothing to do
if tar tf "${output}" | grep -q "^[^/]*/vendor" ; then
exit 0
fi
post_process_unpack "${base_name}" "${output}"
# Do the Go vendoring
pushd "${base_name}/${subdir}" > /dev/null
if [ ! -f go.mod ]; then
echo "ERROR: no vendor/ folder and no go.mod, aborting"
exit 1
fi
go mod vendor -v -modcacherw
popd > /dev/null
post_process_repack $(pwd) "${base_name}" "${output}"