Files
immortalwrt_image_builder/README.md
T
2026-07-13 22:22:56 +08:00

186 lines
3.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ImmortalWrt Image Builder
这是一个用于快速构建 ImmortalWrt 固件的自动化项目,基于 ImmortalWrt 官方 Image Builder 生成自定义固件。
当前仓库提供多个构建脚本:
- `x86-64.sh`:构建 x86/64 通用固件
- `r2s.sh`:构建 FriendlyARM NanoPi R2S 固件
- `hiwifi-b70.sh`:构建 极路由 B70 固件
- `newifi3-d2.sh`:构建 新三路由 固件
脚本会自动安装构建依赖、下载对应版本的 Image Builder、复制 `files/` 目录中的自定义文件,并执行固件构建。
固件的默认登录地址是 `192.168.1.1`. 登录账号: `root`. 密码: `无`
## 环境要求
建议在 Debian/Ubuntu 或 WSL Ubuntu 环境中运行。
最好找一个独立的环境执行代码.
官方说最好找一个非 root 用户执行代码. 怕是 root 权限太大, 怕出现误删文件的情况.
## 使用方法
克隆本仓库:
```bash
git clone https://gitea.9001003.xyz/William/immortalwrt_image_builder.git
cd immortalwrt_image_builder
```
### 构建 x86-64 固件
```bash
bash x86-64.sh
```
构建完成后,固件文件会生成到:
```text
x86-64_output/
```
### 构建 NanoPi R2S 固件
```bash
bash r2s.sh
```
构建完成后,固件文件会生成到:
```text
r2s_output/
```
### 构建 新三路由 wifi3-d2 固件
```bash
bash newifi3_d2.sh
```
构建完成后,固件文件会生成到:
```text
newifi3_output/
```
### 构建 极路由 B70 固件
```bash
bash hiwifi-b70.sh
```
构建完成后,固件文件会生成到:
```text
hiwifi_b70_output/
```
如果输出目录已经存在,脚本会先将旧目录备份为带时间戳的 `.bak` 目录,再移动新的构建结果。
## 默认配置
### x86-64
- ImmortalWrt 版本:`25.12.1`
- Target`x86/64`
- Profile`generic`
- 根分区大小:`600 MB`
- 输出目录:`output/`
### NanoPi R2S
- ImmortalWrt 版本:`25.12.1`
- Target`rockchip/armv8`
- Profile`friendlyarm_nanopi-r2s`
- 根分区大小:`600 MB`
- 输出目录:`r2s_output/`
### 新三路由(Newifi3 D2
- ImmortalWrt 版本:`25.12.1`
- Target`ramips/mt7621`
- Profile`d-team_newifi-d2`
- 输出目录:`newifi3_output/`
> mt7621newifi3-d2)构建已移除 rootfs_partsize 参数,使用 ImageBuilder 默认分区策略。
### 极路由 B70
- ImmortalWrt 版本:`25.12.1`
- Target`ramips/mt7621`
- Profile`hiwifi_hc5962`
- 输出目录:`newifi3_output/`
## 自定义固件
### ImmortalWrt 版本
脚本在运行时会询问用户 ImmortalWrt 版本. 不知道用什么版本的, 直接默认版本就好.
版本查询 https://github.com/immortalwrt/immortalwrt/tags
### 修改预装软件包
编辑对应脚本中 `build()` 函数里的 `PKG_LIST` 数组。
示例:
```bash
PKG_LIST=(
openssh-sftp-server
vim-full
curl
luci-i18n-firewall-zh-cn
)
```
如果要从固件中移除某个包,可以在包名前加 `-`,例如:
```bash
PKG_LIST=(
-dropbear # 排除 dropbear
openssh-sftp-server
luci-i18n-firewall-zh-cn
)
```
### 添加自定义文件
仓库中的 `files/` 目录会被复制到固件根文件系统。
例如:
```text
files/etc/uci-defaults/99-sshd-root-login
```
构建后会出现在固件中的:
```text
/etc/uci-defaults/99-sshd-root-login
```
这个机制适合放置默认配置、初始化脚本、SSH 配置、LuCI 配置等文件。
## 关于开发
如果需要增加新设备固件. 你可以用以下`提示词``材料`喂给AI
材料:
- 代码模板: 找项目其中一个构建脚本作为模板, 比如: x86-64.sh
- imm openwrt image builder 下载地址
AI提示词:
```
image builder 下载地址: xxxx
目标设备: xxx
我想构建xxx设备固件, 请你按这个代码模板编写代码.
```