记录时间:2020 年 2 月 1 日
关键词:OpenWrt imagebuilder K2 package 固件打包
K2在openwrt官方支持的固件列表里为psg1218a,如果没有做任何硬改,直接使用官方的固件也很不错。另外相比从源码开始编译,使用imagebuilder来做简单的固件定制更方便快捷体积小(其实就是提前把软件包集成在固件中)。
此记录全程以K2路由器为例,其他路由器需要找到相对应的下载地址,请灵活变通。另外要注意涉及的下载、镜像地址和脚本可能在未来过时或失效。
使用imagebuilder打包
- 下载image builder
在清华镜像站下载image builder https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/
K2的19.07.1版本在https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.1/targets/ramips/mt7620/
文件名为openwrt-imagebuilder-19.07.1-ramips-mt7620.Linux-x86_64.tar.xz
直接使用文件管理器,解压这个压缩包到主目录,打开解压出的这个文件夹。
- 在当前目录下右键打开终端,执行以下指令更换一下清华源
1
sed -i 's#downloads.openwrt.org#mirrors.tuna.tsinghua.edu.cn/openwrt#' repositories.conf
- 安装必要的软件
1
sudo apt-get install build-essential libncurses5-dev libncursesw5-dev zlib1g-dev gawk git gettext libssl-dev xsltproc wget unzip python
- 执行并找到目标配置的名称,k2为psg1218a,其实就是官方固件文件名中的设备名称
1
make info
- 开始打包,可以在PACKAGES后自行添加需要的软件包速度比较快,完成后,固件就在当前目录中的
1
make image PROFILE="psg1218a" PACKAGES="luci luci-i18n-base-zh-cn luci-i18n-firewall-zh-cn"
bin
文件夹内
如果不满意,需要再次打包时,先执行一下make clean
,再进行make image。
另外还可以添加一些除官方源外的其他源或者下载好位于本地的package,具体可以参考官方的说明。
利用GitHub Actions自动打包
方便快捷,就是下载回来有点难。。。
1 | name: OpenWrt image builder |
参考
OpenWrt.org-Using the Image Builder: https://openwrt.org/docs/guide-user/additional-software/imagebuilder
imagebuilder快速编译OpenWrt固件使用教程+高级自定义+在线编译: https://www.right.com.cn/forum/thread-522029-1-1.html
Openwrt 国内源配置 · DarkGod’ Blog:https://www.dazhuanlan.com/2019/10/17/5da7cdea1f0c8/