From efc9fc5576cdbf3071c149d33ee6744b83e58da5 Mon Sep 17 00:00:00 2001 From: Dave Wallace Date: Fri, 12 Feb 2021 13:07:35 -0500 Subject: Fix installation of lftools python packages in docker images. - fix build script to remove $DOCKER_BUILD_DIR before copying ci-management repo into it. - remove unnecessary jenkins account configuration. Change-Id: I6267b13efad1426194ea87f63c7284bed4b988a1 Signed-off-by: Dave Wallace --- docker/scripts/dbld_lfit_requirements.sh | 51 ++++++++++++++------------------ docker/scripts/lib_apt.sh | 1 + docker/scripts/lib_common.sh | 12 ++++++-- docker/scripts/lib_dnf.sh | 1 + docker/scripts/lib_yum.sh | 1 + 5 files changed, 34 insertions(+), 32 deletions(-) diff --git a/docker/scripts/dbld_lfit_requirements.sh b/docker/scripts/dbld_lfit_requirements.sh index a3c7661d1..4b02e2441 100755 --- a/docker/scripts/dbld_lfit_requirements.sh +++ b/docker/scripts/dbld_lfit_requirements.sh @@ -21,12 +21,6 @@ export CIMAN_DOCKER_SCRIPTS=${CIMAN_DOCKER_SCRIPTS:-"$(dirname $BASH_SOURCE)"} must_be_run_as_root must_be_run_in_docker_build -# Add jenkins user and make it equivalent to root -groupadd jenkins || true -useradd -m -s /bin/bash -g jenkins jenkins || true -rm -rf /home/jenkins -ln -s /root /home/jenkins - # Add packagecloud files cat < /root/.packagecloud {"url":"https://packagecloud.io","token":"\$token"} @@ -37,30 +31,29 @@ login \$pclogin password EOF -# Check if docker group exists -if grep -q docker /etc/group -then - # Add jenkins user to docker group - usermod -a -G docker jenkins -fi - -# Check if mock group exists -if grep -q mock /etc/group -then - # Add jenkins user to mock group so it can build RPMs - # using mock if available - usermod -a -G mock jenkins -fi - -# Give jenkins account root privileges -jenkins_uid=$(id -u jenkins) -perl -i -p -e "s/$jenkins_uid\:/0\:/g" /etc/passwd - # Copy lf-env.sh for LF Releng scripts -cp $DOCKER_CIMAN_ROOT/global-jjb/jenkins-init-scripts/lf-env.sh /root -chmod 644 /root/lf-env.sh +lf_env_sh="/root/lf-env.sh" +cp $DOCKER_CIMAN_ROOT/global-jjb/jenkins-init-scripts/lf-env.sh $lf_env_sh +chmod 644 "$lf_env_sh" +cat <>"$lf_env_sh" + +# When running in CI docker image, use the pre-installed venv +# instead of installing python packages every job run. +# +unset -f lf-activate-venv +lf-activate-venv() { + echo "\${FUNCNAME[0]}(): INFO: Adding $LF_VENV/bin to PATH" + PATH="$LF_VENV/bin:$PATH" + return 0 +} +EOF # Install lftools & boto3 for log / artifact upload. -source /root/lf-env.sh -lf-activate-venv lftools python3 -m pip install boto3 +mkdir -p $LF_VENV +OLD_PATH="$PATH" +python3 -m venv $LF_VENV +PATH="$LF_VENV/bin:$PATH" +python3 -m pip install --upgrade pip +python3 -m pip install --upgrade --upgrade-strategy eager lftools +PATH="$OLD_PATH" diff --git a/docker/scripts/lib_apt.sh b/docker/scripts/lib_apt.sh index 449b008e7..40b521123 100644 --- a/docker/scripts/lib_apt.sh +++ b/docker/scripts/lib_apt.sh @@ -105,6 +105,7 @@ ENV FDIOTOOLS_IMAGE=$executor_image ENV LC_ALL=C.UTF-8 ENV CIMAN_ROOT="$DOCKER_CIMAN_ROOT" ENV PATH=$PATH:$DOCKER_CIMAN_ROOT/docker/scripts +ENV LF_VENV="/root/lf-venv" # Install baseline packages (minimum build & utils). # diff --git a/docker/scripts/lib_common.sh b/docker/scripts/lib_common.sh index 3449bf398..39f439f63 100644 --- a/docker/scripts/lib_common.sh +++ b/docker/scripts/lib_common.sh @@ -249,14 +249,20 @@ export DOCKER_APT_DEBIAN_DOCKER_GPGFILE="$DOCKER_GPG_KEY_DIR/$APT_DEBIAN_DOCKER_ export DOCKER_DOWNLOADS_DIR="/root/Downloads" docker_build_setup_ciman() { - mkdir -p $DOCKER_BUILD_DIR $DOCKER_GPG_KEY_DIR - if [ "$(dirname $CIMAN_ROOT)" != "$DOCKER_BUILD_DIR" ] ; then - echo_log "Syncing $CIMAN_ROOT into $DOCKER_CIMAN_ROOT..." + echo_log "Updating $CIMAN_ROOT git submodules..." pushd $CIMAN_ROOT git submodule update --init --recursive popd + if [ -d "$DOCKER_BUILD_DIR" ] ; then + echo_log "Removing existing DOCKER_BUILD_DIR: $DOCKER_BUILD_DIR..." + rm -rf $DOCKER_BUILD_DIR + fi + echo_log "Syncing $CIMAN_ROOT into $DOCKER_CIMAN_ROOT..." + mkdir -p $DOCKER_BUILD_DIR $DOCKER_GPG_KEY_DIR rsync -a $CIMAN_ROOT/. $DOCKER_CIMAN_ROOT + else + mkdir -p $DOCKER_BUILD_DIR $DOCKER_GPG_KEY_DIR fi } diff --git a/docker/scripts/lib_dnf.sh b/docker/scripts/lib_dnf.sh index e3fd768af..48821807d 100644 --- a/docker/scripts/lib_dnf.sh +++ b/docker/scripts/lib_dnf.sh @@ -68,6 +68,7 @@ ENV FDIOTOOLS_IMAGE=$executor_image ENV LC_ALL=C.UTF-8 ENV CIMAN_ROOT="$DOCKER_CIMAN_ROOT" ENV PATH=$PATH:$DOCKER_CIMAN_ROOT/docker/scripts +ENV LF_VENV="/root/lf-venv" # Copy-in build tree containing # ci-management, vpp, & csit git repos diff --git a/docker/scripts/lib_yum.sh b/docker/scripts/lib_yum.sh index d4da28972..dfc34b097 100644 --- a/docker/scripts/lib_yum.sh +++ b/docker/scripts/lib_yum.sh @@ -61,6 +61,7 @@ ENV FDIOTOOLS_IMAGE=$executor_image ENV LC_ALL=en_US.UTF-8 ENV CIMAN_ROOT="$DOCKER_CIMAN_ROOT" ENV PATH=$PATH:$DOCKER_CIMAN_ROOT/docker/scripts +ENV LF_VENV="/root/lf-venv" # Copy-in build tree containing # ci-management, vpp, & csit git repos -- cgit 1.2.3-korg