From cdc6bbbf0a2697d22479bf5eb9bf5f87b4304df2 Mon Sep 17 00:00:00 2001 From: "Roberto A. Foglietta" Date: Sat, 24 Dec 2022 11:01:08 +0100 Subject: [PATCH] scripts/ci_build.sh installs dependencies and uses mktemp CI build requires some commands in order to operate properly and some of these are checked to be in the executable path but nothing more. This fix the issue installing them at the beginning of the script. Previous user or concurrent users may use scripts/ci_build.sh and in particular root user creates a temporary directory that is not removable by common users. Using a combination of mktemp and trap on EXIT will solve all of these problems. This patch unites the following patches: - scripts/ci_build.sh installs required commands - scripts/ci_build.sh virtualenv uses mktemp to avoid conflicts plus a last minute very important typo correction in the code. Signed-off-by: Roberto A. Foglietta --- scripts/ci_build.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/ci_build.sh b/scripts/ci_build.sh index fa7208c..41fac8a 100755 --- a/scripts/ci_build.sh +++ b/scripts/ci_build.sh @@ -14,13 +14,22 @@ export PATH=$PATH:/sbin # Go to Isar root cd "$(dirname "$0")/.." +for i in virtualenv umoci skopeo reprepro quilt zstd; do + if ! command -v $i > /dev/null; then + if [ "$updated" != "1" ]; then + sudo apt-get update + fi + sudo apt install -y $i + updated=1 + fi +done + # install avocado in virtualenv in case it is not there already 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 - source /tmp/avocado_venv/bin/activate + tmpdir=$(mktemp -p "$TMPDIR" -d avocado_venv.XXXX) + trap "rm -rf $tmpdir" EXIT + virtualenv --python python3 $tmpdir + source $tmpdir/bin/activate pip install avocado-framework==96.0 fi -- 2.34.1