+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