前言
大学生寒假在家的生活往往是枯燥乏味的,恰好这个假期站长本人也没有找到工作,在家闲着也是闲着,也就趁着春节这个时间折腾了下家里的这台软路由,想着能发挥点作用为我所用。本来想着找别人做好的 现成 固件刷刷玩玩的,后来发现别人编译的固件不太符合自己的口味,要不就是缺少docker,要不就是少了一些什么扩展之类的,后来索性自己重新拉取仓库代码重新编译一个新的固件了。
说起来固件新也不新,用的是官方仓库稳定版分支openwrt-24.10应该就是所谓的24.10.0这个版本,折腾完毕后总体体验下来感觉良好,所有功能都挺正常,自己需要的也都能顾及到。
下面是我的拉取的packages仓库列表。
git clone https://github.com/sbwml/luci-app-alist.git luci-app-alist
git clone https://github.com/xiaorouji/openwrt-passwall2.git luci-app-passwall2
git clone https://github.com/xiaorouji/openwrt-passwall-packages.git
git clone https://github.com/sbwml/luci-app-qbittorrent.git luci-app-qbittorrent
git clone https://github.com/rufengsuixing/luci-app-adguardhome.git luci-app-adguardhome
git clone https://github.com/UnblockNeteaseMusic/luci-app-unblockneteasemusic.git luci-app-unblockneteasemusic
git clone https://github.com/sirpdboy/luci-app-ddns-go.git luci-app-ddns-go
git clone https://github.com/sirpdboy/luci-app-poweroffdevice luci-app-poweroffdevice
git clone https://github.com/f8q8/luci-app-autoreboot.git luci-app-autoreboot
git clone https://github.com/monokoo/luci-app-arpbind.git luci-app-arpbind
git clone https://github.com/lisaac/luci-app-dockerman.git
git clone https://github.com/lisaac/luci-lib-docker.git
git clone https://github.com/jerrykuku/luci-theme-argon
git clone https://github.com/zhengmz/luci-app-zerotier.git
mkdir -p luci-app-diskman && \
wget https://raw.githubusercontent.com/lisaac/luci-app-diskman/master/applications/luci-app-diskman/Makefile -O luci-app-diskman/Makefile
mkdir -p parted && \
wget https://raw.githubusercontent.com/lisaac/luci-app-diskman/master/Parted.Makefile -O parted/Makefile
需求
我大概考虑了一下我的具体需求,也就是基本的ipv4/ipv6双栈访问,ddns+frp,zerotier,以及必要的魔法,还有就是能跑一跑docker容器来扩展我的服务需求(比如alist挂载啊,自动下载啊,博客等等)。考虑完以上的需求之后就是一些编译的操作要点了。
仓库的选取
首先就是选取那个openwrt分支来进行构建了,现在市场上主流的几个固件分支就是openwrt主分支,lean大佬的lede分支,istore os,immortalwrt等等,本次站长选择的是openwrthttps://github.com/openwrt/openwrt官方仓库的源码,相比起其余分支的源码,其内容精简,体积也较小,非常适合没有过多需求的编译。
官方仓库自带的alist功能不全,acme尝试了几次没法正常的生成证书,dockerman代码过于陈旧导致小毛病不断等等,最终我选择了删除feeds带来的插件代码并重新拉取,以及合适的插件选择docker版本方便管理等等。
编译的基本问题
本人偷懒选择了WSL(Windows subsystem for Linux)来编译固件,那么编译的过程中需要将WSL的网络模式选择为Mirror(或者采用配置环境变量的方式来让子系统的编译流量走小猫走)。
export http_proxy='192.168.31.1:7890'
export https_proxy='192.168.31.1:7890'
关于仓库的拉取其实也没啥好说的,主要就是以下命令:
sudo apt update -y
sudo apt full-upgrade -y
sudo apt install -y ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
bzip2 ccache clang cmake cpio curl device-tree-compiler flex gawk gcc-multilib g++-multilib gettext \
genisoimage git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libfuse-dev libglib2.0-dev \
libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libpython3-dev \
libreadline-dev libssl-dev libtool llvm lrzsz msmtp ninja-build p7zip p7zip-full patch pkgconf \
python3 python3-pyelftools python3-setuptools qemu-utils rsync scons squashfs-tools subversion \
swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev #安装依赖
#克隆仓库
git clone https://github.com/openwrt/openwrt.git
cd openwrt
#通常我会删除部分官方自带软件包以保证插件功能
rm -rf feeds/luci/applications/luci-app-alist/
rm -rf feeds/luci/applications/luci-app-dockerman/
rm -rf feeds/luci/collections/luci-lib-docker/
#更新feeds
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig #打开编译配置
官方固件需要选择的地方多点,我通常会开启以下部分来丰富系统功能:
block-mount #添加挂载点 Base-System → block-mount
luci-compat #luci基本 Luci → Modules → luci-compat
luci-mod-dashboard #luci状态页面 Luci → Modules → luci-mod-dashboard
Chinese Simplified (zh_Hans) #中文翻译 Luci → Modules → Translation → Chinese Simplified (zh_Hans)
vsftpd #sftp Network → File Transfer → vsftpd
openssh-sftp-server #SSHscp支持 Network → SSH → openssh-sftp-server
vim-fuller #完全体vim Utilities → Editors → vim → vim-full → vim-fuller
bash #终端 Utilities → Shells → bash
docker-compose #docker-compose Utilities → docker-compose
最后就是编译了,我们一般先下载dl库,方便后续更快的编译
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin make download -j8 #以8线程下载dl库
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin make V=s -j$(nproc) #自适应线程编译
编译完成后刷入系统调试后大概就是这样一个情况,除了CPU性能拉跨之外别的没有什么拖后腿的。