Skip to content

Commit 28f6ffb

Browse files
authored
Update setup to install go 1.19 (viamrobotics#99)
1 parent b249523 commit 28f6ffb

1 file changed

Lines changed: 35 additions & 10 deletions

File tree

‎etc/setup.sh‎

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@ do_bullseye(){
2727
echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x $(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) main" > /etc/apt/sources.list.d/nodesource.list
2828
2929
# Install most things
30-
apt-get update && apt-get install -y build-essential nodejs libnlopt-dev libx264-dev libtensorflowlite-dev protobuf-compiler protoc-gen-grpc-web ffmpeg && apt-get clean
30+
apt-get update && apt-get install -y build-essential nodejs libnlopt-dev libx264-dev libopus-dev libtensorflowlite-dev protobuf-compiler protoc-gen-grpc-web ffmpeg && apt-get clean
3131
3232
# Install backports
3333
apt-get install -y -t $(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)-backports golang-go
3434
3535
# Raspberry Pi support
36+
grep -q Raspberry /proc/cpuinfo && apt-get install -y wiringpi libpigpio-dev && exit
37+
38+
# Other arm64 (bring in pi repo at low priority for build support)
3639
test "$(uname -m)" != "aarch64" || curl -fsSL https://archive.raspberrypi.org/debian/raspberrypi.gpg.key | gpg --yes --dearmor -o /usr/share/keyrings/raspberrypi.gpg
3740
test "$(uname -m)" != "aarch64" || echo "deb [signed-by=/usr/share/keyrings/raspberrypi.gpg] http://archive.raspberrypi.org/debian/ $(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) main" > /etc/apt/sources.list.d/raspi.list
41+
test "$(uname -m)" != "aarch64" || echo -e "Package: *\nPin: origin archive.raspberrypi.org\nPin-Priority: 1" > /etc/apt/preferences.d/raspi-low-prio
3842
test "$(uname -m)" != "aarch64" || ( apt-get update && apt-get install -y wiringpi libpigpio-dev && apt-get clean )
3943
EOS
4044

@@ -48,6 +52,7 @@ do_bullseye(){
4852
EOS
4953

5054
mod_profiles
55+
check_gcloud_auth
5156
}
5257

5358
do_linux(){
@@ -78,10 +83,12 @@ do_linux(){
7883
export GOPRIVATE=github.com/viamrobotics/*,go.viam.com/*
7984
export CC=gcc-11
8085
export CXX=g++-11
86+
export PATH="\$PATH:\$(ruby -e 'puts Gem.user_dir')/bin"
8187
EOS
8288

8389
do_brew
8490
mod_profiles
91+
check_gcloud_auth
8592
}
8693

8794

@@ -100,20 +107,23 @@ do_darwin(){
100107
export CGO_LDFLAGS=-L/opt/homebrew/lib
101108
export CGO_CFLAGS=-I/opt/homebrew/include
102109
export GOPRIVATE=github.com/viamrobotics/*,go.viam.com/*
110+
export PATH="\$PATH:\$(ruby -e 'puts Gem.user_dir')/bin"
103111
EOS
104112

105-
else # assuming x86_64, but untested
113+
else # assuming x86_64, but untested
106114

107115
cat > ~/.viamdevrc <<-EOS
108116
eval "\$(/usr/local/bin/brew shellenv)"
109117
export LIBRARY_PATH=/usr/local/lib
110118
export GOPRIVATE=github.com/viamrobotics/*,go.viam.com/*
119+
export PATH="\$PATH:\$(ruby -e 'puts Gem.user_dir')/bin"
111120
EOS
112121

113122
fi
114123

115124
do_brew
116125
mod_profiles
126+
check_gcloud_auth
117127
}
118128

119129
mod_profiles(){
@@ -133,30 +143,45 @@ mod_profiles(){
133143
grep -q github.com ~/.ssh/known_hosts || ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
134144
}
135145

146+
# This workaround is for https://viam.atlassian.net/browse/RSDK-526, without the application default credential file our tests will
147+
# create goroutines that get leaked and fail. Once https://github.com/googleapis/google-cloud-go/issues/5430 is fixed we can remove this.
148+
check_gcloud_auth(){
149+
APP_CREDENTIALS_DIR="$HOME/.config/gcloud"
150+
mkdir -p $APP_CREDENTIALS_DIR
151+
APP_CREDENTIALS_FILE="$APP_CREDENTIALS_DIR/application_default_credentials.json"
152+
if [ ! -f "$APP_CREDENTIALS_FILE" ]; then
153+
echo "Missing gcloud application default credentials, this can cause goroutines to leak if not configured. Creating with empty config at $APP_CREDENTIALS_FILE"
154+
echo '{"client_id":"XXXX","client_secret":"XXXX","refresh_token":"XXXX","type":"authorized_user"}' > $APP_CREDENTIALS_FILE
155+
fi
156+
}
157+
136158
do_brew(){
137159
# Install brew
138160
brew --version > /dev/null 2>&1 || bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || exit 1
139161

162+
gem install license_finder --conservative
163+
140164
# Has to be after the install so the brew eval can run
141165
source ~/.viamdevrc
142166

143167
brew bundle --file=- <<-EOS
144168
# viam tap
145169
tap "viamrobotics/brews"
146170
171+
# pinned
172+
brew "gcc@11"
173+
brew "go@1.19"
174+
brew "node@18"
175+
brew "protobuf@3"
176+
147177
# unpinned
148178
brew "nlopt"
149179
brew "x264"
180+
brew "opus"
150181
brew "protoc-gen-grpc-web"
151182
brew "pkg-config"
152-
brew "tensorflowlite"
153183
brew "ffmpeg"
154-
155-
# pinned
156-
brew "gcc@11"
157-
brew "go@1.18"
158-
brew "node@18"
159-
brew "protobuf@3"
184+
brew "tensorflowlite" # Needs to be last
160185
161186
EOS
162187

@@ -165,7 +190,7 @@ do_brew(){
165190
fi
166191

167192
brew unlink "gcc" "go" "node" "protobuf"
168-
brew link --overwrite "gcc@11" "go@1.18" "node@18" "protobuf@3" || exit 1
193+
brew link --overwrite "gcc@11" "go@1.19" "node@18" "protobuf@3" || exit 1
169194

170195
echo "Brew installed software versions..."
171196
brew list --version

0 commit comments

Comments
 (0)