Remove unused code
[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
29 wget_args=""
30 [ -n "$GOLDEN_BASE_IMAGE_FETCH_USER" ] && wget_args="$wget_args --http-user=$GOLDEN_BASE_IMAGE_FETCH_USER"
31 [ -n "$GOLDEN_BASE_IMAGE_FETCH_PASSWORD" ] && wget_args="$wget_args --http-password=$GOLDEN_BASE_IMAGE_FETCH_PASSWORD"
32
33 fetch_image() {
34     sourceurl=$1
35     echo "Download $sourceurl to $WORKTMP/base-img"
36     mkdir -pv $WORKTMP/base-img
37     pushd $WORKTMP/base-img
38     wget --no-check-certificate --no-verbose -N \
39     --auth-no-challenge $wget_args \
40     $sourceurl
41     popd
42 }
43
44 fetch_image $BASE_IMAGE_URL
45 cp $MANIFEST_PATH/packages.yaml $scriptdir/dib_elements/myproduct/package-installs.yaml
46
47 DIB_DEBUG_TRACE=1 \
48   FS_TYPE=xfs \
49   PACKAGES_TO_INSTALL="$(_get_package_list install)" \
50   PACKAGES_TO_UNINSTALL="$(_get_package_list uninstall)" \
51   DIB_RPMLISTS=$RPMLISTS \
52   DIB_CHECKSUM=$CHECKSUM_DIR \
53   DIB_LOCAL_REPO=$REPO_DIR \
54   DIB_DISTRIBUTION_MIRROR=$CENTOS_SNAP \
55   DIB_YUM_REPO_CONF="${REPO_FILES}/repositories.repo ${REPO_FILES}/localrepo.repo" \
56   DIB_LOCAL_IMAGE=$WORKTMP/base-img/$BASE_IMAGE_NAME \
57   ELEMENTS_PATH=$scriptdir/dib_elements/ \
58   /usr/bin/disk-image-create --root-label img-rootfs --image-size $BASE_IMAGE_SIZE vm centos7 selinux-permissive myproduct -o $TMP_GOLDEN_IMAGE
59
60 rm -rf $WORKTMP/base-img