本帖最后由 alps2006 于 2022-9-30 00:29 编辑
编译环境
目前 openwrt 主要是在需要在 linux 环境下安装, 支持 ubuntu, centos, wls-ubuntu, mac 等, 但官方主要推荐基于 ubuntu 编译, 且自己也刚好有台 ubuntu 的云服务器. 主要的环境: - Openwrt 源码: 基于 Lean 大的源码进行编译. https://github.com/coolsnowwolf/lede
- 系统: Ubuntu 18.04.6 LTS
- 磁盘空间: 根据启用的插件决定, 常规默认参数, 启用 ssr 插件 + easymesh + adblock + smartdns, 编译达到 14G+
- 其它: 能够访问国外资源, 因为编译时部分依赖需要
安装 xray 客户端
目前我使用的是国内的腾讯云服务器, 无法访问国外的资源, 所以安装了 xray 客户端连接梯子服务器, 并在本地暴露了 http 服务端口, 使用 export proxy 在终端使用 . 主要操作:
- 下载二制包, 我使用的是目前最新的 1.6 版本
- wget https://github.com/XTLS/Xray-core/releases/download/v1.6.0/Xray-linux-64.zip
复制代码
- 解压并运行, config 需要自行配置, 详细参考其它资源
- unzip Xray-linux-64.zip
- cd Xray-linux-64
- ./xray -c config.json &
复制代码
- 设置终端 proxy, 执行 (前提是暴露了 http 端口为 1087)
- export http_proxy=http://127.0.0.1:1087; export https_proxy=http://127.0.0.1:1087; export all_proxy=http://127.0.0.1:1087
复制代码
- 需要取消终端 proxy, 执行
- unset http_proxy; unset https_proxy; unset all_proxy;
复制代码
安装依赖
编译前需要安装好编译相关的依赖库和程序, 在 ubuntu 下使用 apt-get 可以很方便的安装, 主要执行:
- 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 cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib \git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev \libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libreadline-dev libssl-dev libtool lrzsz \mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 python3-pip libpython3-dev qemu-utils \rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev
复制代码
编译
源码下载
使用 git clone 下载最新的 lean 大源码: - git clone https://github.com/coolsnowwolf/ledecd lede
复制代码
添加 ssr feeds 仓库目前最新源码默认情况未添加 ssr 的 feeds 支持, 需要自行添加, 执行: - echo "src-git helloworld https://github.com/fw876/helloworld.git" >> "feeds.conf.default"
复制代码
更新及安装 feeds
- ./scripts/feeds update -a
复制代码
配置在编译前需要进行配置硬件设备信息(包括硬件平台, 版本, 型号等), 以及模块插件等. 通过执行 make menuconfig 能打开参数配置界面, 下面以我 HC5962 配置说明: - │ │ Target System (MediaTek Ralink MIPS) ---> │ │
- │ │ Subtarget (MT7621 based boards) ---> │ │
- │ │ Target Profile (HiWiFi HC5962) ---> │ │
- │ │ Target Images ---> │ │ (选择了 squashfs)
- │ │ [ ] Enable experimental features by default │ │
- │ │ Global build settings ---> │ │
- │ │ [ ] Advanced configuration options (for developers) ---- │ │
- │ │ [ ] Build the OpenWrt Image Builder │ │
- │ │ [ ] Build the OpenWrt SDK │ │
- │ │ [ ] Package the OpenWrt-based Toolchain │ │
- │ │ [ ] Image configuration ---> │ │
- │ │ Base system ---> │ │
- │ │ Administration ---> │ │
- │ │ Boot Loaders ---- │ │
- │ │ Development ---> │ │
- │ │ Extra packages ---> │ │
- │ │ Firmware ---> │ │
- │ │ Fonts ---> │ │
- │ │ Kernel ---- │ │
- │ │ Kernel modules ---> │ │
- │ │ Languages ---> │ │
- │ │ Libraries ---> │ │
- │ │ LuCI ---> │ │ (二级菜单 Application 中选择了 luci-app-easymesh, adblock, 而 ssr-plus 自己要选择对应的 core )
- │ │ Mail ---> │ │
- │ │ Multimedia ---> │ │
- │ │ Network ---> │ │ (选择了 smartdns)
- │ │ Sound ---> │ │
- │ │ Utilities ---> │ │
- │ │ Xorg ---> │ │
复制代码
最后使用方向键导航到下方的 回车保存, 不要修改 .config 命名的文件名, 使用 make 编译时会默认使用.
下载 dl 库并编译
首次编译需要建议使用单线程编译:
编译后生成的路径是 bin/targets 目录, 一般使用 xxx-sysupdate.bin 进行升级.
二次更新流上最新代码编译
重新配置编译
- rm -rf ./tmp && rm -rf .config
复制代码
FAQ (问题)巧用 tar 压缩命令解决磁盘空间不够的问题 我使用的云服务器有 50G 的空间, 之前有在编译其它大型程序(差不多 30 G), 所以剩余可用的空间只有几个 G. 但之前的编译又不能删除, 那只能压缩一部分空间出来了.
常规压缩的话磁盘空间也不够, 因为原始文件并没有删除. 后面查了一下资料, 可以使用 tar 命令的 --remove-source-files 进行压缩, 一边压缩一边删除, 执行: - tar -czf xxxx.tar.gz --remove-files xxxx
复制代码通过压缩, 最终端释放了 15G 的空间出来.
编译时出现 ld returned 解决. 第一次编译时, 由于磁盘空间不够编译失败, 后面释放空间后,编译一直报这个错误. collect2: error: ld returned 1 exit status
/home/ubuntu/lede/build_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/gcc-8.4.0/gcc/c/Make-lang.in:85: recipe for target cc1'' failed'
通过删除 build_dir, staging_dir, tmp 目录重新编译解决.
关于 easymesh 使用崩溃的问题? 目前我使用最新 master ( 20220919) 源码编译, 第一次编译的简洁版本开启简单mesh 使用并没有问题, 后面陆续增加插件编译, 确实会出现开启就卡死的情况.
经过编译插件信息对比发现应该是 adbyby-plus 插件与 ssr-plus 插件所依赖的 adbyby 冲突导致的, 把 adbyby-plus 插件替换为 adblock 即解决.
ssr-plus 使用 xray-core 无法连接网络. 当增加 ssr-plus feeds后, 配置时需要选择 ssr-plus 的核心为 xray-core, 但在配置界面中无法看到 xray plus, 最终通过修改 .config 文件, 把 CONFIG_PACKAGE_xray-plugin=y 启用.
|