diff --git a/.gitignore b/.gitignore index 1f85d8c4..23974ec2 100644 --- a/.gitignore +++ b/.gitignore @@ -54,4 +54,5 @@ MCP_HTTP_REST_IMPLEMENTATION_PLAN.md .roo .kilocode .continue -tmux_logger \ No newline at end of file +tmux_logger +release \ No newline at end of file diff --git a/examples/osal/sshagent/sshagent b/examples/osal/sshagent/sshagent new file mode 100755 index 00000000..aee7f9da Binary files /dev/null and b/examples/osal/sshagent/sshagent differ diff --git a/examples/osal/sshagent/sshagent.vsh b/examples/osal/sshagent/sshagent.vsh index 038c720b..b9abe1fa 100755 --- a/examples/osal/sshagent/sshagent.vsh +++ b/examples/osal/sshagent/sshagent.vsh @@ -1,4 +1,4 @@ -#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run +#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run import freeflowuniverse.herolib.osal.sshagent import freeflowuniverse.herolib.builder diff --git a/install_v.sh b/install_v.sh index 19e4183a..4393d227 100755 --- a/install_v.sh +++ b/install_v.sh @@ -34,24 +34,24 @@ for arg in "$@"; do -h|--help) print_help exit 0 - ;; + ;; --reset) RESET=true - ;; + ;; --remove) REMOVE=true - ;; + ;; --herolib) HEROLIB=true - ;; + ;; --analyzer) INSTALL_ANALYZER=true - ;; + ;; *) echo "Unknown option: $arg" echo "Use -h or --help to see available options" exit 1 - ;; + ;; esac done @@ -66,8 +66,8 @@ function run_sudo() { if [ "$(id -u)" -eq 0 ]; then # We are root, run the command directly "$@" - # Check if sudo is installed - elif command_exists sudo; then + # Check if sudo is installed + elif command_exists sudo; then # Use sudo to run the command sudo "$@" else @@ -81,6 +81,59 @@ export DIR_BUILD="/tmp" export DIR_CODE="$DIR_BASE/code" export DIR_CODE_V="$DIR_BASE/_code" +check_release() { + if ! command -v lsb_release >/dev/null 2>&1; then + echo "❌ lsb_release command not found. Install 'lsb-release' package first." + exit 1 + fi + + CODENAME=$(lsb_release -sc) + RELEASE=$(lsb_release -rs) + + if dpkg --compare-versions "$RELEASE" lt "24.04"; then + echo "â„šī¸ Detected Ubuntu $RELEASE ($CODENAME). Skipping mirror fix (requires 24.04+)." + return 1 + fi + + return 0 +} + +ubuntu_sources_fix() { + if check_release; then + local CODENAME + CODENAME=$(lsb_release -sc) + local TIMESTAMP + TIMESTAMP=$(date +%Y%m%d_%H%M%S) + + echo "🔎 Fixing apt mirror setup for Ubuntu $(lsb_release -rs) ($CODENAME)..." + + if [ -f /etc/apt/sources.list ]; then + echo "đŸ“Ļ Backing up /etc/apt/sources.list -> /etc/apt/sources.list.backup.$TIMESTAMP" + sudo mv /etc/apt/sources.list /etc/apt/sources.list.backup.$TIMESTAMP + fi + + if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then + echo "đŸ“Ļ Backing up /etc/apt/sources.list.d/ubuntu.sources -> /etc/apt/sources.list.d/ubuntu.sources.backup.$TIMESTAMP" + sudo mv /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.backup.$TIMESTAMP + fi + + echo "📝 Writing new /etc/apt/sources.list.d/ubuntu.sources" + sudo tee /etc/apt/sources.list.d/ubuntu.sources >/dev/null < /dev/null then ssh-keyscan git.threefold.info >> ~/.ssh/known_hosts - fi + fi git config --global pull.rebase false - + } function package_check_install { local command_name="$1" if command -v "$command_name" >/dev/null 2>&1; then echo "command '$command_name' is already installed." - else + else package_install '$command_name' fi } @@ -109,16 +162,16 @@ function package_install { local command_name="$1" if [[ "${OSNAME}" == "ubuntu" ]]; then if is_github_actions; then - run_sudo apt -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" install $1 -q -y --allow-downgrades --allow-remove-essential + run_sudo apt -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" install $1 -q -y --allow-downgrades --allow-remove-essential else - apt -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" install $1 -q -y --allow-downgrades --allow-remove-essential + apt -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" install $1 -q -y --allow-downgrades --allow-remove-essential fi - elif [[ "${OSNAME}" == "darwin"* ]]; then + elif [[ "${OSNAME}" == "darwin"* ]]; then brew install $command_name - elif [[ "${OSNAME}" == "alpine"* ]]; then + elif [[ "${OSNAME}" == "alpine"* ]]; then apk add $command_name - elif [[ "${OSNAME}" == "arch"* ]]; then + elif [[ "${OSNAME}" == "arch"* ]]; then pacman --noconfirm -Su $command_name else echo "platform : ${OSNAME} not supported" @@ -142,36 +195,37 @@ is_github_actions() { function myplatform { if [[ "${OSTYPE}" == "darwin"* ]]; then export OSNAME='darwin' - elif [ -e /etc/os-release ]; then + elif [ -e /etc/os-release ]; then # Read the ID field from the /etc/os-release file export OSNAME=$(grep '^ID=' /etc/os-release | cut -d= -f2) if [ "${os_id,,}" == "ubuntu" ]; then - export OSNAME="ubuntu" + export OSNAME="ubuntu" fi if [ "${OSNAME}" == "archarm" ]; then - export OSNAME="arch" - fi + export OSNAME="arch" + fi if [ "${OSNAME}" == "debian" ]; then - export OSNAME="ubuntu" - fi + export OSNAME="ubuntu" + fi else echo "Unable to determine the operating system." - exit 1 + exit 1 fi - - + + # if [ "$(uname -m)" == "x86_64" ]; then # echo "This system is running a 64-bit processor." # else # echo "This system is not running a 64-bit processor." # exit 1 - # fi - + # fi + } myplatform function os_update { + ubuntu_sources_fix echo ' - os update' if [[ "${OSNAME}" == "ubuntu" ]]; then if is_github_actions; then @@ -179,53 +233,53 @@ function os_update { else rm -f /var/lib/apt/lists/lock rm -f /var/cache/apt/archives/lock - rm -f /var/lib/dpkg/lock* - fi + rm -f /var/lib/dpkg/lock* + fi export TERM=xterm export DEBIAN_FRONTEND=noninteractive - run_sudo dpkg --configure -a + run_sudo dpkg --configure -a run_sudo apt update -y if is_github_actions; then echo "** IN GITHUB ACTIONS, DON'T DO UPDATE" - else - set +e + else + set +e echo "** UPDATE" apt-mark hold grub-efi-amd64-signed set -e apt upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes apt autoremove -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes - fi + fi #apt install apt-transport-https ca-certificates curl software-properties-common -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes package_install "apt-transport-https ca-certificates curl wget software-properties-common tmux make gcc" package_install "rclone rsync mc redis-server screen net-tools git dnsutils htop ca-certificates screen lsb-release binutils pkg-config libssl-dev iproute2" - - elif [[ "${OSNAME}" == "darwin"* ]]; then + + elif [[ "${OSNAME}" == "darwin"* ]]; then if command -v brew >/dev/null 2>&1; then echo ' - homebrew installed' - else + else export NONINTERACTIVE=1 - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" unset NONINTERACTIVE fi set +e brew install mc redis curl tmux screen htop wget rclone tcc set -e - elif [[ "${OSNAME}" == "alpine"* ]]; then + elif [[ "${OSNAME}" == "alpine"* ]]; then apk update screen git htop tmux apk add mc curl rsync htop redis bash bash-completion screen git rclone - sed -i 's#/bin/ash#/bin/bash#g' /etc/passwd - elif [[ "${OSNAME}" == "arch"* ]]; then + sed -i 's#/bin/ash#/bin/bash#g' /etc/passwd + elif [[ "${OSNAME}" == "arch"* ]]; then pacman -Syy --noconfirm pacman -Syu --noconfirm pacman -Su --noconfirm arch-install-scripts gcc mc git tmux curl htop redis wget screen net-tools git sudo htop ca-certificates lsb-release screen rclone - + # Check if builduser exists, create if not if ! id -u builduser > /dev/null 2>&1; then useradd -m builduser echo "builduser:$(openssl rand -base64 32 | sha256sum | base64 | head -c 32)" | chpasswd echo 'builduser ALL=(ALL) NOPASSWD: ALL' | tee /etc/sudoers.d/builduser fi - + # if [[ -n "${DEBUG}" ]]; then # execute_with_marker "paru_install" paru_install # fi @@ -235,7 +289,7 @@ function os_update { function hero_lib_pull { - pushd $DIR_CODE/github/freeflowuniverse/herolib 2>&1 >> /dev/null + pushd $DIR_CODE/github/freeflowuniverse/herolib 2>&1 >> /dev/null if [[ $(git status -s) ]]; then echo "There are uncommitted changes in the Git repository herolib." return 1 @@ -254,7 +308,7 @@ function hero_lib_get { pushd $DIR_CODE/github/freeflowuniverse 2>&1 >> /dev/null git clone --depth 1 --no-single-branch https://github.com/freeflowuniverse/herolib.git popd 2>&1 >> /dev/null - fi + fi } # function install_secp256k1 { @@ -283,7 +337,7 @@ function hero_lib_get { # else # make install # fi - + # # Cleanup # cd .. # rm -rf secp256k1-0.3.2 v0.3.2.tar.gz @@ -311,7 +365,7 @@ remove_all() { echo "Removing v-analyzer from system..." run_sudo rm -f $(which v-analyzer) fi - + # Remove v-analyzer path from rc files for RC_FILE in ~/.zshrc ~/.bashrc; do if [ -f "$RC_FILE" ]; then @@ -327,7 +381,7 @@ remove_all() { echo "Cleaned up $RC_FILE" fi done - + echo "V removal complete" } @@ -335,31 +389,31 @@ remove_all() { # Function to check if a service is running and start it if needed check_and_start_redis() { - + # Normal service management for non-container environments if [[ "${OSNAME}" == "ubuntu" ]] || [[ "${OSNAME}" == "debian" ]]; then - + # Handle Redis installation for GitHub Actions environment if is_github_actions; then - - # Import Redis GPG key + + # Import Redis GPG key curl -fsSL https://packages.redis.io/gpg | run_sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg # Add Redis repository echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | run_sudo tee /etc/apt/sources.list.d/redis.list # Install Redis run_sudo apt-get update run_sudo apt-get install -y redis - + # Start Redis redis-server --daemonize yes - + # Print versions redis-cli --version redis-server --version - + return fi - + # Check if running inside a container if grep -q "/docker/" /proc/1/cgroup || [ ! -d "/run/systemd/system" ]; then echo "Running inside a container. Starting redis directly." @@ -378,7 +432,7 @@ check_and_start_redis() { fi return fi - + if systemctl is-active --quiet "redis"; then echo "redis is already running." else @@ -391,7 +445,7 @@ check_and_start_redis() { exit 1 fi fi - elif [[ "${OSNAME}" == "darwin"* ]]; then + elif [[ "${OSNAME}" == "darwin"* ]]; then # Check if we're in GitHub Actions if is_github_actions; then echo "Running in GitHub Actions on macOS. Starting redis directly..." @@ -416,14 +470,14 @@ check_and_start_redis() { brew services start redis fi fi - elif [[ "${OSNAME}" == "alpine"* ]]; then + elif [[ "${OSNAME}" == "alpine"* ]]; then if rc-service "redis" status | grep -q "running"; then echo "redis is already running." else echo "redis is not running. Starting it..." rc-service "redis" start fi - elif [[ "${OSNAME}" == "arch"* ]]; then + elif [[ "${OSNAME}" == "arch"* ]]; then if systemctl is-active --quiet "redis"; then echo "redis is already running." else @@ -437,7 +491,7 @@ check_and_start_redis() { } v-install() { - + # Check if v is already installed and in PATH if command_exists v; then echo "V is already installed and in PATH." @@ -445,8 +499,8 @@ v-install() { # For now, just exit the function assuming it's okay return 0 fi - - + + # Only clone and install if directory doesn't exist # Note: The original check was for ~/code/v, but the installation happens in ~/_code/v. if [ ! -d ~/_code/v ]; then @@ -459,8 +513,8 @@ v-install() { exit 1 fi fi - - + + # Only clone and install if directory doesn't exist # Note: The original check was for ~/code/v, but the installation happens in ~/_code/v. # Adjusting the check to the actual installation directory. @@ -474,48 +528,48 @@ v-install() { fi # Check if the built executable can report its version if ! ~/_code/v/v -version > /dev/null 2>&1; then - echo "Error: Built V executable (~/_code/v/v) failed to report version." - exit 1 + echo "Error: Built V executable (~/_code/v/v) failed to report version." + exit 1 fi echo "V built successfully. Creating symlink..." run_sudo ./v symlink - + # Verify v is in path if ! command_exists v; then echo "Error: V installation failed or not in PATH" echo "Please ensure ~/code/v is in your PATH" exit 1 fi - + echo "V installation successful!" - + } v-analyzer() { - + set -ex - + # Install v-analyzer if requested if [ "$INSTALL_ANALYZER" = true ]; then echo "Installing v-analyzer..." cd /tmp v download -RD https://raw.githubusercontent.com/vlang/v-analyzer/main/install.vsh - + # Check if v-analyzer bin directory exists if [ ! -d "$HOME/.config/v-analyzer/bin" ]; then echo "Error: v-analyzer bin directory not found at $HOME/.config/v-analyzer/bin" echo "Please ensure v-analyzer was installed correctly" exit 1 fi - + echo "v-analyzer installation successful!" fi - + # Add v-analyzer to PATH if installed if [ -d "$HOME/.config/v-analyzer/bin" ]; then V_ANALYZER_PATH='export PATH="$PATH:$HOME/.config/v-analyzer/bin"' - + # Function to add path to rc file if not present add_to_rc() { local RC_FILE="$1" @@ -529,7 +583,7 @@ v-analyzer() { fi fi } - + # Add to both .zshrc and .bashrc if they exist add_to_rc ~/.zshrc if [ "$(uname)" = "Darwin" ] && [ -f ~/.bashrc ]; then @@ -552,17 +606,17 @@ mkdir -p ~/code # Check if v needs to be installed if [ "$RESET" = true ] || ! command_exists v; then - + os_update - + sshknownkeysadd - + # Install secp256k1 - + v-install - - - + + + fi diff --git a/lib/builder/this_remote.v b/lib/builder/this_remote.v index 703e561f..60ecffa0 100644 --- a/lib/builder/this_remote.v +++ b/lib/builder/this_remote.v @@ -18,6 +18,7 @@ pub mut: pub fn this_remote_exec(args_ ThisRemoteArgs) !bool { mut args := args_ if args.script.trim_space().starts_with('/tmp/remote_') { + // TODO: don't understand this return false // means we need to execute } addr := texttools.to_array(args.nodes) diff --git a/lib/builder/ubuntu_solutions.v b/lib/builder/ubuntu_solutions.v new file mode 100644 index 00000000..f0321325 --- /dev/null +++ b/lib/builder/ubuntu_solutions.v @@ -0,0 +1,2 @@ +pub fn ubuntu_sources_fix() { +} diff --git a/release b/release deleted file mode 100755 index 1546a3f0..00000000 Binary files a/release and /dev/null differ