Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support/download/go-post-process: implement Go vendoring support
This commit introduces the download post-process script support/download/go-post-process, and hooks it into the Go package infrastructure. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Skiff fixup: - run "go mod init" just before "go mod vendor" - this fixes the case when go.mod does not exist - use -modcacherw to fix "make clean" permissions errors - proposal was e-mailed to the buildroot mailing list Signed-off-by: Christian Stewart <christian@paral.in> Signed-off-by: Christian Stewart <christian@paral.in>
- Loading branch information
1 parent
626fc0a
commit 5f31774
Showing
4 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
. $(dirname $0)/post-process-helpers | ||
|
||
# Parse our options | ||
while getopts "n:g:o:" OPT; do | ||
case "${OPT}" in | ||
g) gomod_init="${OPTARG}";; | ||
o) output="${OPTARG}";; | ||
n) base_name="${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 | ||
|
||
unpack ${base_name} ${output} | ||
|
||
# Do the Go vendoring | ||
pushd ${base_name} > /dev/null | ||
# modcacherw option leaves directories in the module cache at their default | ||
# permissions rather than making them read-only. | ||
if [ ! -f go.mod ] && [ -n "${gomod_init}" ]; then | ||
go mod init -modcacherw ${gomod_init} | ||
fi | ||
go mod vendor -modcacherw -v | ||
popd > /dev/null | ||
|
||
repack ${base_name} ${output} |