AArch64 (arm64) support for image building, mock
[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_patch="$scriptdir/docker-context/Dockerfile-dib.$(uname -m).patch"
58 if [ -e "${dib_patch}" ]; then patch "$scriptdir/docker-context/Dockerfile-dib" "${dib_patch}"; fi
59
60 docker build -f $scriptdir/docker-context/Dockerfile-dib -t dib $scriptdir/docker-context
61 docker build -f $scriptdir/docker-context/Dockerfile-buildtools -t buildtools $scriptdir/docker-context
62
63 # Create manifest RPM
64 $LIBDIR/create_manifest_rpm.sh
65
66 # Create RPMs
67 if [ -n "$rpm_search_paths" ]; then
68     $LIBDIR/build_rpms.sh $rpm_search_paths
69 fi
70
71 # Create repo config
72 $LIBDIR/build_step_create_yum_repo_files.sh
73
74 # QCOW
75 $LIBDIR/build_step_golden_image.sh
76 sha1short=$(grep -v product-manifest $RPMLISTS/rpmlist | sha1sum | cut -c-8)
77
78 # ISO images
79 $LIBDIR/build_step_create_install_cd.sh
80
81 echo "=== SUCCESS ==="
82 echo "Build results are in $WORKRESULTS"
83 echo "Installed RPMS checksum: ${sha1short} (this will change if list of installed RPMs changes)"