Merge "Improve nginx role testability"
[oom/offline-installer.git] / build / creating_data / download-docker-images.sh
1 #! /usr/bin/env bash
2
3 #   COPYRIGHT NOTICE STARTS HERE
4 #
5 #   Copyright 2018 © Samsung Electronics Co., Ltd.
6 #
7 #   Licensed under the Apache License, Version 2.0 (the "License");
8 #   you may not use this file except in compliance with the License.
9 #   You may obtain a copy of the License at
10 #
11 #       http://www.apache.org/licenses/LICENSE-2.0
12 #
13 #   Unless required by applicable law or agreed to in writing, software
14 #   distributed under the License is distributed on an "AS IS" BASIS,
15 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #   See the License for the specific language governing permissions and
17 #   limitations under the License.
18 #
19 #   COPYRIGHT NOTICE ENDS HERE
20
21
22 # boilerplate
23 RELATIVE_PATH=../ # relative path from this script to 'common-functions.sh'
24 if [ "$IS_COMMON_FUNCTIONS_SOURCED" != YES ] ; then
25     SCRIPT_DIR=$(dirname "${0}")
26     LOCAL_PATH=$(readlink -f "$SCRIPT_DIR")
27     . "${LOCAL_PATH}"/"${RELATIVE_PATH}"/common-functions.sh
28 fi
29
30 SRC_IMAGE_LIST=$1
31 if [[ -z "$SRC_IMAGE_LIST" ]]; then
32     SRC_IMAGE_LIST="docker_image_list.txt"
33 fi
34
35 echo "Download all images"
36
37 lines=$(cat $SRC_IMAGE_LIST | wc -l)
38 line=1
39 while read -r image; do
40     echo "== pkg #$line of $lines =="
41
42     name=$(echo $image|awk '{print $1}')
43     digest=$(echo $image|awk '{print $2}')
44
45     echo "$name digest:$digest"
46     if [[ "$digest" == "<none>" ]]; then
47         retry docker -l error pull "$name"
48     else
49         retry docker -l error pull "$name"
50     fi
51     line=$((line+1))
52
53 done < "$SRC_IMAGE_LIST"