summaryrefslogtreecommitdiffstats
path: root/docker/scripts/dbld_lfit_requirements.sh
blob: 278b78ede21d50c909db0a9204779057fd48aad1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /bin/bash

# Copyright (c) 2021 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -euxo pipefail

export CIMAN_DOCKER_SCRIPTS=${CIMAN_DOCKER_SCRIPTS:-"$(dirname $BASH_SOURCE)"}
. "$CIMAN_DOCKER_SCRIPTS/lib_common.sh"

must_be_run_in_docker_build

# Add packagecloud files
cat <<EOF >/root/.packagecloud
{"url":"https://packagecloud.io","token":"\$token"}
EOF
cat <<EOF >/root/packagecloud_api
machine packagecloud.io
login \$pclogin
password
EOF

# Copy lf-env.sh for LF Releng scripts
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 <<EOF >>"$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.
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
# on Debian-9 lftools needs to be installed before it is upgraded
# in order to get the latest version.
if [ "$OS_ID" = "debian"  ] && [ "$OS_VERSION_ID" = "9" ] ; then
    python3 -m pip install lftools
fi
python3 -m pip install --upgrade --upgrade-strategy eager lftools
PATH="$OLD_PATH"