blob: 0a72d15bb00cec326606675d81c0b18f799971f3 [file] [log] [blame]
Piotr Perzanowski6d14adb2018-12-18 17:00:08 +01001#! /usr/bin/env bash
Petr Ospalý03e61242019-01-03 16:54:50 +01002
Piotr Perzanowski6d14adb2018-12-18 17:00:08 +01003# 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
Petr Ospalý03e61242019-01-03 16:54:50 +010020
21
Tomáš Levora284fbf82019-04-23 14:28:47 +020022# Load common-functions library
23. $(dirname ${0})/../common-functions.sh
Petr Ospalý03e61242019-01-03 16:54:50 +010024
Tomáš Levora284fbf82019-04-23 14:28:47 +020025LIST_FILE="${1}"
Tomáš Levora51ec4d12019-02-27 17:00:25 +010026IMG_DIR="${2}"
Petr Ospalý03e61242019-01-03 16:54:50 +010027
Piotr Perzanowski6d14adb2018-12-18 17:00:08 +010028if [[ -z "$IMG_DIR" ]]; then
29 IMG_DIR="./images"
30fi
Petr Ospalý03e61242019-01-03 16:54:50 +010031
Piotr Perzanowski6d14adb2018-12-18 17:00:08 +010032echo "Creating ${IMG_DIR}"
33if [[ ! -d "${IMG_DIR}" ]]; then
34 mkdir -p "${IMG_DIR}"
35fi
Petr Ospalý03e61242019-01-03 16:54:50 +010036
Piotr Perzanowski6d14adb2018-12-18 17:00:08 +010037save_image() {
38 local name_tag=$1
39 echo "$name_tag"
40 local img_name=$(echo "${name_tag}" | tr /: __)
41 local img_path="${IMG_DIR}/${img_name}.tar"
Petr Ospalý03e61242019-01-03 16:54:50 +010042
Piotr Perzanowski6d14adb2018-12-18 17:00:08 +010043 if [[ ! -f "${img_path}" ]] ; then
44 echo "[DEBUG] save ${name_tag} to ${img_path}"
45 echo "${name_tag}" >> $IMG_DIR/_image_list.txt
46 retry docker -l error save -o "${img_path}" ${name_tag}
47 else
48 echo "[DEBUG] ${name_tag} already saved"
49 fi
50}
Petr Ospalý03e61242019-01-03 16:54:50 +010051
Piotr Perzanowski6d14adb2018-12-18 17:00:08 +010052echo "Save all images"
53line=1
Tomáš Levora284fbf82019-04-23 14:28:47 +020054lines=$(clean_list "$LIST_FILE" | wc -l)
55for image in $(clean_list "$LIST_FILE"); do
Piotr Perzanowski6d14adb2018-12-18 17:00:08 +010056 echo "== pkg #$line of $lines =="
Tomáš Levora51ec4d12019-02-27 17:00:25 +010057 save_image "${image}"
Piotr Perzanowski6d14adb2018-12-18 17:00:08 +010058 line=$((line+1))
Tomáš Levora284fbf82019-04-23 14:28:47 +020059done