Merge "vpp: print "git diff" before running API checkstyle"
[ci-management.git] / docker / scripts / dbld_lfit_requirements.sh
1 #! /bin/bash
2
3 # Copyright (c) 2021 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 set -euxo pipefail
17
18 export CIMAN_DOCKER_SCRIPTS=${CIMAN_DOCKER_SCRIPTS:-"$(dirname $BASH_SOURCE)"}
19 . $CIMAN_DOCKER_SCRIPTS/lib_common.sh
20
21 must_be_run_as_root
22 must_be_run_in_docker_build
23
24 # Add packagecloud files
25 cat <<EOF > /root/.packagecloud
26 {"url":"https://packagecloud.io","token":"\$token"}
27 EOF
28 cat <<EOF >/root/packagecloud_api
29 machine packagecloud.io
30 login \$pclogin
31 password
32 EOF
33
34 # Copy lf-env.sh for LF Releng scripts
35 lf_env_sh="/root/lf-env.sh"
36 cp $DOCKER_CIMAN_ROOT/global-jjb/jenkins-init-scripts/lf-env.sh $lf_env_sh
37 chmod 644 "$lf_env_sh"
38 cat <<EOF >>"$lf_env_sh"
39
40 # When running in CI docker image, use the pre-installed venv
41 # instead of installing python packages every job run.
42 #
43 unset -f lf-activate-venv
44 lf-activate-venv() {
45     echo "\${FUNCNAME[0]}(): INFO: Adding $LF_VENV/bin to PATH"
46     PATH="$LF_VENV/bin:$PATH"
47     return 0
48 }
49 EOF
50
51 # Install lftools & boto3 for log / artifact upload.
52 python3 -m pip install boto3
53 mkdir -p $LF_VENV
54 OLD_PATH="$PATH"
55 python3 -m venv $LF_VENV
56 PATH="$LF_VENV/bin:$PATH"
57 python3 -m pip install --upgrade pip
58 python3 -m pip install --upgrade --upgrade-strategy eager lftools
59 PATH="$OLD_PATH"