[v5,02/12] ci_build.sh: Install python3-apt if not installed

Message ID 20230526070027.16890-3-ubely@ilbers.de
State RFC
Headers show
Series Improving base-apt usage PoC | expand

Commit Message

Uladzimir Bely May 26, 2023, 7 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 2fa5cccd..ff7c114a 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
@@ -127,6 +127,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