for user locally deploy compass-ci, if testbox=vm-*, default os_mount=initramfs, so need to use osimage instead of os rootfs, delete download-rootfs script.
Signed-off-by: Liu Yinsi liuyinsi@163.com --- sbin/download-osimage | 36 ++++++++++++++++++++++++++++++++++++ sbin/download-rootfs | 40 ---------------------------------------- sparrow/5-build/os-ready | 2 +- 3 files changed, 37 insertions(+), 41 deletions(-) create mode 100755 sbin/download-osimage delete mode 100755 sbin/download-rootfs
diff --git a/sbin/download-osimage b/sbin/download-osimage new file mode 100755 index 0000000..f041846 --- /dev/null +++ b/sbin/download-osimage @@ -0,0 +1,36 @@ +#!/bin/bash +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +# download osimage. +# 1. download default osimage openeuler aarch64 20.03 +# example usage: +# ./download-osimage +# 2. download osimage you want by add params $os, $os_arch, $os_version. +# example usage: +# ./download-osimage debian aarch64 sid + +os=${1:-openeuler} +os_arch=${2:-$(arch)} +os_version=${3:-20.03} + +. ${CCI_SRC}/container/defconfig.sh + +load_cci_defaults + +rootfs_dir=/initrd/osimage/${os}/${os_arch}/${os_version} + +download_osimage() +{ + mkdir -p /srv/$rootfs_dir + cd $rootfs_dir + + wget http://api.compass-ci.openeuler.org:$%7BSRV_HTTP_INITRD_PORT%7D/$rootfs_dir/... + wget http://api.compass-ci.openeuler.org:$%7BSRV_HTTP_INITRD_PORT%7D/$rootfs_dir/... +} + +is_virtual() +{ + dmidecode -s system-product-name | grep -iq "virtual" +} + +is_virtual || download_osimage diff --git a/sbin/download-rootfs b/sbin/download-rootfs deleted file mode 100755 index f8c245d..0000000 --- a/sbin/download-rootfs +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. - -# download os rootfs. -# 1. download default os rootfs openeuler aarch64 20.03 -# example usage: -# ./download-rootfs -# 2. download os rootfs you want by add params $os, $os_arch, $os_version. -# example usage: -# ./download-rootfs debian aarch64 sid - -os=${1:-openeuler} -os_arch=${2:-$(arch)} -os_version=${3:-20.03} - -. ${CCI_SRC}/container/defconfig.sh -. ${CCI_SRC}/lib/log.sh - -load_cci_defaults - -rootfs_dir=/srv/os/${os}/${os_arch}/${os_version} - -download_os_rootfs() -{ - mkdir -p $rootfs_dir - cd $rootfs_dir - - download_url="http://api.compass-ci.openeuler.org:$%7BSRV_HTTP_OS_PORT%7D/os/$%7Bos%7D/$%7..." - wget $download_url - - [ "$?" -ne 0 ] && { - log_error "failed to download os rootfs: $download_url" - exit 1 - } - - gzip -dc ${os_version}.cgz | cpio -id - rm -rf ${os_version}.cgz -} - -download_os_rootfs diff --git a/sparrow/5-build/os-ready b/sparrow/5-build/os-ready index 5e1acc4..d4ed2b8 100755 --- a/sparrow/5-build/os-ready +++ b/sparrow/5-build/os-ready @@ -4,4 +4,4 @@
. $CCI_SRC/lib/check_public_network.sh
-public_network_ok && $CCI_SRC/sbin/download-rootfs +public_network_ok && $CCI_SRC/sbin/download-osimage
On Tue, Apr 13, 2021 at 07:03:17PM +0800, Liu Yinsi wrote:
for user locally deploy compass-ci, if testbox=vm-*, default os_mount=initramfs, so need to use osimage instead of os rootfs, delete download-rootfs script.
Signed-off-by: Liu Yinsi liuyinsi@163.com
sbin/download-osimage | 36 ++++++++++++++++++++++++++++++++++++ sbin/download-rootfs | 40 ---------------------------------------- sparrow/5-build/os-ready | 2 +- 3 files changed, 37 insertions(+), 41 deletions(-) create mode 100755 sbin/download-osimage delete mode 100755 sbin/download-rootfs
diff --git a/sbin/download-osimage b/sbin/download-osimage new file mode 100755 index 0000000..f041846 --- /dev/null +++ b/sbin/download-osimage @@ -0,0 +1,36 @@ +#!/bin/bash +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+# download osimage. +# 1. download default osimage openeuler aarch64 20.03 +# example usage: +# ./download-osimage +# 2. download osimage you want by add params $os, $os_arch, $os_version. +# example usage: +# ./download-osimage debian aarch64 sid
+os=${1:-openeuler} +os_arch=${2:-$(arch)} +os_version=${3:-20.03}
+. ${CCI_SRC}/container/defconfig.sh
+load_cci_defaults
+rootfs_dir=/initrd/osimage/${os}/${os_arch}/${os_version}
+download_osimage() +{
mkdir -p /srv/$rootfs_dir
cd $rootfs_dir && {
wget http://api.compass-ci.openeuler.org:${SRV_HTTP_INITRD_PORT}/$rootfs_dir/current
wget http://api.compass-ci.openeuler.org:${SRV_HTTP_INITRD_PORT}/$rootfs_dir/run-ipconfig.cgz
}
+}
+is_virtual() +{
dmidecode -s system-product-name | grep -iq "virtual"
you can add return 1/0 here
+}
+is_virtual || download_osimage
for the judgement, you can alse use following styles:
dmidecode -s system-product-name | grep -iq "virtual" [ $? -eq 0 ] || xxxx
aaa=$(dmidecode -s system-product-name) [[ ${aaa##*virtual} == ${aaa} ]] || xxx
aaa=$(dmidecode -s system-product-name | grep -i -o "virtual") [[ -n $aaa ]] || && xxx
Thanks, Luan Shengde
diff --git a/sbin/download-rootfs b/sbin/download-rootfs deleted file mode 100755 index f8c245d..0000000 --- a/sbin/download-rootfs +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
-# download os rootfs. -# 1. download default os rootfs openeuler aarch64 20.03 -# example usage: -# ./download-rootfs -# 2. download os rootfs you want by add params $os, $os_arch, $os_version. -# example usage: -# ./download-rootfs debian aarch64 sid
-os=${1:-openeuler} -os_arch=${2:-$(arch)} -os_version=${3:-20.03}
-. ${CCI_SRC}/container/defconfig.sh -. ${CCI_SRC}/lib/log.sh
-load_cci_defaults
-rootfs_dir=/srv/os/${os}/${os_arch}/${os_version}
-download_os_rootfs() -{
mkdir -p $rootfs_dir
cd $rootfs_dir
download_url="http://api.compass-ci.openeuler.org:${SRV_HTTP_OS_PORT}/os/${os}/${os_arch}/${os_version}.cgz"
wget $download_url
[ "$?" -ne 0 ] && {
log_error "failed to download os rootfs: $download_url"
exit 1
}
gzip -dc ${os_version}.cgz | cpio -id
rm -rf ${os_version}.cgz
-}
-download_os_rootfs diff --git a/sparrow/5-build/os-ready b/sparrow/5-build/os-ready index 5e1acc4..d4ed2b8 100755 --- a/sparrow/5-build/os-ready +++ b/sparrow/5-build/os-ready @@ -4,4 +4,4 @@
. $CCI_SRC/lib/check_public_network.sh
-public_network_ok && $CCI_SRC/sbin/download-rootfs
+public_network_ok && $CCI_SRC/sbin/download-osimage
2.23.0
+load_cci_defaults
+rootfs_dir=/initrd/osimage/${os}/${os_arch}/${os_version}
+download_osimage() +{
mkdir -p /srv/$rootfs_dir
cd $rootfs_dir && {
wget http://api.compass-ci.openeuler.org:${SRV_HTTP_INITRD_PORT}/$rootfs_dir/current
wget http://api.compass-ci.openeuler.org:${SRV_HTTP_INITRD_PORT}/$rootfs_dir/run-ipconfig.cgz
}
good
+}
+is_virtual() +{
dmidecode -s system-product-name | grep -iq "virtual"
you can add return 1/0 here
good
+}
+is_virtual || download_osimage
for the judgement, you can alse use following styles:
dmidecode -s system-product-name | grep -iq "virtual" [ $? -eq 0 ] || xxxx
aaa=$(dmidecode -s system-product-name) [[ ${aaa##*virtual} == ${aaa} ]] || xxx
aaa=$(dmidecode -s system-product-name | grep -i -o "virtual") [[ -n $aaa ]] || && xxx
not necessary
Thanks, Yinsi
Thanks, Luan Shengde
diff --git a/sbin/download-rootfs b/sbin/download-rootfs deleted file mode 100755 index f8c245d..0000000 --- a/sbin/download-rootfs +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
-# download os rootfs. -# 1. download default os rootfs openeuler aarch64 20.03 -# example usage: -# ./download-rootfs -# 2. download os rootfs you want by add params $os, $os_arch, $os_version. -# example usage: -# ./download-rootfs debian aarch64 sid
-os=${1:-openeuler} -os_arch=${2:-$(arch)} -os_version=${3:-20.03}
-. ${CCI_SRC}/container/defconfig.sh -. ${CCI_SRC}/lib/log.sh
-load_cci_defaults
-rootfs_dir=/srv/os/${os}/${os_arch}/${os_version}
-download_os_rootfs() -{
mkdir -p $rootfs_dir
cd $rootfs_dir
download_url="http://api.compass-ci.openeuler.org:${SRV_HTTP_OS_PORT}/os/${os}/${os_arch}/${os_version}.cgz"
wget $download_url
[ "$?" -ne 0 ] && {
log_error "failed to download os rootfs: $download_url"
exit 1
}
gzip -dc ${os_version}.cgz | cpio -id
rm -rf ${os_version}.cgz
-}
-download_os_rootfs diff --git a/sparrow/5-build/os-ready b/sparrow/5-build/os-ready index 5e1acc4..d4ed2b8 100755 --- a/sparrow/5-build/os-ready +++ b/sparrow/5-build/os-ready @@ -4,4 +4,4 @@
. $CCI_SRC/lib/check_public_network.sh
-public_network_ok && $CCI_SRC/sbin/download-rootfs
+public_network_ok && $CCI_SRC/sbin/download-osimage
2.23.0