fix: 优化脚本 Shebang, close #56

This commit is contained in:
Del Wang
2025-08-17 07:18:16 +08:00
parent 43e6739726
commit 1405eca23f
14 changed files with 39 additions and 25 deletions
+1
View File
@@ -6,6 +6,7 @@ ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone \
&& apk add --no-cache \
bash \
file \
patch \
python3 \
+12 -5
View File
@@ -4,6 +4,7 @@
> 刷机有风险,操作需谨慎。请勿下载使用不明来历的固件!
小爱音箱 Pro 补丁固件制作流程:
- 固件提取(登录小米账号获取 OTA 链接)
- 开启固化 SSH(支持自定义登录密码)
- 禁用系统自动更新(系统更新后需要重新刷机打补丁)
@@ -12,31 +13,31 @@
## 下载固件
你可以直接在 [Github Releases](https://github.com/idootop/open-xiaoai/releases) 页面下载打包好的固件:
- [Xiaomi 智能音箱 Pro v1.56.31](https://github.com/idootop/open-xiaoai/releases/tag/OH2P_1.56.31)
- [小爱音箱 Pro v1.88.206](https://github.com/idootop/open-xiaoai/releases/tag/LX06_1.88.206)
> [!TIP]
> 里面有两个文件,下载 `patched` 那个:
>
> - `xxx_patched.squashfs` 打补丁后的固件
> - `xxx.squashfs` 原版固件(可用来刷回原系统)
> [!NOTE]
> 默认 SSH 登录密码为 `open-xiaoai`,如需修改请自行制作固件。
> [!IMPORTANT]
> 请下载和你当前小爱音箱版本一致的固件,跨版本刷机可能会出现未知错误,导致设备变砖。
> 如果上面没有你的版本,请升级设备固件到最新版本,或者按照下面的教程自行制作固件。
> [!CAUTION]
> 当前支持的最新固件版本为:
>
> - Xiaomi 智能音箱 Pro 👉 [v1.56.31](https://github.com/idootop/open-xiaoai/releases/tag/OH2P_1.56.31)
> - 小爱音箱 Pro 👉 [v1.88.206](https://github.com/idootop/open-xiaoai/releases/tag/LX06_1.88.206)
>
> 更新版本的固件可能存在变化,导致刷机失败,设备变砖,请自行评估风险。
## 制作固件
你可以按照下面的 2 种方法,制作自定义固件。
@@ -72,6 +73,12 @@ SSH_PASSWORD=open-xiaoai
> 如果你是 Apple Silicon 芯片,请先在 Docker Desktop - Settings - General - Virtual Machine Options 中打开 Apple Virtual framework 选项,然后开启 `Use Rosetta for x86_64/amd64 emulation on Apple Silicon`
```shell
# 克隆代码
git clone https://github.com/idootop/open-xiaoai.git
# 进入当前项目根目录
cd packages/client-patch
# 使用 Docker 进行构建
docker run -it --rm \
--platform linux/amd64 \
@@ -119,7 +126,7 @@ npm run build
示例:
```bash
#! /bin/sh
#!/bin/sh
/usr/sbin/tts_play.sh '初始化成功'
```
```
+4 -4
View File
@@ -5,10 +5,10 @@
"type": "module",
"scripts": {
"ota": "tsx --env-file=.env src/ota.ts",
"extract": "sh src/extract.sh",
"patch": "sh src/patch.sh",
"squashfs": "sh src/squashfs.sh",
"build": "sh src/build.sh"
"extract": "bash src/extract.sh",
"patch": "bash src/patch.sh",
"squashfs": "bash src/squashfs.sh",
"build": "bash src/build.sh"
},
"dependencies": {
"@mi-gpt/miot": "^1.2.1"
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
+2 -2
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
@@ -28,7 +28,7 @@ apply_patches() {
# 清理临时文件
rm "$temp_patch"
elif [[ "$file" == *.sh ]]; then
sh "$file"
bash "$file"
fi
fi
done
+11 -5
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
@@ -40,14 +40,20 @@ elif [ "$MODEL" = "LX06" ]; then
IMAGE_MAX_SIZE=$((0x02800000))
fi
SIZE=`stat -L -c %s $FIRMWARE/root-patched.squashfs`
echo "📊 当前固件大小: $SIZE 字节"
SIZE=$(stat -L -c %s "$FIRMWARE/root-patched.squashfs")
SIZE_MB=$((SIZE / 1024 / 1024))
IMAGE_MAX_SIZE_MB=$((IMAGE_MAX_SIZE / 1024 / 1024))
echo "📊 当前固件大小: $SIZE 字节 ($SIZE_MB MB)"
if [ "$SIZE" -ge "$IMAGE_MAX_SIZE" ]; then
echo "❌ 固件大小超过允许的最大值:$IMAGE_MAX_SIZE 字节"
echo "❌ 固件大小超过允许的最大值:$IMAGE_MAX_SIZE 字节 ($IMAGE_MAX_SIZE_MB MB)"
exit 1
fi
echo "✅ 固件大小检查通过,剩余空间: $((IMAGE_MAX_SIZE - SIZE)) 字节"
REMAINING_BYTES=$((IMAGE_MAX_SIZE - SIZE))
REMAINING_MB=$((REMAINING_BYTES / 1024 / 1024))
echo "✅ 固件大小检查通过,剩余可用空间: $REMAINING_BYTES 字节 ($REMAINING_MB MB)"
cp -rf $FIRMWARE $BASE_DIR/assets/$FIRMWARE