Pin pip to 20.3.3 and disable tmpfs in DIB
[ta/build-tools.git] / create_mock_config.sh
1 #!/bin/bash
2 # Copyright 2019 Nokia
3 #
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 -e
17
18 scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
19 source $scriptdir/lib.sh
20 _read_manifest_vars
21
22 config_ini=${1:-$BUILD_CONFIG_INI}
23 output_repo_files_dir=${2:-$REPO_FILES}
24 output_mock_dir=${2:-$output_repo_files_dir}
25 [ -f "$config_ini" ] || _abort "Config INI '$config_ini' not found"
26
27 # Create .repo files
28 $LIBDIR/build_step_create_yum_repo_files.sh $config_ini $output_repo_files_dir
29
30 # Create mock config
31 mkdir -p $output_mock_dir
32 cp $LIBDIR/mock/logging.ini $output_mock_dir/
33 cp $LIBDIR/mock/site-defaults.cfg $output_mock_dir/
34 mock_cfg=$output_mock_dir/mock.cfg
35 sed -e "/#REPOSITORIES#/r $output_repo_files_dir/repositories.repo" $LIBDIR/mock/mock.cfg.template > $mock_cfg
36 sed -i \
37   -e "s/#RPM_ARCH#/\"$(uname -m)\"/" \
38   -e "s/#RPM_PACKAGER#/\"$(_read_build_config $config_ini rpm packager)\"/" \
39   -e "s/#RPM_VENDOR#/\"$(_read_build_config $config_ini rpm vendor)\"/" \
40   -e "s/#RPM_LICENSE#/\"$(_read_build_config $config_ini rpm license)\"/" \
41   -e "s/#RPM_RELEASE_ID#/\"$(_read_build_config $config_ini rpm release_id)\"/" \
42   -e "s/#PRODUCT_RELEASE_BUILD_ID#/\"$PRODUCT_RELEASE_BUILD_ID\"/" \
43   -e "s/#PRODUCT_RELEASE_LABEL#/\"$PRODUCT_RELEASE_LABEL\"/" \
44   $mock_cfg
45
46 docker_sock=/var/run/docker.sock
47 if [ -S "$docker_sock" ]; then
48   sed -i "/#ADDITIONAL_CONFIG_OPTS#/a config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('$docker_sock', '$docker_sock'))" $mock_cfg
49 fi
50 if [ -n "$DOCKER_HOST" ]; then
51   sed -i "/#ADDITIONAL_CONFIG_OPTS#/a config_opts['environment']['DOCKER_HOST'] = '${DOCKER_HOST}:2375'" $mock_cfg
52 fi
53
54 # HACK ??
55 # include kernels in order for yum development group to install
56 sed -i -e 's/exclude=kernel/#exclude=kernel/' $mock_cfg
57
58 echo "Wrote mock configuration to: $output_mock_dir"