From: Thomas Walker Lynch Date: Wed, 31 Jul 2024 14:24:37 +0000 (+0000) Subject: improved install and environment scripts, some makefile changes X-Git-Url: https://git.reasoningtechnology.com/usr/lib/python2.7/encodings/cp855.py?a=commitdiff_plain;h=e1ab80027f14a8f31ff867138b77d9c5ea427a6b;p=GQL-to-Cypher improved install and environment scripts, some makefile changes --- diff --git a/developer/makefile b/developer/makefile index a03082d..00103e4 100644 --- a/developer/makefile +++ b/developer/makefile @@ -1,12 +1,13 @@ -# Use `make variable` to print the value assigned to the variable ISLAND. -# Spaces in and after non-white characters are part of the value. -# This includes trailing spaces on the line, and space leading to a comment marker. -# Note the next line has 4 trailing spaces after 'island': +# Embedded and trailing spaces are included in the value, there are +# 4 of each used here. Leading spaces are not included. If there is a comment +# starting with a hash, the trailing spaces leading up to are included. +# Use `make variable` to print the value assigned to the variables, including +# ISLAND. ISLAND = land island -ANTLR_JAR = ../tool/executor/antlr-4.9.2-complete.jar +# JAVA_HOME, CLASSPATH, and ANTLR_JAR variables come from `env_dev` JAVA_COMP = $(JAVA_HOME)/bin/javac JAVA_INTERP = $(JAVA_HOME)/bin/java JAR = $(JAVA_HOME)/bin/jar diff --git a/executor/clean.sh b/executor/clean.sh index 8be044c..4f94bd5 100755 --- a/executor/clean.sh +++ b/executor/clean.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash -# Get the project root path by removing 'executor' from the script path -script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" -project_root="${script_path%/*}" +# Check if REPO_HOME is set, if not exit with an error +if [ -z "$REPO_HOME" ]; then + echo "REPO_HOME is not set. Please initialize the environment." + exit 1 +fi # Function to handle errors handle_error() { @@ -11,11 +13,11 @@ handle_error() { } # Call specific clean scripts -./clean_Java.sh || { echo "Java cleanup failed."; } -./clean_ANTLR.sh || { echo "ANTLR cleanup failed."; } +"$REPO_HOME/executor/clean_Java" || { echo "Java cleanup failed."; } +"$REPO_HOME/executor/clean_ANTLR" || { echo "ANTLR cleanup failed."; } # Remove the contents of the tool directory while preserving the directory itself and .gitignore -find "$project_root/tool" -mindepth 1 -maxdepth 1 -not -name ".gitignore" -not -name "upstream" -not -type l -exec rm -rf {} + || handle_error -find "$project_root/tool" -maxdepth 1 -type l -exec rm -f {} + || handle_error +find "$REPO_HOME/tool" -mindepth 1 -maxdepth 1 -not -name ".gitignore" -not -name "upstream" -not -type l -exec rm -rf {} + || handle_error +find "$REPO_HOME/tool" -maxdepth 1 -type l -exec rm -f {} + || handle_error -echo 'Tool directory cleanup complete. Run `clean_upstream.sh` to remove cached upstream files.' +echo "Tool directory cleanup complete." diff --git a/executor/clean_ANTLR b/executor/clean_ANTLR new file mode 100755 index 0000000..22d6736 --- /dev/null +++ b/executor/clean_ANTLR @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Check if REPO_HOME is set, if not exit with an error +if [ -z "$REPO_HOME" ]; then + echo "REPO_HOME is not set. Please initialize the environment." + exit 1 +fi + +# Function to handle errors +handle_error() { + echo "Error occurred during ANTLR cleanup. Exiting." + exit 1 +} + +# Clean the ANTLR directory +antlr_dir=$(find "$REPO_HOME/tool" -maxdepth 1 -type d -name "antlr4-*" | head -n 1) +if [ -n "$antlr_dir" ]; then + find "$antlr_dir" -mindepth 1 -maxdepth 1 -not -type l -exec rm -rf {} + || handle_error + find "$antlr_dir" -maxdepth 1 -type l -exec rm -f {} + || handle_error +else + echo "ANTLR directory does not exist." +fi + +echo "ANTLR cleanup complete." diff --git a/executor/clean_ANTLR.sh b/executor/clean_ANTLR.sh deleted file mode 100755 index 4c77844..0000000 --- a/executor/clean_ANTLR.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -# Get the project root path by removing 'executor' from the script path -script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" -project_root="${script_path%/*}" - -# Function to handle errors -handle_error() { - echo "Error occurred during ANTLR cleanup. Exiting." - exit 1 -} - -# Clean the ANTLR directory -antlr_dir="$project_root/tool/upstream/antlr4-*" -if [ -d "$antlr_dir" ]; then - find "$antlr_dir" -mindepth 1 -maxdepth 1 -not -type l -exec rm -rf {} + || handle_error - find "$antlr_dir" -maxdepth 1 -type l -exec rm -f {} + || handle_error -else - echo "ANTLR directory does not exist." -fi - -echo "ANTLR cleanup complete." diff --git a/executor/clean_Java b/executor/clean_Java new file mode 100755 index 0000000..8c7df26 --- /dev/null +++ b/executor/clean_Java @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Check if REPO_HOME is set, if not exit with an error +if [ -z "$REPO_HOME" ]; then + echo "REPO_HOME is not set. Please initialize the environment." + exit 1 +fi + +# Function to handle errors +handle_error() { + echo "Error occurred during Java cleanup. Exiting." + exit 1 +} + +# Clean the JDK directory +jdk_dir=$(find "$REPO_HOME/tool" -maxdepth 1 -type d -name "jdk-*" | head -n 1) +if [ -n "$jdk_dir" ]; then + find "$jdk_dir" -mindepth 1 -maxdepth 1 -not -type l -exec rm -rf {} + || handle_error + find "$jdk_dir" -maxdepth 1 -type l -exec rm -f {} + || handle_error +else + echo "JDK directory does not exist." +fi + +echo "Java cleanup complete." diff --git a/executor/clean_Java.sh b/executor/clean_Java.sh deleted file mode 100755 index 922d3a9..0000000 --- a/executor/clean_Java.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -# Get the project root path by removing 'executor' from the script path -script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" -project_root="${script_path%/*}" - -# Function to handle errors -handle_error() { - echo "Error occurred during Java cleanup. Exiting." - exit 1 -} - -# Clean the JDK directory -jdk_dir="$project_root/tool/upstream/jdk-*" -if [ -d "$jdk_dir" ]; then - find "$jdk_dir" -mindepth 1 -maxdepth 1 -not -type l -exec rm -rf {} + || handle_error - find "$jdk_dir" -maxdepth 1 -type l -exec rm -f {} + || handle_error -else - echo "JDK directory does not exist." -fi - -echo "Java cleanup complete." diff --git a/executor/clean_upstream b/executor/clean_upstream new file mode 100755 index 0000000..2fc57e3 --- /dev/null +++ b/executor/clean_upstream @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Check if REPO_HOME is set, if not exit with an error +if [ -z "$REPO_HOME" ]; then + echo "REPO_HOME is not set. Please initialize the environment." + exit 1 +fi + +# Function to handle errors +handle_error() { + echo "Error occurred during upstream cleanup. Exiting." + exit 1 +} + +# Check if the upstream directory exists +if [ -d "$REPO_HOME/tool/upstream" ]; then + echo "Cleaning up upstream directory..." + find "$REPO_HOME/tool/upstream" -mindepth 1 -maxdepth 1 -not -type l -exec rm -rf {} + || handle_error + find "$REPO_HOME/tool/upstream" -maxdepth 1 -type l -exec rm -f {} + || handle_error +else + echo "Upstream directory does not exist." +fi + +echo "Upstream cleanup complete." diff --git a/executor/clean_upstream.sh b/executor/clean_upstream.sh deleted file mode 100755 index 567cde4..0000000 --- a/executor/clean_upstream.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -# Get the project root path by removing 'executor' from the script path -script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" -project_root="${script_path%/*}" - -# Function to handle errors -handle_error() { - echo "Error occurred during upstream cleanup. Exiting." - exit 1 -} - -# Check if the upstream directory exists -if [ -d "$project_root/tool/upstream" ]; then - echo "Cleaning up upstream directory..." - find "$project_root/tool/upstream" -mindepth 1 -maxdepth 1 -not -type l -exec rm -rf {} + || handle_error - find "$project_root/tool/upstream" -maxdepth 1 -type l -exec rm -f {} + || handle_error -else - echo "Upstream directory does not exist." -fi - -echo "Upstream cleanup complete." diff --git a/executor/env_base b/executor/env_base new file mode 100644 index 0000000..f184dfa --- /dev/null +++ b/executor/env_base @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Ensure the script is sourced +if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then + echo "This script must be sourced, not executed. Exiting." + return 1 +fi + +# These are things set by the `repo` command found in the `resource` project, +# but if you don't have that, then source this into the environment. + +script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" +export REPO_HOME="${script_path%/*}" +export PROJECT=$(basename "$REPO_HOME") + +PPS1="\n[$PROJECT]\n\u@\h§$(pwd)§\n> " +PPS2=">> " + +alias ls="ls -a" + +echo REPO_HOME "$REPO_HOME" +echo PROJECT "$PROJECT" +echo "${BASH_SOURCE[0]}" "complete" diff --git a/executor/env_dev b/executor/env_dev new file mode 100644 index 0000000..5c0627b --- /dev/null +++ b/executor/env_dev @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Ensure the script is sourced +if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then + echo "This script must be sourced, not executed. Exiting." + return 1 +fi + +# Check if REPO_HOME is set, if not source env_base +if [ -z "$REPO_HOME" ]; then + script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" + source "${script_path}/env_base" +fi + +export JAVA_HOME="$REPO_HOME/tool/jdk-22.0.1+8" +export CLASSPATH=".:$REPO_HOME/tool/executor/antlr-4.11.1-complete.jar:$CLASSPATH" +export ANTLR_JAR="$REPO_HOME/tool/executor/antlr-4.11.1-complete.jar" + +export PATH="$JAVA_HOME/bin:$REPO_HOME/tool/executor:$PATH" + +alias ls="ls -a" +cd "$REPO_HOME/developer" + +echo "${BASH_SOURCE[0]}" "complete" diff --git a/executor/env_pm b/executor/env_pm new file mode 100644 index 0000000..332aa8d --- /dev/null +++ b/executor/env_pm @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# Ensure the script is sourced +if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then + echo "This script must be sourced, not executed. Exiting." + return 1 +fi + +# Check if REPO_HOME is set, if not source env_base +if [ -z "$REPO_HOME" ]; then + script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" + source "${script_path}/env_base" +fi + +PATH="$REPO_HOME/executor:$PATH" +PROJECT="$PROJECT"_PM + +echo "${BASH_SOURCE[0]}" "complete" diff --git a/executor/install b/executor/install new file mode 100755 index 0000000..3720ce6 --- /dev/null +++ b/executor/install @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Check if REPO_HOME is set, if not exit with an error +if [ -z "$REPO_HOME" ]; then + echo "REPO_HOME is not set. Please initialize the environment." + exit 1 +fi + +# Call install scripts and handle errors +"$REPO_HOME/executor/install_Java" || { echo "Java installation failed."; } +"$REPO_HOME/executor/install_ANTLR" || { echo "ANTLR installation failed."; exit 1; } + +# Create symbolic link +ln -sfn "$REPO_HOME/tool/executor" "$REPO_HOME/tool/bin" + +echo "All installations complete. Java and ANTLR have been installed successfully." diff --git a/executor/install.sh b/executor/install.sh deleted file mode 100755 index 5a4e453..0000000 --- a/executor/install.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -# Call install scripts and handle errors -./install_Java.sh || { echo "Java installation failed. "; } -./install_ANTLR.sh || { echo "ANTLR installation failed."; exit 1; } - -# Create symbolic link -script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" -project_root="${script_path%/*}" - -ln -sfn "$project_root/tool/executor" "$project_root/tool/bin" - -echo "All installations complete. Java and ANTLR have been installed successfully." diff --git a/executor/install_ANTLR b/executor/install_ANTLR new file mode 100755 index 0000000..59ca911 --- /dev/null +++ b/executor/install_ANTLR @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# +# GQL_to_Cypher/ +# ├── tool/ +# │ ├── executor/ +# │ │ └── antlr-4.11.1-complete.jar (copied from upstream) +# │ ├── jdk-22.0.1+8/ +# │ ├── upstream/ (cache of downloaded data) +# │ │ └── antlr-4.11.1-complete.jar +# │ └── .gitignore +# └── ... + + +# Check if REPO_HOME is set, if not exit with an error +if [ -z "$REPO_HOME" ]; then + echo "REPO_HOME is not set. Please initialize the environment." + exit 1 +fi + +# Define the version and URL for ANTLR, if you change the version be sure to update the URL +ANTLR_VERSION="4.11.1" +ANTLR_URL="https://www.antlr.org/download/antlr-4.11.1-complete.jar" + +# Create the upstream directory if it doesn't exist +mkdir -p "$REPO_HOME/tool/upstream" +mkdir -p "$REPO_HOME/tool/executor" + +# Download the ANTLR JAR file to the upstream directory +antlr_jar="$REPO_HOME/tool/upstream/antlr-$ANTLR_VERSION-complete.jar" +if [ ! -f "$antlr_jar" ]; then + echo "Downloading ANTLR..." + curl -L -o "$antlr_jar" "$ANTLR_URL" +fi + +if [ ! -s "$antlr_jar" ]; then + echo "ANTLR download failed. Exiting." + exit 1 +fi + +# Move the ANTLR JAR file to the executor directory +cp "$antlr_jar" "$REPO_HOME/tool/executor/" + +echo "ANTLR installation complete." diff --git a/executor/install_ANTLR.sh b/executor/install_ANTLR.sh deleted file mode 100755 index 6d899ba..0000000 --- a/executor/install_ANTLR.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash - -# Define the version and URL for ANTLR -ANTLR_VERSION="4.11.1" -ANTLR_URL="https://github.com/antlr/antlr4/archive/refs/tags/4.11.1.tar.gz" - -# Get the project root path by removing 'executor' from the script path -script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" -project_root="${script_path%/*}" - -# Create the upstream directory if it doesn't exist -mkdir -p "$project_root/tool/upstream" - -# Download ANTLR tarball and extract to the upstream directory -antlr_tar="$project_root/tool/upstream/antlr-$ANTLR_VERSION.tar.gz" -if [ ! -f "$antlr_tar" ]; then - echo "Downloading ANTLR..." - curl -L -o "$antlr_tar" "$ANTLR_URL" -fi - -if [ ! -s "$antlr_tar" ]; then - echo "ANTLR download failed. Exiting." - exit 1 -fi - -echo "Extracting ANTLR..." -tar -xzf "$antlr_tar" -C "$project_root/tool/upstream" || { echo "ANTLR extraction failed. Exiting."; exit 1; } -rm "$antlr_tar" - -# Move the ANTLR jar to the executor directory -antlr_jar="$project_root/tool/upstream/antlr-$ANTLR_VERSION-complete.jar" -if [ ! -f "$antlr_jar" ]; then - echo "ANTLR JAR file not found after extraction. Exiting." - exit 1 -fi - -mkdir -p "$project_root/tool/executor" -mv "$antlr_jar" "$project_root/tool/executor/" - -echo "ANTLR installation complete." diff --git a/executor/install_Java b/executor/install_Java new file mode 100755 index 0000000..bc037fa --- /dev/null +++ b/executor/install_Java @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +# +# GQL_to_Cypher/ +# ├── tool/ +# │ ├── executor/ +# │ │ └── antlr-4.11.1-complete.jar +# │ ├── jdk-22.0.1+8/ +# │ │ ├── bin/ +# │ │ ├── conf/ +# │ │ ├── include/ +# │ │ ├── jmods/ +# │ │ ├── legal/ +# │ │ ├── lib/ +# │ │ ├── release +# │ │ └── ... +# │ ├── upstream/ +# │ │ ├── antlr-4.11.1-complete.jar +# │ │ └── jdk-22.0.1.tar.gz +# │ └── .gitignore +# └── ... + +# Check if REPO_HOME is set, if not exit with an error +if [ -z "$REPO_HOME" ]; then + echo "REPO_HOME is not set. Please initialize the environment." + exit 1 +fi + +# Define the version and URL for the JDK, if you change the version be sure to update the URL +JDK_VERSION="22.0.1" +JDK_URL="https://github.com/adoptium/temurin22-binaries/releases/download/jdk-22.0.1%2B8/OpenJDK22U-jdk_x64_linux_hotspot_22.0.1_8.tar.gz" + +# Create the upstream directory if it doesn't exist +mkdir -p "$REPO_HOME/tool/upstream" +mkdir -p "$REPO_HOME/tool" + +# Download the JDK to the upstream directory +jdk_tar="$REPO_HOME/tool/upstream/jdk-$JDK_VERSION.tar.gz" +if [ ! -f "$jdk_tar" ]; then + echo "Downloading JDK..." + curl -L -o "$jdk_tar" "$JDK_URL" +fi + +if [ ! -s "$jdk_tar" ]; then + echo "JDK download failed. Exiting." + exit 1 +fi + +echo "Extracting JDK..." +tar -xzf "$jdk_tar" -C "$REPO_HOME/tool" || { echo "JDK extraction failed. Exiting."; exit 1; } + +# Find the extracted JDK directory +jdk_dir=$(find "$REPO_HOME/tool" -maxdepth 1 -type d -name "jdk-*" | head -n 1) +if [ -z "$jdk_dir" ]; then + echo "JDK extraction failed. Exiting." + exit 1 +fi + +# Set JAVA_HOME and update PATH to use the local JDK +export JAVA_HOME="$jdk_dir" +export PATH="$JAVA_HOME/bin:$PATH" + +# Test Java installation +if ! java -version > /dev/null 2>&1; then + echo "Java version check failed." + exit 1 +fi + +echo "Java installation complete." diff --git a/executor/install_Java.sh b/executor/install_Java.sh deleted file mode 100755 index 7f8dc48..0000000 --- a/executor/install_Java.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -# Set the platform type: currently "Debian" or "Fedora" -PLATFORM="Fedora" - -# Define the version and URL for the JDK -JDK_VERSION="22.0.1" -JDK_URL="https://github.com/adoptium/temurin22-binaries/releases/download/jdk-22.0.1%2B8/OpenJDK22U-jdk_x64_linux_hotspot_22.0.1_8.tar.gz" - -# Get the project root path by removing 'executor' from the script path -script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" -project_root="${script_path%/*}" - -# Create the upstream directory if it doesn't exist -mkdir -p "$project_root/tool/upstream" - -# Download and extract JDK to the upstream directory -jdk_tar="$project_root/tool/upstream/jdk-$JDK_VERSION.tar.gz" -if [ ! -f "$jdk_tar" ]; then - echo "Downloading JDK..." - curl -L -o "$jdk_tar" "$JDK_URL" -fi - -if [ ! -s "$jdk_tar" ]; then - echo "JDK download failed. Exiting." - exit 1 -fi - -echo "Extracting JDK..." -tar -xzf "$jdk_tar" -C "$project_root/tool/upstream" || { echo "JDK extraction failed. Exiting."; exit 1; } -rm "$jdk_tar" - -# Find the extracted JDK directory -jdk_dir=$(find "$project_root/tool/upstream" -maxdepth 1 -type d -name "jdk-*" | head -n 1) -if [ -z "$jdk_dir" ]; then - echo "JDK extraction failed. Exiting." - exit 1 -fi - -# Set JAVA_HOME and update PATH to use the local JDK -export JAVA_HOME="$jdk_dir" -export PATH="$JAVA_HOME/bin:$PATH" - -# Test Java installation -if ! java -version > /dev/null 2>&1; then - echo "Java version check failed." - exit 1 -fi - -echo "Java installation complete." diff --git a/executor/use_tool b/executor/use_tool deleted file mode 100644 index 83c0858..0000000 --- a/executor/use_tool +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" -project_root="${script_path%/*}" -export PROJECT=$(basename "$project_root") - -# Set JAVA_HOME -export JAVA_HOME="$project_root/tool/jdk-17.0.2+8" - -# Set PATH to include tool/executor and JAVA_HOME/bin -export PATH="$JAVA_HOME/bin:$project_root/tool/executor:$PATH" - -# Set environment variables for ANTLR -export CLASSPATH=".:$project_root/tool/executor/antlr-4.9.2-complete.jar:$CLASSPATH" - -alias ls="ls -a" -cd "$project_root/developer" - -echo $0 "complete" diff --git a/lector/for_developers.md b/lector/for_developers.md index fae3ad9..c702f7f 100644 --- a/lector/for_developers.md +++ b/lector/for_developers.md @@ -8,8 +8,8 @@ to use the `repo` command found in RT's `resource` project. The `repo` command will start a new shell with the proper environment variables setup for the project, and nothing else. -A project can also be entered by sourcing `use_tool` by running the command -`. exector/use_tool` in a shell. `use_tool` is analogous to `activate` in Python. +A project can also be entered by sourcing `env_dev` by running the command +`. exector/env_dev` in a shell. `use_tool` is analogous to `activate` in Python.