OpenWrt路由器编译指南
RealKiro opened this issue · comments
未日 commented
1⃣️编译前相关
查看空间容量:
df -h
-
解决方案:
- 方法一:
用这个命令查看一下apt-get的相关进程:
- 方法一:
$ ps -e | grep apt
显示:
11669 ? 00:00:02 aptd
25379 ? 00:00:00 update-apt-xapi
然后就执行
$ sudo kill 25379
$ sudo apt-get update
-
- 方法二:
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
- 预先下载dl库,可以避免下载造成的编译失败。下载后拷贝到 /dl里面
make download V=s
make -j1 V=s
- 清除bin和编译好的二进制过渡文件(慎用)
make clean
- make dirclean=[make clean]+[清除交叉编译工具及工具链目录](慎用)
make dirclean
- 清空编译环境, make distclean=[清除所有相关的东西,包括下载的软件包,配置文件,feed内容等]
make distclean -j1 V=s
- 重新编译清除选项:
rm -rf build_dir staging_dir tmp
- 重新配置
rm -rf ./tmp
rm -rf .config
2⃣️开始编译
-
openwrt编译笔记
-
系统更新
sudo apt-get update
sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3.5 python2.7 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler g++-multilib antlr3 gperf wget
sudo apt-get full-upgrade -y
sudo apt-get install -y build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib g++-multilib p7zip p7zip-full msmtp libssl-dev texinfo libreadline-dev libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint ccache curl wget vim nano python python3 python-pip python3-pip python-ply python3-ply haveged lrzsz device-tree-compiler scons antlr3 gperf ecj fastjar
- 下载源码
git clone https://github.com/coolsnowwolf/lede
或
git clone https://github.com/project-openwrt/openwrt
- 切换到dev分支或master主分支(慎用):
git checkout dev
git checkout master
- clone分支(示例):
git clone https://github.com/coolsnowwolf/lede -b master
git clone https://github.com/coolsnowwolf/lede -b dev
- 进入目录:
cd openwrt
- 更新源+安装源:
./scripts/feeds update -a
./scripts/feeds install -a
或一次性更新feed
./scripts/feeds update -a && ./scripts/feeds install -a
- 打开配置:
make menuconfig
- 打开内核配置(慎用):
make kernel_menuconfig
(一定要在file systems的Native language support设置好,不然网络共享文件名乱码)
- 配置差异部分
make defconfig
./scripts/diffconfig.sh > seed.config
- 提前下载DL库
make download V=s
- 编译
make -j1 V=s
(-jn的n为电脑cpu的进程数)
- 非第一次编译
cd openwrt
git pull
./scripts/feeds update -a && ./scripts/feeds install -a
rm -rf ./tmp && rm -rf .config
make menuconfig
make kernel_menuconfig
make -j2 V=s
- 没关闭终端的情况下简化为
rm -rf ./tmp
make menuconfig
make -j2 V=s
- 部分插件在branch分支,如Openclash(可选):
git clone https://github.com/vernesong/OpenClash -b master package/lean/luci-app-openclash
-
芝麻开门:
-
路径:
lede/feeds.conf.default
#src-git helloworld https://github.com/fw876/helloworld
前面的注释符号去掉,再更新一次feeds
即可
-
默认主题修改
-
改源码的话,在
feeds/luci/collections/luci
文件夹下面的Makefile
文件里面,找到LUCI_DEPENDS
这一项, -
替换
and the default Bootstrap theme
为and the default Argon theme
-
替换
luci-theme-bootstrap
为luci-theme-argon
(其它主题替换同理) -
重新更新安装
feeds
即可在make menuconfig
里面默认选中你要的主题了,也会默认启用。
- DHCP与AP示例
K2关掉DHCP 删掉防火墙劫持DNS的命令
K2/新三 改为WDS桥接
K2 LAN IP和新三改成一个段 网关指向软路由 DNS指向新三
- 改ip
CONFIG_TARGET_PREINIT_IP="192.168.1.1"
CONFIG_TARGET_PREINIT_BROADCAST="192.168.1.255"
- 临时打补丁以修正Bug示例
wget -O package/lean/qBittorrent/Makefile https://raw.githubusercontent.com/coolsnowwolf/lede/5001036ea61ec091dd990325d946dd7ff2ec6286/package/lean/qBittorrent/Makefile
wget -O /usr/share/shadowsocksr/subscribe.lua https://raw.githubusercontent.com/coolsnowwolf/lede/b9ee8de9d6907fedb5b6c51f407deb4e2b200f72/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua
- Docker
/etc/docker-init