开始支持自动构建,加入安装反馈

This commit is contained in:
2025-11-19 16:56:47 +08:00
parent dd90529435
commit e511f75437
8 changed files with 159 additions and 2 deletions

1
build.config Normal file
View File

@@ -0,0 +1 @@
@VERSION@=1.1.4

92
build.sh Executable file
View File

@@ -0,0 +1,92 @@
#!/usr/bin/env bash
########################################
# 配置部分
########################################
config_file="build.config" # 配置文件路径
if [[ -z "$1" ]];then
echo "Need TARGET DIR"
exit
fi
target_dir="${1}" # 要处理的目标目录
########################################
# 读取 ace-base.config 生成替换字典
########################################
declare -A replacements
while IFS= read -r line; do
# 跳过空行
[[ -z "$line" ]] && continue
# 匹配类似 @PKG_NAME@=amber-ce-bookworm 的格式
if [[ "$line" =~ ^@(.*)@=(.*)$ ]]; then
key="${BASH_REMATCH[1]}"
val="${BASH_REMATCH[2]}"
replacements["$key"]="$val"
fi
done < "$config_file"
########################################
# 第一步:文本文件内容替换
########################################
# 定义一个函数来判断文件是否是文本文件(示例仅供参考)
is_text_file() {
local f="$1"
file --mime-type "$f" | grep -q "text/"
}
# 查找所有文件,逐一判断是否文本类型,如果是则进行内容替换
find "$target_dir" -type f -print0 | while IFS= read -r -d '' file; do
if is_text_file "$file"; then
for key in "${!replacements[@]}"; do
# 用 sed 对文件内容进行替换
sed -i "s|@$key@|${replacements[$key]}|g" "$file"
done
fi
done
########################################
# 第二步:先重命名文件
########################################
find "$target_dir" -type f -print0 | while IFS= read -r -d '' file; do
# 拆分目录和文件名
dir_path="$(dirname "$file")"
filename="$(basename "$file")"
newfilename="$filename"
for key in "${!replacements[@]}"; do
newfilename="${newfilename//@$key@/${replacements[$key]}}"
done
# 如果新文件名和原文件名不同,则执行重命名
if [[ "$newfilename" != "$filename" ]]; then
mv -v "$file" "$dir_path/$newfilename"
fi
done
########################################
# 第三步:再重命名目录(由浅到深)
########################################
# 先按目录层级进行排序(层数少的先处理)
# awk -F/ '{print NF, $0}' 会将路径按 / 分割并统计层数,然后 sort -n 升序,层数越小越先处理
find "$target_dir" -type d | awk -F/ '{print NF, $0}' | sort -n | cut -d' ' -f2- | while IFS= read -r dir; do
# 如果要连同最顶层目录一起改名,可以保留;若不需要改最顶层,可以加条件跳过
# [ "$dir" = "$target_dir" ] && continue # 如需跳过顶层可取消注释
parent_path="$(dirname "$dir")"
dirname_only="$(basename "$dir")"
newdirname="$dirname_only"
for key in "${!replacements[@]}"; do
newdirname="${newdirname//@$key@/${replacements[$key]}}"
done
# 需要改名则执行
if [[ "$newdirname" != "$dirname_only" ]]; then
mv -v "$dir" "$parent_path/$newdirname"
fi
done
echo "处理完成!"

7
debian-build.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
HERE=$(dirname $(realpath $0))
rm -fr pkg
cp -r src pkg
${HERE}/build.sh pkg
fakeroot dpkg-deb -b -Z xz pkg/ .
rm -fr pkg

View File

@@ -1,6 +1,6 @@
Package: apm Package: apm
Source: amber-ce Source: amber-ce
Version: 1.1.4 Version: @VERSION@
Architecture: amd64 Architecture: amd64
Maintainer: shenmo <shenmo@spark-app.store> Maintainer: shenmo <shenmo@spark-app.store>
Installed-Size: 48980 Installed-Size: 48980

View File

@@ -13,7 +13,11 @@ systemctl restart apparmor.service || true
if [ -f /usr/lib/sysctl.d/apm.conf ];then if [ -f /usr/lib/sysctl.d/apm.conf ];then
sysctl -p /usr/lib/sysctl.d/apm.conf sysctl -p /usr/lib/sysctl.d/apm.conf
fi fi
# Send statistics data
/tmp/apm-install/feedback.sh &
# Remove temp dir
rm -rf /tmp/apm-install
;; ;;
triggered) triggered)

53
src/tmp/apm-install/feedback.sh Executable file
View File

@@ -0,0 +1,53 @@
#!/bin/bash
# 提取配置信息
VERSION=@VERSION@
UUID=$(cat /etc/machine-id)
# 获取系统信息
LSB_OUTPUT=$(lsb_release --all 2>/dev/null)
DISTRIBUTOR_ID=$(echo "$LSB_OUTPUT" | grep -i 'Distributor ID:' | awk -F: '{print $2}' | xargs)
RELEASE=$(echo "$LSB_OUTPUT" | grep -i 'Release:' | awk -F: '{print $2}' | xargs)
ARCHITECTURE=$(uname -m)
# 构建当前时间
CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# 构建 JSON 数据
JSON_DATA=$(cat <<EOF
{
"Distributor ID": "$DISTRIBUTOR_ID",
"Release": "$RELEASE",
"Architecture": "$ARCHITECTURE",
"Store_Version": "$SIMPLIFIED_VERSION",
"UUID": "$UUID",
"TIME": "$CURRENT_TIME"
}
EOF
)
#echo "Spark Store Feedback"
# 调试输出 JSON 数据
#echo "发送的 JSON 数据:"
#echo "$JSON_DATA" | jq .
# 目标 URL
URL="https://status.deepinos.org.cn/upload"
# 使用 curl 发送 POST 请求
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X POST -H "Content-Type: application/json" -d "$JSON_DATA" "$URL")
# 检查 HTTP 响应码
if [ "$RESPONSE" -eq 200 ]; then
#echo "上传成功"
true
elif [ "$RESPONSE" -eq 400 ]; then
echo "错误:客户端请求错误,请检查 JSON 数据或接口逻辑"
elif [ "$RESPONSE" -eq 422 ]; then
echo "错误:请求数据无效,请检查 JSON 字段值"
elif [ "$RESPONSE" -eq 500 ]; then
echo "错误:服务器内部错误,请联系服务器管理员"
else
echo "错误:未处理的响应码 $RESPONSE"
fi

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
VERSION=1.1.4 VERSION=@VERSION@
# 获取脚本名称用于帮助信息 # 获取脚本名称用于帮助信息
SCRIPT_NAME=$(basename "$0") SCRIPT_NAME=$(basename "$0")
PATH_PREFIX=/var/lib/apm/apm/files/ace-env/ PATH_PREFIX=/var/lib/apm/apm/files/ace-env/

0
src/var/lib/apm/apm/files/ace-env.tar.xz Executable file → Normal file
View File