-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update build scripts/move main package/add install script
- Loading branch information
Showing
6 changed files
with
186 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Configuration | ||
PROGRAM_NAME="OstrichDB" | ||
REPO="Solitude-Software-Solutions/OstrichDB" | ||
RELEASE_TAG="Pre_Rel_v0.6.0_dev" | ||
RELEASE_URL="https://github.com/${REPO}/archive/refs/tags/${RELEASE_TAG}.tar.gz" | ||
BUILD_SCRIPT="scripts/build.sh" | ||
|
||
echo "============== OstrichDB Installer ==============" | ||
|
||
# Detect the operating system | ||
OS=$(uname -s) | ||
ARCH=$(uname -m) | ||
echo "Detected system: $OS $ARCH" | ||
|
||
# Setup installation directory | ||
INSTALL_DIR="$HOME/.ostrichdb/" | ||
mkdir -p "$INSTALL_DIR" | ||
|
||
# Add the installation directory to PATH immediately for this session | ||
export PATH="$INSTALL_DIR:$PATH" | ||
|
||
# Ensure that installation directory is in the PATH permanently | ||
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then | ||
echo "Adding $INSTALL_DIR to PATH permanently" | ||
|
||
# Determine shell config file | ||
if [[ "$SHELL" == *"bash"* ]]; then | ||
SHELL_CONFIG="$HOME/.bashrc" | ||
elif [[ "$SHELL" == *"zsh"* ]]; then | ||
SHELL_CONFIG="$HOME/.zshrc" | ||
fi | ||
|
||
# Add to shell config if not already present | ||
if [[ -f "$SHELL_CONFIG" ]]; then | ||
if ! grep -q "export PATH=\"$INSTALL_DIR:\$PATH\"" "$SHELL_CONFIG"; then | ||
echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >> "$SHELL_CONFIG" | ||
echo "Updated $SHELL_CONFIG with PATH information" | ||
fi | ||
else | ||
echo "Warning: Could not determine your shell configuration file." | ||
echo "Please manually add $INSTALL_DIR to your PATH." | ||
fi | ||
fi | ||
|
||
# Check for Odin compiler | ||
if ! command -v odin &> /dev/null; then | ||
echo "Error: Odin compiler not found in PATH." | ||
echo "Please install Odin first. You can install it via:" | ||
if [[ "$OS" == "Darwin" ]]; then | ||
echo " - Homebrew: brew install odin" | ||
elif [[ "$OS" == "Linux" ]]; then | ||
echo " - Check your distribution's package manager" | ||
fi | ||
echo " - Or from source: https://github.com/odin-lang/Odin" | ||
exit 1 | ||
fi | ||
|
||
echo "✓ Odin compiler found" | ||
|
||
# Create temporary directory | ||
TMP_DIR=$(mktemp -d) | ||
cd "$TMP_DIR" | ||
|
||
echo "Downloading $PROGRAM_NAME version $RELEASE_TAG..." | ||
curl -fsSL "$RELEASE_URL" -o "${PROGRAM_NAME}.tar.gz" | ||
tar -xzf "${PROGRAM_NAME}.tar.gz" | ||
|
||
# The extraction creates a directory with the release tag | ||
EXTRACT_DIR="OstrichDB-${RELEASE_TAG//\//_}" | ||
cd "$EXTRACT_DIR" | ||
|
||
# Check if build script exists | ||
if [ ! -f "$BUILD_SCRIPT" ]; then | ||
echo "Error: Build script not found at expected path: $BUILD_SCRIPT" | ||
echo "The release structure may have changed. Please check the repository." | ||
exit 1 | ||
fi | ||
|
||
echo "Building $PROGRAM_NAME..." | ||
# Change to the src directory and build | ||
cd src | ||
odin build main | ||
|
||
# Check if build was successful | ||
if [ $? -eq 0 ]; then | ||
echo "$(tput setaf 2)Build successful$(tput sgr0)" | ||
|
||
# Create bin directory and move the executable | ||
mkdir -p ../bin && mv main.bin ../bin/ | ||
|
||
# Copy the binary to installation directory | ||
echo "Installing OstrichDB to $INSTALL_DIR/ostrichdb" | ||
cp "../bin/main.bin" "$INSTALL_DIR/ostrichdb" | ||
chmod +x "$INSTALL_DIR/ostrichdb" | ||
else | ||
echo "$(tput setaf 1)Build failed$(tput sgr0)" | ||
exit 1 | ||
fi | ||
|
||
# Cleanup | ||
cd | ||
rm -rf "$TMP_DIR" | ||
|
||
if command -v ostrichdb >/dev/null 2>&1; then | ||
echo "✅ Installation successful!" | ||
echo "OstrichDB has been installed to $INSTALL_DIR/ostrichdb" | ||
echo "" | ||
echo "To start using OstrichDB, open a new terminal and run:" | ||
echo " ostrichdb" | ||
else | ||
echo "Warning: Installation complete, but the 'ostrichdb' command is not in your PATH." | ||
echo "Please restart your terminal or run:" | ||
echo " source $SHELL_CONFIG" | ||
echo "" | ||
echo "Then you can start OstrichDB by running:" | ||
echo " ostrichdb" | ||
fi | ||
|
||
echo "" | ||
echo "Thank you for installing OstrichDB!" |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# Used to run OstrichDB without rebuilding. Mostly used for development purposes. | ||
#Author: Marshall A Burns | ||
#GitHub: @SchoolyB | ||
#License: Apache License 2.0 (see LICENSE file for details) | ||
#Copyright (c) 2024-Present Marshall A Burns and Solitude Software Solutions LLC | ||
|
||
# Get the directory of this script | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
# Change to the project root directory | ||
cd "$DIR/.." | ||
|
||
# Change to the bin directory | ||
cd bin | ||
|
||
# Check if the executable exists | ||
if [ -f "main.bin" ]; then | ||
# Run the program | ||
./main.bin | ||
|
||
# Capture the exit code | ||
exit_code=$? | ||
|
||
# Check the exit code | ||
if [ $exit_code -ne 0 ]; then | ||
echo "$(tput setaf 1)Program exited with code $exit_code$(tput sgr0)" | ||
fi | ||
|
||
# Return to the project root directory | ||
cd "$DIR/.." | ||
else | ||
echo "$(tput setaf 1)Executable not found. Please build the project first.$(tput sgr0)" | ||
fi |
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