From dab6d6c4e659935b94069ec18795f95f0628c23b Mon Sep 17 00:00:00 2001 From: Philip Guyton Date: Mon, 22 Jan 2024 16:24:47 +0000 Subject: [PATCH] Failure to remove legacy poetry version in 5.0.6-0 rpm #2782 Add legacy poetry install path to avoid failing its uninstall. Without this additional path, when build.sh is run from within RPM's constrained %posttrans scriptlet, we fail to find and uninstall our prior 1.1.15 poetry version. This leads to having both poetry 1.1.15 (via upstream installer) and our new pipx installed poetry 1.7.1. ## Includes: - Remove dangling legacy poetry symlink - apparently neglected by legacy poetry installer/uninstaller. - After the above there is an in-memory 'poetry' resolution to `/root/.local/bin/poetry' until path is reset. So use reset as opportunity to remove legacy path. - Add echo of PATH used by remainder of build.sh. - Remove .venv related path from PATH as the entire directory is deleted in the %post RPM scriptlet. And build.sh (outside of development) is run after this: from %posttrans. --- build.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build.sh b/build.sh index e76cdff16..f3b855609 100644 --- a/build.sh +++ b/build.sh @@ -4,10 +4,17 @@ set -o errexit # Install Poetry, a dependency management, packaging, and build system. # Uninstall legacy/transitional Poetry version of 1.1.15 +PATH="$HOME/.local/bin:$PATH" # account for more constrained environments. if which poetry && poetry --version | grep -q "1.1.15"; then echo "Poetry version 1.1.15 found - UNINSTALLING" curl -sSL https://install.python-poetry.org | python3 - --uninstall + rm --force /root/.local/bin/poetry # remove dangling dead link. fi +PATH="${PATH//'/root/.local/bin:'/''}" # null all legacy poetry paths +# We are run, outside of development, only by RPM's %posttrans. +# As such our .venv dir has already been removed in %post (update mode). +PATH="${PATH//'/opt/rockstor/.venv/bin:'/''}" # null now removed .venv from path. +echo "build.sh has PATH=$PATH" # Install Poetry via PIPX as a global app # https://peps.python.org/pep-0668/#guide-users-towards-virtual-environments export PIPX_HOME=/opt/pipx # virtual environment location, default ~/.local/pipx @@ -24,6 +31,7 @@ python3.11 -m pipx install poetry==1.7.1 # https://github.com/python-poetry/poetry/issues/3078 export LANG=C.UTF-8 export PYTHONIOENCODING=utf8 +# /usr/local/bin/poetry -> /opt/pipx/venvs/poetry /usr/local/bin/poetry install --no-interaction --no-ansi > poetry-install.txt 2>&1 echo