forked from openwrt/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
golang: Move module cache into DL_DIR
This also adds a config option GOLANG_MOD_CACHE_WORLD_READABLE; if enabled, chmod is run after a Go package build to make all files/directories in the module cache world-readable. Signed-off-by: Jeffery To <[email protected]>
- Loading branch information
Showing
4 changed files
with
80 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/sh | ||
|
||
log() { | ||
# shellcheck disable=SC2039 | ||
local IFS=" " | ||
printf '%s\n' "$*" | ||
} | ||
|
||
log_error() { | ||
# shellcheck disable=SC2039 | ||
local IFS=" " | ||
printf 'Error: %s\n' "$*" >&2 | ||
} | ||
|
||
cache_cleanup() { | ||
if ! [ -d "$GO_MOD_CACHE_DIR" ]; then | ||
return 0 | ||
fi | ||
|
||
# in case go is called without -modcacherw | ||
find "$GO_MOD_CACHE_DIR" -type d -not -perm -u+w -exec chmod u+w '{}' + | ||
|
||
if [ -n "$CONFIG_GOLANG_MOD_CACHE_WORLD_READABLE" ]; then | ||
find "$GO_MOD_CACHE_DIR" -type d -not -perm -go+rx -exec chmod go+rx '{}' + | ||
find "$GO_MOD_CACHE_DIR" -not -type d -not -perm -go+r -exec chmod go+r '{}' + | ||
fi | ||
|
||
return 0 | ||
} | ||
|
||
|
||
if [ "$#" -lt 1 ]; then | ||
log_error "Missing command" | ||
exit 1 | ||
fi | ||
|
||
command="$1" | ||
shift 1 | ||
|
||
case "$command" in | ||
cache_cleanup) | ||
cache_cleanup | ||
;; | ||
*) | ||
log_error "Invalid command \"$command\"" | ||
exit 1 | ||
;; | ||
esac |
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