feat: 开放小爱音箱补丁固件构建源代码和教程

This commit is contained in:
Del Wang
2025-04-12 23:49:07 +08:00
parent 0585ddab72
commit 2cf6623db9
21 changed files with 1794 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
#!/bin/bash
set -e
BASE_DIR=$(pwd)
WORK_DIR=$BASE_DIR/temp
PASSWORD=${SSH_PASSWORD:-"open-xiaoai"}
PASSWORD=$(openssl passwd -1 -salt "open-xiaoai" "$PASSWORD")
# 应用指定目录下的补丁文件
apply_patches() {
local patch_dir="$1"
local message="$2"
echo "🔥 $message"
if [ -d "$patch_dir" ]; then
for file in "$patch_dir"/*; do
if [ -f "$file" ]; then
if [[ "$file" == *.patch ]]; then
# 创建临时文件用于占位符替换
local temp_patch=$(mktemp)
# 将补丁文件中的 {SSH_PASSWORD} 替换为 PASSWORD
sed "s/{SSH_PASSWORD}/$PASSWORD/g" "$file" > "$temp_patch"
# 应用替换后的补丁
patch -p1 < "$temp_patch"
# 清理临时文件
rm "$temp_patch"
elif [[ "$file" == *.sh ]]; then
sh "$file"
fi
fi
done
fi
}
if [ ! -f "$BASE_DIR/assets/.model" ]; then
echo "❌ 固件信息不存在,请先下载固件到:$BASE_DIR/assets/"
exit 1
fi
PATCH_DIR=$BASE_DIR/patches
MODEL=$(cat $BASE_DIR/assets/.model)
cd $WORK_DIR/squashfs-root
# 应用通用补丁
apply_patches "$PATCH_DIR" "正在应用通用补丁..."
# 应用特定型号补丁
apply_patches "$PATCH_DIR/$MODEL" "正在应用 $MODEL 补丁..."
echo "✅ 补丁应用完成"