
+check_passwd_file() {
check_passwd_file => export_root_passwd
+ root_pwd_file="$HOME/.config/compass-ci/rootfs-passwd"
local root_passwd_file=...
+ export ROOT_NEW_PASSWD=
That line is not necessary. Still not aligned.
+ [ -f "$root_pwd_file" ] || { + echo "[INFO] Please set the password file." + echo "$HOME/.config/compass-ci/rootfs-passwd" + exit 1 + } + + export ROOT_NEW_PASSWD=$(cat "$root_pwd_file")
ROOT_NEW_PASSWD => ROOT_PASWD
+} + +pull_docker_image() +{ + docker pull $image + if [ $? = 0 ]; then + echo "finish downloading image" + else + echo "[INFO] Pull docker image failed."
[INFO] => ERROR:
+ exit
exit 1 Thanks, Fengguang
+ fi +} + +docker_cp_image() +{ + docker cp -a init_docker:/tmp/${image_name} $HOME/ + echo "result: $(ls $HOME/${image_name})" +} diff --git a/container/osimage/centos/packages-to-install b/container/osimage/centos/packages-to-install new file mode 100644 index 0000000..a09bc28 --- /dev/null +++ b/container/osimage/centos/packages-to-install @@ -0,0 +1,9 @@ +openssh-server +openssl +cifs-utils +hostname +curl +iproute +iputils +which +time diff --git a/container/osimage/centos/run b/container/osimage/centos/run new file mode 100755 index 0000000..3851429 --- /dev/null +++ b/container/osimage/centos/run @@ -0,0 +1,27 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +. ${CCI_SRC}/container/osimage/centos/lib +. ${CCI_SRC}/container/defconfig.sh + +check_passwd_file + +DIR=$(dirname $(realpath $0)) +cmd=( + docker run + --name init_docker + -v $DIR/create-image:/root/bin/create-image + -v $DIR/packages-to-install:/tmp/packages-to-install + -v $DIR/files-to-exclude:/tmp/files-to-exclude + -e ROOT_NEW_PASSWD=$ROOT_NEW_PASSWD + -e image_name=$image_name
Please use IMAGE_NAME for env var.
+ $image + /root/bin/create-image +) + +pull_docker_image +${cmd[@]} +docker_cp_image +docker_rm init_docker &> /dev/null +echo "build finished" -- 2.23.0