Pin pip to 20.3.3 and disable tmpfs in DIB
[ta/build-tools.git] / build_images.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 -x
17 set -e
18 set -o pipefail
19
20 usage() {
21     echo "Usage: $0 -m <manifest-dir> -w <work-dir> [-r <rpmbuilder-dir> -p <rpm-create-search-dir>]"
22     exit 1
23 }
24
25 rpm_search_paths=""
26 while getopts "m:w:p:r:" OPT; do
27     case $OPT in
28     m)
29         export MANIFEST_PATH=$(readlink -f $OPTARG)
30         ;;
31     w)
32         export WORK=$OPTARG
33         ;;
34     r)
35         export RPMBUILDER_PATH=$(readlink -f $OPTARG)
36         ;;
37     p)
38         rpm_search_paths+=" $OPTARG"
39         ;;
40     *)
41         usage
42         ;;
43     esac
44 done
45
46 [ -z "$MANIFEST_PATH" ] && usage
47 [ -z "$WORK" ] && usage
48 [ -n "$rpm_search_paths" -a -z "$RPMBUILDER_PATH" ] && usage
49 shift "$((OPTIND-1))"
50 [ "$#" -ne 0 ] && usage
51
52 scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
53 source $scriptdir/lib.sh
54
55 _initialize_work_dirs
56
57 dib_file="${scriptdir}/docker-context/Dockerfile-dib"
58 dib_patch="${dib_file}.$(uname -m).patch"
59 if [ -e "${dib_patch}" ] && ! patch -R --dry-run "${dib_file}" "${dib_patch}"; then
60     patch "${dib_file}" "${dib_patch}"
61 fi
62
63 docker build --network=host -f $scriptdir/docker-context/Dockerfile-dib -t dib $scriptdir/docker-context
64 docker build --network=host -f $scriptdir/docker-context/Dockerfile-buildtools -t buildtools $scriptdir/docker-context
65
66 # Create manifest RPM
67 $LIBDIR/create_manifest_rpm.sh
68
69 # Create RPMs
70 if [ -n "$rpm_search_paths" ]; then
71     $LIBDIR/build_rpms.sh $rpm_search_paths
72 fi
73
74 # Create repo config
75 $LIBDIR/build_step_create_yum_repo_files.sh
76
77 # QCOW
78 $LIBDIR/build_step_golden_image.sh
79 sha1short=$(grep -v product-manifest $RPMLISTS/rpmlist | sha1sum | cut -c-8)
80
81 # ISO images
82 $LIBDIR/build_step_create_install_cd.sh
83
84 echo "=== SUCCESS ==="
85 echo "Build results are in $WORKRESULTS"
86 echo "Installed RPMS checksum: ${sha1short} (this will change if list of installed RPMs changes)"