summaryrefslogtreecommitdiffstats
path: root/docker/scripts/dbld_lfit_requirements.sh
blob: 7e58ac87c0d705393150c6fc6ab583c6fc6141cd (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
64
65
66
67
68
69
70
#! /bin/bash

# Copyright (c) 2020 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_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 <<EOF > /root/.packagecloud
{"url":"https://packagecloud.io","token":"\$token"}
EOF
cat <<EOF >/root/packagecloud_api
machine packagecloud.io
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

# Install lftools[openstack] -- from global-jjb/shell/python-tools-install.sh
pinned_version=""
if [ "$OS_NAME" = "debian-9" } ; then
    # debian-9 does not have osc-lib==2.2.0 available breaking docker image
    # build so pin the version of lftools which does not pin osc-lib==2.2.0
    pinned_version="==0.34.1"
fi
python3 -m pip install --no-deps lftools[openstack]$pinned_version