Upstream-Status: Inappropriate [oe-specific] diff --git a/install.sh b/install.sh index 4b5b633..f8bfba7 100755 --- a/install.sh +++ b/install.sh @@ -36,6 +36,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" OPENPLC_DIR="$SCRIPT_DIR" VENV_DIR="$OPENPLC_DIR/venvs/runtime" SCRIPTS_DIR="$OPENPLC_DIR/scripts" +ROOT_DIR="$D" # Colors for output RED='\033[0;31m' @@ -71,12 +72,14 @@ has_systemd_support() { # Check if systemctl command exists if ! command -v systemctl >/dev/null 2>&1; then + log_warning "systemctl command not found" return 1 fi # Check if systemd is running as PID 1 # This handles Docker containers and GitHub Actions where systemctl may exist but systemd isn't PID 1 if [ ! -d "/run/systemd/system" ]; then + log_warning "systemd not running as PID 1" return 1 fi @@ -85,6 +88,7 @@ has_systemd_support() { local pid1_name pid1_name=$(cat /proc/1/comm 2>/dev/null) if [ "$pid1_name" != "systemd" ]; then + log_warning "PID 1 is not systemd" return 1 fi fi @@ -92,6 +96,7 @@ has_systemd_support() { # Final check: can we actually communicate with systemd? # Use 'if' to prevent set -e from aborting on failure if ! systemctl show-environment >/dev/null 2>&1; then + log_warning "cannot communicate with systemd" return 1 fi @@ -100,7 +105,7 @@ has_systemd_support() { # Install systemd service for OpenPLC Runtime install_systemd_service() { - local service_file="/etc/systemd/system/openplc-runtime.service" + local service_file="$ROOT_DIR/etc/systemd/system/openplc-runtime.service" log_info "Installing OpenPLC Runtime systemd service..." @@ -321,9 +326,11 @@ setup_plugin_venvs() { log_warning "Plugins directory not found: $plugins_dir" return 0 fi - # Find directories with requirements.txt for all plugins (regardless of enabled status) local plugins_with_requirements=() + #: +# ln -s /proc/self/fd /dev/fd +find "$plugins_dir" -name "requirements.txt" -type f -print0 > tmp while IFS= read -r -d '' requirements_file; do # Get the directory name (plugin name) local plugin_dir=$(dirname "$requirements_file") @@ -335,9 +342,13 @@ setup_plugin_venvs() { continue fi + echo ${#plugins_with_requirements[@]} plugins_with_requirements+=("$plugin_name") + echo ${#plugins_with_requirements[@]} log_info "Found plugin with requirements: $plugin_name" - done < <(find "$plugins_dir" -name "requirements.txt" -type f -print0) + done < tmp + rm tmp + echo ${#plugins_with_requirements[@]} # If no plugins found, return if [ ${#plugins_with_requirements[@]} -eq 0 ]; then @@ -489,18 +500,18 @@ build_native_plugins() { # Setup runtime directory (needed for both Linux and Docker) # On MSYS2, use /run/runtime which maps to the MSYS2 installation directory if is_msys2; then - mkdir -p /run/runtime 2>/dev/null || true - chmod 775 /run/runtime 2>/dev/null || true + mkdir -p $ROOT_DIR/run/runtime 2>/dev/null || true + chmod 775 $ROOT_DIR/run/runtime 2>/dev/null || true else - mkdir -p /var/run/runtime - chmod 775 /var/run/runtime 2>/dev/null || true # Ignore permission errors in Docker + mkdir -p $ROOT_DIR/var/run/runtime + chmod 775 $ROOT_DIR/var/run/runtime 2>/dev/null || true # Ignore permission errors in Docker # Create persistent data directory for native Linux installs # This directory stores .env and database files that must survive reboot # In Docker, /var/run/runtime is mounted as a persistent volume instead if has_systemd_support; then - mkdir -p /var/lib/openplc-runtime - chmod 755 /var/lib/openplc-runtime + mkdir -p $ROOT_DIR/var/lib/openplc-runtime + chmod 755 $ROOT_DIR/var/lib/openplc-runtime log_info "Created persistent data directory at /var/lib/openplc-runtime" fi fi @@ -510,11 +521,23 @@ chmod +x "$OPENPLC_DIR/install.sh" 2>/dev/null || true chmod +x "$OPENPLC_DIR/scripts/"* 2>/dev/null || true chmod +x "$OPENPLC_DIR/start_openplc.sh" 2>/dev/null || true -install_dependencies +#install_dependencies +#python3 -m venv tempvenv +#./tempvenv/bin/python3 -m pip install crossenv +#log_info "///////////////////////////////////////////////////////////////////////////////" +#log_info "tgtpy $TGTPY" +#log_info "venvdir $VENV_DIR" +#./tempvenv/bin/python3 -m crossenv $TGTPY cross-venv #$VENV_DIR +#. cross-venv/bin/activate +#. $VENV_DIR/bin/activate python3 -m venv "$VENV_DIR" +#./cross-venv/bin/cross-python3 -m venv "$VENV_DIR" "$VENV_DIR/bin/python3" -m pip install --upgrade pip setuptools wheel "$VENV_DIR/bin/python3" -m pip install -r "$OPENPLC_DIR/requirements.txt" "$VENV_DIR/bin/python3" -m pip install -e . +#python3 -m pip install --upgrade pip setuptools wheel +#python3 -m pip install -r "$OPENPLC_DIR/requirements.txt" +#python3 -m pip install -e . echo "Dependencies installed..." echo "Virtual environment created at $VENV_DIR" diff --git a/scripts/manage_plugin_venvs.sh b/scripts/manage_plugin_venvs.sh index 2069e14..6c8ea9e 100755 --- a/scripts/manage_plugin_venvs.sh +++ b/scripts/manage_plugin_venvs.sh @@ -97,7 +97,7 @@ create_plugin_venv() { log_info "MSYS2 detected: using --system-site-packages for pre-built package access" python3 -m venv --system-site-packages "$venv_path" else - python3 -m venv "$venv_path" + python3 -m venv --system-site-packages "$venv_path" fi # Upgrade pip diff --git a/start_openplc.sh b/start_openplc.sh index af80f51..2ee5449 100755 --- a/start_openplc.sh +++ b/start_openplc.sh @@ -86,7 +86,7 @@ setup_runtime_venv() { log_info "Runtime virtual environment already exists." else log_info "Creating runtime virtual environment..." - python3 -m venv "$VENV_DIR" + python3 -m venv --system-site-packages "$VENV_DIR" if [ $? -ne 0 ]; then log_error "Failed to create runtime virtual environment." exit 1