Skip to content

Commit

Permalink
Fix build cache permissions.
Browse files Browse the repository at this point in the history
  • Loading branch information
udhos committed Sep 28, 2018
1 parent 11dd8f4 commit 8348a6a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions update-golang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,31 @@ path() {
fi
}

perm_build_cache() {
local gocache
gocache=$("$abs_gotool" env | grep GOCACHE) ;# grab GOCACHE=path

local buildcache
buildcache=$(echo "$gocache" | awk -F= '{ print $2 }') ;# grab path
buildcache=$(eval echo "$buildcache") ;# unquote

local own
own=":"

if [ "$EUID" -eq 0 ]; then
# running as root - try user id from sudo
own="$SUDO_UID:$SUDO_GID"
fi

if [ "$own" == ":" ]; then
# try getting the usual user id
own=$(id -u):$(id -g)
fi

msg recursively forcing build cache ["$buildcache"] ownership to "$own"
chown -R "$own" "$buildcache"
}

test() {
local ret=1
local t="$abs_gotool version"
Expand Down Expand Up @@ -399,6 +424,7 @@ path
msg golang "$label" installed at: "$abs_goroot"

test
perm_build_cache ;# must be after test, since testing might create root:root files
cleanup

exit 0
Expand Down
2 changes: 1 addition & 1 deletion update-golang.sh.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9ed23aa6b2fb6acc58e841c15d7b58b83f756a423e8cb98921f1d51430c4339b update-golang.sh
33c45171eaf873d4f60ff539345b9b16981e3a5e0063a2d71aec10bfc63b4bef update-golang.sh

0 comments on commit 8348a6a

Please sign in to comment.