安装环境
system:ubuntu
platform:X86_X64
首次编译环境搭建
系统环境
sudo apt-get update
安装编译需要的组件:
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install binutils
sudo apt-get install patch
sudo apt-get install bzip2
sudo apt-get install flex
sudo apt-get install bison
sudo apt-get install make
sudo apt-get install autoconf
sudo apt-get install gettext
sudo apt-get install texinfo
sudo apt-get install unzip
sudo apt-get install sharutils
sudo apt-get install subversion
sudo apt-get install libncurses5-dev
sudo apt-get install ncurses-term
sudo apt-get install zlib1g-dev
sudo apt-get install gawk
sudo apt-get install asciidoc
sudo apt-get install libz-dev
如果编译过程中提示缺少某个组件,同样使用sudo apt-get install安装即可
编译环境搭建完成
更新本地环境
更新软件列表、升级软件包<
sudo sh -c "apt update && apt upgrade -y"
首次编译
一定要记住,千万别用root环境编译!!!
一定要记住,千万别用root环境编译!!!
一定要记住,千万别用root环境编译!!!
到这里就可以退出root用户了,用普通用户即可.
重要的事情说三遍
拉取源码
拉取源码到编译环境
git clone https://github.com/coolsnowwolf/lede.git openwrt
添加自定义源
注:以下是自己正在使用的软件源,这里你也可以换成自己喜欢的软件源
# 进入openwrt目录
cd ~/openwrt
# 添加自定义源
cat >> feeds.conf.default <<EOF
src-git kenzo https://github.com/kenzok8/openwrt-packages
src-git passwall https://github.com/xiaorouji/openwrt-passwall
EOF
更新下载软件仓库的源码到本地,并安装自定义源包含的软件包
./scripts/feeds update -a && ./scripts/feeds install -a
单独添加软件包(可选项)
如果需要单独添加软件,请拉取源码到 package 目录之下。示例如下:
# 添加 OpenAppFilter 应用过滤插件
git clone https://github.com/destan19/OpenAppFilter package/OpenAppFilter
设置默认主题(可选项)
注:此操作请在编译前执行,设置 argon 为默认主题,以此为例举一反三
# 删除自定义源默认的 argon 主题
rm -rf package/lean/luci-theme-argon
# 拉取 argon 原作者的源码
git clone -b 18.06 https://github.com/jerrykuku/luci-theme-argon.git package/lean/luci-theme-argon
# 替换默认主题为 luci-theme-argon
sed -i 's/luci-theme-bootstrap/luci-theme-argon/' feeds/luci/collections/luci/Makefile
设置路由器默认的 LAN IP(可选项)
注:此操作请在编译前执行
# 设置默认IP为 192.168.199.1
sed -i 's/192.168.1.1/192.168.199.1/g' package/base-files/files/bin/config_generate
仅制作.config文件,无需本地编译固件(可选项)
根据自己的定制需求,调整 OpenWrt 系统组件
make menuconfig
通过以下命令行获得 seed.config 配置文件,然后使用 GitHub Actions 云编译。
# 若在调整OpenWrt系统组件的过程有多次保存操作,则建议先删除.config.old文件再继续操作
rm -f .config.old
# 根据编译环境生成默认配置
make defconfig
# 对比默认配置的差异部分生成配置文件(可以理解为增量)
./scripts/diffconfig.sh > seed.config
若需要编译固件
根据自己的定制需求,调整 OpenWrt 系统组件
make menuconfig
下载编译所需的软件包
make download -j8 V=s
编译 OpenWrt 固件
# -j1:单线程编译
make -j1 V=s
单线程编译可提高编译成功率,但过程非常漫长,也完全取决于机器的性能。编译完成后固件输出路径: /openwrt/bin/targets/ 之下。
二次编译
一定要记住,千万别用root环境编译!!!
一定要记住,千万别用root环境编译!!!
一定要记住,千万别用root环境编译!!!
到这里就可以退出root用户了,用普通用户即可.
重要的事情说三遍
更新本地编译环境
# 更新软件列表、升级软件包
sudo sh -c "apt update && apt upgrade -y"
# 拉取最新源码
cd ~/openwrt && git pull
# 更新下载安装订阅源包含的软件包
cd ~/openwrt
./scripts/feeds update -a && ./scripts/feeds install -a
清理旧文件
# 删除/bin和/build_dir目录中的文件
make clean
如果要更换架构,例如要从 x86_64 换到 MediaTek Ralink MIPS 建议执行以下命令深度清理 /bin 和 /build_dir 目录的中的文件 (make clean) 以及 /staging_dir、/toolchain、/tmp 和 /logs 中的文件。
make dirclean
如果需要对组件重新调整,则建议先删除旧配置
rm -rf ./tmp && rm -rf .config
根据自己的定制需求,再次调整 OpenWrt 系统组件
make menuconfig
下载编译所需的软件包
make download -j8 V=s
编译 OpenWrt 固件
make -j$(nproc) || make -j1 || make -j1 V=s
二次编译可以优先使用多线程,报错会自动使用单线程,仍然报错会单线程执行编译并输出详细日志。
附加内容
如果没有特殊的定制需求,运行 make menuconfig 命令配置目标架构完成后,进入 LUCI --> Applications 选择需要的插件,进入 LUCI --> Themes 选择喜欢的主题皮肤,编译即可。
如果是硬路由务必记得勾选 luci-app-mtwifi 闭源的 Wi-Fi 驱动
- x86_64 平台
Target System (x86) --->
Subtarget (x86_64) --->
Target Profile (Generic x86/64) --->
无特殊需求,那么 Target Images 勾选
[*] squashfs (NEW)
[*] Build GRUB images (Linux x86 or x86_64 host only) (NEW)
[*] GZip images (NEW)
自定义固件大小
(32) Kernel partition size (in MB) (NEW)
(400) Root filesystem partition size (in MB) (NEW)
如果因为勾选基于 EXT4 文件系统编译固件而造成编译报错,建议调高 Root filesystem partition size
- 常用插件列表
在调整 OpenWrt 系统组件时:[*] 表示编译软件包并加入到固件;[M] 表示编译软件包但不加入固件;[ ] 则表示不对软件包进行任何设置。
## 插件类
LuCI ---> Applications ---> luci-app-adbyby-plus #去广告
LuCI ---> Applications ---> luci-app-arpbind #IP/MAC绑定
LuCI ---> Applications ---> luci-app-autoreboot #高级重启
LuCI ---> Applications ---> luci-app-aliddns #阿里DDNS客户端
LuCI ---> Applications ---> luci-app-ddns #动态域名 DNS
LuCI ---> Applications ---> luci-app-filetransfer #文件传输
LuCI ---> Applications ---> luci-app-firewall #添加防火墙
LuCI ---> Applications ---> luci-app-frpc #内网穿透 Frp
LuCI ---> Applications ---> luci-app-mwan3 #MWAN负载均衡
LuCI ---> Applications ---> luci-app-nlbwmon #网络带宽监视器
LuCI ---> Applications ---> luci-app-ramfree #释放内存
LuCI ---> Applications ---> luci-app-samba #网络共享(Samba)
LuCI ---> Applications ---> luci-app-sqm #流量智能队列管理(QOS)
LuCI ---> Applications ---> luci-app-openclash #你懂的那只猫
LuCI ---> Applications ---> luci-app-dnsfilter #广告过滤
LuCI ---> Applications ---> luci-app-passwall #不敢解释
LuCI ---> Applications ---> luci-app-mtwifi #闭源Wi-Fi驱动
LuCI ---> Applications ---> luci-app-eqos #根据IP控制网速
LuCI ---> Applications ---> luci-app-syncdial #薛定谔的多拨应用
LuCI ---> Applications ---> luci-app-zerotier #虚拟局域网
LuCI ---> Applications ---> luci-app-jd-dailybonus #京东签到自动领豆
LuCI ---> Applications ---> luci-app-oaf #应用过滤神器
LuCI ---> Applications ---> luci-app-watchcat #断网检测功能与定时重启
LuCI ---> Applications ---> luci-app-wol #WOL网络唤醒
LuCI ---> Applications ---> luci-app-wrtbwmon #实时流量监测
LuCI ---> Applications ---> luci-app-upnp #通用即插即用UPnP(端口自动转发)
LuCI ---> Applications ---> luci-app-argon-config #Argon主题设置
# 常用主题类
LuCI ---> Themes ---> luci-theme-argon
# 网络相关 (普通用户用不上)
Network ---> IP Addresses and Names ---> ddns-scripts_cloudflare.com-v4
Network ---> IP Addresses and Names ---> bind-dig
Network ---> Routing and Rediction ---> ip-full
Network ---> File Transfer ---> curl
Network ---> File Transfer ---> wget-ssl
Network ---> iperf3
Network ---> ipset
Network ---> socat #多功能的网络工具
Base system --> dnsmasq-full #DNS缓存和DHCP服务(dnsmasq-full和dnsmasq二者不可共存)
# 工具类 (普通用户用不上)
Utilities --> acpid #电源管理接口(适用于x86平台)
Utilities --> Editors --> nano #Nano 编辑器
Utilities --> Shells --> bash #命令解释程序
Utilities --> disc --> fdisk #MBR分区工具
Utilities --> disc --> gdisk #GBT分区工具
Utilities --> disc --> lsblk #列出磁盘设备及分区查看工具
Utilities --> Filesystem --> resize2fs #调整文件系统大小
Utilities --> Filesystem --> e2fsprogs #Ext2(及Ext3/4)文件系统工具
# IPv6(未来运营商可能不再提供 IPv4 公网地址,有远程访问需求的建议加入)
Extra packages ---> ipv6helper (勾选此项即可,下面几项自动勾选)
Network ---> odhcp6c
Network ---> odhcpd-ipv6only
LuCI ---> Protocols ---> luci-proto-ipv6
LuCI ---> Protocols ---> luci-proto-ppp


Comments | NOTHING