From f5e5ff27595c3643f9ab1431b592f0279866eb49 Mon Sep 17 00:00:00 2001 From: catborise Date: Fri, 25 Sep 2026 20:44:52 +0300 Subject: [PATCH] fix(install): refine openSUSE Leap dependencies and streamline installer execution - Add Python 3.11 package detection and alternatives configuration for openSUSE/SLES - Relax libvirt-python and lxml minimum versions in requirements to match distro-provided packages - Gracefully handle missing hostname command in minimal/containerized SUSE environments - Prevent redundant git clone if workspace already exists in target path --- conf/requirements.txt | 4 ++-- webvirtcloud.sh | 37 ++++++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/conf/requirements.txt b/conf/requirements.txt index 778cbbc..a19f3c3 100644 --- a/conf/requirements.txt +++ b/conf/requirements.txt @@ -11,8 +11,8 @@ drf-spectacular[sidecar]==0.28.0 eventlet==0.40.1 gunicorn==23.0.0 libsass==0.23.0 -libvirt-python>=11.0.0 -lxml>=5.2.0 +libvirt-python>=9.0.0 +lxml>=4.9.0 ldap3==2.9.1 markdown==3.8.2 paramiko==3.4.0 diff --git a/webvirtcloud.sh b/webvirtcloud.sh index cc96f23..2104c30 100755 --- a/webvirtcloud.sh +++ b/webvirtcloud.sh @@ -285,8 +285,12 @@ generate_secret_key() { install_webvirtcloud () { create_user - echo "* Cloning $APP_NAME from github to the web directory." - log "git clone $APP_REPO_URL $APP_PATH" + if [ ! -d "$APP_PATH/.git" ]; then + echo "* Cloning $APP_NAME from github to the web directory." + log "git clone $APP_REPO_URL $APP_PATH" + else + echo "* $APP_NAME already present in $APP_PATH." + fi echo "* Configuring settings.py file." cp "$APP_PATH/webvirtcloud/settings.py.template" "$APP_PATH/webvirtcloud/settings.py" @@ -308,9 +312,11 @@ install_webvirtcloud () { # set CSRF TRUSTED ORIGINS host_ip="'http://127.0.0.1', " - for i in $(hostname -I); do - host_ip+="'http://$i', " - done + if command -v hostname >/dev/null 2>&1; then + for i in $(hostname -I 2>/dev/null); do + host_ip+="'http://$i', " + done + fi sed -i "s|^\\(CSRF_TRUSTED_ORIGINS = \\).*|\\1\[ \'http://$fqdn\', $host_ip ]|" "$APP_PATH/webvirtcloud/settings.py" echo "* Checking up Python3 version." @@ -359,7 +365,9 @@ set_selinux () { set_hosts () { echo "* Setting up hosts file." - echo >> /etc/hosts "127.0.0.1 $(hostname) $fqdn" + local hname + hname="$(hostname 2>/dev/null || uname -n)" + echo >> /etc/hosts "127.0.0.1 $hname $fqdn" } restart_supervisor () { @@ -734,9 +742,24 @@ case $distro in progress echo "* Installing OS requirements." - PACKAGES="git python3-devel python3-pip python3-virtualenv libvirt-devel python3-libvirt python3-lxml openldap2-devel cyrus-sasl-devel libopenssl-devel libxslt-devel libxml2-devel gcc pkg-config nginx" + # On SUSE, install Python 3.11 stack to satisfy Python >= 3.10 requirement along with native libvirt and ldap bindings + if zypper se -s python311-devel >/dev/null 2>&1; then + PACKAGES="git hostname python311 python311-base python311-devel python311-pip python311-libvirt-python python311-lxml python311-ldap libvirt-devel cyrus-sasl-devel libopenssl-devel gcc pkg-config nginx" + else + PACKAGES="git hostname python3-devel python3-pip python3-virtualenv libvirt-devel python3-libvirt python3-lxml openldap2-devel cyrus-sasl-devel libopenssl-devel gcc pkg-config nginx" + fi install_packages + # Ensure python3 and pip3 point to python 3.11+ if installed + if command -v python3.11 >/dev/null 2>&1; then + update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 2>/dev/null || true + ln -sf /usr/bin/python3.11 /usr/bin/python3 + if command -v pip3.11 >/dev/null 2>&1; then + update-alternatives --install /usr/bin/pip3 pip3 /usr/bin/pip3.11 1 2>/dev/null || true + ln -sf /usr/bin/pip3.11 /usr/bin/pip3 + fi + fi + set_hosts # Supervisor on SUSE (available as python3-supervisor, supervisor, or via pip)