feat(build): checking if golang already installed

will send all my patches little by little so that it can easily be
merged

i plan on improving a little bit the form part by making a little
bubbletea cli but its not urgent, so ill rework the codebase in the
meantime :)
This commit is contained in:
djnn 2024-06-09 00:57:10 +02:00
parent e81c599cb5
commit 34718f4153
No known key found for this signature in database
GPG Key ID: 93C5A058CE33FBF2
2 changed files with 15 additions and 5 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
rfswift

View File

@ -2,18 +2,26 @@
# Quick and dirty building shell script which will evolve with more time make inside a Makefile
# stop the script if any command fails
set -euo pipefail
install_go() {
go version && { echo "golang is already installed. moving on" && return 0 ; }
[ -d thirdparty ] || mkdir thirdparty
cd thirdparty
arch=`uname -i`
prog="" # default Go binary tar.gz
version="1.22.4"
case "$arch" in
x86_64|amd64)
prog="go1.22.3.linux-amd64.tar.gz";;
prog="go${version}.linux-amd64.tar.gz";;
i?86)
prog="go1.22.3.linux-386.tar.gz";;
prog="go${version}.linux-386.tar.gz";;
arm64|aarch64|unknown) # Let assume from now unknown is RPi 5 => TODO: fix
prog="go1.22.3.linux-arm64.tar.gz";;
prog="go${version}.linux-arm64.tar.gz";;
*)
printf 'Unsupported architecture: "%s" -> Download or build Go instead\n' "$arch" >&2; exit 2;;
esac
@ -32,7 +40,7 @@ building_rfswift() {
}
echo "[+] Installing Go"
install_go
install_go
echo "[+] Building RF Switch Go Project"
building_rfswift
@ -50,4 +58,4 @@ imagename=${imagename:-$DEFAULT_IMAGE}
dockerfile=${dockerfile:-$DEFAULT_DOCKERFILE}
echo "[+] Building the Docker container"
sudo docker build . -t $imagename -f $dockerfile
sudo docker build . -t $imagename -f $dockerfile