Pin pip to 20.3.3 and disable tmpfs in DIB
[ta/build-tools.git] / create_golden_image.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 scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
21 source $scriptdir/lib.sh
22
23 BASE_IMAGE_URL=${BASE_IMAGE_URL:-$(_read_build_config DEFAULT base_image)}
24 CENTOS_SNAP=${CENTOS_SNAP:-$(_read_build_config DEFAULT centos_reposnap)}
25
26 BASE_IMAGE_NAME=`echo $BASE_IMAGE_URL | awk -F "/" '{print $NF}'`
27 BASE_IMAGE_SIZE="8GiB"
28 [ "$(uname -m)" != aarch64 ] || EXTRA_ELEMENTS="block-device-efi"
29
30 wget_args=""
31 [ -n "$GOLDEN_BASE_IMAGE_FETCH_USER" ] && wget_args="$wget_args --http-user=$GOLDEN_BASE_IMAGE_FETCH_USER"
32 [ -n "$GOLDEN_BASE_IMAGE_FETCH_PASSWORD" ] && wget_args="$wget_args --http-password=$GOLDEN_BASE_IMAGE_FETCH_PASSWORD"
33
34 fetch_image() {
35     sourceurl=$1
36     echo "Download $sourceurl to $WORKTMP/base-img"
37     mkdir -pv $WORKTMP/base-img
38     pushd $WORKTMP/base-img
39     wget --no-check-certificate --no-verbose -N \
40     --auth-no-challenge $wget_args \
41     $sourceurl
42     popd
43 }
44
45 fetch_image $BASE_IMAGE_URL
46 cp $MANIFEST_PATH/packages.yaml $scriptdir/dib_elements/myproduct/package-installs.yaml
47
48 DIB_DEBUG_TRACE=1 \
49   FS_TYPE=xfs \
50   PACKAGES_TO_INSTALL="$(_get_package_list install)" \
51   PACKAGES_TO_UNINSTALL="$(_get_package_list uninstall)" \
52   DIB_RPMLISTS=$RPMLISTS \
53   DIB_CHECKSUM=$CHECKSUM_DIR \
54   DIB_LOCAL_REPO=$REPO_DIR \
55   DIB_DISTRIBUTION_MIRROR=$CENTOS_SNAP \
56   DIB_YUM_REPO_CONF="${REPO_FILES}/repositories.repo ${REPO_FILES}/localrepo.repo" \
57   DIB_LOCAL_IMAGE=$WORKTMP/base-img/$BASE_IMAGE_NAME \
58   ELEMENTS_PATH=$scriptdir/dib_elements/ \
59   /usr/bin/disk-image-create --root-label img-rootfs --image-size $BASE_IMAGE_SIZE vm centos7 selinux-permissive myproduct ${EXTRA_ELEMENTS:-} -o $TMP_GOLDEN_IMAGE
60
61 rm -rf $WORKTMP/base-img