aboutsummaryrefslogtreecommitdiff
path: root/debian/install_vlang_full.sh
diff options
context:
space:
mode:
authorLeon Zimmermann <leonzimmermann@DEBIANBOX.zelda>2026-07-31 13:10:12 +0200
committerLeon Zimmermann <leonzimmermann@DEBIANBOX.zelda>2026-07-31 13:10:12 +0200
commit09a8ff2cd6226ecda122e6e32615f865ede620cf (patch)
tree86fe59d4d180c237d4645c6709da0ed04e47df66 /debian/install_vlang_full.sh
parent95aaf02dc34dd1d95ad6edd5f9341f557a1638d0 (diff)
downloadhelper-scripts-09a8ff2cd6226ecda122e6e32615f865ede620cf.tar.xz
helper-scripts-09a8ff2cd6226ecda122e6e32615f865ede620cf.zip
Added vlang installer for debian 13HEADmaster
Diffstat (limited to 'debian/install_vlang_full.sh')
-rw-r--r--debian/install_vlang_full.sh103
1 files changed, 103 insertions, 0 deletions
diff --git a/debian/install_vlang_full.sh b/debian/install_vlang_full.sh
new file mode 100644
index 0000000..4eb33f5
--- /dev/null
+++ b/debian/install_vlang_full.sh
@@ -0,0 +1,103 @@
+#!/bin/sh
+
+# Exit immediately if a command fails
+set -e
+
+# Overview
+echo "=================================================="
+echo "This script will perform the following actions:"
+echo " 1. Check your home for ~/Projects"
+echo " 2. Update the system package repository."
+echo " 3. Clone vlang into ~/Projects and build it"
+echo " 4. Build all v tools and recompile it with prod"
+echo "=================================================="
+
+# Ask for confirmation
+read -p "Do you want to proceed? [y/N]: " -r response
+response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
+if [[ "$response" != "y" ]]; then
+ echo "Operation cancelled."
+ exit 1
+fi
+
+# Helper function to run commands with sudo if not already root
+run_as_root() {
+ if [ "$(id -u)" -eq 0 ]; then
+ "$@"
+ else
+ # Asking for sudo permission before executing
+ sudo "$@"
+ fi
+}
+
+# Get projects directory and create it if necessary
+PROJECTS_DIR="${XDG_PROJECTS_DIR:-$HOME/Projects}"
+if [ ! -d "$PROJECTS_DIR" ]; then
+ echo "Creating directory $PROJECTS_DIR"
+ mkdir -p "$PROJECTS_DIR"
+else
+ echo "Found $PROJECTS_DIR"
+fi
+
+if [ "$(id -u)" -ne 0 ]; then
+ echo "Privileged access required to install packages."
+ sudo -v || { echo "Authentication failed."; exit 1; }
+fi
+
+# Install all necessary packages for vlang
+PACKAGES="git build-essential libsqlite3-dev sqlite3 unixodbc postgresql-client libpq-dev libxi-dev libxcursor-dev mesa-common-dev make"
+
+echo "Updating package lists..."
+run_as_root apt-get update -y
+
+echo "Installing packages: $PACKAGES"
+if run_as_root apt-get install -y $PACKAGES; then
+ echo "Success: All packages were installed successfully!"
+else
+ # This block triggers if set -e isn't used or if custom failure logic is needed
+ echo "Error: Package installation failed." >&2
+ exit 1
+fi
+
+# Clone and Build Vlang inside PROJECTS_DIR (as regular user)
+cd "$PROJECTS_DIR"
+
+if [ -d "v" ]; then
+ echo "Directory 'v' already exists in $PROJECTS_DIR. Skipping clone."
+else
+ echo "Cloning V repository..."
+ git clone --depth=1 https://github.com/vlang/v
+fi
+
+echo "Building V..."
+cd v
+make
+
+# Verify vlang executable
+if [ -x "./v" ]; then
+ echo "Success: V compiler successfully built!"
+ echo "Executable path: $(pwd)/v"
+else
+ echo "Error: V build failed. Binary not found." >&2
+ exit 1
+fi
+
+# Build v for prod + tools
+./v -prod self
+./v -prod build-tools
+
+# Symlink V
+echo "Creating symlink..."
+run_as_root ./v symlink
+
+# Verify symlink
+hash -r 2>/dev/null || true
+
+if command -v v >/dev/null 2>&1; then
+ echo "Success: V is installed and available in PATH!"
+ v version
+else
+ echo "Error: 'v' command was not found in PATH." >&2
+ exit 1
+fi
+