[v2] scripts/ci_build.sh installs required commands

Message ID CAJGKYO6iBUqXsi4q6TLWPs7ED57pibL=gjAtOkhYONiUbYaF6w@mail.gmail.com
State Not Applicable, archived
Headers show
Series [v2] scripts/ci_build.sh installs required commands | expand

Commit Message

Roberto A. Foglietta Dec. 24, 2022, 10:07 a.m. UTC
Hi all,

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.

v2: typos fixed

patch sent by elastic mail and went in moderation as usual, here in attachment.

Best regards, R-

Comments

Roberto A. Foglietta Dec. 24, 2022, 3:47 p.m. UTC | #1
[PATCH] scripts/ci_build.sh virtualenv uses mktemp to avoid conflicts

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 applies on the top of the current one:

 * scripts/ci_build.sh installs required commands

The patch has been sent by elastic mail and went in moderation as
usual, and here in attachment.

Best regards, R-
Roberto A. Foglietta Dec. 25, 2022, 11:28 a.m. UTC | #2
On Sat, 24 Dec 2022 at 16:47, Roberto A. Foglietta
<roberto.foglietta@gmail.com> wrote:
>
> [PATCH] scripts/ci_build.sh virtualenv uses mktemp to avoid conflicts
>
> 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.

v2: bugfix in checking updated variable plus apt update verbose by now

>
> This patch applies on the top of the current one:
>
>  * scripts/ci_build.sh installs required commands
>
> The patch has been sent by elastic mail and went in moderation as
> usual, and here in attachment.
>
> Best regards, R-
Roberto A. Foglietta Dec. 25, 2022, 3:38 p.m. UTC | #3
ALL THE PATCHES UNITED IN THE FOLLOWING

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.

The patch has been sent by elastic mail and went in moderation as
usual, and here in attachment. Best regards, R-

Patch

From 46ae757d7f90ea817f3087f9e350253b1cfa1a69 Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Sat, 24 Dec 2022 11:01:08 +0100
Subject: [PATCH v2] scripts/ci_build.sh installs required commands

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.

v2: typos fixed

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
 scripts/ci_build.sh | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/scripts/ci_build.sh b/scripts/ci_build.sh
index fa7208c..e897942 100755
--- a/scripts/ci_build.sh
+++ b/scripts/ci_build.sh
@@ -14,10 +14,18 @@  export PATH=$PATH:/sbin
 # Go to Isar root
 cd "$(dirname "$0")/.."
 
+for i in virtualenv umoci skopeo reprepro quilt; do
+	if ! command -v $i > /dev/null; then
+	    if [ "$updated" == "1" ]; then
+                sudo apt-get update -qq
+	    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
-- 
2.34.1