-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…1556) Updated the Go driver documentation, Linux installer, and Github CI file. The documentation needed to clarify what was needed. The installer needed to be fixed. The CI file needed to have the updated Go versions. The driver installation for Linux will no longer install Java, Golang, or ANTLR for the user. This is left to the users system administrator. Instead, it will validate the current installation of those components, then build and install the driver. Also updated - modified: drivers/golang/go.mod modified: drivers/golang/go.sum
- Loading branch information
1 parent
d14fe8c
commit 6bfb60f
Showing
6 changed files
with
149 additions
and
135 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
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 |
---|---|---|
@@ -1,141 +1,140 @@ | ||
#!/bin/sh | ||
|
||
# get OS | ||
os=$(uname) | ||
|
||
# get architecture | ||
arch=$(uname -m) | ||
|
||
java=$(java -version 2>&1 | head -n 1 | cut -d ' ' -f 3 | cut -d '.' -f 1 | cut -d '"' -f 2) | ||
# Check JDK version | ||
echo "Checking for JDK..." | ||
if ! java -version >/dev/null 2>&1 || [ $java -lt 11 ]; then | ||
echo "JDK not found or less than version 11, would you like to install? ()" | ||
echo "Y/N ->" | ||
read answer | ||
if [ "$answer" = y ] || [ "$answer" = Y ]; then | ||
echo "Installing..." | ||
if [[ "$os" == "Darwin" ]]; then | ||
cd /tmp | ||
if [[ "$arch" == "x86_64" ]]; then | ||
curl "https://download.oracle.com/java/20/latest/jdk-20_macos-x64_bin.dmg" -o jdk-20_bin.dmg | ||
elif [[ "$arch" == "arm64" ]]; then | ||
curl "https://download.oracle.com/java/20/latest/jdk-20_macos-aarch64_bin.dmg" -o jdk-20_bin.dmg | ||
fi | ||
hdiutil mount jdk-20_bin.dmg | ||
# sudo installer -pkg "/Volumes/JDK 20/JDK 20.pkg" -target "/" | ||
sudo open -w "/Volumes/JDK 20/JDK 20.pkg" | ||
hdiutil unmount "/Volumes/JDK 20" | ||
rm jdk-20_bin.dmg | ||
|
||
elif [[ "$os" == "Linux" ]]; then | ||
mkdir -p ~/tmp/jdk20 | ||
cd ~/tmp/jdk20 | ||
if [[ "$arch" == "x86_64" ]]; then | ||
curl "https://download.oracle.com/java/20/latest/jdk-20_linux-x64_bin.tar.gz" -o jdk-20_bin.tar.gz | ||
elif [[ "$arch" == "arm64" ]]; then | ||
curl "https://download.oracle.com/java/20/latest/jdk-20_linux-aarch64_bin.tar.gz" -o jdk-20_bin.tar.gz | ||
fi | ||
sudo tar zxvf jdk-20_bin.tar.gz -C /usr/local/ | ||
cd ~/ | ||
rm -rf ~/tmp/jdk20/ | ||
fi | ||
echo "JDK installation complete." | ||
else | ||
echo "Please install JDK >= 11.0.16" | ||
exit 0 | ||
fi | ||
# Check Java installation | ||
echo "Checking for minimum Java installation..." | ||
|
||
java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}') | ||
|
||
if [ ! -z $java_version ]; then | ||
echo "Java version $java_version" | ||
else | ||
echo "JDK already installed." | ||
echo "Java not found. Please install Java." | ||
fi | ||
|
||
antlr=$(/usr/local/jdk-20/bin/jar xf /usr/local/antlr/antlr-*-complete.jar META-INF/MANIFEST.MF >/dev/null 2>&1 && grep 'Implementation-Version' META-INF/MANIFEST.MF | cut -d ' ' -f 2 && rm -rf META-INF) | ||
# Check ANTLR installation and version | ||
echo "Checking for ANTLR..." | ||
check_antlr () { | ||
if [ ! -z $antlr ]; then | ||
if ([ "$(echo $antlr | cut -d '.' -f 1)" -lt 4 ] && [ "$(echo $antlr | cut -d '.' -f 2)" -lt 11 ] && [ "$(echo $antlr | cut -d '.' -f 3)" -lt 1 ]); then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
else | ||
return 0 | ||
fi | ||
} | ||
|
||
if check_antlr; then | ||
echo "ANTLR not found in Default Location or less than version 4.11.1, would you like to Install?" | ||
echo "(If installed in other location, please edit the location inside the shell script before running)" | ||
echo "Y/N ->" | ||
read answer | ||
if [ "$answer" = y ] || [ "$answer" = Y ]; then | ||
mkdir -p ~/tmp/antlr4.11.1 | ||
cd ~/tmp/antlr4.11.1 | ||
curl -LO "https://www.antlr.org/download/antlr-4.11.1-complete.jar" | ||
sudo mkdir -p /usr/local/antlr | ||
sudo mv ~/tmp/antlr4.11.1/antlr-4.11.1-complete.jar /usr/local/antlr/antlr-4.11.1-complete.jar | ||
|
||
echo 'export CLASSPATH=".:/usr/local/antlr/antlr-4.11.1-complete.jar"' >>~/.bashrc | ||
. ~/.bashrc | ||
echo "ANTLR installation complete." | ||
else | ||
echo "Please install ANTLR >= 4.11.1" | ||
exit 0 | ||
fi | ||
# | ||
# Get Java version | ||
java_major=$(echo $java_version | cut -d '.' -f1) | ||
java_minor=$(echo $java_version | cut -d '.' -f2) | ||
java_patch=$(echo $java_version | cut -d '.' -f3) | ||
|
||
# Check Java version | ||
java_version_flag=0 | ||
if [ $java_major -lt 11 ]; then | ||
java_version_flag=0 | ||
elif [ $java_minor -lt 0 ]; then | ||
java_version_flag=0 | ||
elif [ $java_patch -lt 0 ]; then | ||
java_version_flag=0 | ||
else | ||
echo "ANTLR already installed." | ||
java_version_flag=1 | ||
fi | ||
|
||
# Check Go installation and version | ||
echo "Checking for Go..." | ||
if ! command -v go >/dev/null 2>&1 || { [ $(go version | grep -o -E '[0-9]+\.[0-9]+' | head -n 1 | cut -d '.' -f 1) -lt 1 ] && [ $(go version | grep -o -E '[0-9]+\.[0-9]+' | head -n 1 | cut -d '.' -f 2) -lt 19 ]; }; then | ||
echo "Go not installed or version is less than 1.19, would you like to install?" | ||
echo "Y/N ->" | ||
read answer | ||
if [ "$answer" = y ] || [ "$answer" = Y ]; then | ||
if [[ "$os" == "Darwin" ]]; then | ||
cd /tmp | ||
if [[ "$arch" == "x86_64" ]]; then | ||
curl "https://go.dev/dl/go1.20.2.darwin-amd64.pkg" -o go1.20.2.pkg | ||
elif [[ "$arch" == "arm64" ]]; then | ||
curl "https://go.dev/dl/go1.20.2.darwin-arm64.pkg" -o go1.20.2.pkg | ||
fi | ||
|
||
#sudo installer -pkg "go1.20.2.pkg" -target "/" | ||
sudo open -w golang.pkg | ||
|
||
elif [[ "$os" == "Linux" ]]; then | ||
mkdir -p ~/tmp/go1.20.2 | ||
cd ~/tmp/go1.20.2 | ||
if [[ "$arch" == "x86_64" ]]; then | ||
curl "https://go.dev/dl/go1.20.2.linux-amd64.tar.gz" -o go1.20.2.tar.gz | ||
elif [[ "$arch" == "arm64" ]]; then | ||
curl "https://go.dev/dl/go1.20.2.linux-arm64.tar.gz" -o go1.20.2.tar.gz | ||
fi | ||
|
||
if command -v go >/dev/null 2>&1; then | ||
rm -rf /usr/local/go | ||
fi | ||
sudo tar -C /usr/local -xzf go1.20.2.linux-amd64.tar.gz | ||
|
||
if ! [[ ":$PATH:" == *":/usr/local/go/bin:"* ]]; then | ||
export PATH=$PATH:/usr/local/go/bin | ||
fi | ||
fi | ||
echo "Go installation complete" | ||
else | ||
echo "Please install Go >= 1.19" | ||
exit 0 | ||
fi | ||
if [ $java_version_flag -eq 0 ]; then | ||
echo "Java version less than 11.0.0" | ||
echo "NOTE: If a newer version of Java is installed, but not set as " | ||
echo " the current version, exit and select it before continuing." | ||
exit 0 | ||
else | ||
echo "Go already installed." | ||
echo "Java is installed." | ||
echo "" | ||
fi | ||
|
||
# Check ANTLR installation | ||
echo "Checking for minimum ANTLR installation..." | ||
jar xf /usr/local/antlr/antlr-*-complete.jar META-INF/MANIFEST.MF >/dev/null 2>&1 | ||
antlr_version=$(grep 'Implementation-Version' META-INF/MANIFEST.MF | cut -d ' ' -f 2) | ||
rm -rf META-INF | ||
|
||
if [ ! -z $antlr_version ]; then | ||
echo "ANTLR version $antlr_version" | ||
else | ||
echo "ANTLR not found. Please install ANTLR." | ||
exit 0 | ||
fi | ||
|
||
# Check ANTLR version | ||
antlr_version_flag=0 | ||
antlr_major=$(echo $antlr_version | cut -d '.' -f 1) | ||
antlr_minor=$(echo $antlr_version | cut -d '.' -f 2) | ||
antlr_patch=$(echo $antlr_version | cut -d '.' -f 3 | sed 's/\r//') | ||
|
||
if [ $antlr_major -lt 4 ]; then | ||
antlr_version_flag=0 | ||
elif [ $antlr_minor -lt 11 ]; then | ||
antlr_version_flag=0 | ||
elif [ $antlr_patch -lt 1 ]; then | ||
antlr_version_flag=0 | ||
else | ||
antlr_version_flag=1 | ||
fi | ||
|
||
if [ $antlr_version_flag -eq 0 ]; then | ||
echo "ANTLR version less than 4.11.1" | ||
exit 0 | ||
else | ||
echo "ANTLR is installed." | ||
echo "" | ||
fi | ||
|
||
# Check Go installation | ||
echo "Checking for minimum Golang installation..." | ||
go_version=$(go version 2>&1 | cut -d' ' -f3) | ||
|
||
if [ ! -z $go_version ]; then | ||
echo "Golang version $go_version" | ||
else | ||
echo "Golang not found. Please install Golang." | ||
exit 0 | ||
fi | ||
|
||
# Check Go version | ||
go_version_flag=0 | ||
go_major=$(echo $go_version | cut -d '.' -f1 | cut -d 'o' -f 2) | ||
go_minor=$(echo $go_version | cut -d '.' -f2) | ||
go_patch=$(echo $go_version | cut -d '.' -f3) | ||
|
||
if [ $go_major -lt 1 ]; then | ||
go_version_flag=0 | ||
elif [ $go_minor -lt 18 ]; then | ||
go_version_flag=0 | ||
elif [ $go_patch -lt 0 ]; then | ||
go_version_flag=0 | ||
else | ||
go_version_flag=1 | ||
fi | ||
|
||
if [ $go_version_flag -eq 0 ]; then | ||
echo "Golang version less than 1.19.0" | ||
exit 0 | ||
else | ||
echo "Golang is installed." | ||
echo "" | ||
fi | ||
|
||
# Check CLASSPATH | ||
echo "Checking for ANTLR in CLASSPATH..." | ||
test_classpath=$(echo $CLASSPATH | grep antlr) | ||
|
||
if [ ! -z $test_classpath ]; then | ||
echo "CLASSPATH = $CLASSPATH" | ||
echo "" | ||
else | ||
echo "ANTLR not set in CLASSPATH. Please set up CLASSPATH." | ||
exit 0 | ||
fi | ||
|
||
# Generate Parser and Lexer | ||
echo "Generating Parser & Lexer..." | ||
java -Xmx500M -cp "/usr/local/lib/antlr-4.11.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool -Dlanguage=Go -visitor Age.g4 | ||
java -Xmx500M org.antlr.v4.Tool -Dlanguage=Go -visitor parser/Age.g4 | ||
|
||
# Install Golang driver | ||
echo "Installing Driver..." | ||
go get -u ./... | ||
|
||
echo "Successfully Installed Driver!" | ||
exit 0 |
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