diff --git a/build.sh b/build.sh index bcca8ba76e8af8f16d9114aec2b1f694197a5a51..cde96f48d72f6f04832c38c02847e39c760c1b09 100755 --- a/build.sh +++ b/build.sh @@ -7,13 +7,7 @@ grep -q "[[:space:]]" <<<"${SRC}" && { echo "\"${SRC}\" contains whitespace. Not cd "${SRC}" || exit -if [[ -f "${SRC}"/scripts/general.sh ]]; then - source ${SRC}/scripts/general.sh -else - echo "Error: missing build directory structure" - echo "Please clone the full repository by https://gitee.com/kunpeng_compute/KunPengDevBoard-Build" - exit 255 -fi +source ${SRC}/scripts/common.sh check_root_user @@ -45,7 +39,6 @@ if [[ ! -d ${DOWNLOAD_DIR} ]]; then mkdir -p ${DOWNLOAD_DIR} fi -source ${SRC}/scripts/log.sh source ${SRC}/scripts/install_host_tools.sh source ${SRC}/scripts/install_bisheng.sh source ${SRC}/scripts/make_image.sh diff --git a/scripts/general.sh b/scripts/common.sh similarity index 80% rename from scripts/general.sh rename to scripts/common.sh index 82eb1577886115688f15fb7a55d4a9c5fdb905d8..a5b2e874001aecfffd69cc51a0e8b271e189fa8c 100755 --- a/scripts/general.sh +++ b/scripts/common.sh @@ -53,29 +53,30 @@ function check_root_user() function display_alert() { local tmp="" - [[ -n $2 ]] && tmp="[\e[0;33m $2 \x1B[0m]" - - case $3 in - err) - echo -e "[\e[0;31m error \x1B[0m] $1 $tmp" - ;; - - wrn) - echo -e "[\e[0;35m warn \x1B[0m] $1 $tmp" - ;; - - ext) - echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0m $tmp" - ;; - - info) - echo -e "[\e[0;32m o.k. \x1B[0m] $1 $tmp" - ;; - - *) - echo -e "[\e[0;32m .... \x1B[0m] $1 $tmp" - ;; - esac + + if [[ "$RUN_MODE" == "CI" ]]; then + [[ -n $2 ]] && tmp=" $2 " + echo -e "[`date` $3] $1 $tmp" + else + [[ -n $2 ]] && tmp="[\e[0;33m $2 \x1B[0m]" + case $3 in + err) + echo -e "[\e[0;31m error \x1B[0m] $1 $tmp" + ;; + + wrn) + echo -e "[\e[0;35m warn \x1B[0m] $1 $tmp" + ;; + + info) + echo -e "[\e[0;32m info \x1B[0m] $1 $tmp" + ;; + + *) + echo -e "[\e[0;32m .... \x1B[0m] $1 $tmp" + ;; + esac + fi } function run_on_rootfs() diff --git a/scripts/install_rpms.sh b/scripts/install_rpms.sh index d20af0f4e1acf8190d4767bb0f6ec8aeb475a16d..96c9e929560c36a03389abe63dcacc7e6cb2b9f6 100755 --- a/scripts/install_rpms.sh +++ b/scripts/install_rpms.sh @@ -6,21 +6,21 @@ function download_file() { local url="$1" local file_path=$(basename "$url") - LOG "download_file ${file_path} begin ..." + display_alert "download_file ${file_path} begin ..." "" "info" pushd ${DOWNLOAD_DIR} if [ ! -f "$file_path" ]; then - wget "$url" -O "$file_path" --no-check-certificate + wget -q --show-progress --progress=bar:force "$url" -O "$file_path" --no-check-certificate # 检查文件是否下载成功 if [ $? -ne 0 ]; then rm -f ${file_path} fi if [ ! -f "$file_path" ]; then - LOG "Failed to download $file_path." + display_alert "Failed to download $file_path." "" "error" exit 1 fi fi popd - LOG "download_file ${file_path} end ..." + display_alert "download_file ${file_path} end ..." "" "info" set -e echo "$file_path" } diff --git a/scripts/log.sh b/scripts/log.sh deleted file mode 100755 index 2dd08746259b274d2cd3aa3d3fbc1e0a6d035dec..0000000000000000000000000000000000000000 --- a/scripts/log.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -function ERROR() -{ - echo `date` - ERROR, $* | tee -a ${LOG_DIR}/make_rootfs.log -} - -function LOG() -{ - echo `date` - INFO, $* | tee -a ${LOG_DIR}/make_rootfs.log -} diff --git a/scripts/make_rootfs.sh b/scripts/make_rootfs.sh index 21a24f411ccd8711a744fb04691e898b13c2aac5..b81c9896b64365e38c3e0f3c1d9bcc36baa017ab 100755 --- a/scripts/make_rootfs.sh +++ b/scripts/make_rootfs.sh @@ -18,7 +18,7 @@ function umount_all() } function exit_handler() { - LOG "handle exit signal ..." + display_alert "handle exit signal ..." "" "info" umount_all resume_repo # 回到用户调用脚本的当前路径 @@ -72,7 +72,7 @@ function make_rootfs() function fix_timesyncd() { set +e - LOG "process timesyncd.conf ..." + display_alert "process timesyncd.conf ..." "" "info" cat ${ROOTFS}/etc/systemd/timesyncd.conf | grep "^NTP=*" if [ $? -ne 0 ]; then sed -i -e '/^#NTP=/cNTP=0.cn.pool.ntp.org' ${ROOTFS}/etc/systemd/timesyncd.conf @@ -94,7 +94,7 @@ function fix_gnome() function process_chroot() { - LOG "process chroot script ..." + display_alert "process chroot script ..." "" "info" cp -f ${SCRIPTS_CHROOT} ${ROOTFS}/make_cfg.sh chmod +x ${ROOTFS}/make_cfg.sh mount --bind /dev ${ROOTFS}/dev @@ -108,7 +108,7 @@ function process_chroot() function resume_repo() { if [[ -d /etc/yum.repos.d.bak ]]; then - LOG "resume yum repo ..." + display_alert "resume yum repo ..." "" "info" rm -rf /etc/yum.repos.d mv /etc/yum.repos.d.bak /etc/yum.repos.d fi