OpenWrt单独编译ipk包(以dogcom为例)
去下面的地址(二选一,第二个是清华源)找到SDK包的下载链接:
添加非root账户
整个编译过程需要在非root环境下进行。若有非root账户,跳过此节。
adduser helloworld # 后续输入密码
usermod -s /bin/bash helloworld # 为新建的用户指定默认shell
usermod -aG sudo helloworld # 赋予用户root权限退出,重新登录helloworld
安装相关的环境
sudo apt update
sudo apt install build-essential clang flex bison g++ gawk gcc-multilib g++-multilib gettext git libncurses5-dev libssl-dev python3-distutils rsync unzip zlib1g-dev file wget准备SDK并开始编译
- 下载SDK包
wget https://mirrors.tuna.tsinghua.edu.cn/lede/releases/23.05.0/targets/mediatek/mt7622/openwrt-sdk-23.05.0-mediatek-mt7622_gcc-12.3.0_musl.Linux-x86_64.tar.xz
tar -xf openwrt-sdk-23.05.0-mediatek-mt7622_gcc-12.3.0_musl.Linux-x86_64.tar.xz
cd ~/openwrt-sdk-23.05.0-mediatek-mt7622_gcc-12.3.0_musl.Linux-x86_64- 移除源
vi feeds.conf.default在每行前面加上#注释。单独编译插件并不需要这些,如果不注释的话将会导致非常多的插件被编译,中间的下载过程很慢甚至中断。
- 下面照常更新下仓库(虽然已经注释完了)
./scripts/feeds update -a && ./scripts/feeds install -a- 将源码放到对应的目录下面。通常放在当前目录下的package目录中的对应目录下。如果你不确定,请直接放在package。下面分别克隆dogcom的可执行程序和其界面程序到package目录下:
cd package
git clone https://github.com/mchome/openwrt-dogcom.git
git clone https://github.com/mchome/luci-app-dogcom.git- 生成
.config
make menuconfig
# 使用上下方向键移动选项,Enter确认,ESC返回,使用Tab在菜单和底栏之间移动
# 确保Network/openwrt-dogcom和LuCi/luci-app-dogcom的选项为M[*] 表示编译软件包并加入到固件;
[M] 表示编译软件包但不加入固件;
[ ] 则表示不对软件包进行任何设置。- 下载编译的包极其依赖
make download -j2 V=s #j后面的数字代表线程数- 编译
建议单线程编译,成功率高:
make -j1 V=s编译结果
编译完后,我看到控制台出现以下信息:
……
Generating index for package ./libpthread_1.2.4-4_aarch64_cortex-a53.ipk
Generating index for package ./librt_1.2.4-4_aarch64_cortex-a53.ipk
Generating index for package ./libstdcpp6_12.3.0-4_aarch64_cortex-a53.ipk
Generating index for package ./dogcom_v1.6.2-1_aarch64_cortex-a53.ipk
Generating index for package ./luci-app-dogcom_1.0.2-1_all.ipk
Signing package index...
Cannot open file '/home/helloworld/openwrt-sdk-23.05.0-mediatek-mt7622_gcc-12.3.0_musl.Linux-x86_64/key-build' for reading
Cannot open file '/home/helloworld/openwrt-sdk-23.05.0-mediatek-mt7622_gcc-12.3.0_musl.Linux-x86_64/key-build' for reading
make[2]: *** [package/Makefile:88: package/index] Error 1
make[2]: Leaving directory '/home/helloworld/openwrt-sdk-23.05.0-mediatek-mt7622_gcc-12.3.0_musl.Linux-x86_64'
make[1]: *** [Makefile:58: world] Error 2
make[1]: Leaving directory '/home/helloworld/openwrt-sdk-23.05.0-mediatek-mt7622_gcc-12.3.0_musl.Linux-x86_64'
make: *** [/home/helloworld/openwrt-sdk-23.05.0-mediatek-mt7622_gcc-12.3.0_musl.Linux-x86_64/include/toplevel.mk:225: world] Error 2看到有error以为完了,其实我没管,直接去目标目录ls bin/packages/aarch64_cortex-a53/base/去找,发现已经编译好了对应的ipk文件,直接拷贝出来通过mobxterm拖到路由器上安装就行了。
二次编译还未试,可参考https://iii80.com/?action=show&id=975。