acosail_mk_all_dist_sample/main.sh

147 lines
3.5 KiB
Bash
Executable File

#!/bin/bash
if [ "$(id -u)" -eq 0 ]; then
echo "请使用普通用户身份执行此脚本。"
exit 1
fi
sudo echo "">/dev/null
export ACO_GIT_USR_NAME=""
export ACO_GIT_PASWD=""
export ACO_TMPDIR=$(mktemp /tmp/aco_pub_sample_task_XXXX)
ACO_SCRIPT_REL_PATH=$(dirname "$0")
export ACO_SCRIPT_ABS_PATH=$(realpath ${ACO_SCRIPT_REL_PATH})
cleanup() {
echo "exiting"
rm -rf $TMPDIR $ACO_TMPDIR
rm -rf ${ACO_SCRIPT_ABS_PATH}/materials/kernel_Image/debs
exit 0
}
trap cleanup SIGINT
trap cleanup EXIT
err_handler()
{
ret=$?
[ "$ret" -eq 0 ] && return
echo "ERROR: Running ${FUNCNAME[1]} failed!"
echo "ERROR: exit code $ret from line ${BASH_LINENO[0]}:"
echo " $BASH_COMMAND"
exit $ret
}
trap 'err_handler' ERR
set -eE
print_help() {
echo "用法: $0 [选项]"
echo "选项:"
echo " --help 显示帮助信息"
echo " --all 打包所有产品"
echo " --set 设置目标产品"
echo " target=<目标> 指定目标类型,可选值为 test、release、debug"
echo ""
echo "示例:"
echo " $0 --help 显示帮助信息"
echo " $0 --all 打包所有产品"
echo " $0 --set 设置目标产品"
echo " $0 target=release 打包指定目标为 release 的产品"
}
for script in ./scripts/*.sh; do . "$script"; done
export TIMESTAMP=$(generate_timestamp)
export CUR_DISTS_DIR=${ACO_SCRIPT_ABS_PATH}/dists/build_dists_${TIMESTAMP}
while (( "$#" )); do
case "$1" in
--help)
print_help
exit 0
;;
target=*)
export ACO_TAGET="${1#*=}"
opts=("test" "release" "debug")
# if [[ ! "$TARGET" =~ ^(test|release|debug)$ ]]; then
if [[ ! " ${opts[*]} " =~ " ${TARGET} " ]]; then
echo "TARGET is not in \"${opts[@]}\""
exit 1
fi
;;
--all)
export ACO_PUBLICALL=true
echo "##########################"
echo "# packge all products ..."
echo "##########################"
;;
--set)
export ACO_SET_PRODUCT=true
;;
*)
echo "未知参数: $1"
exit 1
;;
esac
shift
done
if [ -z ${ACO_SELF_BUILD_DTB} ]; then
echo "请输入36服务器的git用户名:"
read ACO_GIT_USR_NAME
echo "请输入36服务器的git密码:"
read -s ACO_GIT_PASWD
fi
if [ ${ACO_SET_PRODUCT} = "true" ]; then
do_select_product
export ACO_TARGET_PRODUCT=$(cat .aco_target_product)
echo ${ACO_TARGET_PRODUCT}
config_file_name_sf=$(basename "$ACO_TARGET_PRODUCT")
config_file_basename=${config_file_name_sf%%.txt}
check_config_file_name ${config_file_basename}
else
if [ ${ACO_PUBLICALL} != "true" ]; then
if [ -f .aco_target_product ]; then
export ACO_TARGET_PRODUCT=$(cat .aco_target_product)
echo ${ACO_TARGET_PRODUCT}
config_file_name_sf=$(basename "$ACO_TARGET_PRODUCT")
config_file_basename=${config_file_name_sf%%.txt}
check_config_file_name ${config_file_basename}
else
do_select_product
fi
else
export ACO_TARGET_PRODUCT=$(cat .aco_target_product)
echo ${ACO_TARGET_PRODUCT}
config_file_name_sf=$(basename "$ACO_TARGET_PRODUCT")
config_file_basename=${config_file_name_sf%%.txt}
check_config_file_name ${config_file_basename}
fi
fi
# global_config
print_aco_variables "ACO_"
prepare_materials
pre_public_all
if [[ ${ACO_PUBLICALL} == "true" ]]; then
public_all
else
do_packge ${config_file_basename} ${ACO_TARGET_PRODUCT}
fi
archive
upload