noble-amd64-hafnium: python environment refactor

Drop the symbolic link to python, use pip3 instead when
installing dependencies, and manage python environment
changes after installing all pkgs.

Change-Id: I451da8b1c5830dad66e1ed1c17a34afd0dbdbd58
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/noble-amd64-hafnium/Dockerfile b/noble-amd64-hafnium/Dockerfile
index f191515..3b464d9 100644
--- a/noble-amd64-hafnium/Dockerfile
+++ b/noble-amd64-hafnium/Dockerfile
@@ -39,32 +39,6 @@
     apt update -q=2 ;\
     apt install -q=2 --yes --no-install-recommends ${PKG_DEPS} ;
 
-# Preparing for the python3 dependencies in a venv.
-# Adding the bin folder to path, so the respective pip
-# tool is used.
-RUN python3 -m venv /opt/venv
-ENV PATH=${PATH}:/opt/venv/bin
-
-RUN set -ex ;\
-    # Install Python requirements
-    pip install --no-cache-dir -r /opt/requirements_python3.txt ;\
-    # Set Python in the previously installed venv the default one to use.
-    ln -s -f /opt/venv/bin/python /usr/bin/python ;\
-    # Setup buildslave user for Jenkins
-    useradd -m -s /bin/bash buildslave ;\
-    echo "buildslave:$BUILDSLAVE_PASSWORD" | chpasswd ;\
-    echo 'buildslave ALL = NOPASSWD: ALL' > /etc/sudoers.d/jenkins ;\
-    chmod 0440 /etc/sudoers.d/jenkins ;\
-    mkdir -p /var/run/sshd ${TOOLS_DIR} ;\
-    # Install Arm GCC toolchain (aarch64-none-elf)
-    curl --connect-timeout 5 --retry 8 --retry-delay 2 --create-dirs -fsSLo /tmp/gcc-arm-x86_64-aarch64-none-elf.tar.xz \
-        https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf.tar.xz ;\
-    tar -Jxf /tmp/gcc-arm-x86_64-aarch64-none-elf.tar.xz -C ${TOOLS_DIR} --strip-components=1 ;\
-    # Setup environment for sshd
-    bash -ex /tmp/tf-environment.install ;\
-    # Fix permissions
-    chown -R buildslave:buildslave ${TOOLS_DIR} ;
-
 # Install Clang and LLVM.
 # Use the packages from LLVM's repository rather than the default Ubuntu
 # repository so we can control the exact version.
@@ -91,5 +65,29 @@
 # Clear APT cache to save space.
 RUN rm -rf /var/lib/apt/lists/*
 
+# Preparing for the python3 dependencies in a venv.
+# Adding the bin folder to path, so the respective pip
+# tool is used.
+RUN python3 -m venv /opt/venv
+ENV PATH=/opt/venv/bin:${PATH}
+
+RUN set -ex ;\
+    # Install Python requirements
+    pip3 install --no-cache-dir -r /opt/requirements_python3.txt ;\
+    # Setup buildslave user for Jenkins
+    useradd -m -s /bin/bash buildslave ;\
+    echo "buildslave:$BUILDSLAVE_PASSWORD" | chpasswd ;\
+    echo 'buildslave ALL = NOPASSWD: ALL' > /etc/sudoers.d/jenkins ;\
+    chmod 0440 /etc/sudoers.d/jenkins ;\
+    mkdir -p /var/run/sshd ${TOOLS_DIR} ;\
+    # Install Arm GCC toolchain (aarch64-none-elf)
+    curl --connect-timeout 5 --retry 8 --retry-delay 2 --create-dirs -fsSLo /tmp/gcc-arm-x86_64-aarch64-none-elf.tar.xz \
+        https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf.tar.xz ;\
+    tar -Jxf /tmp/gcc-arm-x86_64-aarch64-none-elf.tar.xz -C ${TOOLS_DIR} --strip-components=1 ;\
+    # Setup environment for sshd
+    bash -ex /tmp/tf-environment.install ;\
+    # Fix permissions
+    chown -R buildslave:buildslave ${TOOLS_DIR} ;
+
 EXPOSE 22
 ENTRYPOINT ["/usr/sbin/setup-sshd"]