[#37] 删除旧部署构建目录;跑通src/sys/tests; 增加一键构建 server pkg和client gpu pkg
This commit is contained in:
@@ -37,22 +37,11 @@ _argus_is_number() {
|
||||
[[ "$1" =~ ^[0-9]+$ ]]
|
||||
}
|
||||
|
||||
load_build_user() {
|
||||
if [[ "$_ARGUS_BUILD_USER_LOADED" == "1" ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local project_root config_files config uid gid
|
||||
project_root="$(argus_project_root)"
|
||||
config_files=(
|
||||
"$project_root/configs/build_user.local.conf"
|
||||
"$project_root/configs/build_user.conf"
|
||||
)
|
||||
|
||||
uid="$ARGUS_BUILD_UID_DEFAULT"
|
||||
gid="$ARGUS_BUILD_GID_DEFAULT"
|
||||
|
||||
for config in "${config_files[@]}"; do
|
||||
_argus_read_user_from_files() {
|
||||
local uid_out_var="$1" gid_out_var="$2"; shift 2
|
||||
local uid_val="$ARGUS_BUILD_UID_DEFAULT" gid_val="$ARGUS_BUILD_GID_DEFAULT"
|
||||
local config
|
||||
for config in "$@"; do
|
||||
if [[ -f "$config" ]]; then
|
||||
while IFS= read -r raw_line || [[ -n "$raw_line" ]]; do
|
||||
local line key value
|
||||
@@ -68,42 +57,58 @@ load_build_user() {
|
||||
key="$(_argus_trim "$key")"
|
||||
value="$(_argus_trim "$value")"
|
||||
case "$key" in
|
||||
UID)
|
||||
uid="$value"
|
||||
;;
|
||||
GID)
|
||||
gid="$value"
|
||||
;;
|
||||
*)
|
||||
echo "[ARGUS build_user] Unknown key '$key' in $config" >&2
|
||||
;;
|
||||
UID) uid_val="$value" ;;
|
||||
GID) gid_val="$value" ;;
|
||||
*) echo "[ARGUS build_user] Unknown key '$key' in $config" >&2 ;;
|
||||
esac
|
||||
done < "$config"
|
||||
break
|
||||
fi
|
||||
done
|
||||
printf -v "$uid_out_var" '%s' "$uid_val"
|
||||
printf -v "$gid_out_var" '%s' "$gid_val"
|
||||
}
|
||||
|
||||
if [[ -n "${ARGUS_BUILD_UID:-}" ]]; then
|
||||
uid="$ARGUS_BUILD_UID"
|
||||
fi
|
||||
if [[ -n "${ARGUS_BUILD_GID:-}" ]]; then
|
||||
gid="$ARGUS_BUILD_GID"
|
||||
load_build_user_profile() {
|
||||
local profile="${1:-default}"
|
||||
if [[ "$_ARGUS_BUILD_USER_LOADED" == "1" ]]; then
|
||||
return 0
|
||||
fi
|
||||
local project_root uid gid
|
||||
project_root="$(argus_project_root)"
|
||||
case "$profile" in
|
||||
pkg)
|
||||
_argus_read_user_from_files uid gid \
|
||||
"$project_root/configs/build_user.pkg.conf" \
|
||||
"$project_root/configs/build_user.local.conf" \
|
||||
"$project_root/configs/build_user.conf"
|
||||
;;
|
||||
default|*)
|
||||
_argus_read_user_from_files uid gid \
|
||||
"$project_root/configs/build_user.local.conf" \
|
||||
"$project_root/configs/build_user.conf"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -n "${ARGUS_BUILD_UID:-}" ]]; then uid="$ARGUS_BUILD_UID"; fi
|
||||
if [[ -n "${ARGUS_BUILD_GID:-}" ]]; then gid="$ARGUS_BUILD_GID"; fi
|
||||
|
||||
if ! _argus_is_number "$uid"; then
|
||||
echo "[ARGUS build_user] Invalid UID '$uid'" >&2
|
||||
return 1
|
||||
echo "[ARGUS build_user] Invalid UID '$uid'" >&2; return 1
|
||||
fi
|
||||
if ! _argus_is_number "$gid"; then
|
||||
echo "[ARGUS build_user] Invalid GID '$gid'" >&2
|
||||
return 1
|
||||
echo "[ARGUS build_user] Invalid GID '$gid'" >&2; return 1
|
||||
fi
|
||||
|
||||
export ARGUS_BUILD_UID="$uid"
|
||||
export ARGUS_BUILD_GID="$gid"
|
||||
_ARGUS_BUILD_USER_LOADED=1
|
||||
}
|
||||
|
||||
load_build_user() {
|
||||
local profile="${ARGUS_BUILD_PROFILE:-default}"
|
||||
load_build_user_profile "$profile"
|
||||
}
|
||||
|
||||
argus_build_user_args() {
|
||||
load_build_user
|
||||
printf '%s' "--build-arg ARGUS_BUILD_UID=${ARGUS_BUILD_UID} --build-arg ARGUS_BUILD_GID=${ARGUS_BUILD_GID}"
|
||||
|
||||
Reference in New Issue
Block a user