Generate the root password, download and load the Docker image, and copy the image package to the host.
Signed-off-by: Wang Chenglong 18509160991@163.com --- container/osimage/openeuler/lib | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 container/osimage/openeuler/lib
diff --git a/container/osimage/openeuler/lib b/container/osimage/openeuler/lib new file mode 100755 index 0000000..cf291ea --- /dev/null +++ b/container/osimage/openeuler/lib @@ -0,0 +1,45 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +DIR="$(pwd)" +os_name="$(echo $DIR |awk -F "/" '{print $(NF - 2)}')" +os_version="$(echo $DIR |awk -F "/" '{print $NF}')" +docker_url="https://repo.openeuler.org/openEuler-$%7Bos_version%7D/docker_img/aarch64/op..." +docker_tar="openEuler-${os_version}-docker.aarch64.tar.xz" +image=$(echo "${os_name}-${os_version}" | tr '[A-Z]' '[a-z]') +IMAGE_NAME="${os_name}-${os_version}-$(date +"%Y%m%d").cgz" + +export_root_passwd() { + local root_pwd_file="$HOME/.config/compass-ci/rootfs-passwd" + [ -f "$root_pwd_file" ] || { + echo "[INFO] Please set the password file." + echo "$HOME/.config/compass-ci/rootfs-passwd" + exit 1 + } + + export ROOT_PASSWD=$(cat "$root_pwd_file") +} + +pull_docker_image() +{ + if [ "$os_version" == '20.09' ]; then + [ -f "$HOME/$docker_tar" ] || wget -O "$HOME/$docker_tar" "$docker_url" + elif [ "$os_version" == '20.03-LTS' ]; then + [ -f "$HOME/$docker_tar" ] || wget -O "$HOME/$docker_tar" "$docker_url" + fi + + docker load -i "$HOME/$docker_tar" + if [ $? = 0 ]; then + echo "finish downloading image" + else + echo "[ERROR] Pull docker image failed." + exit 1 + fi +} + +docker_cp_image() +{ + docker cp -a init_docker:/tmp/${IMAGE_NAME} $HOME/ + echo "result: $(ls $HOME/${IMAGE_NAME})" +}
On Thu, Nov 26, 2020 at 09:27:51AM +0800, Wang Chenglong wrote:
Generate the root password, download and load the Docker image, and copy the image package to the host.
Signed-off-by: Wang Chenglong 18509160991@163.com
container/osimage/openeuler/lib | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 container/osimage/openeuler/lib
diff --git a/container/osimage/openeuler/lib b/container/osimage/openeuler/lib new file mode 100755 index 0000000..cf291ea --- /dev/null +++ b/container/osimage/openeuler/lib @@ -0,0 +1,45 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+DIR="$(pwd)" +os_name="$(echo $DIR |awk -F "/" '{print $(NF - 2)}')"
| awk
+os_version="$(echo $DIR |awk -F "/" '{print $NF}')"
| awk
+docker_url="https://repo.openeuler.org/openEuler-$%7Bos_version%7D/docker_img/aarch64/op..." +docker_tar="openEuler-${os_version}-docker.aarch64.tar.xz" +image=$(echo "${os_name}-${os_version}" | tr '[A-Z]' '[a-z]')
if use /bin/bash, can echo ${os_name,,} to convert lowercase
+IMAGE_NAME="${os_name}-${os_version}-$(date +"%Y%m%d").cgz"
+export_root_passwd() {
- local root_pwd_file="$HOME/.config/compass-ci/rootfs-passwd"
- [ -f "$root_pwd_file" ] || {
echo "[INFO] Please set the password file."
echo "$HOME/.config/compass-ci/rootfs-passwd"
exit 1
}
export ROOT_PASSWD=$(cat "$root_pwd_file")
+}
+pull_docker_image() +{
- if [ "$os_version" == '20.09' ]; then
[ -f "$HOME/$docker_tar" ] || wget -O "$HOME/$docker_tar" "$docker_url"
- elif [ "$os_version" == '20.03-LTS' ]; then
[ -f "$HOME/$docker_tar" ] || wget -O "$HOME/$docker_tar" "$docker_url"
- fi
- docker load -i "$HOME/$docker_tar"
add blank line here
- if [ $? = 0 ]; then
echo "finish downloading image"
- else
echo "[ERROR] Pull docker image failed."
exit 1
- fi
+}
+docker_cp_image() +{
- docker cp -a init_docker:/tmp/${IMAGE_NAME} $HOME/
- echo "result: $(ls $HOME/${IMAGE_NAME})"
+}
2.23.0
+os_name="$(echo $DIR |awk -F "/" '{print $(NF - 2)}')"
| awk
Good.
+os_version="$(echo $DIR |awk -F "/" '{print $NF}')"
| awk
Good.
+docker_url="https://repo.openeuler.org/openEuler-$%7Bos_version%7D/docker_img/aarch64/op..." +docker_tar="openEuler-${os_version}-docker.aarch64.tar.xz" +image=$(echo "${os_name}-${os_version}" | tr '[A-Z]' '[a-z]')
if use /bin/bash, can echo ${os_name,,} to convert lowercase
Good.
- docker load -i "$HOME/$docker_tar"
add blank line here
Good.
Thanks, Chenglong
- if [ $? = 0 ]; then
echo "finish downloading image"
- else
echo "[ERROR] Pull docker image failed."
exit 1
- fi
+}
+docker_cp_image() +{
- docker cp -a init_docker:/tmp/${IMAGE_NAME} $HOME/
- echo "result: $(ls $HOME/${IMAGE_NAME})"
+}
2.23.0
On Thu, Nov 26, 2020 at 09:27:51AM +0800, Wang Chenglong wrote:
Generate the root password, download and load the Docker image, and copy
^^^^^^^^^^^^^^^^^ load is ok
the image package to the host.
Signed-off-by: Wang Chenglong 18509160991@163.com
container/osimage/openeuler/lib | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 container/osimage/openeuler/lib
diff --git a/container/osimage/openeuler/lib b/container/osimage/openeuler/lib new file mode 100755 index 0000000..cf291ea --- /dev/null +++ b/container/osimage/openeuler/lib @@ -0,0 +1,45 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+DIR="$(pwd)" +os_name="$(echo $DIR |awk -F "/" '{print $(NF - 2)}')" +os_version="$(echo $DIR |awk -F "/" '{print $NF}')" +docker_url="https://repo.openeuler.org/openEuler-$%7Bos_version%7D/docker_img/aarch64/op..."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the file name is fixed?
+docker_tar="openEuler-${os_version}-docker.aarch64.tar.xz"
what's mean docker_tar, how about image_file_name
+image=$(echo "${os_name}-${os_version}" | tr '[A-Z]' '[a-z]') +IMAGE_NAME="${os_name}-${os_version}-$(date +"%Y%m%d").cgz"
+export_root_passwd() {
- local root_pwd_file="$HOME/.config/compass-ci/rootfs-passwd"
the path is fixed?
- [ -f "$root_pwd_file" ] || {
echo "[INFO] Please set the password file."
echo "$HOME/.config/compass-ci/rootfs-passwd"
exit 1
}
export ROOT_PASSWD=$(cat "$root_pwd_file")
+}
+pull_docker_image()
load_docker_image
+{
- if [ "$os_version" == '20.09' ]; then
[ -f "$HOME/$docker_tar" ] || wget -O "$HOME/$docker_tar" "$docker_url"
- elif [ "$os_version" == '20.03-LTS' ]; then
[ -f "$HOME/$docker_tar" ] || wget -O "$HOME/$docker_tar" "$docker_url"
- fi
- docker load -i "$HOME/$docker_tar"
- if [ $? = 0 ]; then
echo "finish downloading image"
- else
echo "[ERROR] Pull docker image failed."
exit 1
- fi
+}
+docker_cp_image()
how about cp_image_to_host
Thanks, Shenwei
+{
- docker cp -a init_docker:/tmp/${IMAGE_NAME} $HOME/
- echo "result: $(ls $HOME/${IMAGE_NAME})"
+}
2.23.0
On Thu, Nov 26, 2020 at 09:53:05AM +0800, Xiao Shenwei wrote:
On Thu, Nov 26, 2020 at 09:27:51AM +0800, Wang Chenglong wrote:
Generate the root password, download and load the Docker image, and copy
^^^^^^^^^^^^^^^^^ load is ok
good. i got it.
Thanks, Chenglong
the image package to the host.
Signed-off-by: Wang Chenglong 18509160991@163.com
+DIR="$(pwd)" +os_name="$(echo $DIR |awk -F "/" '{print $(NF - 2)}')" +os_version="$(echo $DIR |awk -F "/" '{print $NF}')" +docker_url="https://repo.openeuler.org/openEuler-$%7Bos_version%7D/docker_img/aarch64/op..."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
the file name is fixed?
Yes, it is the official link address.
+docker_tar="openEuler-${os_version}-docker.aarch64.tar.xz"
what's mean docker_tar, how about image_file_name
ok.
The docker package downloaded from the official file is in tar format.
Maybe i can use docker_tar_file.
+image=$(echo "${os_name}-${os_version}" | tr '[A-Z]' '[a-z]') +IMAGE_NAME="${os_name}-${os_version}-$(date +"%Y%m%d").cgz"
+export_root_passwd() {
- local root_pwd_file="$HOME/.config/compass-ci/rootfs-passwd"
the path is fixed?
Yes. it is better for users to set password in fixed path.
- [ -f "$root_pwd_file" ] || {
echo "[INFO] Please set the password file."
echo "$HOME/.config/compass-ci/rootfs-passwd"
exit 1
}
export ROOT_PASSWD=$(cat "$root_pwd_file")
+}
+pull_docker_image()
load_docker_image
Good.
+docker_cp_image()
how about cp_image_to_host
Good.
Thanks, Chenglong
Thanks, Shenwei
+{
- docker cp -a init_docker:/tmp/${IMAGE_NAME} $HOME/
- echo "result: $(ls $HOME/${IMAGE_NAME})"
+}
2.23.0
On Thu, Nov 26, 2020 at 09:27:51AM +0800, Wang Chenglong wrote:
Generate the root password, download and load the Docker image, and copy the image package to the host.
Signed-off-by: Wang Chenglong 18509160991@163.com
container/osimage/openeuler/lib | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 container/osimage/openeuler/lib
diff --git a/container/osimage/openeuler/lib b/container/osimage/openeuler/lib new file mode 100755 index 0000000..cf291ea --- /dev/null +++ b/container/osimage/openeuler/lib @@ -0,0 +1,45 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+DIR="$(pwd)" +os_name="$(echo $DIR |awk -F "/" '{print $(NF - 2)}')" +os_version="$(echo $DIR |awk -F "/" '{print $NF}')" +docker_url="https://repo.openeuler.org/openEuler-$%7Bos_version%7D/docker_img/aarch64/op..." +docker_tar="openEuler-${os_version}-docker.aarch64.tar.xz" +image=$(echo "${os_name}-${os_version}" | tr '[A-Z]' '[a-z]') +IMAGE_NAME="${os_name}-${os_version}-$(date +"%Y%m%d").cgz"
+export_root_passwd() {
please keep same style () {
}
Thanks, Baijing
- local root_pwd_file="$HOME/.config/compass-ci/rootfs-passwd"
- [ -f "$root_pwd_file" ] || {
echo "[INFO] Please set the password file."
echo "$HOME/.config/compass-ci/rootfs-passwd"
exit 1
}
export ROOT_PASSWD=$(cat "$root_pwd_file")
+}
+pull_docker_image() +{
- if [ "$os_version" == '20.09' ]; then
[ -f "$HOME/$docker_tar" ] || wget -O "$HOME/$docker_tar" "$docker_url"
- elif [ "$os_version" == '20.03-LTS' ]; then
[ -f "$HOME/$docker_tar" ] || wget -O "$HOME/$docker_tar" "$docker_url"
- fi
- docker load -i "$HOME/$docker_tar"
- if [ $? = 0 ]; then
echo "finish downloading image"
- else
echo "[ERROR] Pull docker image failed."
exit 1
- fi
+}
+docker_cp_image() +{
- docker cp -a init_docker:/tmp/${IMAGE_NAME} $HOME/
- echo "result: $(ls $HOME/${IMAGE_NAME})"
+}
2.23.0
On Thu, Nov 26, 2020 at 11:31:19AM +0800, Bai Jing wrote:
On Thu, Nov 26, 2020 at 09:27:51AM +0800, Wang Chenglong wrote:
Generate the root password, download and load the Docker image, and copy the image package to the host.
Signed-off-by: Wang Chenglong 18509160991@163.com
container/osimage/openeuler/lib | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 container/osimage/openeuler/lib
diff --git a/container/osimage/openeuler/lib b/container/osimage/openeuler/lib new file mode 100755 index 0000000..cf291ea --- /dev/null +++ b/container/osimage/openeuler/lib @@ -0,0 +1,45 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+DIR="$(pwd)" +os_name="$(echo $DIR |awk -F "/" '{print $(NF - 2)}')" +os_version="$(echo $DIR |awk -F "/" '{print $NF}')" +docker_url="https://repo.openeuler.org/openEuler-$%7Bos_version%7D/docker_img/aarch64/op..." +docker_tar="openEuler-${os_version}-docker.aarch64.tar.xz" +image=$(echo "${os_name}-${os_version}" | tr '[A-Z]' '[a-z]') +IMAGE_NAME="${os_name}-${os_version}-$(date +"%Y%m%d").cgz"
+export_root_passwd() {
please keep same style () {
}
Good.
Thanks, Baijing
- local root_pwd_file="$HOME/.config/compass-ci/rootfs-passwd"
- [ -f "$root_pwd_file" ] || {
echo "[INFO] Please set the password file."
echo "$HOME/.config/compass-ci/rootfs-passwd"
exit 1
}
export ROOT_PASSWD=$(cat "$root_pwd_file")
+}
+pull_docker_image() +{
- if [ "$os_version" == '20.09' ]; then
[ -f "$HOME/$docker_tar" ] || wget -O "$HOME/$docker_tar" "$docker_url"
- elif [ "$os_version" == '20.03-LTS' ]; then
[ -f "$HOME/$docker_tar" ] || wget -O "$HOME/$docker_tar" "$docker_url"
- fi
- docker load -i "$HOME/$docker_tar"
- if [ $? = 0 ]; then
echo "finish downloading image"
- else
echo "[ERROR] Pull docker image failed."
exit 1
- fi
+}
+docker_cp_image() +{
- docker cp -a init_docker:/tmp/${IMAGE_NAME} $HOME/
- echo "result: $(ls $HOME/${IMAGE_NAME})"
+}
2.23.0