[v6,11/11] ci_build.sh: Install python3-apt if not installed

Message ID 20240314073047.29465-12-ubely@ilbers.de
State Superseded, archived
Headers show
Series Improving base-apt usage | expand

Commit Message

Uladzimir Bely March 14, 2024, 7:27 a.m. UTC
This is mostly related to gitlab CI that migth use an image without
preinstalled python3-apt.

Also, make system python packages available in virtualenv.

Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
 scripts/ci_build.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch

diff --git a/scripts/ci_build.sh b/scripts/ci_build.sh
index 51ed3920..b2fa6b9c 100755
--- a/scripts/ci_build.sh
+++ b/scripts/ci_build.sh
@@ -19,7 +19,7 @@  if ! command -v avocado > /dev/null; then
     sudo apt-get update -qq
     sudo apt-get install -y virtualenv
     rm -rf /tmp/avocado_venv
-    virtualenv --python python3 /tmp/avocado_venv
+    virtualenv --python python3 /tmp/avocado_venv --system-site-packages
     # shellcheck source=/dev/null
     source /tmp/avocado_venv/bin/activate
     pip install avocado-framework==100.1
@@ -131,6 +131,12 @@  if echo "$TAGS" | grep -Fqive "-startvm"; then
     fi
 fi
 
+# install python3-apt
+if [ ! -f /usr/share/doc/python3-apt/copyright ]; then
+    sudo apt-get update -qq
+    sudo apt-get install -y python3-apt
+fi
+
 # Provide working path
 mkdir -p .config/avocado
 cat <<EOF > .config/avocado/avocado.conf